Approval
An agent asks before it acts. Enter approves, Esc denies, the scope slides between once and always, and anything dangerous needs a hold.
npx shadcn@latest add @captain/approvalRan
pnpm test billingalways in this repoRun pnpm db:reset on staging?
Migration 0042 stopped halfway. Atlas wants a clean schema before it retries.
Drops and reseeds 31 tables on staging-eu. The last backup is from 06:40 today.
$ pnpm db:reset --env staging --seed fixtures/billingRun pnpm lint --fix in billing-service?
Formats the 14 files in #482 before review.
Approval is a Pro component
The demo and the docs are free. The source comes with Pro, through this page, the shadcn CLI and the MCP.
Usage
import { Approval } from "@/components/ui/approval"
<Approval
dangerous
title={<>Run <code>pnpm db:reset</code> on staging?</>}
effect="Drops and reseeds 31 tables on staging-eu."
command="pnpm db:reset --env staging"
onDecision={({ approved, scope }) => agent.reply(approved, scope)}
/>Props
| Prop | Type | Default | What it does |
|---|---|---|---|
| title | ReactNode | The question. Inline <code> is set as code. | |
| command | string | The exact command or call, shown in a code well. | |
| reason | ReactNode | Why the agent wants it. | |
| effect | ReactNode | What it will do. Set in the danger colour when dangerous. | |
| dangerous | boolean | Approve becomes a hold, and always-allow is not offered. | |
| alwaysLabel | ReactNode | Offers a once / always choice, e.g. Always for pnpm lint. | |
| holdDuration | number | 1400 | Hold length in ms for dangerous actions. |
| onDecision | ({ approved, scope }) => void | Called once. The card then collapses to one line. | |
| autoFocus | boolean | true | Focus on mount so Enter and Esc work at once. |
| resolvedLabel | (decision) => ReactNode | Text for the collapsed line. |
Keyboard
- Enter
- Approve
- Esc
- Deny
- Space or Enter (hold)
- Approve a dangerous action
- ← →
- Once or always
Accessibility
- A labelled group: the question is the label, reason and effect are the description.
- Dangerous requests focus the hold button, so a held Enter or Space approves and a tap cannot.
- The scope is a radiogroup with arrow keys. The outcome is announced as status.