Domain

ApprovalCard

Durable human-in-the-loop approval surface for reviewing risky tool operations before they execute.

import { ApprovalCard } from '@lostgradient/cinder';
approvalhuman-in-the-looptool
01

Overview

Reference usage

Presentational human-in-the-loop approval surface for reviewing a tool operation before the host application executes it.

Usage

svelte
<script lang="ts">
  import { ApprovalCard } from '@lostgradient/cinder';
</script>

<ApprovalCard
  tool={{ name: 'deploy-cloud', risk: 'medium' }}
  sandbox={{
    provider: 'codex',
    name: 'workspace-write',
    workingDir: '/workspace/project',
  }}
  operation={{
    kind: 'command',
    command: 'bun run --filter=@lostgradient/cinder validate',
    argsPreview: { package: '@lostgradient/cinder' },
  }}
  env={['DATABASE_URL', 'OPENAI_API_KEY']}
  policyVersion="policy-2026-06"
  idempotencyKey="approval-01JZ8T"
  state="pending"
  onResolve={(resolution) => console.log(resolution)}
/>

ApprovalCard is fully controlled. It does not execute commands, apply patches, persist policy decisions, or read environment values. The component only renders the supplied context and invokes callback props for host-owned actions.

Resolution callback

onResolve is the single decision contract. It fires for every action — Approve, Approve with edits and Deny — with the complete ApprovalResolution payload: the selected decision, parsed editedArgs for edited approvals, the approver's note as reason (saved with the decision; when denying, the agent reads it as the reason), and the remember checkbox state. Action buttons render only while the request is actionable and onResolve is wired; a card without the callback is purely presentational.

decision: 'deny' means the approver actively refused the operation. decision: 'cancel' is for a host that dismisses the prompt without a decision, such as on Escape; the component draws no Dismiss button, so Approve is the only primary action and Deny the only other one.

The shared approval row

layout="row" is the one approval row used in a chat transcript and beneath a tool call in a step rail. It sits on a neutral raised surface, never a warning fill, and the risk glyph carries the alert.

svelte
<script lang="ts">
  import { ApprovalCard } from '@lostgradient/cinder';
</script>

<ApprovalCard
  layout="row"
  question="Refund order 4471 for $42.00?"
  tool={{ name: 'issue-refund', label: 'Issue refund', risk: 'high', irreversible: true }}
  source="Tool runner"
  requestedAt="2026-11-02T10:38:00.000Z"
  consequence="Sends $42.00 back to the original card"
  operation={{
    kind: 'other',
    argsPreview: { orderId: 4471, amount: '$42.00', reason: 'Arrived damaged' },
  }}
  policyVersion="policy-2026-06"
  idempotencyKey="approval-row-4471"
  state="pending"
  onResolve={(resolution) => console.log(resolution)}
/>
  • The title is the question and wraps; it never truncates.
  • Line two reads the tool's label, its name as a small monospaced identifier, the risk word (Reads, Changes things or Dangerous, muted regular text, never red), "Can't be undone" when tool.irreversible, then "Approval from source" and the time it was asked ("4 min ago"; sourcePrefix replaces "Approval from" in every layout). The line wraps between its pieces and never inside one: each piece keeps the middot that follows it, so "Can't be undone" and "4 min ago" are never cut off or split from their middot. In a card narrower than 40rem, who asked and when move to their own line. Omit tool.label when the call above the row already names the tool.
  • consequence is one muted line below it, such as "Sends $42.00 back to the original card".
  • The Input disclosure shows a chevron, a bold "Input" and the arguments as one inline line of pairs ("Order ID 4471 · Amount $42.00 · Reason Arrived damaged"), cut with an ellipsis only if it must. Opening it shows the command, the touched files and a PayloadInspector labelled Input in its Fields view.
  • "Add a note" is a link that opens a "Note (optional)" field. The note is sent as reason with Approve and with Deny.
  • Pass rememberScope ("the rest of this chat") to offer "Allow label for the rest of this chat" as a checkbox on its own line before Deny and Approve; checking it sets remember. Leave it out for a tool set to Always, which never offers it.
  • Deny is secondary and Approve is the only primary action. In a card narrower than 32rem, and on a touch screen, Deny and Approve are equal-width 44px targets under "Add a note".
  • disabledReason turns Deny and Approve off while the approval is pending and writes the reason above the actions; both buttons go inert with aria-disabled, so they stay focusable, and name the reason with aria-describedby. "Add a note" and Input stay available.

A decided approval stays in the transcript as a decision in neutral text: state="denied" with decidedBy="you" and decidedAt reads "Denied by you · 10:40 AM", with no decision buttons and no error colour. The row reads the question, the tool line, the Input summary, then the decision, so the decision is the last thing under what was asked. An approval decided on another page while this one was open adds decidedIn, and the row collapses to what became of it: a check (or, for a denial, the neutral prohibition glyph) in place of the risk shield, the question, and "Approved by you in Reviews · 10:46 AM" under it, with no tool line, no Input summary and no dot.

The approval's own page

layout="detail" is the approval on its own page, such as a review. It reads top to bottom as an eyebrow with the risk glyph (eyebrow, "Tool approval" by default), the question, who asked and how long it has waited ("Asked by Tool runner in a chat · waiting 4 min"; sourcePrefix replaces "Asked by"; sourceHref and sourceInHref write the source and the place as links, and sourceIn names the place), what the source said as a collapsed line (said: "Tool runner said Order 4471 is $42.00…", one line cut with an ellipsis that opens in place), the context snippet, the tool ("It wants to run Issue refund issue-refund · Dangerous"; toolPrefix replaces the opening words), the Input block with its Fields and JSON switch, and one line with the risk glyph that carries "Can't be undone." and consequence. A failure sits under that line, then the note, the optional rememberScope checkbox, Deny and Approve, and the footnote. It has no Details disclosure.

Once decided, the green outcome line leads ("Approved by you 10:33 AM today · Tool runner in a chat", with the chat a link when sourceInHref is set and the day word "today", "yesterday" or the date after the time), only an approval is green and a denial stays neutral text, and result follows the Input block. A read-only approval says nothing more than its outcome unless there is a notice, an expiry or an unavailableReason to add.

decisionNote writes the note the approver left under the outcome, in any layout: "Your note Check the carrier's claim first. Sent to the agent as the reason." for a denial. view is bindable, so a page can hold one Fields and JSON choice and give it to every card on it.

Answers in flight, failed answers and read-only approvals

The host owns the answer, so it tells the card where the answer stands:

  • resolving="approve" writes "Approving…" with a spinner on Approve and turns Deny off; resolving="deny" does the same for Deny ("Denying…"). The note and the checkbox stop taking changes, the approval stays pending, and a second press is ignored until the host clears resolving.
  • failure={{ summary, detail }} writes a tinted, bordered danger message (an Alert, announced as it appears: "Couldn't approve. Interborough couldn't reach the agent. Nothing was refunded.") below the input, with the summary in bold. Nothing was decided, so Deny and Approve stay live and Approve is the retry; the card draws no second "Try again".
  • An approval that passed its expiresAt is expired: read-only, with no Deny or Approve, and a notice that says when it expired in the viewer's time zone ("This approval expired at 10:15 AM CST, the time its request set."). Pass notice to write your own sentence for any read-only approval, such as what was refunded or what happened elsewhere.
  • result writes what a decided approval led to ("Result: Refunded $18.50 to the original card."), and decidedIn says where it was decided when that was not here ("Approved by you in Reviews at 10:44 AM", with decidedBy and decidedAt). In the card layout a decision made elsewhere replaces the whole card with a check glyph, that sentence and one more: "Refund order 4471 for $42.00 · Issue refund." followed by notice, such as "The run is continuing, so this page changed. You don't need to do anything here." Nothing of the card is left to answer, so nobody answers twice.
  • footnote writes a muted line under the buttons while the approval waits, such as what happens once you decide. It goes with the buttons.
  • context is a snippet written above the question, such as "Test chat · this runs for real: order 4471 is refunded".

An unavailable approval is a held approval nobody can answer now, such as one that belongs to an agent whose plugin is disabled. The row shows the neutral word "Unavailable" at the right, the input line, and unavailableReason below it, with no Deny or Approve.

Operation rendering

  • tool.name renders in monospace as the identifier; tool.label is the human name written before it.
  • tool.risk is read as a muted word (Reads, Changes things, Dangerous). One shield glyph carries the alert in amber while the approval is pending and goes quiet once it is decided; its aria-label names the risk level ("High risk").
  • In the card layout the header stacks who asked and when, the question, the tool line, the risk line and the consequence on a neutral surface. Without a question the title is "Approval required for name".
  • operation.kind: 'command' renders the command as a syntax-highlighted shell CodeBlock.
  • operation.kind: 'patch' renders the supplied unified patch as a syntax-highlighted diff.
  • operation.filesTouched renders one row per unique path, each with a copy button. Duplicate paths are collapsed.
  • operation.argsPreview renders through PayloadInspector; oversized previews are replaced with a bounded truncation notice before rendering. Both layouts open the Fields view, with the exact stored JSON one click away on the Fields/JSON switch. The card names the block <tool> arguments; pass inputLabel (for example Runs with) to name it yourself.
  • env renders variable names only, as plain text. Values are not accepted and are stripped if a caller accidentally passes NAME=value.
  • Sandbox context, environment names, and the policy version / idempotency key / snapshot id all live in a single collapsed "Details" disclosure so supporting context stays out of the approver's way until they ask for it. The disclosure appears only when the host supplies a sandbox, environment names or a snapshot; a request with none of them has nothing to disclose, and the policy version and idempotency key stay with the request. The action buttons are the last element of a pending card.

Approval states

Pending requests render action buttons. Non-pending requests render a read-only summary in neutral text; a denied approval is never drawn in an error colour. When expiresAt passes while state is still pending, the effective state becomes expired, actions disappear, and no callback fires automatically.

Heading levels

The card title defaults to an h3 with section headings one level deeper. Pass headingLevel to fit the card into the host page's document outline, matching the Card convention.

Live preview

Command approval

Approval required for deploy-cloud

Changes things

bun run --filter=@lostgradient/cinder validate

Files touched

1 file
  • packages/components/src/components/approval-card/approval-card.svelte
deploy-cloud arguments
deploy-cloud arguments view
2 fields

Package @lostgradient/cinderDry run No

Saved with your decision. If you deny, the agent reads it as the reason.

02

When to use

Use when
  • A tool call, command, file write, or patch needs explicit human approval before execution.
  • Showing policy, sandbox, idempotency, environment-name, and argument context for an approval request.
Avoid when
  • The action has already completed and only needs historical display — use feed or run-step-timeline instead.
  • Collecting arbitrary form input for a workflow — compose form controls directly instead.
03

Examples

Command approval

A pending command approval with sandbox context, arguments, environment names, and editable arguments.

Question answered somewhere else

A question answered in Reviews while the page is open reads the same as an approval: "Answered by you in Reviews" with the time, then the question and what happened. Nothing is left to answer here.

Approval answered somewhere else

When the approval is approved in Reviews while the page is open, the card is replaced by who decided, where and when, and the page says it changed. Approve and Deny are gone, so nobody approves twice.

Card, approving failed

Deny failing reads the same way: a red-toned inline message below the effect line says what failed and what is still true. Nothing was decided, so the live Deny and Approve are the retry and there is no separate Try again.

Refund approval card

The card follows the approval-row rules on a neutral raised surface: who asked and when, the wrapping question, the tool with its identifier small and monospaced, muted "Dangerous · Can't be undone", then the effect line. The arguments sit under "Runs with" and a note field is sent with both Approve and Deny.

Card with Allow for the rest of this chat

A tool set to On changes offers the checkbox on its own line, below the note and above Deny and Approve. The note travels with Approve, with Allow, and with Deny. A tool set to Always shows only the note, Deny and Approve.

One Fields and JSON switch for the whole page

The card binds its view, so a page can hold one Fields and JSON choice and hand it to every payload: switching it on one card switches the other too.

Approval detail

The approval's own page: the eyebrow with its risk glyph, the question, who asked (the source and the chat are links) and how long it has waited, what the source said as a collapsed line, what the tool is, the Input block with Fields and JSON, then one line with the risk glyph that says what cannot be undone and what approving does. Deny and Approve sit below.

Approval detail, approved

A decided detail is read-only with no actions: the green outcome line leads with the decision, who made it and when, then where it was asked, the input and the result.

Approval detail, expired

An expired approval is read-only. Beside who asked it reads Expired with a neutral dot, the input stays, and a notice says when it expired and what that means.

Approval detail, approving failed

The failure shows in the detail as a red-toned inline message below the consequence line. Nothing was approved, so the row stays in Waiting; the decision bar stays live with Deny and a primary Approve, and Approve is the retry.

Approval detail with Allow for this chat

On the detail page the checkbox sits on its own line below the note and above Deny and Approve; the note travels with every decision.

Expired approval

A read-only approval request whose pending decision window has expired.

Patch approval

A high-risk patch approval that previews the proposed diff, touched files, and arguments.

Approval row

The shared approval row: risk glyph and question, the tool and where it came from, the consequence, Input, Add a note, Deny and Approve.

Approve in flight

Approve reads "Approving…" with a spinner and both buttons turn off; the approval stays pending until the answer lands.

Approval row with a context line

A context slot writes a line above the question, such as a test chat whose tools run for real.

Denied approval

A denied approval stays in the transcript as a neutral decision with who decided and when, the input it was asked about, and the note that went to the agent as the reason.

Decided approval with its result

A decided approval shows who decided and when, then what it led to.

Approval answered on another page

An approval decided on another page while this one was open collapses to who decided, where and when, with no Deny or Approve left, under the question it asked.

Expired approval

An approval that passed its `expiresAt` is read-only and says when it expired.

Approve failed

A red-toned inline message says what failed and what is still true. Nothing was decided, so Approve is the retry.

Approval row with Allow for this chat

A tool set to On changes offers a checkbox on its own line before Deny and Approve; a tool set to Always never does.

Unavailable approval

A held approval nobody can answer now shows a neutral word and the reason, with no decision buttons.

Approval row, agent unreachable

When the approval cannot be answered right now, the reason sits above Add a note, Deny and Approve, and both buttons are named by it. The question, the line, the consequence and Input stay visible.

04

Props

Props for approval-card
Name
Type
Default
Description
tool required { /** The tool's identifier, such as `issue-refund`. The `row` layout writes it small and monospaced. */ name: string; /** The tool's human name, such as …
Show full type { /** The tool's identifier, such as `issue-refund`. The `row` layout writes it small and monospaced. */ name: string; /** The tool's human name, such as `Issue refund`, written before the identifier. Omit it when the surrounding rows already name the call. */ label?: string; /** Risk level assigned by the policy evaluator. Read as Reads, Changes things or Dangerous in muted text; the glyph carries the alert. */ risk: ApprovalToolRisk; /** True when the operation cannot be reversed. Adds "Can't be undone", which never breaks across lines. */ irreversible?: boolean; }
Tool requesting approval.
sandbox { /** Sandbox provider, such as Codex or a remote execution backend. */ provider: string; /** Sandbox profile or policy name. */ name: string; /** Wor…
Show full type { /** Sandbox provider, such as Codex or a remote execution backend. */ provider: string; /** Sandbox profile or policy name. */ name: string; /** Working directory for the pending operation. */ workingDir: string; }
Optional sandbox context in which the operation will run.
operation required { /** Operation family being approved. */ kind: 'command'; /** Shell command for command approvals. */ command: string; /** File paths that the operat…
Show full type { /** Operation family being approved. */ kind: 'command'; /** Shell command for command approvals. */ command: string; /** File paths that the operation may read or write. Duplicate paths are collapsed for display. */ filesTouched?: string[]; /** * JSON-like argument preview shown to the approver. * * @schemaPermissive */ argsPreview?: unknown; }
Operation details shown to the approver.
env string[] [] Environment variable names only. Values are ignored if accidentally supplied as NAME=value.
snapshotId text Snapshot identifier for the pending approval context.
policyVersion required text Policy version that produced the approval request.
idempotencyKey required text Idempotency key that makes repeated decisions durable.
expiresAt text Optional ISO timestamp after which a pending approval is treated as expired.
state required 'pending''approved''approved_with_edits''denied''expired''cancelled''unavailable' Persisted approval state.
editableArgs boolean false Whether approving with edited JSON arguments is available. Default false.
headingLevel 23456 3 Heading level for the card title; section headings render one level deeper. Default 3.
layout 'card' | 'row' | 'detail' 'card' Layout: the full card, the shared row (one approval inside a transcript or beneath a tool call), or the approval's own detail page. Default 'card'.
question text The question the approval asks, such as Refund order 4471 for $42.00?. Default Run <tool>?.
source text Who asked, written after the source prefix: Tool runner, or the agent.
sourcePrefix text The words before source. Default Approval from, or Asked by in the detail layout.
sourceHref text Where the source's name leads, in the detail layout: the name is written as a link ("Asked by Tool runner in a chat").
sourceIn text Where it was asked, written after "in" in the detail layout, such as the chat's title: "Asked by Tool runner in Please refund order 4471".
sourceInHref text Where sourceIn leads, written as a link in the detail layout.
said text What the source said when it asked, in the detail layout: a collapsed line under who asked, "Tool runner said Order 4471 is $42.00…", that opens in place to the whole text.
eyebrow text The small line above the question in the detail layout, beside the risk glyph. Default Tool approval.
toolPrefix text The words before the tool in the detail layout: "It wants to run Issue refund issue-refund · Dangerous". Default It wants to run.
requestedAt text When the approval was asked. Written as relative time ("4 min ago") while the approval is pending.
consequence text What approving does, in one line, such as Sends $42.00 back to the original card.
rememberScope text Offers "Allow <tool> for <scope>" as a checkbox on its own line before Deny and Approve, with the scope written after "for", such as the rest of this chat. Leave it out for a tool set to Always, which never offers it. Checking it sets remember on the resolution.
decidedBy text Who decided, once the approval is decided: you. Written as "Denied by you".
decidedAt text When the approval was decided, written as a time of day after the outcome ("Denied by you · 10:40 AM").
decisionNote text The note the approver left with the decision, written under the outcome as "Your note", the note, and a caption saying where it went: "Sent to the agent as the reason." for a denial.
disabledReason text Why Deny and Approve are off while the approval is still pending, such as Approving is off until Interborough is reachable. Written above the actions and named by both buttons.
unavailableReason text Why an unavailable approval cannot be answered now, written beneath it.
resolving 'approve' | 'deny' The answer that is on its way: approve writes "Approving…" with a spinner on Approve, deny writes "Denying…" with a spinner on Deny, and both buttons, the note and the checkbox turn off until the host clears it. The approval stays pending.
failure { /** What failed, in a few words, such as `Couldn't approve.`. */ summary: string; /** The reason and what is still true, such as `Interborough couldn't …
Show full type { /** What failed, in a few words, such as `Couldn't approve.`. */ summary: string; /** The reason and what is still true, such as `Interborough couldn't reach the agent. Nothing was refunded.`. */ detail?: string; }
Why the last answer did not go through, written as a red-toned inline message below the consequence. Nothing was decided, so Deny and Approve stay live; Approve is the retry.
notice text A notice written beneath a read-only approval, such as why it expired or what happened elsewhere. Without one, an approval that passed its expiresAt says when it expired.
result text What the approval led to, once it is decided: written as "Result: Refunded $18.50 to the original card.".
decidedIn text Where it was decided when that was not here, such as Reviews: "Approved by you in Reviews at 10:44 AM".
outcomeLabel text Names the decision for a request that is not a tool approval, in place of Approved or Denied, such as Answered for a question: "Answered by you in Reviews at 10:44 AM". The request's question is then the sentence beneath, with no tool named.
footnote text A line of text written under the buttons while the approval is pending, such as what happens once you decide.
inputLabel text What the payload is called in the Input block, such as Runs with. Default Input in the row and <tool> arguments in the card.
context snippet A line of context written above the question, such as "Test chat · this runs for real".
view bindable 'fields' | 'json' 'fields' Which view of the arguments the Input block shows, Fields or JSON. Bindable, so one switch can govern every payload on a page. Default fields.
now number The reference time for relative times. Defaults to now.
onResolve (resolution: ApprovalResolution) => void Called for approve, approve-with-edits, and deny with the complete resolution payload.
id text
05

Accessibility

Renders as an article with native button controls so approval actions are discoverable without polluting the landmark list.
Expiration changes update the visible state but do not fire approval callbacks automatically.