Loading component…
Loading component…
An agent asks for one specific right – who, why and exactly what will happen – and you allow it once, for an hour or always; then it folds into one line with Revoke
To reuse this local React demo, copy all files from the Code tab into the same folder, then import PermissionRequest from ./permission-request.
import { PermissionRequest } from "@/components/ui/permission-request";
export function PushRequest({ onAnswer }: { onAnswer: (allowed: boolean, until?: number) => void }) {
return (
<PermissionRequest
agent={{ name: "Coder", model: "GPT-6 Sol" }}
action="push to main"
target="acme/web"
risk="risky"
reason="The fix for the flaky checkout test passed review and all checks."
preview={[
{ id: "a", label: "src/checkout/cart.ts", meta: "+12 −4" },
{ id: "b", label: "Deploys to production after the merge" },
]}
onDecisionChange={(d) => d && onAnswer(d.allow, d.until)}
/>
);
}| Name | Type | Default | Description |
|---|---|---|---|
| agent | { name, model?, avatar? } | Who asks – the avatar is a small mark, e.g. the model maker's logo; defaults to initials | |
| action | string | What it wants to do, read after "wants to", e.g. "push to main" | |
| target | string | Where, e.g. "acme/web" or "Stripe · live mode" – shown under the title with toolIcon | |
| toolIcon | ReactNode | The tool's mark next to the target | |
| risk | "safe" \| "risky" \| "destructive" | "risky" | Risky and destructive carry a tag; destructive also turns Allow red and leaves out Always |
| reason | string | The agent's own words on why it needs this | |
| preview | { id, label, meta?, icon? }[] | Exactly what will happen – files, recipients, amounts; meta is right-aligned, e.g. "+12 −4" | |
| previewTitle | string | "What will happen" | Heading of the preview |
| previewLimit | number | 3 | Rows shown before "N more" |
| scopes | ("once" \| "timed" \| "always")[] | all three | The choices of how long; one choice hides the switch |
| scope / defaultScope / onScopeChange | PermissionScope | "once" | Controlled or uncontrolled choice of how long |
| duration | number | 60 | Minutes a timed grant holds |
| decision / defaultDecision | PermissionDecision \| null | { allow, scope, at, until? } – null while it waits | |
| onDecisionChange | (decision \| null) => void | Allow, Deny – and null for Revoke, Change or Ask again | |
| now | number | Date.now() | The clock for the time left – without it the card ticks every second while a timed grant runs |
| className | string | Extra class on the root |
Fills its container up to 400px
Below 340px the reason loses its indent, the buttons share the width and the keyboard hints go
Touch screens get taller choices and buttons and no keyboard hints
Dark mode built in: switches when an ancestor (usually <html>) has the class dark or data-theme="dark"