Skip to content
GitHub (opens in a new tab)

ApprovalCard

The agent asks before it acts: risk, what will happen in words, an exact preview of the command or diff, and Approve (⌘/Ctrl+Enter) / Deny (Escape) with an optional auto-deny countdown.

stableOrganismcontracts/approvalcard.json

Preview

ApprovalCard

The agent asks before it acts. Not AlertDialog. Not InsightCard.

Master

A high-risk command with a 60-second countdown. Approve (⌘/Ctrl+Enter) or Deny (Escape) resolves the card to one line; Reset brings it back.

Run database migration?

High risk

Agent wants to run a command on staging in acme-demo.

Auto-deny in1:00

Exact commandacme-demo / staging
npm run db:migrate -- --env=staging# applies 2 migrations · drops column invoices.legacy_total

Usage

ApprovalCard gates one side effect. Show the exact command or diff, never a paraphrase. Approve is the view's one solid primary. AgentPlan accepts a whole plan; AlertDialog interrupts the page.

Do's

  • an agent needs a person's OK before a command, file edit, or other side effect
  • human-in-the-loop gates in a chat, trail, or inbox
  • a resolved decision should stay in the log as one line
  • inside AgentMonitor, as variant="compact" for the run's waiting state
  • compact inside AgentMonitor, with waitingSec, to say how long the agent has waited for the OK

Don'ts

  • a generic yes/no that interrupts the page — AlertDialog
  • a recommendation the person may act on later — InsightCard
  • a plan of several steps to accept — AgentPlan
  • inline page status — Alert
<ApprovalCard
  title="Run database migration?"
  description="Agent wants to run a command on staging in acme-demo."
  risk="high"
  action={{
    kind: "command",
    command: "npm run db:migrate -- --env=staging",
    note: "applies 2 migrations · drops column invoices.legacy_total",
    target: "acme-demo / staging",
  }}
  countdownSec={60}
  onApprove={approve}
  onDeny={deny}
/>

When to use

  • an agent needs a person's OK before a command, file edit, or other side effect
  • human-in-the-loop gates in a chat, trail, or inbox
  • a resolved decision should stay in the log as one line
  • inside AgentMonitor, as variant="compact" for the run's waiting state
  • compact inside AgentMonitor, with waitingSec, to say how long the agent has waited for the OK

When not to use

  • a generic yes/no that interrupts the page — AlertDialog
  • a recommendation the person may act on later — InsightCard
  • a plan of several steps to accept — AgentPlan
  • inline page status — Alert

What an agent reads

import { ApprovalCard } from "agentic-ds-kit";
must
  • title is h3, article aria-labelledby it
  • facts are a dl, so each label is read as a term
  • ⌘/Ctrl+Enter approves and Escape denies while focus is in the card (Escape not on another control); plain Enter never approves; buttons carry aria-keyshortcuts
  • the key hint line is aria-hidden and hidden on touch screens and below --grid-breakpoint-sm
  • diff lines announce Added / Removed
  • countdown is role=timer with aria-live off; at 10 seconds left a polite status says "Denies in 10 seconds" once; the bar is a kit Progress with an accessible name
  • resolved row is an article named "Approved: <title>" and takes focus if the card had it
  • focus uses the shared ring (canvas 1px, focus-ring 3px)
  • entry motion is opacity and transform only, off under prefers-reduced-motion
  • compact: the title h3 also reads the risk (e.g. ", High risk") to screen readers; the same keys and aria-keyshortcuts apply
  • compact waitingSec: the m:ss value is role=timer with aria-live off, after the visible word waiting
  • A card resolved while on screen first exits (fade, light blur, small drop on the exit timing, no more clicks), then the resolved row rises in where it was and takes focus if the card had it. The card itself rises in on the enter timing. No motion under prefers-reduced-motion
defaults
  • risk medium
  • status pending
  • variant default
  • approveLabel Approve
  • denyLabel Deny
stops if
  • Do not invent a local ApprovalCard, ConfirmCard, or PermissionCard
  • Do not paraphrase the action: show the exact command or diff
  • Approve is the view's one solid primary; Deny stays outline neutral
  • Do not use raw hex; risk colors come from status tokens
  • Do not hide the risk Badge for high-risk actions in the default variant; only variant="compact" inside AgentMonitor leaves it to screen readers
  • Do not use variant="compact" for standalone approvals (chat, trail, inbox); it is only for AgentMonitor's waiting state
  • Do not pass waitingSec to the default variant or use it as a deadline; it only shows in compact, and auto-deny is countdownSec

From contracts/approvalcard.json: must is the a11y requirements, defaults the prop defaults, stops if the doNot rules where the agent asks instead of inventing a cousin.

Props

NameTypeRequiredDefaultNotes
titlestringYes—The question, e.g. "Run database migration?"
descriptionstringNo——
risklow | medium | highNomediumSets the risk Badge.
actionobjectYes—{ kind: "command", command, note?, target? } or { kind: "diff", file, lines: { type: "context" | "add" | "remove", text }[] }. Shown exactly as it will run.
factsarrayNo—{ label, value }[], e.g. Will do / Why medium. What will happen and why the risk is what it is, in words, as a dl above the preview. The exact action still shows.
statuspending | approved | denied | expiredNopendingAnything but pending renders the one-line resolved row.
variantdefault | compactNodefaultcompact is for AgentMonitor's waiting state only: one row with the title (and the countdown when countdownSec is set), one line of description, the exact preview and small right-aligned Deny and Approve with their key chips (Esc, ⌘⏎). No risk Badge, heading or facts; the risk is read to screen readers with the title.
waitingSecnumberNo—Compact only: seconds the agent has already waited for this OK, shown as "waiting m:ss" in the title row and counting up while pending. Hidden when left out; ignored by the default variant. Not a deadline: use countdownSec for auto-deny.
countdownSecnumberNo—Auto-deny countdown in seconds. At 0 the card calls onExpire, else onDeny. Pending only.
onApprovefunctionNo—Approve button (Check icon) and ⌘/Ctrl+Enter while focus is in the card. Plain Enter never approves.
onDenyfunctionNo—Deny button and Escape while focus is in the card but not on another control.
onExpirefunctionNo—Countdown reached 0. Falls back to onDeny.
resolvedBystringNo—Resolved row, e.g. "you".
resolvedAtstringNo—Resolved row, e.g. "2s ago".
approveLabelstringNoApprove—
denyLabelstringNoDeny—
  • Component
    →

    AlertDialog

    Must-choose overlay that interrupts until the user cancels or confirms.

  • Component
    →

    InsightCard

    A recommended insight or opportunity as a compact card, with tone and optional actions.

  • Component
    →

    AgentPlan

    What an agent intends to do, before or during a run.

  • Component
    →

    Alert

    Inline status banner that stays on the page.