# zidane-ui/views

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

## Components

### `ViewSessionNavProvider`

Component.

Provides the app's way to open what a view's session actions start.

```ts
function ViewSessionNavProvider(props: ViewSessionNavProviderProps): Element
```

**Parameters**

- `props` (`ViewSessionNavProviderProps`): [`ViewSessionNavProviderProps`](https://zidane.si/docs/reference/ui-views.md#ViewSessionNavProviderProps).

**Returns** `Element`

**Props**

- `children` (`ReactNode`): The app.
- `value` (`ViewSessionNav`): The app's way to open a session and a draft. Memoize it.

Source: [ui/src/views/session-nav.tsx:46](https://github.com/Tahul/zidane/blob/main/ui/src/views/session-nav.tsx#L46)

### `ViewsProvider`

Component.

Provides a [`ViewsHost`](https://zidane.si/docs/reference/ui-views-headless.md#ViewsHost) to the components below it.

```ts
function ViewsProvider(props: ViewsProviderProps): Element
```

**Parameters**

- `props` (`ViewsProviderProps`): Provider props: the `host` and the `children` to render.

**Returns** `Element`

**Props**

- `children` (`ReactNode`): The app.
- `host` (`ViewsHost`): Where the stored views come from.

Source: [ui/src/views/ViewsProvider.tsx:28](https://github.com/Tahul/zidane/blob/main/ui/src/views/ViewsProvider.tsx#L28)

## Functions

### `useViewSessionNav`

Function.

The app's [`ViewSessionNav`](https://zidane.si/docs/reference/ui-views.md#ViewSessionNav), with the transcript's `openSession` when the app gives none.

```ts
function useViewSessionNav(): ViewSessionNav
```

**Returns** `ViewSessionNav`

Source: [ui/src/views/session-nav.tsx:51](https://github.com/Tahul/zidane/blob/main/ui/src/views/session-nav.tsx#L51)

### `useViewsHost`

Function.

`zidane-ui/views`: the views area (docs/VIEWS.md). It holds the provider
that puts a `ViewsHost` in context and the hooks that read it. The
components that draw a view load in their own chunk, the first time the
transcript draws a \`\`\`view fence with its `views` option on, so this
entry stays small for apps that mount the provider with views off.

```ts
function useViewsHost(): ViewsHost | null
```

**Returns** `ViewsHost | null`

Source: [ui/src/views/ViewsProvider.tsx:33](https://github.com/Tahul/zidane/blob/main/ui/src/views/ViewsProvider.tsx#L33)

### `useViewsLabels`

Function.

`zidane-ui/views`: the views area (docs/VIEWS.md). It holds the provider
that puts a `ViewsHost` in context and the hooks that read it. The
components that draw a view load in their own chunk, the first time the
transcript draws a \`\`\`view fence with its `views` option on, so this
entry stays small for apps that mount the provider with views off.

```ts
function useViewsLabels(): { cancel: string; copiedShort: string; retry: string; viewActionDenied: string; viewActionFailed: string; viewActionRuns: (tool: string) => string; viewActions: string; viewActionSends: (text: string) => string; viewActionWaiting: string; viewChoiceOptions: string; viewCloseTab: string; viewCopyFailed: string; viewCopyImage: string; viewCopyText: string; viewCustomConsoleError: string; viewCustomEmpty: string; viewCustomFailed: string; viewCustomFrame: (title: string) => string; viewCustomImage: (title: string) => string; viewCustomOff: string; viewCustomOverflow: string; viewCustomRun: string; viewCustomSnapshot: (title: string) => string; viewCustomUnsupported: string; viewCustomWaiting: string; viewDeleteFailed: string; viewDrawing: string; viewErrors: string; viewExpand: string; viewFormNo: string; viewFormYes: string; viewFrame: (title: string) => string; viewImageHidden: (alt: string) => string; viewInPanel: string; viewInputsFailed: string; viewInputsOff: string; viewInputsPending: string; viewInputsSend: string; viewInputsSending: string; viewInputsSent: string; viewInputsUnsupported: string; viewInvalid: (name: string) => string; viewLinkDomain: (domain: string) => string; viewLive: (seconds: number) => string; viewLoadFailed: string; viewLoading: string; viewMcpAppAllow: string; viewMcpAppAllowed: (names: string) => string; viewMcpAppAsks: (names: string) => string; viewMcpAppDownloadBody: (server: string, size: string) => string; viewMcpAppDownloadSave: string; viewMcpAppDownloadTitle: (name: string) => string; viewMcpAppFailed: string; viewMcpAppFrame: (server: string, title: string) => string; viewMcpAppFrom: (server: string) => string; viewMcpAppOff: string; viewMcpAppPermission: (name: 'camera' | 'microphone' | 'geolocation' | 'clipboardWrite') => string; viewMcpAppRefused: string; viewMcpAppRun: string; viewMcpAppUiOff: string; viewMcpAppUnsupported: string; viewMcpAppWaiting: string; viewMissingRef: (ref: string) => string; viewNewerVersion: string; viewNo: string; viewOpenChat: string; viewOpenInArtifacts: string; viewOpenInChat: string; viewOpenPanel: string; viewPending: string; viewPin: string; viewPinFailed: string; viewPinnedHomeOff: string; viewRefresh: string; viewRefreshedAgo: (age: string) => string; viewRefreshedAt: (when: string) => string; viewRefreshFailed: string; viewRefreshing: string; viewRefreshUnsupported: string; viewRename: string; viewRenameFailed: string; viewRenameTitle: (title: string) => string; viewSave: string; viewSaved: string; viewSavedDelete: string; viewSaveFailed: string; viewSessionAgent: string; viewSessionAgentDefault: string; viewSessionAlways: string; viewSessionAnother: string; viewSessionArtifacts: string; viewSessionAsk: (verb: 'start' | 'send' | 'schedule' | 'command') => string; viewSessionChip: (status: string, title: string) => string; viewSessionCommand: string; viewSessionDraft: string; viewSessionFailed: string; viewSessionMore: string; viewSessionOnce: (verb: 'start' | 'send' | 'schedule' | 'command') => 'Start once' | 'Run once'; viewSessionOpen: string; viewSessionOpenToast: string; viewSessionPrompt: string; viewSessionRan: string; viewSessionScheduled: string; viewSessionSent: string; viewSessionStarted: (title: string) => string; viewSessionStartedDefault: (title: string, agent: string) => string; viewSessionStatus: (status: 'done' | 'failed' | 'running' | 'blocked') => string; viewSessionWhen: string; viewSessionWhere: string; viewSessionWhereBranch: (branch: string) => string; viewSessionWhereProject: string; viewShowLatest: string; viewShowOriginal: string; viewSourceAgo: (age: string) => string; viewSourceAllow: string; viewSourceAllowMenu: string; viewSourceAllowOnce: string; viewSourceAllowTool: string; viewSourceAllowView: string; viewSourceAskBar: string; viewSourceAskTitle: string; viewSourceDetail: (target: string, state: string) => string; viewSourceDetails: string; viewSourceError: (reason: string, message: string) => string; viewSourceFailed: (name: string) => string; viewSourceFetched: (age: string) => string; viewSourceMore: (count: number) => string; viewSourceNeedsSignIn: (server: string) => string; viewSourceNoArgs: string; viewSourceNotNow: string; viewSourceOld: (age: string) => string; viewSourceReadOnly: string; viewSourceReason: (reason: ViewSourceFailure) => string; viewSourceSignIn: string; viewSourcesMenu: string; viewSourcesOff: string; viewSourceToolChanged: (server: string) => string; viewSourceToolNotAllowed: string; viewSourceWantMany: (count: number) => string; viewSourceWantsAccess: (server: string) => string; viewSourceWantsRun: string; viewSourceWantsSessions: string; viewStateControl: string; viewStateFailed: string; viewStateSearch: string; viewStateUnsupported: string; viewTitleField: string; viewTurnFailed: string; viewTurnIntoBlock: string; viewTurnIntoPanel: string; viewTurnOnHome: string; viewUnknown: (name: string) => string; viewUnpin: string; viewUnsave: string; viewUnsaveConfirm: string; viewUnsaveConfirmAction: string; viewUnsaveConfirmBody: string; viewUntitled: string; viewVersionOf: (version: number, latest: number) => string; viewVersionPick: string; viewYes: string }
```

**Returns** `{ cancel: string; copiedShort: string; retry: string; viewActionDenied: string; viewActionFailed: string; viewActionRuns: (tool: string) => string; viewActions: string; viewActionSends: (text: string) => string; viewActionWaiting: string; viewChoiceOptions: string; viewCloseTab: string; viewCopyFailed: string; viewCopyImage: string; viewCopyText: string; viewCustomConsoleError: string; viewCustomEmpty: string; viewCustomFailed: string; viewCustomFrame: (title: string) => string; viewCustomImage: (title: string) => string; viewCustomOff: string; viewCustomOverflow: string; viewCustomRun: string; viewCustomSnapshot: (title: string) => string; viewCustomUnsupported: string; viewCustomWaiting: string; viewDeleteFailed: string; viewDrawing: string; viewErrors: string; viewExpand: string; viewFormNo: string; viewFormYes: string; viewFrame: (title: string) => string; viewImageHidden: (alt: string) => string; viewInPanel: string; viewInputsFailed: string; viewInputsOff: string; viewInputsPending: string; viewInputsSend: string; viewInputsSending: string; viewInputsSent: string; viewInputsUnsupported: string; viewInvalid: (name: string) => string; viewLinkDomain: (domain: string) => string; viewLive: (seconds: number) => string; viewLoadFailed: string; viewLoading: string; viewMcpAppAllow: string; viewMcpAppAllowed: (names: string) => string; viewMcpAppAsks: (names: string) => string; viewMcpAppDownloadBody: (server: string, size: string) => string; viewMcpAppDownloadSave: string; viewMcpAppDownloadTitle: (name: string) => string; viewMcpAppFailed: string; viewMcpAppFrame: (server: string, title: string) => string; viewMcpAppFrom: (server: string) => string; viewMcpAppOff: string; viewMcpAppPermission: (name: 'camera' | 'microphone' | 'geolocation' | 'clipboardWrite') => string; viewMcpAppRefused: string; viewMcpAppRun: string; viewMcpAppUiOff: string; viewMcpAppUnsupported: string; viewMcpAppWaiting: string; viewMissingRef: (ref: string) => string; viewNewerVersion: string; viewNo: string; viewOpenChat: string; viewOpenInArtifacts: string; viewOpenInChat: string; viewOpenPanel: string; viewPending: string; viewPin: string; viewPinFailed: string; viewPinnedHomeOff: string; viewRefresh: string; viewRefreshedAgo: (age: string) => string; viewRefreshedAt: (when: string) => string; viewRefreshFailed: string; viewRefreshing: string; viewRefreshUnsupported: string; viewRename: string; viewRenameFailed: string; viewRenameTitle: (title: string) => string; viewSave: string; viewSaved: string; viewSavedDelete: string; viewSaveFailed: string; viewSessionAgent: string; viewSessionAgentDefault: string; viewSessionAlways: string; viewSessionAnother: string; viewSessionArtifacts: string; viewSessionAsk: (verb: 'start' | 'send' | 'schedule' | 'command') => string; viewSessionChip: (status: string, title: string) => string; viewSessionCommand: string; viewSessionDraft: string; viewSessionFailed: string; viewSessionMore: string; viewSessionOnce: (verb: 'start' | 'send' | 'schedule' | 'command') => 'Start once' | 'Run once'; viewSessionOpen: string; viewSessionOpenToast: string; viewSessionPrompt: string; viewSessionRan: string; viewSessionScheduled: string; viewSessionSent: string; viewSessionStarted: (title: string) => string; viewSessionStartedDefault: (title: string, agent: string) => string; viewSessionStatus: (status: 'done' | 'failed' | 'running' | 'blocked') => string; viewSessionWhen: string; viewSessionWhere: string; viewSessionWhereBranch: (branch: string) => string; viewSessionWhereProject: string; viewShowLatest: string; viewShowOriginal: string; viewSourceAgo: (age: string) => string; viewSourceAllow: string; viewSourceAllowMenu: string; viewSourceAllowOnce: string; viewSourceAllowTool: string; viewSourceAllowView: string; viewSourceAskBar: string; viewSourceAskTitle: string; viewSourceDetail: (target: string, state: string) => string; viewSourceDetails: string; viewSourceError: (reason: string, message: string) => string; viewSourceFailed: (name: string) => string; viewSourceFetched: (age: string) => string; viewSourceMore: (count: number) => string; viewSourceNeedsSignIn: (server: string) => string; viewSourceNoArgs: string; viewSourceNotNow: string; viewSourceOld: (age: string) => string; viewSourceReadOnly: string; viewSourceReason: (reason: ViewSourceFailure) => string; viewSourceSignIn: string; viewSourcesMenu: string; viewSourcesOff: string; viewSourceToolChanged: (server: string) => string; viewSourceToolNotAllowed: string; viewSourceWantMany: (count: number) => string; viewSourceWantsAccess: (server: string) => string; viewSourceWantsRun: string; viewSourceWantsSessions: string; viewStateControl: string; viewStateFailed: string; viewStateSearch: string; viewStateUnsupported: string; viewTitleField: string; viewTurnFailed: string; viewTurnIntoBlock: string; viewTurnIntoPanel: string; viewTurnOnHome: string; viewUnknown: (name: string) => string; viewUnpin: string; viewUnsave: string; viewUnsaveConfirm: string; viewUnsaveConfirmAction: string; viewUnsaveConfirmBody: string; viewUntitled: string; viewVersionOf: (version: number, latest: number) => string; viewVersionPick: string; viewYes: string }`

Source: [ui/src/views/ViewsProvider.tsx:58](https://github.com/Tahul/zidane/blob/main/ui/src/views/ViewsProvider.tsx#L58)

### `useViewsMeta`

Function.

`zidane-ui/views`: the views area (docs/VIEWS.md). It holds the provider
that puts a `ViewsHost` in context and the hooks that read it. The
components that draw a view load in their own chunk, the first time the
transcript draws a \`\`\`view fence with its `views` option on, so this
entry stays small for apps that mount the provider with views off.

```ts
function useViewsMeta(
  host: ViewsHost | null,
  sessionId: string | null,
): ViewsMetaState | null
```

**Parameters**

- `host` (`ViewsHost | null`): The views host, or `null`.
- `sessionId` (`string | null`): The session, or `null`.

**Returns** `ViewsMetaState | null`

Source: [ui/src/views/ViewsProvider.tsx:48](https://github.com/Tahul/zidane/blob/main/ui/src/views/ViewsProvider.tsx#L48)

## Interfaces

### `ViewSessionDraft`

Interface.

A new chat a view's action fills, not sent.

```ts
interface ViewSessionDraft
```

**Properties**

- `cwd` (`string`): The project folder it runs in.
- `prompt` (`string`): The filled prompt and its context block.
- `title?` (`string`): The filled title, when the action has one.

Source: [ui/src/views/session-nav.tsx:14](https://github.com/Tahul/zidane/blob/main/ui/src/views/session-nav.tsx#L14)

### `ViewSessionNav`

Interface.

What a view's session actions ask of the app. Each member is optional: its control hides without it.

```ts
interface ViewSessionNav
```

**Properties**

- `openDraft?` (`(draft: ViewSessionDraft, from: ViewRef) => void`): Opens the new-chat draft with this prompt in its composer, never sent.
- `openSession?` (`(sessionId: string, from: ViewRef) => void`): Shows a session a view's action started or links to. `from`: the view, so the app knows its host.

Source: [ui/src/views/session-nav.tsx:24](https://github.com/Tahul/zidane/blob/main/ui/src/views/session-nav.tsx#L24)

### `ViewSessionNavProviderProps`

Interface.

Props for [`ViewSessionNavProvider`](https://zidane.si/docs/reference/ui-views.md#ViewSessionNavProvider).

```ts
interface ViewSessionNavProviderProps
```

**Properties**

- `children` (`ReactNode`): The app.
- `value` (`ViewSessionNav`): The app's way to open a session and a draft. Memoize it.

Source: [ui/src/views/session-nav.tsx:34](https://github.com/Tahul/zidane/blob/main/ui/src/views/session-nav.tsx#L34)

### `ViewsProviderProps`

Interface.

Props for [`ViewsProvider`](https://zidane.si/docs/reference/ui-views.md#ViewsProvider).

```ts
interface ViewsProviderProps
```

**Properties**

- `children` (`ReactNode`): The app.
- `host` (`ViewsHost`): Where the stored views come from.

Source: [ui/src/views/ViewsProvider.tsx:16](https://github.com/Tahul/zidane/blob/main/ui/src/views/ViewsProvider.tsx#L16)
