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.
function ApprovalBar(props: ApprovalBarProps): Element | nullParameters
| Name | Type | Description |
|---|---|---|
| props | ApprovalBarProps | The |
Returns
Element | nullProps
| Name | Type | Description |
|---|---|---|
| className? | string | Extra classes on the inline card's root. |
| onFileEdit? | (request: WireApprovalRequest) => void | Opens the file-edit review for an |
| renderFrame? | (props: ApprovalFrameProps) => ReactElement | Draws the inline card's surface. See |
| sessionId | string | null | The session whose first pending approval shows. |
| style? | CSSProperties | Inline styles on the inline card's root. |
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.
function ApprovalCard(props: ApprovalCardProps): ElementParameters
| Name | Type | Description |
|---|---|---|
| props | ApprovalCardProps | The |
Returns
ElementProps
| Name | Type | Description |
|---|---|---|
| className? | string | Extra classes on the root (the |
| 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. |
| request | WireApprovalRequest | The pending approval to show. |
| style? | CSSProperties | Inline styles on the root. |
ApprovalConcernComponent#
Renders what worried the decision model about a call it handed to the user.
function ApprovalConcern(props: ApprovalConcernProps): ElementParameters
| Name | Type | Description |
|---|---|---|
| props | ApprovalConcernProps | The |
Returns
ElementProps
| Name | Type | Description |
|---|---|---|
| className? | string | Extra classes on the line. |
| concern | ModelApproval | The decision model's verdict, from the request's |
| style? | CSSProperties | Inline styles on the line. |
ApprovalShellComponent#
Renders a titled panel with a body and an optional footer, as a dialog named by its title.
function ApprovalShell(props: ApprovalShellProps): ElementParameters
| Name | Type | Description |
|---|---|---|
| props | ApprovalShellProps | The |
Returns
ElementProps
| Name | Type | Description |
|---|---|---|
| children | ReactNode | 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. |
| title | string | The panel's heading. |
ApprovalsProviderComponent#
Provides an ApprovalsHost and optional label overrides to the approval components below it.
function ApprovalsProvider(props: ApprovalsProviderProps): ElementParameters
| Name | Type | Description |
|---|---|---|
| props | ApprovalsProviderProps | Provider props: the |
Returns
ElementProps
| Name | Type | Description |
|---|---|---|
| children | ReactNode | The components that read from |
| host | ApprovalsHost | 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. |
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.
function FileEditApproval(props: FileEditApprovalProps): ElementParameters
| Name | Type | Description |
|---|---|---|
| props | FileEditApprovalProps | The |
Returns
ElementProps
| Name | Type | Description |
|---|---|---|
| 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 |
| request | WireApprovalRequest | The pending |
| style? | CSSProperties | Inline styles on the default shell. |
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.
function SafelistPanel(props: SafelistPanelProps): Element | nullParameters
| Name | Type | Description |
|---|---|---|
| props | SafelistPanelProps | An optional |
Returns
Element | nullProps
| Name | Type | Description |
|---|---|---|
| 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: |
| style? | CSSProperties | Inline styles on the default shell. |
Functions#
useApprovalsHostFunction#
Returns the ApprovalsHost from the nearest ApprovalsProvider. Throws when called outside one.
function useApprovalsHost(): ApprovalsHostReturns
useApprovalsLabelsFunction#
Returns the approval components' strings: the defaults merged with any overrides given to ApprovalsProvider or LabelsProvider.
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 }Returns
{ 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 }usePendingApprovalsFunction#
Returns every pending approval, oldest first. Re-renders on every change to the queue.
function usePendingApprovals(): readonly WireApprovalRequest[]Returns
readonly WireApprovalRequest[]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.
function useResolveApproval(): ((requestId: string, decision: ApprovalDecision) => void) | undefinedReturns
((requestId: string, decision: ApprovalDecision) => void) | undefineduseSessionApprovalHeadFunction#
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.
function useSessionApprovalHead(sessionId: string | null): WireApprovalRequest | nullParameters
| Name | Type | Description |
|---|---|---|
| sessionId | string | null | The session, or |
Returns
WireApprovalRequest | nullInterfaces#
ApprovalBarPropsInterface#
Props for ApprovalBar.
interface ApprovalBarPropsProperties
| Name | Type | Description |
|---|---|---|
| className? | string | Extra classes on the inline card's root. |
| onFileEdit? | (request: WireApprovalRequest) => void | Opens the file-edit review for an |
| renderFrame? | (props: ApprovalFrameProps) => ReactElement | Draws the inline card's surface. See |
| sessionId | string | null | The session whose first pending approval shows. |
| style? | CSSProperties | Inline styles on the inline card's root. |
ApprovalCardPropsInterface#
Props for ApprovalCard.
interface ApprovalCardPropsProperties
| Name | Type | Description |
|---|---|---|
| className? | string | Extra classes on the root (the |
| 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. |
| request | WireApprovalRequest | The pending approval to show. |
| style? | CSSProperties | Inline styles on the root. |
ApprovalConcernPropsInterface#
Props for ApprovalConcern.
interface ApprovalConcernPropsProperties
| Name | Type | Description |
|---|---|---|
| className? | string | Extra classes on the line. |
| concern | ModelApproval | The decision model's verdict, from the request's |
| style? | CSSProperties | Inline styles on the line. |
ApprovalFramePropsInterface#
What ApprovalCardProps.renderFrame receives: the card's layout classes and its content.
interface ApprovalFramePropsProperties
| Name | Type | Description |
|---|---|---|
| children | ReactNode | The card's content. |
| className | string | The card's layout classes (a column, capped in height), to put on the frame. |
| tone | 'attention' | Always |
ApprovalShellPropsInterface#
What a shell receives: the panel's title, description, content and footer, and how to close it.
interface ApprovalShellPropsProperties
| Name | Type | Description |
|---|---|---|
| children | ReactNode | 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. |
| title | string | The panel's heading. |
ApprovalsProviderPropsInterface#
Props for ApprovalsProvider.
interface ApprovalsProviderPropsProperties
| Name | Type | Description |
|---|---|---|
| children | ReactNode | The components that read from |
| host | ApprovalsHost | 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. |
FileEditApprovalPropsInterface#
Props for FileEditApproval.
interface FileEditApprovalPropsProperties
| Name | Type | Description |
|---|---|---|
| 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 |
| request | WireApprovalRequest | The pending |
| style? | CSSProperties | Inline styles on the default shell. |
SafelistPanelPropsInterface#
Props for SafelistPanel.
interface SafelistPanelPropsProperties
| Name | Type | Description |
|---|---|---|
| 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: |
| style? | CSSProperties | Inline styles on the default shell. |