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.
function TerminalProvider(props: TerminalProviderProps): ElementParameters
| Name | Type | Description |
|---|---|---|
| props | TerminalProviderProps | Provider props: the |
Returns
ElementProps
| Name | Type | Description |
|---|---|---|
| actions? | TerminalAppActions | What only the app can do (open links, add to chat, settings). Keep it stable: a new object re-renders every view. |
| children | ReactNode | The app. |
| enabled? | boolean |
|
| 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 ( |
| waiting? | TerminalWaiting | null | Set while the link to what runs terminals is coming up or down: the unavailable state says so. |
Functions#
useOptionalTerminalStoreFunction#
The TerminalStore from the nearest TerminalProvider, or null outside one (an app without terminals).
function useOptionalTerminalStore(): TerminalStore | nullReturns
TerminalStore | nulluseScopeTerminalsFunction#
A scope's terminals (state, active terminal, error, agent badge), re-rendering when they change.
function useScopeTerminals(scope: TerminalScope | null): ScopeTerminalsParameters
| Name | Type | Description |
|---|---|---|
| scope | TerminalScope | null | The scope, or |
Returns
useTerminalActionsFunction#
The app's actions from the nearest TerminalProvider.
function useTerminalActions(): TerminalAppActionsReturns
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.
function useTerminalLayout(scope: TerminalScope): TerminalLayoutParameters
| Name | Type | Description |
|---|---|---|
| scope | TerminalScope | The scope. |
Returns
useTerminalsEnabledFunction#
Whether terminals are on (TerminalProvider's enabled).
function useTerminalsEnabled(): booleanReturns
booleanuseTerminalStoreFunction#
The TerminalStore from the nearest TerminalProvider. Throws outside one.
function useTerminalStore(): TerminalStoreReturns
Interfaces#
TerminalAppActionsInterface#
What only the app can do for the terminal components. Each one left out hides what needs it.
interface TerminalAppActionsProperties
| Name | Type | Description |
|---|---|---|
| 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 |
| 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; |
| 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. |
TerminalExcerptInterface#
A selection of a terminal's output, to add to the chat.
interface TerminalExcerptProperties
| Name | Type | Description |
|---|---|---|
| endLine | number | Last buffer line of the selection (1-based). |
| label | string | The terminal's label ( |
| startLine | number | First buffer line of the selection (1-based). |
| text | string | The selected text. |
TerminalTabHandlersInterface#
Keyboard handlers a terminal area registers on its root (TerminalAppActions.registerTabScope).
interface TerminalTabHandlersProperties
| Name | Type | Description |
|---|---|---|
| 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 ( |
Types#
TerminalProviderPropsType#
Props for TerminalProvider: a host (the provider creates the store) or a store the app created.
type TerminalProviderProps = ({ host: TerminalHost; store?: never } | { host?: never; store: TerminalStore }) & { actions?: TerminalAppActions; children: ReactNode; enabled?: boolean; labels?: Partial<TerminalLabels>; symbolsFontUrl?: string; waiting?: TerminalWaiting | null }TerminalWaitingType#
Why there are no terminals for a while: the link to what runs them is coming up, or down.
type TerminalWaiting = 'connecting' | 'unreachable'