Embed the chat
Embed the chat
import { SourcingChat, SourcingClient, SourcingProvider } from '@search-engine-sdk/react';
import '@search-engine-sdk/react/styles.css';
const client = new SourcingClient({ baseUrl: '/api/v2' });
export function SourcingPanel() {
return (
<SourcingProvider client={client}>
<SourcingChat />
</SourcingProvider>
);
}
useSourcingClient() throws when SourcingProvider is missing. Load IBM Plex Sans and IBM Plex Mono in the host. The stylesheet falls back to system fonts. Give the panel a bounded height. The transcript and the results list scroll inside it.
Leave chatId empty to create a conversation on the first send. chats().create() allocates an id locally and does not call the server. The server stores the workspace when it accepts the first turn. onChatCreated fires with { id, title } at allocation time. If the host puts that id in the URL, keep this component mounted while the route updates, or the pending first message is dropped. The routed host does this.
Pass a saved id as chatId to reopen it. onNewSearch receives the text when the agent asks for a separate search. With a controlled chatId, that action is shown only when onNewSearch is set. When chatId is omitted and onNewSearch is omitted, the chat starts that search itself.
theme is light, dark, or system (the default, from prefers-color-scheme). tokens overrides individual colors, radius, font, and shadow. classes adds host classes on root, body, thread, and side.
<SourcingChat
theme="dark"
tokens={{ accent: '#7c3aed', radius: '8px' }}
className="sourcing-panel"
classes={{ thread: 'sourcing-thread', side: 'sourcing-results' }}
/>
slots replaces a view and keeps the same session. The built-in filters view is a summary. A custom editor calls loadForms() for the fields and version, then onSubmit(version, edits). onReview(candidateId, 'like' | 'dislike') is the host's feedback handler. onSnapshot receives every controller snapshot. A failed turn calls onError with new Error whose message is the banner text. detail is available on SourcingApiError when the host calls the client directly.
Standalone components (CandidateCard, FilterSummary, Composer, and the others exported from @search-engine-sdk/react) render inside SourcingTheme. Slot prop types live in packages/react/src/slots.ts. Token names live in packages/react/src/theme.tsx.
CopilotFrame, Composer, CriteriaBar, and DescribeBox follow the sourcing workbench: the hint and footer of the copilot column, the sentence of criteria with Adjust, and the box on the home screen. The rest of that screen is the same kind of piece. WorkbenchFrame is the header. ResultsBoard is the sortable table. ProfilePanel is the candidate beside it. HistoryList is a saved-row list. It defaults to conversations; pass pendingLabel and listLabel for another list, such as saved searches. AdjustFrame and RungOption are the criteria dialog. PresenceRow, PlanMeter, YouNote, BotNote, ActionNote, ThoughtNote, QueueList, ArchiveThread, and SignInCard cover the tags, the derivation log, the transcript, queued messages, the saved conversation, and sign-in. The host still owns search state, sorting, streaming, and the dialog's drafts, and passes the rows in. SourcingChat keeps its own card list for an embed.