# zidane-ui/terminal/headless

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

## Functions

### `createMemoryTerminalLayouts`

Function.

Creates [`TerminalLayouts`](https://zidane.si/docs/reference/ui-terminal-headless.md#TerminalLayouts) held in memory, per scope key.

```ts
function createMemoryTerminalLayouts(): TerminalLayouts
```

**Returns** `TerminalLayouts`

Source: [ui/src/terminal/headless/layout.ts:42](https://github.com/Tahul/zidane/blob/main/ui/src/terminal/headless/layout.ts#L42)

### `createTerminalStore`

Function.

Creates the [`TerminalStore`](https://zidane.si/docs/reference/ui-terminal-headless.md#TerminalStore) over a host. An app creates one per page
and hands it to `TerminalProvider` (code outside React reads it too).

```ts
function createTerminalStore(host: TerminalHost): TerminalStore
```

**Parameters**

- `host` (`TerminalHost`): The terminal host.

**Returns** `TerminalStore`

Source: [ui/src/terminal/headless/store.ts:652](https://github.com/Tahul/zidane/blob/main/ui/src/terminal/headless/store.ts#L652)

### `scopeOfTerminalKey`

Function.

The scope a key names when nothing better is known (a reload after a signal from an unknown scope).

```ts
function scopeOfTerminalKey(key: string): TerminalScope
```

**Parameters**

- `key` (`string`): A `terminalScopeKey`.

**Returns** `TerminalScope`

Source: [ui/src/terminal/headless/scope.ts:53](https://github.com/Tahul/zidane/blob/main/ui/src/terminal/headless/scope.ts#L53)

### `terminalProjectKey`

Function.

The key of a project's or a draft's list, as the host names it (`root`, `draftId`).

```ts
function terminalProjectKey(signal: { draftId?: string; root: string }): string
```

**Parameters**

- `signal` (`{ draftId?: string; root: string }`): The project root and the draft, if any.

**Returns** `string`

Source: [ui/src/terminal/headless/scope.ts:40](https://github.com/Tahul/zidane/blob/main/ui/src/terminal/headless/scope.ts#L40)

### `terminalScopeKey`

Function.

A scope's identity: the session id when bound, else `draft:<id>` or
`project:<root>` (a session id never starts with either).

```ts
function terminalScopeKey(scope: TerminalScope): string
```

**Parameters**

- `scope` (`TerminalScope`): The scope.

**Returns** `string`

Source: [ui/src/terminal/headless/scope.ts:29](https://github.com/Tahul/zidane/blob/main/ui/src/terminal/headless/scope.ts#L29)

## Classes

### `TerminalStore`

Class.

The terminal store: every scope's terminals, the live views, the layouts.

```ts
class TerminalStore
```

**Constructor**

```ts
new TerminalStore(host: TerminalHost)
```

**Parameters**

- `host` (`TerminalHost`): The terminal host.

**Returns** `TerminalStore`

**Properties**

- `host` (`TerminalHost`, readonly): The host the store reads and acts through.
- `layouts` (`TerminalLayouts`, readonly): Where the per-scope layouts live: the host's, else in memory.

**Methods**

#### `addView()`

```ts
addView(terminalId: string, view: TerminalViewSink): () => void
```

Registers a live view of `terminalId`; returns its unregister.

**Parameters**

- `terminalId` (`string`): The terminal it shows.
- `view` (`TerminalViewSink`): What it does with the terminal's signals.

**Returns** `() => void`

#### `adoptDraft()`

```ts
adoptDraft(draft: TerminalScope, session: TerminalScope): Promise<void>
```

Hands the draft's terminals to the session created from it. Shown in the
session at once (the host's lists follow); a failed hand-over (or a host
that cannot hand over) gives them back to the project, never leaving them
tied to a draft nobody shows.

**Parameters**

- `draft` (`TerminalScope`): The draft's scope.
- `session` (`TerminalScope`): The session's scope.

**Returns** `Promise<void>`

#### `autoOpen()`

```ts
autoOpen(
  scope: TerminalScope,
  placement: TerminalPlacement,
  measure?: () => TerminalGrid | null,
): Promise<void>
```

Opens a terminal for the user when a placement is opened on a scope with
none of theirs (none at all, or only the agent's). The drawer opens one
only when the user opened it (`toggleDrawer`). A drawer open because the
scope copied its project's layout, or left open before a relaunch, starts
no shell: otherwise every session visited would keep one. Skipped while
another open is in flight (the keybinding opens the drawer and a terminal
at once).

**Parameters**

- `scope` (`TerminalScope`): The scope.
- `placement` (`TerminalPlacement`): The placement that opened.
- `measure?` (`() => TerminalGrid | null`): Measures the grid the area fits, once the state is in.

**Returns** `Promise<void>`

#### `close()`

```ts
close(scope: ScopeRef, terminalId: string): Promise<void>
```

Closes a terminal.

**Parameters**

- `scope` (`ScopeRef`): The scope or its key (where an error shows).
- `terminalId` (`string`): The terminal.

**Returns** `Promise<void>`

#### `dismissError()`

```ts
dismissError(scope: ScopeRef): void
```

Clears the scope's error.

**Parameters**

- `scope` (`ScopeRef`): The scope or its key.

#### `ensure()`

```ts
ensure(scope: TerminalScope): Promise<void>
```

Loads the scope's state once (callers mount per scope).

**Parameters**

- `scope` (`TerminalScope`): The scope.

**Returns** `Promise<void>`

#### `forget()`

```ts
forget(scope: ScopeRef): void
```

Forgets a scope whose session was deleted. One a view still shows is kept, and stays after the view goes
(one entry per such scope); a later signal for the scope starts it afresh.

**Parameters**

- `scope` (`ScopeRef`): The scope or its key.

#### `get()`

```ts
get(scope: ScopeRef | null): ScopeTerminals
```

A scope's terminals (by its scope or key).

**Parameters**

- `scope` (`ScopeRef | null`): The scope or its key; `null` reads as none.

**Returns** `ScopeTerminals`

#### `layout()`

```ts
layout(scope: TerminalScope): TerminalLayout
```

The scope's layout (drawer, order, agent filter).

**Parameters**

- `scope` (`TerminalScope`): The scope.

**Returns** `TerminalLayout`

#### `open()`

```ts
open(
  scope: TerminalScope,
  target?: TerminalTarget,
  size?: TerminalGrid,
): Promise<TerminalInfo | null>
```

Opens a terminal and makes it active. Resolves `null` when it failed (see `error`).

**Parameters**

- `scope` (`TerminalScope`): The scope.
- `target?` (`TerminalTarget`): A session's terminal: in its environment or on the user's machine. Ignored without a session.
- `size?` (`TerminalGrid`): The first grid. Default: the last one fitted, else 80×24.

**Returns** `Promise<TerminalInfo | null>`

#### `openInDrawer()`

```ts
openInDrawer(scope: TerminalScope): void
```

Opens the drawer and a new terminal in it.

**Parameters**

- `scope` (`TerminalScope`): The scope.

#### `panelOnScreen()`

```ts
panelOnScreen(scope: ScopeRef): boolean
```

Whether the side panel's Terminal tab is on screen for the scope.

**Parameters**

- `scope` (`ScopeRef`): The scope or its key.

**Returns** `boolean`

#### `refresh()`

```ts
refresh(scope: TerminalScope): Promise<void>
```

Reads the scope's state again (one read in flight per scope).

**Parameters**

- `scope` (`TerminalScope`): The scope.

**Returns** `Promise<void>`

#### `releaseDraft()`

```ts
releaseDraft(draftId: string): Promise<void>
```

Gives the draft's terminals back to the project (a discarded draft). Never rejects.

**Parameters**

- `draftId` (`string`): The draft.

**Returns** `Promise<void>`

#### `restart()`

```ts
restart(scope: ScopeRef, terminalId: string): Promise<void>
```

Restarts a terminal's process.

**Parameters**

- `scope` (`ScopeRef`): The scope or its key (where an error shows).
- `terminalId` (`string`): The terminal.

**Returns** `Promise<void>`

#### `reveal()`

```ts
reveal(scope: ScopeRef, terminalId: string, placement: TerminalPlacement): void
```

Makes `terminalId` the active terminal, focused by `placement`, with no
shell auto-opened over it (`revealTerminal` picks the placement).

**Parameters**

- `scope` (`ScopeRef`): The scope or its key.
- `terminalId` (`string`): The terminal.
- `placement` (`TerminalPlacement`): The placement that focuses it.

#### `revealTerminal()`

```ts
revealTerminal(scope: TerminalScope, terminalId: string): void
```

Shows one of the scope's terminals, focused: in the side panel's Terminal
tab when it is on screen, else in the drawer, opened for it. Opening the
drawer this way starts no shell of the user's, and the strip shows the
agent's terminals again when it hid the one revealed.

**Parameters**

- `scope` (`TerminalScope`): The scope.
- `terminalId` (`string`): The terminal.

#### `runIn()`

```ts
runIn(scope: TerminalScope, input: string): Promise<TerminalInfo | null>
```

Opens a new terminal in the scope, shows it, and types `input` into it (a
reply's shell block, Run in a terminal). The shell reads what was typed
once it starts. Resolves with the terminal, or `null` when none opened
(the scope's error says why).

**Parameters**

- `scope` (`TerminalScope`): The scope.
- `input` (`string`): What to type, newline included to run it.

**Returns** `Promise<TerminalInfo | null>`

#### `setActive()`

```ts
setActive(scope: ScopeRef, terminalId: string): void
```

Makes `terminalId` the scope's active terminal.

**Parameters**

- `scope` (`ScopeRef`): The scope or its key.
- `terminalId` (`string`): The terminal.

#### `setFittedSize()`

```ts
setFittedSize(scope: TerminalScope, size: TerminalGrid | null): void
```

Remembers the grid the scope's terminal area fits: new terminals start at it.

**Parameters**

- `scope` (`TerminalScope`): The scope.
- `size` (`TerminalGrid | null`): The grid, or `null` (not laid out: keeps the last one).

#### `setHidden()`

```ts
setHidden(scope: ScopeRef, terminalId: string, hidden: boolean): Promise<void>
```

Hides a terminal from the agent, or shows it again.

**Parameters**

- `scope` (`ScopeRef`): The scope or its key (where an error shows).
- `terminalId` (`string`): The terminal.
- `hidden` (`boolean`): Hide it.

**Returns** `Promise<void>`

#### `showPanel()`

```ts
showPanel(scope: ScopeRef): () => void
```

The side panel's Terminal tab shows the scope's terminals, on screen; returns its unregister.

**Parameters**

- `scope` (`ScopeRef`): The scope or its key.

**Returns** `() => void`

#### `showPlacement()`

```ts
showPlacement(scope: ScopeRef): () => void
```

A placement (drawer, panel tab) is showing the scope's terminals; clears the badge. Returns its unregister.

**Parameters**

- `scope` (`ScopeRef`): The scope or its key.

**Returns** `() => void`

#### `subscribe()`

```ts
subscribe(listener: () => void): () => void
```

Registers a listener called after any scope changed. Returns its unsubscribe.

**Parameters**

- `listener` (`() => void`): Called after each change.

**Returns** `() => void`

#### `takeFocus()`

```ts
takeFocus(scope: ScopeRef, seq: number): void
```

The placement took focus request `seq`: drop it (a newer request stays).

**Parameters**

- `scope` (`ScopeRef`): The scope or its key.
- `seq` (`number`): The request taken.

#### `terminal()`

```ts
terminal(terminalId: string): TerminalInfo | null
```

The terminal with this id, in whichever scope holds it.

**Parameters**

- `terminalId` (`string`): The terminal.

**Returns** `TerminalInfo | null`

#### `toggleDrawer()`

```ts
toggleDrawer(scope: TerminalScope): void
```

Shows or hides the scope's drawer.

**Parameters**

- `scope` (`TerminalScope`): The scope.

#### `updateLayout()`

```ts
updateLayout(scope: TerminalScope, patch: Partial<TerminalLayout>): void
```

Changes the scope's layout.

**Parameters**

- `scope` (`TerminalScope`): The scope.
- `patch` (`Partial<TerminalLayout>`): The fields to change.

Source: [ui/src/terminal/headless/store.ts:85](https://github.com/Tahul/zidane/blob/main/ui/src/terminal/headless/store.ts#L85)

## Constants

### `DEFAULT_TERMINAL_LABELS`

Constant.

The default English strings of the terminal components.

```ts
const DEFAULT_TERMINAL_LABELS: { terminalActions: string; terminalAddToChat: string; terminalAddToChatNowhere: string; terminalClear: string; terminalClose: (title: string) => string; terminalConnecting: string; terminalCopy: string; terminalCouldNotLoad: (message: string) => string; terminalDisconnected: string; terminalDismissError: string; terminalDrawer: string; terminalExitedPlain: string; terminalExitedWith: (code: number) => string; terminalFailedToStart: string; terminalGlyphAgent: string; terminalGlyphDisconnected: string; terminalGlyphError: string; terminalGlyphStarting: string; terminalHiddenFromAgent: string; terminalHiddenFromAgentIcon: string; terminalHide: string; terminalHideAgentTerminals: string; terminalHideFromAgent: string; terminalLinkOnServer: (serverName: string) => string; terminalNew: string; terminalNewLocal: string; terminalNoneOpen: string; terminalNotAvailable: string; terminalOpenSettings: string; terminalPaste: string; terminalReconnect: string; terminalRestart: string; terminalRestartAction: string; terminalShow: string; terminalShowAgentTerminals: string; terminalShowToAgent: string; terminalStartedByAgent: (taskId?: string) => string; terminalStarting: string; terminalStopAgentTask: (title: string) => string; terminalTabs: string; terminalToggleLabel: (open: boolean, startedByAgent: number) => string; terminalUnreachable: string }
```

Source: [ui/src/terminal/headless/labels.ts:11](https://github.com/Tahul/zidane/blob/main/ui/src/terminal/headless/labels.ts#L11)

### `DEFAULT_TERMINAL_LAYOUT`

Constant.

The layout of a scope nobody changed.

```ts
const DEFAULT_TERMINAL_LAYOUT: TerminalLayout
```

Source: [ui/src/terminal/headless/layout.ts:34](https://github.com/Tahul/zidane/blob/main/ui/src/terminal/headless/layout.ts#L34)

## Interfaces

### `ScopeTerminals`

Interface.

One scope's terminals as the components read them.

```ts
interface ScopeTerminals
```

**Properties**

- `activeId` (`string | null`): The active terminal.
- `error` (`string | null`): The last failed call (open, restart, …), shown until the next success.
- `focus` (`TerminalFocusRequest | null`): A revealed terminal waiting for its placement to focus it.
- `state` (`TerminalSessionState | null`): Null until the first `state` answers.
- `unseenAgent` (`number`): Agent terminals that started while nothing showed terminals (sessions only).

Source: [ui/src/terminal/headless/store.ts:54](https://github.com/Tahul/zidane/blob/main/ui/src/terminal/headless/store.ts#L54)

### `TerminalAttachResult`

Interface.

What a client needs to start showing a terminal: its history, and where live output resumes.

```ts
interface TerminalAttachResult
```

**Properties**

- `data` (`string`): Output history to show first.
- `offset` (`number`): Character offset where live output resumes.
- `terminal` (`TerminalInfo`): The terminal that was attached.

Source: [dist/media-type-BzRZ4FqT.d.ts:4265](https://github.com/Tahul/zidane/blob/main/dist/media-type-BzRZ4FqT.d.ts#L4265)

### `TerminalDataSignal`

Interface.

A batch of a terminal's output starting at stream offset `offset` (or, for a reset, its history up to there).

```ts
interface TerminalDataSignal
```

**Properties**

- `data` (`string`): The output.
- `offset` (`number`): Stream offset of the first character of `data`.
- `terminalId` (`string`): The terminal.

Source: [ui/src/terminal/headless/host.ts:24](https://github.com/Tahul/zidane/blob/main/ui/src/terminal/headless/host.ts#L24)

### `TerminalFocusRequest`

Interface.

A terminal revealed on request, for the placement it was revealed in to focus once (`takeFocus`).

```ts
interface TerminalFocusRequest
```

**Properties**

- `placement` (`TerminalPlacement`): The placement that focuses it.
- `seq` (`number`): Increases with every request.
- `terminalId` (`string`): The terminal.

Source: [ui/src/terminal/headless/store.ts:44](https://github.com/Tahul/zidane/blob/main/ui/src/terminal/headless/store.ts#L44)

### `TerminalGrid`

Interface.

A grid size in cells.

```ts
interface TerminalGrid
```

**Properties**

- `cols` (`number`): Columns.
- `rows` (`number`): Rows.

Source: [ui/src/terminal/headless/store.ts:68](https://github.com/Tahul/zidane/blob/main/ui/src/terminal/headless/store.ts#L68)

### `TerminalHost`

Interface.

The terminal host.

```ts
interface TerminalHost
```

**Properties**

- `layouts?` (`TerminalLayouts`): Where the per-scope terminal layouts live. Absent: they last as long as the page.
- `ack` (`(terminalId: string, clientId: string, offset: number) => Promise<void>`): A view wrote the output up to `offset`, so the host keeps it flowing.
- `adoptDraft?` (`(draftId: string, sessionId: string) => Promise<{ adopted: string[] }>`): Moves a draft's terminals into the session it became; resolves with the ids moved. Absent: they go back to the project.
- `attach` (`(terminalId: string, clientId: string) => Promise<TerminalAttachResult>`): Attaches a view (`clientId`) and resolves with the history to replay and where live output resumes.
- `close` (`(terminalId: string) => Promise<void>`): Closes a terminal (an agent's: ends its task).
- `detach` (`(terminalId: string, clientId: string) => Promise<void>`): Detaches a view.
- `listen` (`(sink: TerminalSignalSink) => () => void`): Starts telling `sink` what happens. Returns its unsubscribe.
- `open` (`(scope: TerminalScope, options: TerminalOpenOptions) => Promise<TerminalInfo>`): Opens a terminal in the scope, at that size.
- `releaseDraft?` (`(draftId: string) => Promise<void>`): Gives a draft's terminals back to the project (the draft was discarded). Absent: nothing to give back.
- `resize` (`(terminalId: string, clientId: string, cols: number, rows: number, claim: boolean) => Promise<void>`): A view asks for a grid size; `claim`: it is the one being looked at and takes the size.
- `restart?` (`(terminalId: string) => Promise<void>`): Restarts a terminal's process. Absent: no Restart.
- `setHidden?` (`(terminalId: string, hidden: boolean) => Promise<void>`): Hides a session's terminal from its agent, or shows it again. Absent: no such toggle.
- `state` (`(scope: TerminalScope) => Promise<TerminalSessionState>`): The scope's terminals and whether this host can run them. Rejects when they cannot be read.
- `write` (`(terminalId: string, data: string, from?: TerminalWriteOrigin) => Promise<void>`): Sends input (typing, a paste, an emulator reply).

Source: [ui/src/terminal/headless/host.ts:70](https://github.com/Tahul/zidane/blob/main/ui/src/terminal/headless/host.ts#L70)

### `TerminalInfo`

Interface.

Description of one terminal, as the host reports it to clients.

```ts
interface TerminalInfo
```

**Properties**

- `cols` (`number`): Width in character cells.
- `createdAt` (`number`): Creation time in epoch ms.
- `cwd` (`string`): Working directory the terminal started in.
- `environment` (`string`): Environment kind it runs in (`local`, `worktree`, `docker`, `e2b`, …).
- `error?` (`string`): Failure message, when `status` is `error`.
- `exitCode?` (`number`): Exit code, once the process has exited.
- `hiddenFromAgent` (`boolean`): The agent's terminal tools skip it.
- `id` (`string`): Terminal id.
- `label` (`string`): Stable name ("Terminal 2", or the agent's command).
- `lastActivityAt` (`number`): Time of the last output or input in epoch ms.
- `owner` (`TerminalOwner`): Who started the terminal.
- `program?` (`string`): The program in the foreground, for terminals on this machine.
- `rows` (`number`): Height in character cells.
- `scope?` (`TerminalProjectScope`): Set on project / draft terminals (`sessionId` is `''`).
- `sessionId` (`string`): The session it belongs to; `''` for a project / draft terminal (see `scope`).
- `sizeSeq` (`number`): 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` (`TerminalStatus`): Connection and process state.
- `target` (`TerminalTarget`): Where the terminal runs.
- `taskId?` (`string`): The background task it runs (agent terminals).
- `title?` (`string`): Title the program set (OSC 0/2), if any.

Source: [dist/media-type-BzRZ4FqT.d.ts:4155](https://github.com/Tahul/zidane/blob/main/dist/media-type-BzRZ4FqT.d.ts#L4155)

### `TerminalLayout`

Interface.

A scope's terminal layout.

```ts
interface TerminalLayout
```

**Properties**

- `terminalHeight` (`number | null`): The drawer's height (px); `null`: the default.
- `terminalHideAgent` (`boolean`): The tab strip leaves the agent's terminals out.
- `terminalOpen` (`boolean`): The drawer under the chat is shown.
- `terminalOrder` (`readonly string[]`): Terminal ids in the user's dragged order (`orderTerminals`).

Source: [ui/src/terminal/headless/layout.ts:10](https://github.com/Tahul/zidane/blob/main/ui/src/terminal/headless/layout.ts#L10)

### `TerminalLayouts`

Interface.

Where the per-scope layouts live.

```ts
interface TerminalLayouts
```

**Properties**

- `get` (`(scope: TerminalScope) => TerminalLayout`): The scope's layout. The same object until it changes (components read it with `useSyncExternalStore`).
- `show?` (`(scope: TerminalScope) => void`): A component shows the scope (the app may seed its layout from the project's). Absent: nothing to do.
- `subscribe` (`(listener: () => void) => () => void`): Registers a listener called after any layout changed. Returns its unsubscribe.
- `update` (`(scope: TerminalScope, patch: Partial<TerminalLayout>) => void`): Changes the scope's layout.

Source: [ui/src/terminal/headless/layout.ts:22](https://github.com/Tahul/zidane/blob/main/ui/src/terminal/headless/layout.ts#L22)

### `TerminalOpenOptions`

Interface.

Where a new terminal starts, and its first grid size.

```ts
interface TerminalOpenOptions
```

**Properties**

- `cols` (`number`): Columns.
- `rows` (`number`): Rows.
- `target?` (`TerminalTarget`): A session's terminal: in its environment (`session`, the default) or on the user's machine (`local`).

Source: [ui/src/terminal/headless/host.ts:52](https://github.com/Tahul/zidane/blob/main/ui/src/terminal/headless/host.ts#L52)

### `TerminalScope`

Interface.

Whose terminals a store entry, a drawer or a panel shows.

```ts
interface TerminalScope
```

**Properties**

- `cwd` (`string`): Where a terminal without session opens.
- `draft?` (`string`): The new-chat draft (never together with `session`).
- `root` (`string`): The project root: a scope without session or draft is keyed by it.
- `session?` (`string`): The session the terminals are a session's.

Source: [ui/src/terminal/headless/scope.ts:9](https://github.com/Tahul/zidane/blob/main/ui/src/terminal/headless/scope.ts#L9)

### `TerminalSessionState`

Interface.

The terminals of one session and whether this host can run them.

```ts
interface TerminalSessionState
```

**Properties**

- `available` (`boolean`): False when this host can't run terminals (the GUI without the daemon).
- `environment` (`{ kind: string; remote: boolean }`): Kind of the session's environment, and whether it runs somewhere else.
- `reason?` (`string`): Why not, when `available` is false.
- `terminals` (`TerminalInfo[]`): Terminals of the session.

Source: [dist/media-type-BzRZ4FqT.d.ts:4201](https://github.com/Tahul/zidane/blob/main/dist/media-type-BzRZ4FqT.d.ts#L4201)

### `TerminalSignalSink`

Interface.

What the host tells the store, as it happens.

```ts
interface TerminalSignalSink
```

**Properties**

- `output` (`(signal: TerminalDataSignal) => void`): Output of a terminal some view is attached to.
- `projectChanged` (`(signal: { draftId?: string; root: string; terminals: TerminalInfo[] }) => void`): A project's (`draftId` absent) or a draft's full list changed.
- `relink` (`(connected: boolean) => void`): The link to what runs the terminals changed (a daemon restarted, a
  connection came back): every scope reloads, and with `connected` every
  view attaches again (the new link has none).
- `reset` (`(signal: TerminalDataSignal) => void`): A view fell too far behind: its content is replaced with the terminal's history.
- `sessionChanged` (`(sessionId: string, terminals: TerminalInfo[]) => void`): A session's full list of terminals changed (its agent started one, one exited…).

Source: [ui/src/terminal/headless/host.ts:34](https://github.com/Tahul/zidane/blob/main/ui/src/terminal/headless/host.ts#L34)

### `TerminalViewSink`

Interface.

What a view does with the signals of the terminal it shows.

```ts
interface TerminalViewSink
```

**Properties**

- `output` (`(offset: number, data: string) => void`): Live output from `offset`.
- `reattach` (`() => void`): The link came back: attach again from scratch.
- `reset` (`(offset: number, data: string) => void`): The view's content is replaced with the history up to `offset`.

Source: [ui/src/terminal/headless/store.ts:31](https://github.com/Tahul/zidane/blob/main/ui/src/terminal/headless/store.ts#L31)

### `TerminalWriteOrigin`

Interface.

What a view sends along with a write.

```ts
interface TerminalWriteOrigin
```

**Properties**

- `clientId` (`string`): The view writing.
- `response?` (`boolean`): The emulator's answer to a query in the output, not typing (the host keeps only the size owner's).

Source: [ui/src/terminal/headless/host.ts:62](https://github.com/Tahul/zidane/blob/main/ui/src/terminal/headless/host.ts#L62)

## Types

### `TerminalLabels`

Type.

The shape of the terminal label dictionary.

```ts
type TerminalLabels = typeof DEFAULT_TERMINAL_LABELS
```

Source: [ui/src/terminal/headless/labels.ts:69](https://github.com/Tahul/zidane/blob/main/ui/src/terminal/headless/labels.ts#L69)

### `TerminalPlacement`

Type.

Where a scope's terminals show: the drawer under the chat, or the side panel's Terminal tab.

```ts
type TerminalPlacement = 'drawer' | 'panel'
```

Source: [ui/src/terminal/headless/store.ts:41](https://github.com/Tahul/zidane/blob/main/ui/src/terminal/headless/store.ts#L41)

### `TerminalTarget`

Type.

Where it runs: the session's environment, or this machine in the project.

```ts
type TerminalTarget = 'session' | 'local'
```

Source: [dist/media-type-BzRZ4FqT.d.ts:4135](https://github.com/Tahul/zidane/blob/main/dist/media-type-BzRZ4FqT.d.ts#L4135)
