# zidane-ui/chat/testing

Import: `import { … } from 'zidane-ui/chat/testing'`. Source: [ui/src/chat/testing/index.ts](https://github.com/Tahul/zidane/blob/main/ui/src/chat/testing/index.ts).

## Functions

### `createFixtureComposerChrome`

Function.

Creates the fixture's chrome members.

```ts
function createFixtureComposerChrome(
  options?: FixtureComposerChromeOptions,
): FixtureComposerChrome
```

**Parameters**

- `options?` (`FixtureComposerChromeOptions`, default `{}`): What they hold. Leave a list out for the demo one.

**Returns** `FixtureComposerChrome`

Source: [ui/src/chat/testing/fixture-composer-chrome.ts:109](https://github.com/Tahul/zidane/blob/main/ui/src/chat/testing/fixture-composer-chrome.ts#L109)

### `createFixtureComposerHost`

Function.

Creates a [`FixtureComposerHost`](https://zidane.si/docs/reference/ui-chat-testing.md#FixtureComposerHost).

```ts
function createFixtureComposerHost(
  options?: FixtureComposerHostOptions,
): FixtureComposerHost
```

**Parameters**

- `options?` (`FixtureComposerHostOptions`, default `{}`): What it holds. Leave a list out for the demo one.

**Returns** `FixtureComposerHost`

Source: [ui/src/chat/testing/fixture-composer-host.ts:79](https://github.com/Tahul/zidane/blob/main/ui/src/chat/testing/fixture-composer-host.ts#L79)

### `createFixtureHost`

Function.

Creates a complete [`ChatHost`](https://zidane.si/docs/reference/ui-chat-headless.md#ChatHost) over static data, held in memory. The kit's demos, docs, and tests run on it.

```ts
function createFixtureHost(fixture: ChatFixture, options?: FixtureHostOptions): ChatHost
```

**Parameters**

- `fixture` (`ChatFixture`): The sessions, transcripts, models, and interactions to serve.
- `options?` (`FixtureHostOptions`, default `{}`): Whether the host is editable, how it replies to prompts, and the streaming pace.

**Returns** `ChatHost`

Source: [ui/src/chat/headless/fixture-host.ts:67](https://github.com/Tahul/zidane/blob/main/ui/src/chat/headless/fixture-host.ts#L67)

### `createFixtureSidebarHost`

Function.

Creates a [`SidebarHost`](https://zidane.si/docs/reference/ui-chat-headless.md#SidebarHost) held in memory.

```ts
function createFixtureSidebarHost(
  options?: FixtureSidebarHostOptions,
): FixtureSidebarHost
```

**Parameters**

- `options?` (`FixtureSidebarHostOptions`, default `{}`): The environments, and which members to offer.

**Returns** `FixtureSidebarHost`

Source: [ui/src/chat/testing/fixture-sidebar-host.ts:55](https://github.com/Tahul/zidane/blob/main/ui/src/chat/testing/fixture-sidebar-host.ts#L55)

## Constants

### `DEMO_AGENT_PROFILES`

Constant.

Demo agent profiles.

```ts
const DEMO_AGENT_PROFILES: readonly ComposerAgentProfile[]
```

Source: [ui/src/chat/testing/fixture-composer-chrome.ts:95](https://github.com/Tahul/zidane/blob/main/ui/src/chat/testing/fixture-composer-chrome.ts#L95)

### `DEMO_COMPOSER_COMMANDS`

Constant.

Demo commands for the `/` popover.

```ts
const DEMO_COMPOSER_COMMANDS: readonly CommandSummary[]
```

Source: [ui/src/chat/testing/fixture-composer-host.ts:69](https://github.com/Tahul/zidane/blob/main/ui/src/chat/testing/fixture-composer-host.ts#L69)

### `DEMO_COMPOSER_FILES`

Constant.

Demo files for the `@` popover.

```ts
const DEMO_COMPOSER_FILES: readonly FileEntry[]
```

Source: [ui/src/chat/testing/fixture-composer-host.ts:62](https://github.com/Tahul/zidane/blob/main/ui/src/chat/testing/fixture-composer-host.ts#L62)

### `DEMO_COMPOSER_MODELS`

Constant.

Demo chat models for the pickers.

```ts
const DEMO_COMPOSER_MODELS: readonly ComposerModelEntry[]
```

Source: [ui/src/chat/testing/fixture-composer-chrome.ts:66](https://github.com/Tahul/zidane/blob/main/ui/src/chat/testing/fixture-composer-chrome.ts#L66)

### `DEMO_TRANSCRIPT`

Constant.

The showcase session: rate limiting a chat endpoint, then documenting and committing it. Used by the product displays; none of it is real.

```ts
const DEMO_TRANSCRIPT: ChatEvent[]
```

Source: [ui/src/chat/headless/fixtures/demo-transcript.ts:82](https://github.com/Tahul/zidane/blob/main/ui/src/chat/headless/fixtures/demo-transcript.ts#L82)

### `DEMO_TRANSCRIPT_ALL_KINDS`

Constant.

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.

```ts
const DEMO_TRANSCRIPT_ALL_KINDS: ChatEvent[]
```

Source: [ui/src/chat/headless/fixtures/demo-transcript-all-kinds.ts:44](https://github.com/Tahul/zidane/blob/main/ui/src/chat/headless/fixtures/demo-transcript-all-kinds.ts#L44)

## Interfaces

### `ChatFixture`

Interface.

Static data a [`createFixtureHost`](https://zidane.si/docs/reference/ui-chat-testing.md#createFixtureHost) serves: sessions, their transcripts, models, and pending interactions.

```ts
interface ChatFixture
```

**Properties**

- `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.

Source: [ui/src/chat/headless/fixture-host.ts:25](https://github.com/Tahul/zidane/blob/main/ui/src/chat/headless/fixture-host.ts#L25)

### `ChatTranscriptFixture`

Interface.

Static data for the transcript extras.

```ts
interface ChatTranscriptFixture
```

**Properties**

- `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 `providerId:key`.
- `searchSync?` (`boolean`): Share the transcript search between the windows of this page (one host per window).
- `sessions?` (`readonly ChatSessionFacts[]`): The sessions `#chat` cards read.
- `siteIcons?` (`Readonly<Record<string, string>>`): Site icons (data URLs) by origin.
- `skills?` (`Readonly<Record<string, readonly ChatSkillFacts[]>>`): Skills per folder.

Source: [ui/src/chat/headless/fixture-transcript.ts:31](https://github.com/Tahul/zidane/blob/main/ui/src/chat/headless/fixture-transcript.ts#L31)

### `FixtureComposerChrome`

Interface.

The chrome members, with the controls a demo or a test plays.

```ts
interface FixtureComposerChrome extends Required<Pick<ComposerHost, 'controls' | 'models' | 'agents' | 'prefs' | 'pickerPrefs' | 'context' | 'runs'>>
```

**Properties**

- `agents` (`ComposerAgents`, from `Required`): The agent profiles the agent picker offers.
- `context` (`ComposerContext`, from `Required`): A session's context gauge, its breakdown and its settled cost.
- `controls` (`ComposerControls`, from `Required`): The pickers' writes on a session (model, effort, options, agent) and their cache estimates.
- `models` (`ComposerModels`, from `Required`): The model catalogs the pickers list.
- `pickerPrefs` (`ModelPickerPrefsStore`, from `Required`): The model picker's per-device preferences. Absent: an in-memory store for the page's life.
- `prefs` (`ComposerPrefs`, from `Required`): Where picks are remembered across apps (effort and options per model, the next chat's model).
- `runs` (`ComposerRuns`, from `Required`): The current run's counters per session (the run chip, the cost pill).
- `runSignal` (`(signal: RunMeterSignal) => void`): The backend streams a run signal (`run:start`, `stream:progress`, `turn:end`, `run:end`).

Source: [ui/src/chat/testing/fixture-composer-chrome.ts:58](https://github.com/Tahul/zidane/blob/main/ui/src/chat/testing/fixture-composer-chrome.ts#L58)

### `FixtureComposerChromeOptions`

Interface.

What the fixture's chrome holds.

```ts
interface FixtureComposerChromeOptions
```

**Properties**

- `agents?` (`readonly ComposerAgentProfile[]`): The agent profiles. Default: [`DEMO_AGENT_PROFILES`](https://zidane.si/docs/reference/ui-chat-testing.md#DEMO_AGENT_PROFILES).
- `cacheImpact?` (`CacheImpact | null`): What any switch costs the cache (`null`: unknown).
- `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: [`DEMO_COMPOSER_MODELS`](https://zidane.si/docs/reference/ui-chat-testing.md#DEMO_COMPOSER_MODELS).
- `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).

Source: [ui/src/chat/testing/fixture-composer-chrome.ts:35](https://github.com/Tahul/zidane/blob/main/ui/src/chat/testing/fixture-composer-chrome.ts#L35)

### `FixtureComposerHost`

Interface.

The fixture host, with the controls a demo or a test plays.

```ts
interface FixtureComposerHost extends Omit<ComposerHost, keyof FixtureComposerChrome>, FixtureComposerChrome
```

**Properties**

- `agents` (`ComposerAgents`, from `FixtureComposerChrome`): The agent profiles the agent picker offers.
- `autocomplete?` (`ComposerAutocomplete`, from `Omit`): Inline ghost text.
- `completions?` (`ComposerCompletions`, from `Omit`): The completion catalogs.
- `context` (`ComposerContext`, from `FixtureComposerChrome`): A session's context gauge, its breakdown and its settled cost.
- `controls` (`ComposerControls`, from `FixtureComposerChrome`): The pickers' writes on a session (model, effort, options, agent) and their cache estimates.
- `drafts?` (`ComposerDrafts`, from `Omit`): The shared per-session draft.
- `folders?` (`ComposerFolders`, from `Omit`): The folder a new session opens in, remembered. Absent: a new session starts without one.
- `models` (`ComposerModels`, from `FixtureComposerChrome`): The model catalogs the pickers list.
- `pickerPrefs` (`ModelPickerPrefsStore`, from `FixtureComposerChrome`): The model picker's per-device preferences. Absent: an in-memory store for the page's life.
- `prefs` (`ComposerPrefs`, from `FixtureComposerChrome`): Where picks are remembered across apps (effort and options per model, the next chat's model).
- `runs` (`ComposerRuns`, from `FixtureComposerChrome`): The current run's counters per session (the run chip, the cost pill).
- `suggestions?` (`ComposerSuggestions`, from `Omit`): 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.
- `runSignal` (`(signal: RunMeterSignal) => void`, from `FixtureComposerChrome`): The backend streams a run signal (`run:start`, `stream:progress`, `turn:end`, `run:end`).
- `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.

Source: [ui/src/chat/testing/fixture-composer-host.ts:48](https://github.com/Tahul/zidane/blob/main/ui/src/chat/testing/fixture-composer-host.ts#L48)

### `FixtureComposerHostOptions`

Interface.

What [`createFixtureComposerHost`](https://zidane.si/docs/reference/ui-chat-testing.md#createFixtureComposerHost) holds.

```ts
interface FixtureComposerHostOptions extends FixtureComposerChromeOptions
```

**Properties**

- `agents?` (`readonly ComposerAgentProfile[]`, from `FixtureComposerChromeOptions`): The agent profiles. Default: [`DEMO_AGENT_PROFILES`](https://zidane.si/docs/reference/ui-chat-testing.md#DEMO_AGENT_PROFILES).
- `cacheImpact?` (`CacheImpact | null`, from `FixtureComposerChromeOptions`): What any switch costs the cache (`null`: unknown).
- `chats?` (`readonly ChatReferenceEntry[]`): The sessions `#` can reference.
- `commandArgs?` (`Record<string, readonly CommandArgSuggestionSummary[]>`): The argument suggestions per command name.
- `commands?` (`readonly CommandSummary[]`): The `/` commands.
- `context?` (`Record<string, { breakdown?: ContextBreakdown; cost?: ComposerCostStatus; status?: ComposerContextStatus }>`, from `FixtureComposerChromeOptions`): 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?` (`readonly ImageModelRow[]`, from `FixtureComposerChromeOptions`): The image models.
- `models?` (`readonly ComposerModelEntry[]`, from `FixtureComposerChromeOptions`): The chat models. Default: [`DEMO_COMPOSER_MODELS`](https://zidane.si/docs/reference/ui-chat-testing.md#DEMO_COMPOSER_MODELS).
- `prefs?` (`ComposerPrefsState`, from `FixtureComposerChromeOptions`): The remembered picks.
- `runProgress?` (`Record<string, ComposerRunProgress>`, from `FixtureComposerChromeOptions`): Each session's run in progress.
- `sessions?` (`Record<string, FixtureComposerSession>`, from `FixtureComposerChromeOptions`): Each session's picks (the controls write here).
- `skills?` (`readonly SkillConfig[]`): The enabled skills.

Source: [ui/src/chat/testing/fixture-composer-host.ts:30](https://github.com/Tahul/zidane/blob/main/ui/src/chat/testing/fixture-composer-host.ts#L30)

### `FixtureComposerSession`

Interface.

A session's picks as the fixture holds them.

```ts
interface FixtureComposerSession
```

**Properties**

- `agent?` (`string`): The agent profile.
- `effort?` (`string`): The reasoning effort.
- `model?` (`ModelPickRef[]`): The model chain, primary first.
- `options?` (`Record<string, boolean>`): The enabled options.

Source: [ui/src/chat/testing/fixture-composer-chrome.ts:23](https://github.com/Tahul/zidane/blob/main/ui/src/chat/testing/fixture-composer-chrome.ts#L23)

### `FixtureHostOptions`

Interface.

Options for [`createFixtureHost`](https://zidane.si/docs/reference/ui-chat-testing.md#createFixtureHost).

```ts
interface FixtureHostOptions
```

**Properties**

- `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: `send`, `interrupt`, `steer` and `followUp` are absent.
- `tickMs?` (`number`): Milliseconds between streamed chunks (default 24).

Source: [ui/src/chat/headless/fixture-host.ts:50](https://github.com/Tahul/zidane/blob/main/ui/src/chat/headless/fixture-host.ts#L50)

### `FixtureInteractionStep`

Interface.

A scripted pause: the run waits on `interaction`, then streams `then(answer)` (`null`: dismissed).

```ts
interface FixtureInteractionStep
```

**Properties**

- `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 `null` when the request was dismissed.

Source: [ui/src/chat/headless/fixture-host.ts:39](https://github.com/Tahul/zidane/blob/main/ui/src/chat/headless/fixture-host.ts#L39)

### `FixtureSidebarCalls`

Interface.

What the fixture recorded.

```ts
interface FixtureSidebarCalls
```

**Properties**

- `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.

Source: [ui/src/chat/testing/fixture-sidebar-host.ts:31](https://github.com/Tahul/zidane/blob/main/ui/src/chat/testing/fixture-sidebar-host.ts#L31)

### `FixtureSidebarEnvironment`

Interface.

One session's environment, as the fixture holds it.

```ts
interface FixtureSidebarEnvironment
```

**Properties**

- `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.

Source: [ui/src/chat/testing/fixture-sidebar-host.ts:11](https://github.com/Tahul/zidane/blob/main/ui/src/chat/testing/fixture-sidebar-host.ts#L11)

### `FixtureSidebarHost`

Interface.

The [`SidebarHost`](https://zidane.si/docs/reference/ui-chat-headless.md#SidebarHost) [`createFixtureSidebarHost`](https://zidane.si/docs/reference/ui-chat-testing.md#createFixtureSidebarHost) returns, with what it recorded.

```ts
interface FixtureSidebarHost extends SidebarHost
```

**Properties**

- `badges?` (`SessionBadgesSource`, from `SidebarHost`): The rows' badges and when they change, for `createSessionBadges`. Absent: the app reads them its own way, or rows show none.
- `calls` (`FixtureSidebarCalls`): What the host was asked to do.
- `environment?` (`SidebarEnvironmentHost`, from `SidebarHost`): A session's environment commands. Absent: no retry, no environment commands.
- `openHostSettings?` (`(hostId: string) => Promise<void>`, from `SidebarHost`): Opens a saved host's page in the app's settings. Absent: a server folder's host badge is not a button.
- `openWindow?` (`(sessionId: string, mode: SessionWindowMode) => Promise<void>`, from `SidebarHost`): Opens a session in a window of its own. Absent: no window rows.
- `revealPath?` (`(path: string) => Promise<void>`, from `SidebarHost`): Shows a folder of this machine in the file manager. Absent: no "Open in Finder".

Source: [ui/src/chat/testing/fixture-sidebar-host.ts:45](https://github.com/Tahul/zidane/blob/main/ui/src/chat/testing/fixture-sidebar-host.ts#L45)

### `FixtureSidebarHostOptions`

Interface.

What [`createFixtureSidebarHost`](https://zidane.si/docs/reference/ui-chat-testing.md#createFixtureSidebarHost) holds.

```ts
interface FixtureSidebarHostOptions
```

**Properties**

- `environments?` (`Readonly<Record<string, FixtureSidebarEnvironment>>`): Each session's environment commands. Default: none, and no `environment` member.
- `hostSettings?` (`boolean`): Offer `openHostSettings`. Default: true.
- `reveal?` (`boolean`): Offer `revealPath`. Default: true.
- `windows?` (`boolean`): Offer `openWindow`. Default: true.

Source: [ui/src/chat/testing/fixture-sidebar-host.ts:19](https://github.com/Tahul/zidane/blob/main/ui/src/chat/testing/fixture-sidebar-host.ts#L19)

## Types

### `FixtureStep`

Type.

One step of a scripted reply: a transcript event to stream, or a [`FixtureInteractionStep`](https://zidane.si/docs/reference/ui-chat-testing.md#FixtureInteractionStep) that pauses the run.

```ts
type FixtureStep = ChatEvent | FixtureInteractionStep
```

Source: [ui/src/chat/headless/fixture-host.ts:47](https://github.com/Tahul/zidane/blob/main/ui/src/chat/headless/fixture-host.ts#L47)
