zidane-ui/ chat/ testing
import { … } from 'zidane-ui/chat/testing'ui/src/chat/testing/index.ts
Functions#
createFixtureComposerChromeFunction#
Creates the fixture's chrome members.
function createFixtureComposerChrome(
options?: FixtureComposerChromeOptions,
): FixtureComposerChromeParameters
| Name | Type | Default | Description |
|---|---|---|---|
| options? | FixtureComposerChromeOptions | {} | What they hold. Leave a list out for the demo one. |
Returns
createFixtureComposerHostFunction#
Creates a FixtureComposerHost.
function createFixtureComposerHost(
options?: FixtureComposerHostOptions,
): FixtureComposerHostParameters
| Name | Type | Default | Description |
|---|---|---|---|
| options? | FixtureComposerHostOptions | {} | What it holds. Leave a list out for the demo one. |
Returns
createFixtureHostFunction#
Creates a complete ChatHost over static data, held in memory. The kit's demos, docs, and tests run on it.
function createFixtureHost(fixture: ChatFixture, options?: FixtureHostOptions): ChatHostParameters
| Name | Type | Default | Description |
|---|---|---|---|
| fixture | ChatFixture | The sessions, transcripts, models, and interactions to serve. | |
| options? | FixtureHostOptions | {} | Whether the host is editable, how it replies to prompts, and the streaming pace. |
Returns
createFixtureSidebarHostFunction#
Creates a SidebarHost held in memory.
function createFixtureSidebarHost(
options?: FixtureSidebarHostOptions,
): FixtureSidebarHostParameters
| Name | Type | Default | Description |
|---|---|---|---|
| options? | FixtureSidebarHostOptions | {} | The environments, and which members to offer. |
Returns
Constants#
DEMO_AGENT_PROFILESConstant#
Demo agent profiles.
const DEMO_AGENT_PROFILES: readonly ComposerAgentProfile[]DEMO_COMPOSER_COMMANDSConstant#
Demo commands for the / popover.
const DEMO_COMPOSER_COMMANDS: readonly CommandSummary[]DEMO_COMPOSER_FILESConstant#
Demo files for the @ popover.
const DEMO_COMPOSER_FILES: readonly FileEntry[]DEMO_COMPOSER_MODELSConstant#
Demo chat models for the pickers.
const DEMO_COMPOSER_MODELS: readonly ComposerModelEntry[]DEMO_TRANSCRIPTConstant#
The showcase session: rate limiting a chat endpoint, then documenting and committing it. Used by the product displays; none of it is real.
const DEMO_TRANSCRIPT: ChatEvent[]DEMO_TRANSCRIPT_ALL_KINDSConstant#
A synthetic two-exchange session that covers every transcript row kind. Used by the kit's tests and the gallery; none of it is real.
const DEMO_TRANSCRIPT_ALL_KINDS: ChatEvent[]Interfaces#
ChatFixtureInterface#
Static data a createFixtureHost serves: sessions, their transcripts, models, and pending interactions.
interface ChatFixtureProperties
| Name | Type | Description |
|---|---|---|
| extras? | ChatTranscriptFixture | The transcript extras (references, chips, card facts, badge actions, a shared search). Each part left out leaves its member out. |
| interactions? | Record<string, InteractionRequest[]> | Requests already waiting, per session id. |
| models? | ChatModelProvider[] | Providers and models for the model picker. Default: none. |
| sessions | ChatSession[] | The sessions the list starts with. |
| transcripts? | Record<string, ChatEvent[]> | Events per session id. |
ChatTranscriptFixtureInterface#
Static data for the transcript extras.
interface ChatTranscriptFixtureProperties
| Name | Type | Description |
|---|---|---|
| badges? | { effects: Readonly<Record<string, BadgeActionEffect>>; items: Readonly<Record<string, readonly BadgeMenuItem[]>> } | Badge items per folder, and the effect each item id answers. |
| blockRuns? | { exitCode: number; output: string } | Run here: what every block writes, and its exit code. Saved runs live in memory. |
| commands? | Readonly<Record<string, readonly ChatCommandFacts[]>> | Commands per folder. |
| commits? | Readonly<Record<string, ChatCommit>> | Commits by full sha. |
| contexts? | Readonly<Record<string, ChatContextFacts>> | Context gauges by session id. |
| paths? | Readonly<Record<string, Readonly<Record<string, ChatResolvedPath>>>> | What each text names, per folder (a text missing here names nothing). |
| references? | { providers: Readonly<Record<string, readonly ReferenceProviderWire[]>>; views: Readonly<Record<string, ExtensionReferenceView>> } | Reference providers per folder, and the views of their keys by |
| searchSync? | boolean | Share the transcript search between the windows of this page (one host per window). |
| sessions? | readonly ChatSessionFacts[] | The sessions |
| siteIcons? | Readonly<Record<string, string>> | Site icons (data URLs) by origin. |
| skills? | Readonly<Record<string, readonly ChatSkillFacts[]>> | Skills per folder. |
FixtureComposerChromeInterface#
The chrome members, with the controls a demo or a test plays.
interface FixtureComposerChrome extends Required<Pick<ComposerHost, 'controls' | 'models' | 'agents' | 'prefs' | 'pickerPrefs' | 'context' | 'runs'>>Properties
| Name | Type | Description |
|---|---|---|
agentsfrom Required | ComposerAgents | The agent profiles the agent picker offers. |
contextfrom Required | ComposerContext | A session's context gauge, its breakdown and its settled cost. |
controlsfrom Required | ComposerControls | The pickers' writes on a session (model, effort, options, agent) and their cache estimates. |
modelsfrom Required | ComposerModels | The model catalogs the pickers list. |
pickerPrefsfrom Required | ModelPickerPrefsStore | The model picker's per-device preferences. Absent: an in-memory store for the page's life. |
prefsfrom Required | ComposerPrefs | Where picks are remembered across apps (effort and options per model, the next chat's model). |
runsfrom Required | ComposerRuns | The current run's counters per session (the run chip, the cost pill). |
| runSignal | (signal: RunMeterSignal) => void | The backend streams a run signal ( |
FixtureComposerChromeOptionsInterface#
What the fixture's chrome holds.
interface FixtureComposerChromeOptionsProperties
| Name | Type | Description |
|---|---|---|
| agents? | readonly ComposerAgentProfile[] | The agent profiles. Default: |
| cacheImpact? | CacheImpact | null | What any switch costs the cache ( |
| context? | Record<string, { breakdown?: ContextBreakdown; cost?: ComposerCostStatus; status?: ComposerContextStatus }> | Each session's meters. |
| imageModels? | readonly ImageModelRow[] | The image models. |
| models? | readonly ComposerModelEntry[] | The chat models. Default: |
| prefs? | ComposerPrefsState | The remembered picks. |
| runProgress? | Record<string, ComposerRunProgress> | Each session's run in progress. |
| sessions? | Record<string, FixtureComposerSession> | Each session's picks (the controls write here). |
FixtureComposerHostInterface#
The fixture host, with the controls a demo or a test plays.
interface FixtureComposerHost extends Omit<ComposerHost, keyof FixtureComposerChrome>, FixtureComposerChromeProperties
| Name | Type | Description |
|---|---|---|
agentsfrom FixtureComposerChrome | ComposerAgents | The agent profiles the agent picker offers. |
autocomplete?from Omit | ComposerAutocomplete | Inline ghost text. |
completions?from Omit | ComposerCompletions | The completion catalogs. |
contextfrom FixtureComposerChrome | ComposerContext | A session's context gauge, its breakdown and its settled cost. |
controlsfrom FixtureComposerChrome | ComposerControls | The pickers' writes on a session (model, effort, options, agent) and their cache estimates. |
drafts?from Omit | ComposerDrafts | The shared per-session draft. |
folders?from Omit | ComposerFolders | The folder a new session opens in, remembered. Absent: a new session starts without one. |
modelsfrom FixtureComposerChrome | ComposerModels | The model catalogs the pickers list. |
pickerPrefsfrom FixtureComposerChrome | ModelPickerPrefsStore | The model picker's per-device preferences. Absent: an in-memory store for the page's life. |
prefsfrom FixtureComposerChrome | ComposerPrefs | Where picks are remembered across apps (effort and options per model, the next chat's model). |
runsfrom FixtureComposerChrome | ComposerRuns | The current run's counters per session (the run chip, the cost pill). |
suggestions?from Omit | ComposerSuggestions | Next-prompt suggestions. |
| announceDraft | (sessionId: string, text: string, shell?: boolean) => void | Another window changed a session's draft. |
| announceDraftAttachments | (sessionId: string, attachments: PromptAttachment[]) => void | Another window changed a session's staged files. |
| announceGhost | (ghost: ComposerSharedGhost) => void | Another window resolved a ghost text. |
runSignalfrom FixtureComposerChrome | (signal: RunMeterSignal) => void | The backend streams a run signal ( |
| startRun | (sessionId: string) => void | A run started: the session's suggestion goes stale. |
| suggest | (suggestion: ComposerPromptSuggestion) => void | A run ended with a next-prompt suggestion. |
FixtureComposerHostOptionsInterface#
What createFixtureComposerHost holds.
interface FixtureComposerHostOptions extends FixtureComposerChromeOptionsProperties
| Name | Type | Description |
|---|---|---|
agents?from FixtureComposerChromeOptions | readonly ComposerAgentProfile[] | The agent profiles. Default: |
cacheImpact?from FixtureComposerChromeOptions | CacheImpact | null | What any switch costs the cache ( |
| chats? | readonly ChatReferenceEntry[] | The sessions |
| commandArgs? | Record<string, readonly CommandArgSuggestionSummary[]> | The argument suggestions per command name. |
| commands? | readonly CommandSummary[] | The |
context?from FixtureComposerChromeOptions | Record<string, { breakdown?: ContextBreakdown; cost?: ComposerCostStatus; status?: ComposerContextStatus }> | Each session's meters. |
| drafts? | Record<string, SharedDraft> | The shared drafts per session. |
| files? | Record<string, readonly FileEntry[]> | The files under each root. |
| ghosts? | Record<string, readonly string[]> | Ghost text completions per draft text. |
imageModels?from FixtureComposerChromeOptions | readonly ImageModelRow[] | The image models. |
models?from FixtureComposerChromeOptions | readonly ComposerModelEntry[] | The chat models. Default: |
prefs?from FixtureComposerChromeOptions | ComposerPrefsState | The remembered picks. |
runProgress?from FixtureComposerChromeOptions | Record<string, ComposerRunProgress> | Each session's run in progress. |
sessions?from FixtureComposerChromeOptions | Record<string, FixtureComposerSession> | Each session's picks (the controls write here). |
| skills? | readonly SkillConfig[] | The enabled skills. |
FixtureComposerSessionInterface#
A session's picks as the fixture holds them.
interface FixtureComposerSessionProperties
| Name | Type | Description |
|---|---|---|
| agent? | string | The agent profile. |
| effort? | string | The reasoning effort. |
| model? | ModelPickRef[] | The model chain, primary first. |
| options? | Record<string, boolean> | The enabled options. |
FixtureHostOptionsInterface#
Options for createFixtureHost.
interface FixtureHostOptionsProperties
| Name | Type | Description |
|---|---|---|
| editable? | boolean | Allow create / rename / archive / favorite / delete (default true). |
| reply? | (prompt: string, sessionId: string) => FixtureStep[] | What the "agent" answers to a sent prompt; streamed in. None: |
| tickMs? | number | Milliseconds between streamed chunks (default 24). |
FixtureInteractionStepInterface#
A scripted pause: the run waits on interaction, then streams then(answer) (null: dismissed).
interface FixtureInteractionStepProperties
| Name | Type | Description |
|---|---|---|
| interaction | InteractionRequest | The question, plan, or approval the run raises. |
| then? | (response: InteractionResponse | null) => ChatEvent[] | Builds the events to stream after the user answers. Receives the response, or |
FixtureSidebarCallsInterface#
What the fixture recorded.
interface FixtureSidebarCallsProperties
| Name | Type | Description |
|---|---|---|
| hostSettings | string[] | Every host whose settings were opened, in order. |
| ran | { actionId: string; sessionId: string }[] | Every environment command run, in order. |
| retried | string[] | Every environment retried, in order. |
| revealed | string[] | Every folder revealed, in order. |
| windows | { mode: SessionWindowMode; sessionId: string }[] | Every window opened, in order. |
FixtureSidebarEnvironmentInterface#
One session's environment, as the fixture holds it.
interface FixtureSidebarEnvironmentProperties
| Name | Type | Description |
|---|---|---|
| actions | readonly EnvironmentActionSummary[] | The commands it offers. |
| results? | Readonly<Record<string, EnvironmentActionResult>> | What running each one answers (by action id). An action without one answers its label. |
FixtureSidebarHostInterface#
The SidebarHost createFixtureSidebarHost returns, with what it recorded.
interface FixtureSidebarHost extends SidebarHostProperties
| Name | Type | Description |
|---|---|---|
badges?from SidebarHost | SessionBadgesSource | The rows' badges and when they change, for |
| calls | FixtureSidebarCalls | What the host was asked to do. |
environment?from SidebarHost | SidebarEnvironmentHost | A session's environment commands. Absent: no retry, no environment commands. |
openHostSettings?from SidebarHost | (hostId: string) => Promise<void> | Opens a saved host's page in the app's settings. Absent: a server folder's host badge is not a button. |
openWindow?from SidebarHost | (sessionId: string, mode: SessionWindowMode) => Promise<void> | Opens a session in a window of its own. Absent: no window rows. |
revealPath?from SidebarHost | (path: string) => Promise<void> | Shows a folder of this machine in the file manager. Absent: no "Open in Finder". |
FixtureSidebarHostOptionsInterface#
What createFixtureSidebarHost holds.
interface FixtureSidebarHostOptionsProperties
| Name | Type | Description |
|---|---|---|
| environments? | Readonly<Record<string, FixtureSidebarEnvironment>> | Each session's environment commands. Default: none, and no |
| hostSettings? | boolean | Offer |
| reveal? | boolean | Offer |
| windows? | boolean | Offer |
Types#
FixtureStepType#
One step of a scripted reply: a transcript event to stream, or a FixtureInteractionStep that pauses the run.
type FixtureStep = ChatEvent | FixtureInteractionStep