Tool Confirmation
An authorization card shown before a tool runs, with a risk level and a session-scoped remember option.
Tool Confirmation
Basic Usage
Tool Confirmation
Loading demo...
Interaction Contract
- The component runs nothing and remembers nothing. It reports a decision; executing and persisting it are the host's job.
- Both
approveanddenycarry{ remember: boolean }— deny included, so "deny for the rest of this session" is expressible. rememberis internal state, startsfalse, and is not reset after a decision. The card is single-use: unmount it once a decision arrives.riskhas three levels, mirrored ontodata-risk:read(default),writeandexecute. Anything other thanreadis treated as dangerous for emphasis.- Risk text defaults to
Read-only/Writes data/Executes.riskLabelsoverrides them, and a partial override is allowed. summaryandinputare both optional; each region is omitted entirely when unset.inputrenders verbatim in a<pre>with no processing beyond escaping — truncate long payloads before passing them in.- The root is
role="group"with an accessible name of${toolName} confirmation.
API
Props
| Name | Type | Default | Description |
|---|---|---|---|
toolName | string | — | The tool being authorized; also used to build the accessible name. Required. |
summary | string | — | One line on what the tool will do. Not rendered when unset. |
input | string | — | Serialized input preview, shown preformatted. |
risk | 'read' | 'write' | 'execute' | 'read' | Risk level, mirrored onto data-risk. |
allowLabel | string | 'Allow' | Label for the allow button. |
denyLabel | string | 'Deny' | Label for the deny button. |
rememberLabel | string | 'Remember for this session' | Label for the remember checkbox. |
riskLabels | Partial<Record<'read' | 'write' | 'execute', string>> | — | Overrides the risk text, per level; partial overrides are fine. |
Events
| Name | Payload | Description |
|---|---|---|
approve | ({ remember: boolean }) | Emitted when allow is clicked. |
deny | ({ remember: boolean }) | Emitted when deny is clicked, carrying remember as well. |
Slots
TxToolConfirmation exposes no slots. Serialize richer input yourself and pass it through input.
Best Practices
- Unmount the card as soon as a decision arrives rather than reusing it —
rememberdoes not reset itself. - Report
riskhonestly. Labelling a write asreadremoves both the visual emphasis and the user's basis for deciding. - Put only the decision-relevant fields in
input, pre-truncated. It is the one place a user can see what will actually happen, and a full request body makes them skip it. - Override
allowLabel,denyLabel,rememberLabelandriskLabelstogether for non-English surfaces. - When
rememberis true, scope the grant to the current session. Do not quietly promote it to a permanent one — the label promises otherwise.