Skip to content

terminal/TerminalProvider

import { … } from 'zidane-ui/terminal'ui/src/terminal/TerminalProvider.tsx

Components#

TerminalProviderComponent#

Provides the terminal store and the app's actions to the terminal components below it.

TypeScript
function TerminalProvider(props: TerminalProviderProps): Element
Parameters
NameTypeDescription
propsTerminalProviderProps

Provider props: the host or store, the app's actions, enabled, waiting, symbolsFontUrl, labels and the children.

Element
TerminalProvider props
NameTypeDescription
actions?TerminalAppActions

What only the app can do (open links, add to chat, settings). Keep it stable: a new object re-renders every view.

childrenReactNode

The app.

enabled?boolean

false removes the drawer and its toggle (terminals turned off). Default: true.

labels?Partial<TerminalLabels>

Overrides for the built-in strings. Keys you leave out keep the default English label.

symbolsFontUrl?string

Where the app serves the Nerd Font symbols face (SYMBOLS_FONT), loaded before a terminal measures its cells.

waiting?TerminalWaiting | null

Set while the link to what runs terminals is coming up or down: the unavailable state says so.

ui/src/terminal/TerminalProvider.tsx:122

Functions#

useOptionalTerminalStoreFunction#

The TerminalStore from the nearest TerminalProvider, or null outside one (an app without terminals).

TypeScript
function useOptionalTerminalStore(): TerminalStore | null

ui/src/terminal/TerminalProvider.tsx:149

useScopeTerminalsFunction#

A scope's terminals (state, active terminal, error, agent badge), re-rendering when they change.

TypeScript
function useScopeTerminals(scope: TerminalScope | null): ScopeTerminals
Parameters
NameTypeDescription
scopeTerminalScope | null

The scope, or null for none.

ui/src/terminal/TerminalProvider.tsx:178

useTerminalActionsFunction#

The app's actions from the nearest TerminalProvider.

TypeScript
function useTerminalActions(): TerminalAppActions

ui/src/terminal/TerminalProvider.tsx:154

useTerminalLayoutFunction#

A scope's terminal layout (drawer, order, agent filter), re-rendering when it changes. Tells the layouts the scope is shown (TerminalLayouts.show) once per scope.

TypeScript
function useTerminalLayout(scope: TerminalScope): TerminalLayout
Parameters
NameTypeDescription
scopeTerminalScope

The scope.

ui/src/terminal/TerminalProvider.tsx:194

useTerminalsEnabledFunction#

Whether terminals are on (TerminalProvider's enabled).

TypeScript
function useTerminalsEnabled(): boolean
boolean

ui/src/terminal/TerminalProvider.tsx:164

useTerminalStoreFunction#

The TerminalStore from the nearest TerminalProvider. Throws outside one.

TypeScript
function useTerminalStore(): TerminalStore

ui/src/terminal/TerminalProvider.tsx:144

Interfaces#

TerminalAppActionsInterface#

What only the app can do for the terminal components. Each one left out hides what needs it.

TypeScript
interface TerminalAppActions
TerminalAppActions properties
NameTypeDescription
drawerProps?Readonly<Record<string, string | number | boolean>>

Extra attributes for the drawer's root (a focus region's marker).

addToChat?(scope: TerminalScope, excerpt: TerminalExcerpt) => void

Adds a selection to the scope's chat. Absent: no Add to chat.

canAddToChat?(scope: TerminalScope) => boolean

Whether the scope has a chat to add to now (read when a menu opens). Absent: always, given addToChat.

openFile?(scope: TerminalScope, path: string, event: MouseEvent, at?: { column?: number; line: number }) => void

Opens a file a terminal printed (absolute path, optional 1-based position). Absent: paths don't link.

openSettings?() => void

Opens the app's settings where terminals are turned on (the unavailable state's button). Absent: no button.

openUrl?(scope: TerminalScope, url: string, external: boolean, cwd: string) => void

Opens a web link a terminal printed; external: ⌘/Ctrl-click asked for the system browser. cwd: where the terminal's paths resolve ('' when they are not this machine's). Absent: a new window.

registerTabScope?(element: HTMLElement, handlers: TerminalTabHandlers) => () => void

Registers keyboard handlers on a terminal area's root element. Returns the unregister.

remoteName?(scope: TerminalScope) => string | null

The machine the scope's terminals run on when it is not this one: their files don't link, their loopback links don't open.

ui/src/terminal/TerminalProvider.tsx:49

TerminalExcerptInterface#

A selection of a terminal's output, to add to the chat.

TypeScript
interface TerminalExcerpt
TerminalExcerpt properties
NameTypeDescription
endLinenumber

Last buffer line of the selection (1-based).

labelstring

The terminal's label (Terminal 1).

startLinenumber

First buffer line of the selection (1-based).

textstring

The selected text.

ui/src/terminal/TerminalProvider.tsx:29

TerminalTabHandlersInterface#

Keyboard handlers a terminal area registers on its root (TerminalAppActions.registerTabScope).

TypeScript
interface TerminalTabHandlers
TerminalTabHandlers properties
NameTypeDescription
close() => boolean

Closes the active terminal. False when there was none (whatever holds the area closes instead).

step(direction: -1 | 1) => boolean

Activates the next (1) or previous (-1) terminal. False when there was nothing to move to.

ui/src/terminal/TerminalProvider.tsx:41

Types#

TerminalProviderPropsType#

Props for TerminalProvider: a host (the provider creates the store) or a store the app created.

TypeScript
type TerminalProviderProps = ({ host: TerminalHost; store?: never } | { host?: never; store: TerminalStore }) & { actions?: TerminalAppActions; children: ReactNode; enabled?: boolean; labels?: Partial<TerminalLabels>; symbolsFontUrl?: string; waiting?: TerminalWaiting | null }

ui/src/terminal/TerminalProvider.tsx:91

TerminalWaitingType#

Why there are no terminals for a while: the link to what runs them is coming up, or down.

TypeScript
type TerminalWaiting = 'connecting' | 'unreachable'

ui/src/terminal/TerminalProvider.tsx:72