Skip to content

zidane-ui/terminal/testing

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

Functions#

createDemoTerminalHostFunction#

A fixture host holding the demo session's terminals.

TypeScript
function createDemoTerminalHost(): FixtureTerminalHost

ui/src/terminal/testing/demo.ts:20

createFixtureTerminalHostFunction#

Creates a TerminalHost held in memory.

TypeScript
function createFixtureTerminalHost(
  options?: FixtureTerminalOptions,
): FixtureTerminalHost
Parameters
NameTypeDefaultDescription
options?FixtureTerminalOptions{}

The terminals per scope, availability, the prompt, and whether they can be changed.

ui/src/terminal/headless/fixture-host.ts:75

Constants#

DEMO_TERMINAL_SCOPEConstant#

The demo session's scope.

TypeScript
const DEMO_TERMINAL_SCOPE: TerminalScope

ui/src/terminal/testing/demo.ts:9

Interfaces#

FixtureTerminalInterface#

A terminal the fixture starts with: its info (defaults filled in) and the output it already printed.

TypeScript
interface FixtureTerminal extends Partial<TerminalInfo>
FixtureTerminal properties
NameTypeDescription
cols?from Partialnumber

Width in character cells.

createdAt?from Partialnumber

Creation time in epoch ms.

cwd?from Partialstring

Working directory the terminal started in.

environment?from Partialstring

Environment kind it runs in (local, worktree, docker, e2b, …).

error?from Partialstring

Failure message, when status is error.

exitCode?from Partialnumber

Exit code, once the process has exited.

hiddenFromAgent?from Partialboolean

The agent's terminal tools skip it.

history?string

What it printed so far (ANSI allowed).

idstring

Terminal id.

label?from Partialstring

Stable name ("Terminal 2", or the agent's command).

lastActivityAt?from Partialnumber

Time of the last output or input in epoch ms.

owner?from PartialTerminalOwner

Who started the terminal.

program?from Partialstring

The program in the foreground, for terminals on this machine.

rows?from Partialnumber

Height in character cells.

scope?from PartialTerminalProjectScope

Set on project / draft terminals (sessionId is '').

sessionId?from Partialstring

The session it belongs to; '' for a project / draft terminal (see scope).

sizeSeq?from Partialnumber

Bumped on every size change: signals and attach replies reach a view by different routes, so it keeps the newest size, not the last to arrive.

status?from PartialTerminalStatus

Connection and process state.

target?from PartialTerminalTarget

Where the terminal runs.

taskId?from Partialstring

The background task it runs (agent terminals).

title?from Partialstring

Title the program set (OSC 0/2), if any.

ui/src/terminal/headless/fixture-host.ts:18

FixtureTerminalControlInterface#

Changes the fixture from outside.

TypeScript
interface FixtureTerminalControl
FixtureTerminalControl properties
NameTypeDescription
announce(scope: TerminalScope) => void

The scope's list goes out again (as after any change).

exit(terminalId: string, code: number) => void

The terminal's process exits with code.

print(terminalId: string, data: string) => void

The terminal prints data.

relink() => void

The link to the terminals came back: every scope reloads, every view attaches again.

terminals() => TerminalInfo[]

Every terminal now.

writes(terminalId: string) => string[]

The input a terminal received, one entry per write.

ui/src/terminal/headless/fixture-host.ts:44

FixtureTerminalOptionsInterface#

Options of createFixtureTerminalHost.

TypeScript
interface FixtureTerminalOptions
FixtureTerminalOptions properties
NameTypeDescription
available?boolean

false: the host runs no terminals (state says unavailable). Default: true.

drafts?Readonly<Record<string, readonly FixtureTerminal[]>>

The terminals per draft id.

projects?Readonly<Record<string, readonly FixtureTerminal[]>>

The terminals per project root (no session, no draft).

prompt?string

The prompt a new shell prints. Default: $ .

readOnly?boolean

Leave out restart, setHidden, adoptDraft and releaseDraft. Default: false.

reason?string

Why not, when available is false.

sessions?Readonly<Record<string, readonly FixtureTerminal[]>>

The terminals per session id.

ui/src/terminal/headless/fixture-host.ts:26

Types#

FixtureTerminalHostType#

An in-memory TerminalHost and its control.

TypeScript
type FixtureTerminalHost = TerminalHost & { control: FixtureTerminalControl }

ui/src/terminal/headless/fixture-host.ts:60