Skip to content

zidane-ui/session/testing

import { … } from 'zidane-ui/session/testing'ui/src/session/testing/index.ts

Functions#

createFixturePlansBackendFunction#

Creates a FixturePlansBackend.

TypeScript
function createFixturePlansBackend(seed?: FixturePlansSeed): FixturePlansBackend
Parameters
NameTypeDefaultDescription
seed?FixturePlansSeed{}

The plans and task lists it starts with.

ui/src/session/headless/fixture-plans.ts:89

createFixtureScheduleBackendFunction#

Creates a FixtureScheduleBackend.

TypeScript
function createFixtureScheduleBackend(
  options?: FixtureScheduleOptions,
): FixtureScheduleBackend
Parameters
NameTypeDefaultDescription
options?FixtureScheduleOptions{}

The starting schedules, fires, setting and clock.

ui/src/session/headless/fixture-schedules.ts:65

createFixtureSessionHostFunction#

Creates a FixtureSessionHost over the fixture's data.

TypeScript
function createFixtureSessionHost(fixture?: SessionFixture): FixtureSessionHost
Parameters
NameTypeDefaultDescription
fixture?SessionFixture{}

The data per session.

ui/src/session/headless/fixture-host.ts:118

demoUsageSummaryFunction#

A usage summary over range, ending on today: a few months of steady use across three models.

TypeScript
function demoUsageSummary(range: UsageRange, today?: Date): UsageSummary
Parameters
NameTypeDescription
rangeUsageRange

The range it covers.

today?Date

The last day.

ui/src/session/testing/demo.ts:54

planOfFunction#

A session-scope plan over a task list, for fixtures and tests.

TypeScript
function planOf(items: readonly TodoItem[], plan?: Partial<Plan>): Plan
Parameters
NameTypeDefaultDescription
itemsreadonly TodoItem[]

The steps, as todo items.

plan?Partial<Plan>{}

Fields over the defaults (an applying adhoc plan plan-1, untitled).

Plan

ui/src/session/headless/fixture-plans.ts:58

plansSnapshotOfFunction#

The snapshot of a session's plans, as the host broadcasts it (every run live: nothing reads as interrupted).

TypeScript
function plansSnapshotOf(plans: readonly PlanView[]): PlansSnapshot
Parameters
NameTypeDescription
plansreadonly PlanView[]

The plans, oldest first.

ui/src/session/headless/fixture-plans.ts:48

tallyTodosFunction#

Counts todo items by status.

TypeScript
function tallyTodos(items: readonly { status: TodoStatus }[]): TodoTallyCounts
Parameters
NameTypeDescription
itemsreadonly { status: TodoStatus }[]

The todo list.

ui/src/session/headless/fixture-plans.ts:78

Constants#

DEMO_ARTIFACT_KIND_LABELSConstant#

The artifact kinds' labels in the demo, as the backend's kind registry words them.

TypeScript
const DEMO_ARTIFACT_KIND_LABELS: Readonly<Record<string, string>>

ui/src/session/testing/demo.ts:25

DEMO_GITHUB_USAGEConstant#

GitHub's API limits in the demo.

TypeScript
const DEMO_GITHUB_USAGE: readonly ProviderUsageSnapshot[]

ui/src/session/testing/demo.ts:157

DEMO_PROVIDER_USAGEConstant#

Subscription windows: one provider with two accounts' worth of windows, one with credits.

TypeScript
const DEMO_PROVIDER_USAGE: readonly ProviderUsageSnapshot[]

ui/src/session/testing/demo.ts:109

DEMO_SESSION_FIXTUREConstant#

A session (demo) with todos mid-task, two queued messages, three artifacts, running work and turns, plus usage.

TypeScript
const DEMO_SESSION_FIXTURE: SessionFixture

ui/src/session/testing/demo.ts:177

DEMO_TURNSConstant#

The demo's stored turns: a prompt and the answer.

TypeScript
const DEMO_TURNS: readonly SessionTurn[]

ui/src/session/testing/demo.ts:33

SCHEDULES_OFF_MESSAGEConstant#

The message zidane's backend answers while the setting is off.

TypeScript
const SCHEDULES_OFF_MESSAGE: 'Reminders are off. Turn them on in Settings > Sessions > Reminders.'

ui/src/session/headless/fixture-schedules.ts:58

Interfaces#

FixturePlansBackendInterface#

A plans backend in memory.

TypeScript
interface FixturePlansBackend
FixturePlansBackend properties
NameTypeDescription
control(sessionId: string, planId: string, action: PlanControlAction) => PlansSnapshot

A stop or drop (plans.control). Throws the gate's reason.

edit(sessionId: string, planId: string, op: PlanEditOp) => PlansSnapshot

A user edit (plans.edit). Throws the gate's reason.

endRun(sessionId: string, outcome?: 'error' | 'completed' | 'aborted') => void

The session's run ended: the plan it applied stops.

setPlans(sessionId: string, plans: readonly PlanView[]) => void

Replaces a session's plans.

snapshot(sessionId: string) => PlansSnapshot | null

A session's snapshot, null for a session it does not hold.

subscribe(listener: (sessionId: string) => void) => () => void

Calls listener with a session's id after each change. Returns the unsubscribe.

writeTodos(sessionId: string, items: readonly TodoItem[]) => void

The agent's todowrite: updates the applying plan, starts one, or resumes a stopped one with the same step ids.

ui/src/session/headless/fixture-plans.ts:24

FixturePlansSeedInterface#

What a fixture plans backend starts with, per session id.

TypeScript
interface FixturePlansSeed
FixturePlansSeed properties
NameTypeDescription
plans?Readonly<Record<string, readonly PlanView[]>>

Each session's plans, oldest first (possiblyInterrupted shows an applying plan with no live run).

todos?Readonly<Record<string, readonly TodoItem[]>>

Each session's task list as the agent wrote it (todowrite), applied over plans: an applying plan.

ui/src/session/headless/fixture-plans.ts:16

FixtureQueuedEntryInterface#

A queued entry the fixture holds, with its attachments' bytes.

TypeScript
interface FixtureQueuedEntry
FixtureQueuedEntry properties
NameTypeDescription
attachments?PromptAttachment[]

Its attachments, with their bytes.

idstring

The entry's id.

textstring

The message text.

ui/src/session/headless/fixture-host.ts:40

FixtureScheduleBackendInterface#

A scripted reminders backend.

TypeScript
interface FixtureScheduleBackend
FixtureScheduleBackend properties
NameTypeDescription
create(input: unknown) => Schedule

schedules.create, as the person (createdBy: user).

fires(id: string, limit?: number) => ScheduleFire[]

schedules.fires: newest first.

list(filter?: { sessionId?: string }) => Schedule[]

schedules.list: every schedule, or those whose prompt goes to sessionId.

remove(id: string) => boolean

schedules.delete: false when it was gone.

replace(list: readonly Schedule[]) => void

Replaces the stored schedules from outside (the agent set one, one fired).

runNow(id: string) => ScheduleFire

schedules.runNow: records a fire now; the next time does not move.

setEnabled(enabled: boolean) => void

Turns the setting on or off.

status() => SchedulesStatus

schedules.status.

subscribe(onChange: (scheduleId?: string) => void) => () => void

Hears every change (schedules:changed). Returns the unsubscribe.

update(id: string, patch: unknown) => Schedule

schedules.update.

ui/src/session/headless/fixture-schedules.ts:22

FixtureScheduleOptionsInterface#

What createFixtureScheduleBackend starts with.

TypeScript
interface FixtureScheduleOptions
FixtureScheduleOptions properties
NameTypeDefaultDescription
enabled?booleantrue

Settings.schedules.

fires?Readonly<Record<string, readonly ScheduleFire[]>>

Each schedule's fires, newest first.

now?() => numberDate.now

The clock.

schedules?readonly Schedule[]

The stored schedules, oldest first.

ui/src/session/headless/fixture-schedules.ts:46

FixtureSessionControlInterface#

Changes a fixture's data from outside and announces it, as the agent or another window would.

TypeScript
interface FixtureSessionControl
FixtureSessionControl properties
NameTypeDescription
endRun(sessionId: string, outcome?: 'error' | 'completed' | 'aborted') => void

The session's run ended: the plan it applied stops.

recordArtifact(sessionId: string, row: SessionArtifactRow) => void

Records an artifact (newest first).

setPlans(sessionId: string, plans: readonly PlanView[]) => void

Replaces a session's plans.

setQueue(sessionId: string, entries: readonly FixtureQueuedEntry[]) => void

Replaces a session's queue.

setSchedules(list: readonly Schedule[]) => void

Replaces the stored reminders (the agent set one, one fired) and announces the change.

setSchedulesEnabled(enabled: boolean) => void

Turns the Reminders setting on or off and announces it.

setSecrets(sessionId: string, entries: readonly SecretEntry[]) => void

Replaces a session's saved secrets (the agent saved one, another window revoked one).

setWork(sessionId: string, items: readonly RunningWorkItem[]) => void

Replaces a session's running work.

writeTodos(sessionId: string, items: readonly TodoItem[]) => void

The agent's todowrite: updates the applying plan, starts one, or resumes a stopped one with the same step ids.

ui/src/session/headless/fixture-host.ts:86

FixtureSessionHostInterface#

The fixture host: a full SessionHost plus its control.

TypeScript
interface FixtureSessionHost extends SessionHost
FixtureSessionHost properties
NameTypeDescription
artifacts?from SessionHostSessionArtifacts

The recorded artifacts. Absent: no Artifacts panel.

controlFixtureSessionControl

Changes the data from outside.

details?from SessionHostSessionDetailsActions

The details dialog's actions. Absent: the dialog shows facts only.

plans?from SessionHostSessionPlans

The plans. Absent: no Todos panel.

queue?from SessionHostSessionQueue

The type-ahead queues. Absent: no queue.

runningWork?from SessionHostSessionRunningWork

The cancellable work. Absent: no running work dialog.

schedules?from SessionHostSessionSchedules

Reminders (zidane's schedules). Absent: no Reminders panel, no badge.

secrets?from SessionHostSessionSecrets

The saved secrets of a session's project. Absent: no Secrets panel.

side?from SessionHostSessionSideChats

/side chats about a session. Absent: no side chat.

turns?from SessionHostSessionTurns

The stored turns. Absent: no turn details dialog.

usage?from SessionHostSessionUsage

Usage. Absent: no usage card, no usage panel.

ui/src/session/headless/fixture-host.ts:108

SessionFixtureInterface#

What a fixture session host starts with, per session id.

TypeScript
interface SessionFixture
SessionFixture properties
NameTypeDefaultDescription
artifacts?Readonly<Record<string, readonly SessionArtifactRow[]>>

The artifacts per session, newest first.

githubUsage?readonly ProviderUsageSnapshot[]

GitHub's API limits. Absent: no usage.github.

kindLabel?(kind: string) => string

An artifact kind's group label. Default: the raw kind.

plans?Readonly<Record<string, readonly PlanView[]>>

The plans per session, oldest first (possiblyInterrupted shows an applying plan with no live run).

providerUsage?readonly ProviderUsageSnapshot[]

The providers' subscription snapshots. Absent: no usage.providers.

queue?Readonly<Record<string, readonly FixtureQueuedEntry[]>>

The queued messages per session.

scheduleFires?Readonly<Record<string, readonly ScheduleFire[]>>

Each reminder's fires, newest first, by schedule id.

schedules?readonly Schedule[]

The stored reminders (zidane's schedules), oldest first. Absent: no schedules.

schedulesEnabled?booleantrue

Settings.schedules.

secrets?Readonly<Record<string, readonly SecretEntry[]>>

The saved secrets per session (as the session's project holds them). Absent: no secrets.

secretsSaveError?string

secrets.save rejects with this message (a plain-text remote link refusing values).

sides?Readonly<Record<string, string>>

Each session's side chat id, by the parent's id. Absent: no side.

todos?Readonly<Record<string, readonly TodoItem[]>>

The task list per session as the agent wrote it (todowrite), over plans: an applying plan.

turns?Readonly<Record<string, readonly SessionTurn[]>>

The stored turns per session.

usage?Partial<Record<UsageRange, UsageSummary>>

The usage summary per range. Absent: no usage.summary.

work?Readonly<Record<string, readonly RunningWorkItem[]>>

The running work per session.

ui/src/session/headless/fixture-host.ts:50