Skip to content

zidane-ui/approvals

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

Components#

ApprovalBarComponent#

Renders the first pending approval of a session: the inline ApprovalCard, or the file-edit review for the tools that write files. While the inline card shows, esc denies (not from inside the code editor, where it clears the selection), ⌘↵ allows once and ⌘⇧↵ always allows. Renders nothing when the session has no pending approval.

TypeScript
function ApprovalBar(props: ApprovalBarProps): Element | null
Parameters
NameTypeDescription
propsApprovalBarProps

The sessionId, an optional onFileEdit, renderFrame, className and style.

Element | null
ApprovalBar props
NameTypeDescription
className?string

Extra classes on the inline card's root.

onFileEdit?(request: WireApprovalRequest) => void

Opens the file-edit review for an edit, multi_edit or write_file approval on the app's modal layer (once per request; the bar then renders nothing). Absent: the bar renders FileEditApproval in place.

renderFrame?(props: ApprovalFrameProps) => ReactElement

Draws the inline card's surface. See ApprovalCardProps.renderFrame.

sessionIdstring | null

The session whose first pending approval shows. null: nothing shows.

style?CSSProperties

Inline styles on the inline card's root.

ui/src/approvals/ApprovalBar.tsx:194

ApprovalCardComponent#

Renders the inline approval card: the tool, what worried the decision model, the command or input (scrolling inside a capped body while the title and actions stay on screen), and the decisions. Once per request, focus lands on the card itself, never on a button, unless the user is typing somewhere.

TypeScript
function ApprovalCard(props: ApprovalCardProps): Element
Parameters
NameTypeDescription
propsApprovalCardProps

The request, onResolve, an optional renderFrame, className and style.

Element
ApprovalCard props
NameTypeDescription
className?string

Extra classes on the root (the alertdialog).

onResolve?(requestId: string, decision: ApprovalDecision) => void

Called with the user's decision. Absent: the card shows the request without its buttons.

renderFrame?(props: ApprovalFrameProps) => ReactElement

Draws the card's surface (an app's own dock card). Default: a raised card tinted with the warn color.

requestWireApprovalRequest

The pending approval to show.

style?CSSProperties

Inline styles on the root.

ui/src/approvals/ApprovalBar.tsx:86

ApprovalConcernComponent#

Renders what worried the decision model about a call it handed to the user.

TypeScript
function ApprovalConcern(props: ApprovalConcernProps): Element
Parameters
NameTypeDescription
propsApprovalConcernProps

The concern, plus className and style.

Element
ApprovalConcern props
NameTypeDescription
className?string

Extra classes on the line.

concernModelApproval

The decision model's verdict, from the request's concern.

style?CSSProperties

Inline styles on the line.

ui/src/approvals/ApprovalConcern.tsx:25

ApprovalShellComponent#

Renders a titled panel with a body and an optional footer, as a dialog named by its title.

TypeScript
function ApprovalShell(props: ApprovalShellProps): Element
Parameters
NameTypeDescription
propsApprovalShellProps

The title, description, onClose, footer, children, className and style.

Element
ApprovalShell props
NameTypeDescription
childrenReactNode

The body.

className?string

Extra classes on the panel.

description?string

A line under the heading.

footer?ReactNode

The actions row under the body.

onClose?() => void

Called by the close button (the file-edit review denies). Absent: no close button.

style?CSSProperties

Inline styles on the panel.

titlestring

The panel's heading.

ui/src/approvals/ApprovalShell.tsx:36

ApprovalsProviderComponent#

Provides an ApprovalsHost and optional label overrides to the approval components below it.

TypeScript
function ApprovalsProvider(props: ApprovalsProviderProps): Element
Parameters
NameTypeDescription
propsApprovalsProviderProps

Provider props: the host, optional labels, and the children to render.

Element
ApprovalsProvider props
NameTypeDescription
childrenReactNode

The components that read from host.

hostApprovalsHost

The host the approval components read pending approvals from and send decisions to.

labels?Partial<{ approvalAllow: string; approvalAllowForSession: string; approvalAllowNoneSelected: string; approvalAllowOnce: string; approvalAlwaysAllow: string; approvalApplySelected: (selected: number, total: number) => string; approvalClose: string; approvalConcern: (concern: ModelApproval) => string; approvalCwd: (cwd: string) => string; approvalDeny: string; approvalFileEditNoPath: string; approvalFileEditReview: string; approvalFileEditTitle: (tool: string, path: string | null) => string; approvalFromSubagent: (label: string) => string; approvalRunAfter: string; approvalRunBefore: string; approvalsError: (error: ApprovalsError) => string; approvalTimeout: (timeout: string) => string; hunkAdded: (count: number) => string; hunkAmbiguous: (matches: number) => string; hunkAmbiguousHint: (matches: number) => string; hunkFile: string; hunkInclude: (index: number, total: number) => string; hunkNewFile: string; hunkNotInFile: string; hunkNotInFileHint: string; hunkRemoved: (count: number) => string; hunkReplaceAll: string; hunksClear: string; hunksOf: string; hunksSelectAll: string; hunksSelected: string; hunksSomeMissing: string; hunkTitle: (index: number, total: number) => string; hunkVia: (via: string) => string; hunkViaHint: (via: string) => string; safelistCount: (count: number) => string; safelistDescription: string; safelistEmpty: string; safelistEmptyHint: string; safelistLoading: string; safelistProject: string; safelistRevoke: string; safelistRevoking: string; safelistTitle: string }>

Overrides for the approval components' strings. Keys you leave out keep the default English label.

ui/src/approvals/ApprovalsProvider.tsx:50

FileEditApprovalComponent#

Renders the file-edit review of a pending approval: the path, the subagent that asked, what worried the decision model, the diff (or the per-hunk checklist), and the decisions with their a / s / p / d keys. Esc and a click on the modal scrim deny. Focus starts on Allow.

TypeScript
function FileEditApproval(props: FileEditApprovalProps): Element
Parameters
NameTypeDescription
propsFileEditApprovalProps

The request, onDone, an optional renderShell, className and style.

Element
FileEditApproval props
NameTypeDescription
className?string

Extra classes on the default shell.

onDone?() => void

Called once the user decided, or when the request was answered elsewhere: close the modal that holds the review.

renderShell?(props: ApprovalShellProps) => ReactNode

Draws the panel around the review (an app's own modal shell). It receives the title, description, body, footer and onClose (which denies). Default: ApprovalShell.

requestWireApprovalRequest

The pending edit, multi_edit or write_file approval.

style?CSSProperties

Inline styles on the default shell.

ui/src/approvals/FileEditApproval.tsx:80

SafelistPanelComponent#

Renders the safelist: each project's "Always allow" entries with a Revoke button (when the host offers safelist.remove), the empty state, and read or revoke errors. Renders nothing when the host has no safelist.

TypeScript
function SafelistPanel(props: SafelistPanelProps): Element | null
Parameters
NameTypeDescription
propsSafelistPanelProps

An optional renderShell, className and style.

Element | null
SafelistPanel props
NameTypeDescription
className?string

Extra classes on the default shell.

renderShell?(props: ApprovalShellProps) => ReactNode

Draws the panel around the list (an app's own modal shell). It receives the title, description and body. Default: ApprovalShell.

style?CSSProperties

Inline styles on the default shell.

ui/src/approvals/SafelistPanel.tsx:33

Functions#

useApprovalsHostFunction#

Returns the ApprovalsHost from the nearest ApprovalsProvider. Throws when called outside one.

TypeScript
function useApprovalsHost(): ApprovalsHost

ui/src/approvals/ApprovalsProvider.tsx:69

useApprovalsLabelsFunction#

Returns the approval components' strings: the defaults merged with any overrides given to ApprovalsProvider or LabelsProvider.

TypeScript
function useApprovalsLabels(): { approvalAllow: string; approvalAllowForSession: string; approvalAllowNoneSelected: string; approvalAllowOnce: string; approvalAlwaysAllow: string; approvalApplySelected: (selected: number, total: number) => string; approvalClose: string; approvalConcern: (concern: ModelApproval) => string; approvalCwd: (cwd: string) => string; approvalDeny: string; approvalFileEditNoPath: string; approvalFileEditReview: string; approvalFileEditTitle: (tool: string, path: string | null) => string; approvalFromSubagent: (label: string) => string; approvalRunAfter: string; approvalRunBefore: string; approvalsError: (error: ApprovalsError) => string; approvalTimeout: (timeout: string) => string; hunkAdded: (count: number) => string; hunkAmbiguous: (matches: number) => string; hunkAmbiguousHint: (matches: number) => string; hunkFile: string; hunkInclude: (index: number, total: number) => string; hunkNewFile: string; hunkNotInFile: string; hunkNotInFileHint: string; hunkRemoved: (count: number) => string; hunkReplaceAll: string; hunksClear: string; hunksOf: string; hunksSelectAll: string; hunksSelected: string; hunksSomeMissing: string; hunkTitle: (index: number, total: number) => string; hunkVia: (via: string) => string; hunkViaHint: (via: string) => string; safelistCount: (count: number) => string; safelistDescription: string; safelistEmpty: string; safelistEmptyHint: string; safelistLoading: string; safelistProject: string; safelistRevoke: string; safelistRevoking: string; safelistTitle: string }
{ approvalAllow: string; approvalAllowForSession: string; approvalAllowNoneSelected: string; approvalAllowOnce: string; approvalAlwaysAllow: string; approvalApplySelected: (selected: number, total: number) => string; approvalClose: string; approvalConcern: (concern: ModelApproval) => string; approvalCwd: (cwd: string) => string; approvalDeny: string; approvalFileEditNoPath: string; approvalFileEditReview: string; approvalFileEditTitle: (tool: string, path: string | null) => string; approvalFromSubagent: (label: string) => string; approvalRunAfter: string; approvalRunBefore: string; approvalsError: (error: ApprovalsError) => string; approvalTimeout: (timeout: string) => string; hunkAdded: (count: number) => string; hunkAmbiguous: (matches: number) => string; hunkAmbiguousHint: (matches: number) => string; hunkFile: string; hunkInclude: (index: number, total: number) => string; hunkNewFile: string; hunkNotInFile: string; hunkNotInFileHint: string; hunkRemoved: (count: number) => string; hunkReplaceAll: string; hunksClear: string; hunksOf: string; hunksSelectAll: string; hunksSelected: string; hunksSomeMissing: string; hunkTitle: (index: number, total: number) => string; hunkVia: (via: string) => string; hunkViaHint: (via: string) => string; safelistCount: (count: number) => string; safelistDescription: string; safelistEmpty: string; safelistEmptyHint: string; safelistLoading: string; safelistProject: string; safelistRevoke: string; safelistRevoking: string; safelistTitle: string }

ui/src/approvals/ApprovalsProvider.tsx:107

usePendingApprovalsFunction#

Returns every pending approval, oldest first. Re-renders on every change to the queue.

TypeScript
function usePendingApprovals(): readonly WireApprovalRequest[]
readonly WireApprovalRequest[]

ui/src/approvals/ApprovalsProvider.tsx:74

useResolveApprovalFunction#

Returns resolve: answers a pending approval through the host, ignoring a failed send (the request already left the queue). undefined when the host can't answer approvals.

TypeScript
function useResolveApproval(): ((requestId: string, decision: ApprovalDecision) => void) | undefined
((requestId: string, decision: ApprovalDecision) => void) | undefined

ui/src/approvals/ApprovalsProvider.tsx:95

useSessionApprovalHeadFunction#

Returns the first pending approval of sessionId, or null. Re-renders only when that session's first approval changes, so rows of other sessions stay still.

TypeScript
function useSessionApprovalHead(sessionId: string | null): WireApprovalRequest | null
Parameters
NameTypeDescription
sessionIdstring | null

The session, or null for none.

WireApprovalRequest | null

ui/src/approvals/ApprovalsProvider.tsx:84

Interfaces#

ApprovalBarPropsInterface#

Props for ApprovalBar.

TypeScript
interface ApprovalBarProps
ApprovalBarProps properties
NameTypeDescription
className?string

Extra classes on the inline card's root.

onFileEdit?(request: WireApprovalRequest) => void

Opens the file-edit review for an edit, multi_edit or write_file approval on the app's modal layer (once per request; the bar then renders nothing). Absent: the bar renders FileEditApproval in place.

renderFrame?(props: ApprovalFrameProps) => ReactElement

Draws the inline card's surface. See ApprovalCardProps.renderFrame.

sessionIdstring | null

The session whose first pending approval shows. null: nothing shows.

style?CSSProperties

Inline styles on the inline card's root.

ui/src/approvals/ApprovalBar.tsx:169

ApprovalCardPropsInterface#

Props for ApprovalCard.

TypeScript
interface ApprovalCardProps
ApprovalCardProps properties
NameTypeDescription
className?string

Extra classes on the root (the alertdialog).

onResolve?(requestId: string, decision: ApprovalDecision) => void

Called with the user's decision. Absent: the card shows the request without its buttons.

renderFrame?(props: ApprovalFrameProps) => ReactElement

Draws the card's surface (an app's own dock card). Default: a raised card tinted with the warn color.

requestWireApprovalRequest

The pending approval to show.

style?CSSProperties

Inline styles on the root.

ui/src/approvals/ApprovalBar.tsx:65

ApprovalConcernPropsInterface#

Props for ApprovalConcern.

TypeScript
interface ApprovalConcernProps
ApprovalConcernProps properties
NameTypeDescription
className?string

Extra classes on the line.

concernModelApproval

The decision model's verdict, from the request's concern.

style?CSSProperties

Inline styles on the line.

ui/src/approvals/ApprovalConcern.tsx:11

ApprovalFramePropsInterface#

What ApprovalCardProps.renderFrame receives: the card's layout classes and its content.

TypeScript
interface ApprovalFrameProps
ApprovalFrameProps properties
NameTypeDescription
childrenReactNode

The card's content.

classNamestring

The card's layout classes (a column, capped in height), to put on the frame.

tone'attention'

Always attention: the frame of something waiting for the user.

ui/src/approvals/ApprovalBar.tsx:33

ApprovalShellPropsInterface#

What a shell receives: the panel's title, description, content and footer, and how to close it.

TypeScript
interface ApprovalShellProps
ApprovalShellProps properties
NameTypeDescription
childrenReactNode

The body.

className?string

Extra classes on the panel.

description?string

A line under the heading.

footer?ReactNode

The actions row under the body.

onClose?() => void

Called by the close button (the file-edit review denies). Absent: no close button.

style?CSSProperties

Inline styles on the panel.

titlestring

The panel's heading.

ui/src/approvals/ApprovalShell.tsx:14

ApprovalsProviderPropsInterface#

Props for ApprovalsProvider.

TypeScript
interface ApprovalsProviderProps
ApprovalsProviderProps properties
NameTypeDescription
childrenReactNode

The components that read from host.

hostApprovalsHost

The host the approval components read pending approvals from and send decisions to.

labels?Partial<{ approvalAllow: string; approvalAllowForSession: string; approvalAllowNoneSelected: string; approvalAllowOnce: string; approvalAlwaysAllow: string; approvalApplySelected: (selected: number, total: number) => string; approvalClose: string; approvalConcern: (concern: ModelApproval) => string; approvalCwd: (cwd: string) => string; approvalDeny: string; approvalFileEditNoPath: string; approvalFileEditReview: string; approvalFileEditTitle: (tool: string, path: string | null) => string; approvalFromSubagent: (label: string) => string; approvalRunAfter: string; approvalRunBefore: string; approvalsError: (error: ApprovalsError) => string; approvalTimeout: (timeout: string) => string; hunkAdded: (count: number) => string; hunkAmbiguous: (matches: number) => string; hunkAmbiguousHint: (matches: number) => string; hunkFile: string; hunkInclude: (index: number, total: number) => string; hunkNewFile: string; hunkNotInFile: string; hunkNotInFileHint: string; hunkRemoved: (count: number) => string; hunkReplaceAll: string; hunksClear: string; hunksOf: string; hunksSelectAll: string; hunksSelected: string; hunksSomeMissing: string; hunkTitle: (index: number, total: number) => string; hunkVia: (via: string) => string; hunkViaHint: (via: string) => string; safelistCount: (count: number) => string; safelistDescription: string; safelistEmpty: string; safelistEmptyHint: string; safelistLoading: string; safelistProject: string; safelistRevoke: string; safelistRevoking: string; safelistTitle: string }>

Overrides for the approval components' strings. Keys you leave out keep the default English label.

ui/src/approvals/ApprovalsProvider.tsx:36

FileEditApprovalPropsInterface#

Props for FileEditApproval.

TypeScript
interface FileEditApprovalProps
FileEditApprovalProps properties
NameTypeDescription
className?string

Extra classes on the default shell.

onDone?() => void

Called once the user decided, or when the request was answered elsewhere: close the modal that holds the review.

renderShell?(props: ApprovalShellProps) => ReactNode

Draws the panel around the review (an app's own modal shell). It receives the title, description, body, footer and onClose (which denies). Default: ApprovalShell.

requestWireApprovalRequest

The pending edit, multi_edit or write_file approval.

style?CSSProperties

Inline styles on the default shell.

ui/src/approvals/FileEditApproval.tsx:57

SafelistPanelPropsInterface#

Props for SafelistPanel.

TypeScript
interface SafelistPanelProps
SafelistPanelProps properties
NameTypeDescription
className?string

Extra classes on the default shell.

renderShell?(props: ApprovalShellProps) => ReactNode

Draws the panel around the list (an app's own modal shell). It receives the title, description and body. Default: ApprovalShell.

style?CSSProperties

Inline styles on the default shell.

ui/src/approvals/SafelistPanel.tsx:17