Skip to content

zidane-ui/chat/testing/contract

import { … } from 'zidane-ui/chat/testing/contract'ui/src/chat/testing/contract.ts

Functions#

describeChatHostContractFunction#

Declares the shared ChatHost suite for one implementation.

TypeScript
function describeChatHostContract(
  name: string,
  makeHarness: ChatHostHarnessFactory,
  capabilities: readonly ChatHostCapability[],
): void
Parameters
NameTypeDescription
namestring

The implementation's name, shown in the suite title.

makeHarnessChatHostHarnessFactory

Builds a fresh host over a backend that holds and does what it is given, once per test.

capabilitiesreadonly ChatHostCapability[]

The optional members the host offers. Every other optional member must be undefined.

ui/src/chat/testing/contract.ts:275

describeComposerHostContractFunction#

Registers the contract's tests for one implementation.

TypeScript
function describeComposerHostContract(
  name: string,
  makeHarness: ComposerHostHarnessFactory,
  capabilities: readonly ComposerHostCapability[],
): void
Parameters
NameTypeDescription
namestring

The implementation's name, in the suite's title.

makeHarnessComposerHostHarnessFactory

Builds a host over the scripted backend.

capabilitiesreadonly ComposerHostCapability[]

The optional members the implementation offers.

ui/src/chat/testing/composer.contract.ts:292

describeSidebarHostContractFunction#

Declares the shared SidebarHost suite for one implementation.

TypeScript
function describeSidebarHostContract(
  name: string,
  makeHarness: SidebarHostHarnessFactory,
  capabilities: readonly SidebarHostCapability[],
): void
Parameters
NameTypeDescription
namestring

The implementation's name, shown in the suite title.

makeHarnessSidebarHostHarnessFactory

Builds a fresh host over a backend that holds what it is given, once per test.

capabilitiesreadonly SidebarHostCapability[]

The optional members the host offers. Every other optional member must be undefined.

ui/src/chat/testing/sidebar.contract.ts:100

Interfaces#

ChatHostContractBackendInterface#

What the backend behind the host holds, and how it answers a prompt.

TypeScript
interface ChatHostContractBackend
ChatHostContractBackend properties
NameTypeDescription
badgeEffectsReadonly<Record<string, BadgeActionEffect>>

The effect running an item answers, by item id.

badgeItemsReadonly<Record<string, readonly BadgeMenuItem[]>>

The extensions' badge items per folder.

blockRuns{ exitCode: number; output: string }

Run here: what every block writes, and its exit code.

commandsReadonly<Record<string, readonly ChatCommandFacts[]>>

Commands per folder.

commitsReadonly<Record<string, ChatCommit>>

Commits by full sha (any folder).

contextsReadonly<Record<string, ChatContextFacts>>

Context gauges by session id.

mainSessionstring | null

The orchestration Main session's id (created by the first ask), null while orchestration is off.

pathsReadonly<Record<string, Readonly<Record<string, ChatResolvedPath>>>>

What each text names, per folder (a text missing here names nothing: missing).

providerReadyboolean

Whether a model provider can answer a prompt.

references{ providers: Readonly<Record<string, readonly ReferenceProviderWire[]>>; views: Readonly<Record<string, ExtensionReferenceView>> }

Extension reference providers per folder, and the views of their keys by providerId:key.

sessionFactsreadonly ChatSessionFacts[]

The sessions #chat cards read.

sessionsreadonly ChatSession[]

The sessions the backend starts with.

siteIconsReadonly<Record<string, string>>

Site icons by origin (an origin missing here has none).

skillsReadonly<Record<string, readonly ChatSkillFacts[]>>

Skills per folder.

toolOutputsReadonly<Record<string, string>>

A tool call's full output, by call id (any session).

transcriptsReadonly<Record<string, readonly ChatEvent[]>>

Stored events per session id (a session missing here has none).

script(prompt: string) => readonly ChatHostScriptStep[]

What a run does with a sent prompt. The backend echoes the prompt into the transcript, starts the run, plays these steps, and ends the run when they are done (unless a step holds it).

shell(command: string) => string

What a ! run of command prints; the backend streams it into the session's transcript (no prompt echo).

ui/src/chat/testing/contract.ts:130

ChatHostContractControlInterface#

Changes the backend from outside, as another window or the backend does.

TypeScript
interface ChatHostContractControl
ChatHostContractControl properties
NameTypeDescription
searchChanged?(state: ChatSearchState) => void

Another window changed a session's transcript search.

ui/src/chat/testing/contract.ts:176

ChatHostHarnessInterface#

A host built over a scripted backend, and how to tear it down.

TypeScript
interface ChatHostHarness
ChatHostHarness properties
NameTypeDescription
control?ChatHostContractControl

Changes the backend from outside. Absent: the behaviours that need it are skipped.

hostChatHost

The host under test.

dispose?() => void

Closes connections and timers after each test.

ui/src/chat/testing/contract.ts:182

ComposerContractSessionInterface#

A session's picks as the backend holds them: what the controls write.

TypeScript
interface ComposerContractSession
ComposerContractSession properties
NameTypeDescription
agent?string

The agent profile.

effort?string

The reasoning effort.

model?ModelPickRef[]

The model chain, primary first.

options?Record<string, boolean>

The enabled options.

ui/src/chat/testing/composer.contract.ts:125

ComposerHostContractBackendInterface#

What the backend behind the host holds.

TypeScript
interface ComposerHostContractBackend
ComposerHostContractBackend properties
NameTypeDescription
agentsreadonly ComposerAgentProfile[]

The agent profiles.

cacheImpactCacheImpact | null

What any switch costs the cache.

chatsreadonly ChatReferenceEntry[]

The sessions # can reference.

commandArgsReadonly<Record<string, readonly CommandArgSuggestionSummary[]>>

The argument suggestions per command name.

commandsreadonly CommandSummary[]

The / commands.

contextRecord<string, { breakdown?: ComposerContextBreakdown; cost?: ComposerCostStatus; status?: ComposerContextStatus }>

Each session's meters.

draftsRecord<string, SharedDraft>

The shared draft per session (a session missing here has none).

filesReadonly<Record<string, readonly FileEntry[]>>

The files under each root.

ghostsReadonly<Record<string, readonly string[]>>

The ghost text completions per draft text.

lastFolderstring | null

The folder last used for a new session (folders.setLastUsed writes here).

modelsreadonly ComposerModelEntry[]

The chat models.

prefsComposerPrefsState

The remembered picks (prefs write here).

runProgressRecord<string, ComposerRunProgress>

Each session's run in progress.

sessionsRecord<string, ComposerContractSession>

Each session's picks (the controls write here).

skillsreadonly SkillConfig[]

The enabled skills.

ui/src/chat/testing/composer.contract.ts:137

ComposerHostContractControlInterface#

What the other windows (and the agent) do, announced as the backend announces it.

TypeScript
interface ComposerHostContractControl
ComposerHostContractControl properties
NameTypeDescription
runSignal?(signal: RunMeterSignal) => void

The backend streams a run signal. Needed for runs.

setDraft(sessionId: string, text: string, shell?: boolean) => void

Another window changed a session's draft text.

setDraftAttachments(sessionId: string, attachments: PromptAttachment[]) => void

Another window changed a session's staged files.

shareGhost(ghost: ComposerSharedGhost) => void

Another window resolved a ghost text.

startRun(sessionId: string) => void

A run started in a session.

suggest(suggestion: ComposerPromptSuggestion) => void

A run ended with a next-prompt suggestion.

ui/src/chat/testing/composer.contract.ts:174

ComposerHostHarnessInterface#

A host built over a backend, the backend's control, and how to tear them down.

TypeScript
interface ComposerHostHarness
ComposerHostHarness properties
NameTypeDescription
controlComposerHostContractControl

What the other windows do.

hostComposerHost

The host under test.

dispose?() => void

Closes connections after each test.

ui/src/chat/testing/composer.contract.ts:190

SidebarHostContractBackendInterface#

What the backend behind the host holds.

TypeScript
interface SidebarHostContractBackend
SidebarHostContractBackend properties
NameTypeDescription
badgesReadonly<Record<string, readonly SessionBadgeEntry[]>>

Each session's badges; a session left out has none.

environmentsReadonly<Record<string, { actions: readonly EnvironmentActionSummary[]; results: Readonly<Record<string, EnvironmentActionResult>> }>>

Each session's environment: the commands it offers and what running each answers.

ui/src/chat/testing/sidebar.contract.ts:32

SidebarHostContractControlInterface#

Reads what the backend was asked to do.

TypeScript
interface SidebarHostContractControl
SidebarHostContractControl properties
NameTypeDescription
changeArtifacts?(sessionId: string) => void

The backend records or changes an artifact of sessionId. Only called with badges.

changeKinds?() => void

The backend's badge kinds change (extensions installed or removed). Only called with badges.

hostSettingsOpened?() => readonly string[]

The hosts whose settings were opened, in order. Only read with openHostSettings.

retried?() => readonly string[]

The environments set up again, in order. Only read with environment.

revealed?() => readonly string[]

The folders revealed, in order. Only read with revealPath.

windows?() => readonly { mode: SessionWindowMode; sessionId: string }[]

The windows opened, in order. Only read with openWindow.

ui/src/chat/testing/sidebar.contract.ts:45

SidebarHostHarnessInterface#

A host built over a backend, the backend's control, and how to tear them down.

TypeScript
interface SidebarHostHarness
SidebarHostHarness properties
NameTypeDescription
controlSidebarHostContractControl

Reads the backend.

hostSidebarHost

The host under test.

dispose?() => void

Closes connections after each test.

ui/src/chat/testing/sidebar.contract.ts:61

Types#

ChatHostCapabilityType#

An optional ChatHost member, by its path.

TypeScript
type ChatHostCapability =
  | 'sessions'
  | 'sessions.create'
  | 'sessions.rename'
  | 'sessions.setArchived'
  | 'sessions.setFavorite'
  | 'sessions.remove'
  | 'sessions.query'
  | 'sessions.setSpace'
  | 'sessions.search'
  | 'sessions.onChanged'
  | 'sessions.views'
  | 'sessions.main'
  | 'send'
  | 'interrupt'
  | 'shell'
  | 'providerReady'
  | 'interactions'
  | 'interactions.cancel'
  | 'interactions.all'
  | 'models'
  | 'toolOutput'
  | 'cancelTool'
  | 'searchSync'
  | 'references'
  | 'paths'
  | 'chips'
  | 'chips.commit'
  | 'chips.sessions'
  | 'chips.context'
  | 'chips.skills'
  | 'chips.commands'
  | 'badges'
  | 'siteIcons'
  | 'blockRuns'

ui/src/chat/testing/contract.ts:33

ChatHostHarnessFactoryType#

Builds a fresh host (and its backend) for one test.

TypeScript
type ChatHostHarnessFactory = (backend: ChatHostContractBackend) => ChatHostHarness | Promise<ChatHostHarness>

ui/src/chat/testing/contract.ts:192

ChatHostScriptStepType#

One thing the backend does while it runs a prompt, in order.

TypeScript
type ChatHostScriptStep =
  | { kind: 'reply'; text: string }
  | { kind: 'ask'; request: InteractionRequest }
  | { kind: 'hold' }

ui/src/chat/testing/contract.ts:121

ComposerHostCapabilityType#

An optional ComposerHost member, by its path.

TypeScript
type ComposerHostCapability =
  | 'drafts'
  | 'drafts.setAttachments'
  | 'drafts.onChanged'
  | 'drafts.onAttachmentsChanged'
  | 'completions'
  | 'completions.files'
  | 'completions.commands'
  | 'completions.commandArgs'
  | 'completions.chats'
  | 'completions.watchSkills'
  | 'completions.watchExtensionProviders'
  | 'completions.extensionItems'
  | 'completions.submit'
  | 'completions.locationOf'
  | 'folders'
  | 'autocomplete'
  | 'autocomplete.onShared'
  | 'suggestions'
  | 'suggestions.onStale'
  | 'controls'
  | 'controls.setModel'
  | 'controls.setEffort'
  | 'controls.setModelOptions'
  | 'controls.setAgent'
  | 'controls.cacheImpact'
  | 'models'
  | 'models.images'
  | 'models.providers'
  | 'agents'
  | 'agents.onChanged'
  | 'prefs'
  | 'pickerPrefs'
  | 'context'
  | 'context.status'
  | 'context.breakdown'
  | 'context.cost'
  | 'runs'
  | 'runs.progress'
  | 'runs.noteSeen'
  | 'runs.noteProgress'
  | 'runs.settleCost'

ui/src/chat/testing/composer.contract.ts:37

ComposerHostHarnessFactoryType#

Builds a fresh host (and its backend) for one test.

TypeScript
type ComposerHostHarnessFactory = (backend: ComposerHostContractBackend) => ComposerHostHarness | Promise<ComposerHostHarness>

ui/src/chat/testing/composer.contract.ts:200

SidebarHostCapabilityType#

An optional SidebarHost member.

TypeScript
type SidebarHostCapability =
  | 'revealPath'
  | 'openWindow'
  | 'environment'
  | 'badges'
  | 'openHostSettings'

ui/src/chat/testing/sidebar.contract.ts:21

SidebarHostHarnessFactoryType#

Builds a fresh host (and its backend) for one test.

TypeScript
type SidebarHostHarnessFactory = (backend: SidebarHostContractBackend) => SidebarHostHarness | Promise<SidebarHostHarness>

ui/src/chat/testing/sidebar.contract.ts:71