AI Approval
Human-in-the-loop controls: an amber approve or deny card, a hold-to-confirm button for destructive actions, and a multiple-choice question.
"use client"
import * as React from "react"
import { Check, TriangleAlert } from "lucide-react"
import {
AiKitStyles,
AiStyle,
cx,
Face,
Mark,
Roll,
type AiShape,
type AiTone,
} from "@/lib/ai-kit"
const CSS = `
.aik-ap-card{width:min(100%,380px);display:grid;gap:10px;padding:14px;border-radius:16px;background:color-mix(in oklab,var(--aik-amber-fill) 10%,var(--aik-card));box-shadow:0 0 0 1px color-mix(in oklab,var(--aik-amber-fill) 55%,transparent);
transition:background var(--aik-d-panel) var(--aik-ease-out),box-shadow var(--aik-d-panel) var(--aik-ease-out)}
.aik-ap-card:not([data-s="ask"]){background:var(--aik-card);box-shadow:var(--aik-sh-card)}
.aik-ap-h{display:flex;align-items:center;gap:8px}
.aik-ap-lab{flex:1;font:500 11px/18px var(--aik-mono);letter-spacing:.06em;text-transform:uppercase;color:var(--aik-c);transition:color var(--aik-d-state)}
.aik-ap-who{display:inline-flex;align-items:center;gap:6px;font-size:12.5px;color:var(--aik-text-2)}
.aik-ap-who .aik-face{--aik-fs:18px}
.aik-ap-q{font-size:15px;line-height:22px;font-weight:500}
.aik-ap-card code{font:12.5px var(--aik-mono);padding:2px 5px;border-radius:5px;background:var(--aik-hover)}
.aik-ap-facts{display:grid;gap:6px}
.aik-ap-facts li{display:flex;align-items:center;gap:8px;font-size:13px;line-height:18px;color:var(--aik-text-2)}
.aik-ap-facts .ic{color:var(--aik-text-3)}
.aik-ap-foot{display:grid;align-items:center;margin-top:4px}
.aik-ap-foot > *{grid-area:1/1;transition:opacity var(--aik-d-state) var(--aik-ease-out),transform var(--aik-d-state) var(--aik-ease-out)}
.aik-ap-act{display:flex;flex-wrap:wrap;gap:6px;align-items:center}
.aik-ap-act .aik-kbd{margin-right:-3px;height:16px;min-inline-size:16px;font-size:10px}
.aik-ap-act .aik-btn.pri .aik-kbd{color:var(--aik-pri-ink);box-shadow:inset 0 0 0 1px color-mix(in oklab,var(--aik-pri-ink) 36%,transparent)}
.aik-ap-res{font-size:13px;line-height:19px;color:var(--aik-text-2);visibility:hidden;opacity:0;transform:translateY(4px)}
.aik-ap-card:not([data-s="ask"]) .aik-ap-act{visibility:hidden;opacity:0;transform:translateY(-4px)}
.aik-ap-card:not([data-s="ask"]) .aik-ap-res{visibility:visible;opacity:1;transform:none}
.aik-ap-hold{width:min(100%,380px);display:grid;gap:14px;padding:16px;border-radius:16px;background:var(--aik-card);box-shadow:var(--aik-sh-card)}
.aik-ap-hh{display:flex;gap:12px;align-items:flex-start}
.aik-ap-warn{inline-size:32px;block-size:32px;border-radius:10px;display:grid;place-items:center;flex:none;color:var(--aik-red);background:color-mix(in oklab,var(--aik-red) 12%,transparent)}
.aik-ap-hh div{display:grid;gap:2px;min-width:0}
.aik-ap-hh b{font-weight:600;font-size:14px;line-height:20px}
.aik-ap-hh span{font-size:13px;line-height:19px;color:var(--aik-text-2)}
.aik-ap-hbtn{position:relative;display:grid;place-items:center;width:100%;height:44px;border-radius:12px;overflow:hidden;font-weight:600;font-size:13.5px;color:var(--aik-red);background:color-mix(in oklab,var(--aik-red) 12%,transparent);
transition:transform var(--aik-d-press) var(--aik-ease-out),background var(--aik-d-panel) var(--aik-ease-out),color var(--aik-d-state)}
.aik-ap-fill{position:absolute;inset:0;background:color-mix(in oklab,var(--aik-red) 26%,transparent);transform:scaleX(0);transform-origin:0 50%;transition:transform var(--aik-d-state) var(--aik-ease-out)}
.aik-ap-hbtn .aik-roll{position:relative;line-height:20px}
.aik-ap-hold[data-s="hold"] .aik-ap-hbtn{transform:scale(.985)}
.aik-ap-hold[data-s="hold"] .aik-ap-fill{transform:none;transition:transform 1200ms linear}
.aik-ap-hold[data-s="done"] .aik-ap-hbtn{background:var(--aik-red);color:var(--aik-on-fill)}
.aik-ap-hold[data-s="done"] .aik-ap-fill{opacity:0}
.aik-ap-hint{display:grid;justify-items:center;font-size:12.5px;line-height:18px;color:var(--aik-text-3)}
@media (prefers-reduced-motion: reduce){.aik-ap-hold[data-s="hold"] .aik-ap-fill{transition:none;transform:scaleX(.6)}}
.aik-ap-ask{width:min(100%,380px);display:grid;gap:12px}
.aik-ap-qh{display:flex;gap:10px;align-items:flex-start}
.aik-ap-qh .aik-face{--aik-fs:32px}
.aik-ap-qh div{display:grid;gap:2px;min-width:0}
.aik-ap-qh b{font-weight:600;font-size:14.5px;line-height:21px;text-wrap:balance}
.aik-ap-opts{position:relative;display:grid;gap:4px;padding:4px;border-radius:16px;background:var(--aik-card);box-shadow:var(--aik-sh-card)}
.aik-ap-hl{position:absolute;left:4px;right:4px;top:4px;height:48px;border-radius:12px;background:var(--aik-raised);box-shadow:inset 0 0 0 1px transparent;transform:translateY(calc(var(--n,0)*52px));
transition:transform var(--aik-d-state) var(--aik-ease-move),background var(--aik-d-state),box-shadow var(--aik-d-state)}
.aik-ap-ask[data-picked] .aik-ap-hl{background:color-mix(in oklab,var(--aik-green) 12%,transparent);box-shadow:inset 0 0 0 1px color-mix(in oklab,var(--aik-green) 42%,transparent)}
.aik-ap-opt{position:relative;display:flex;align-items:center;gap:10px;height:48px;padding:0 12px 0 10px;border-radius:12px;text-align:left;transition:opacity var(--aik-d-state)}
.aik-ap-opt > span{flex:1;min-width:0;display:grid}
.aik-ap-opt b{font-weight:500;font-size:13.5px;line-height:18px}
.aik-ap-opt em{font-style:normal;font-size:12px;line-height:16px;color:var(--aik-text-2);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.aik-ap-ck{color:var(--aik-green);opacity:0;transform:scale(.5);transition:opacity var(--aik-d-state) var(--aik-ease-out),transform var(--aik-d-state) var(--aik-ease-out)}
.aik-ap-ask[data-picked] .aik-ap-opt[data-cur] .aik-ap-ck{opacity:1;transform:none}
.aik-ap-ask[data-picked] .aik-ap-opt:not([data-cur]){opacity:.38}
.aik-ap-qf{display:flex;align-items:center;justify-content:space-between;gap:8px;min-height:28px;padding:0 4px;font-size:12.5px;line-height:18px;color:var(--aik-text-3)}
.aik-ap-card:focus-visible,.aik-ap-opts:focus-visible{outline:2px solid var(--aik-blue);outline-offset:3px;border-radius:16px}
.aik-ap-card[data-s="fail"] .aik-ap-lab{color:var(--aik-red)}
.aik-ap-facts li > svg{color:var(--aik-text-3)}
.aik-ap-facts li > span{min-width:0}
.aik-ap-hbtn{touch-action:none;user-select:none;-webkit-user-select:none}
.aik-ap-hbtn:disabled{cursor:default}
.aik-ap-hold[data-s="hold"] .aik-ap-fill{transition:transform var(--aik-hold,1200ms) linear}
.aik-ap-opt{width:100%}
.aik-ap-opt:disabled{cursor:default}
.aik-ap-ck{flex:none}
.aik-ap-opts[data-none] .aik-ap-hl{opacity:0}
`
interface AgentTag {
name: string
/** Face colour: a named tone or any CSS colour. */
tone?: AiTone | (string & {})
shape?: AiShape
}
export interface AiApprovalFact {
/** A 16px icon. */
icon?: React.ReactNode
text: React.ReactNode
}
export interface AiApprovalProps extends Omit<
React.HTMLAttributes<HTMLDivElement>,
"title"
> {
/** `ask` is the amber card; the other two are the settled record. */
status: "ask" | "approved" | "denied"
/** What the agent wants to do, as a question. */
title: React.ReactNode
/** What it will change, one line each. */
facts?: AiApprovalFact[]
/** Who is asking. */
agent?: AgentTag
onApprove?: () => void
onDeny?: () => void
/** Shows an "Always allow" button when set. */
onAlways?: () => void
/** The line kept on the card once it is answered. */
resolution?: string
}
const APPROVAL_WORD = {
ask: "Needs you",
approved: "Approved",
denied: "Denied",
} as const
/** The one amber surface on screen: what will run, what it changes, approve or deny. Enter approves, Escape denies. */
export function AiApproval({
status,
title,
facts = [],
agent,
onApprove,
onDeny,
onAlways,
resolution,
className,
...rest
}: AiApprovalProps) {
const asking = status === "ask"
const mark = asking ? "ask" : status === "approved" ? "done" : "fail"
return (
<div
{...rest}
className={cx("aik aik-ap-card", className)}
data-s={mark}
role="group"
aria-label={APPROVAL_WORD[status]}
tabIndex={asking ? 0 : undefined}
onKeyDown={(event) => {
rest.onKeyDown?.(event)
if (!asking || event.defaultPrevented) return
const onButton = (event.target as HTMLElement).closest("button")
if (event.key === "Enter" && !onButton) {
event.preventDefault()
onApprove?.()
} else if (event.key === "Escape") {
event.preventDefault()
onDeny?.()
}
}}
>
<AiKitStyles />
<AiStyle id="ai-approval" css={CSS} />
<div className="aik-ap-h">
<Mark status={mark} />
<Roll className="aik-ap-lab">{APPROVAL_WORD[status]}</Roll>
{agent ? (
<span className="aik-ap-who">
<Face
size={18}
shape={agent.shape ?? "orb"}
tone={agent.tone ?? "blue"}
mood={asking ? "needs" : status === "approved" ? "work" : "idle"}
/>
{agent.name}
</span>
) : null}
</div>
<p className="aik-ap-q">{title}</p>
{facts.length > 0 ? (
<ul className="aik-ap-facts">
{facts.map((fact, index) => (
<li key={index}>
{fact.icon}
<span>{fact.text}</span>
</li>
))}
</ul>
) : null}
<div className="aik-ap-foot">
<div className="aik-ap-act" aria-hidden={!asking}>
<button
type="button"
className="aik-btn sm pri"
disabled={!asking}
onClick={onApprove}
>
Approve<kbd className="aik-kbd">⏎</kbd>
</button>
<button
type="button"
className="aik-btn sm line"
disabled={!asking}
onClick={onDeny}
>
Deny<kbd className="aik-kbd">esc</kbd>
</button>
{onAlways ? (
<button
type="button"
className="aik-btn sm ghost"
disabled={!asking}
onClick={onAlways}
>
Always allow
</button>
) : null}
</div>
<div className="aik-ap-res" role="status">
<span>
{asking
? ""
: (resolution ??
(status === "approved"
? "Approved by you."
: "Denied by you."))}
</span>
</div>
</div>
</div>
)
}
export interface AiHoldConfirmProps extends Omit<
React.HTMLAttributes<HTMLDivElement>,
"title"
> {
/** The action, in a few words. */
title: string
/** What it costs and what it leaves alone. */
description?: string
/** Button text before the hold. */
label?: string
/** Button text once confirmed. */
doneLabel?: string
/** How long the press must last, in milliseconds. */
holdMs?: number
/** Fires once, when the fill completes. */
onConfirm?: () => void
/** Controls the confirmed state. Omit to let the button keep it. */
confirmed?: boolean
/** Forces the held look. For scripted demos; leave undefined in real use. */
holding?: boolean
/** The line under the button once confirmed. */
doneHint?: string
}
/** For actions you cannot take back. The button fills while held and drains the moment you let go. */
export function AiHoldConfirm({
title,
description,
label = "Hold to confirm",
doneLabel = "Confirmed",
holdMs = 1200,
onConfirm,
confirmed,
holding,
doneHint = "Done.",
className,
...rest
}: AiHoldConfirmProps) {
const [pressed, setPressed] = React.useState(false)
const [ownDone, setOwnDone] = React.useState(false)
const [released, setReleased] = React.useState(false)
const timer = React.useRef<number | undefined>(undefined)
const done = confirmed ?? ownDone
const held = !done && (holding ?? pressed)
const seconds = Math.round(holdMs / 100) / 10
React.useEffect(() => () => window.clearTimeout(timer.current), [])
const start = () => {
if (done || pressed) return
setPressed(true)
setReleased(false)
timer.current = window.setTimeout(() => {
setPressed(false)
if (confirmed === undefined) setOwnDone(true)
onConfirm?.()
}, holdMs)
}
const cancel = () => {
if (!pressed) return
window.clearTimeout(timer.current)
setPressed(false)
setReleased(true)
}
const hint = done
? doneHint
: held
? "Keep holding. Release to cancel."
: released
? "Released early. Nothing happened."
: `Press and hold for ${seconds === 1 ? "one second" : `${seconds} seconds`}`
return (
<div
{...rest}
className={cx("aik aik-ap-hold", className)}
data-s={done ? "done" : held ? "hold" : "idle"}
style={
{ "--aik-hold": `${holdMs}ms`, ...rest.style } as React.CSSProperties
}
>
<AiKitStyles />
<AiStyle id="ai-approval" css={CSS} />
<div className="aik-ap-hh">
<span className="aik-ap-warn">
<TriangleAlert size={16} />
</span>
<div>
<b>{title}</b>
{description ? <span>{description}</span> : null}
</div>
</div>
<button
type="button"
className="aik-ap-hbtn"
disabled={done}
onPointerDown={(event) => {
if (event.button !== 0) return
event.currentTarget.setPointerCapture(event.pointerId)
start()
}}
onPointerUp={cancel}
onPointerCancel={cancel}
onKeyDown={(event) => {
if ((event.key === " " || event.key === "Enter") && !event.repeat) {
event.preventDefault()
start()
}
}}
onKeyUp={(event) => {
if (event.key === " " || event.key === "Enter") cancel()
}}
onBlur={cancel}
onContextMenu={(event) => event.preventDefault()}
>
<i className="aik-ap-fill" />
<Roll>{done ? doneLabel : label}</Roll>
</button>
<div className="aik-ap-hint" role="status">
<Roll>{hint}</Roll>
</div>
</div>
)
}
export interface AiQuestionOption {
id: string
label: string
/** A quiet second line. */
description?: string
}
export interface AiQuestionProps extends Omit<
React.HTMLAttributes<HTMLDivElement>,
"onChange"
> {
/** What the agent is asking. */
question: string
/** Up to nine options. Number keys pick them. */
options: AiQuestionOption[]
/** The chosen option's id, or null while it is open. */
value: string | null
/** Called with the chosen option's id. */
onValueChange?: (id: string) => void
/** Shows a Skip button when set. */
onSkip?: () => void
/** Who is asking. */
agent?: AgentTag
/** Highlighted row. Omit to let hover and the arrow keys manage it. */
highlight?: number
/** The line under the options. Defaults to a waiting or answered note. */
note?: string
}
/** When the agent needs a choice, not permission. Arrow keys move the highlight; number keys or Enter pick. */
export function AiQuestion({
question,
options,
value,
onValueChange,
onSkip,
agent,
highlight,
note,
className,
...rest
}: AiQuestionProps) {
const [own, setOwn] = React.useState(0)
const pickedIndex = options.findIndex((option) => option.id === value)
const picked = pickedIndex >= 0
const last = Math.max(options.length - 1, 0)
const row = picked ? pickedIndex : Math.min(highlight ?? own, last)
const who = agent?.name ?? "The agent"
const choose = (index: number) => {
const option = options[index]
if (option && !picked) onValueChange?.(option.id)
}
return (
<div
{...rest}
className={cx("aik aik-ap-ask", className)}
data-picked={picked ? "" : undefined}
>
<AiKitStyles />
<AiStyle id="ai-approval" css={CSS} />
<div className="aik-ap-qh">
{agent ? (
<Face
size={32}
shape={agent.shape ?? "arch"}
tone={agent.tone ?? "amber"}
mood={picked ? "happy" : "needs"}
/>
) : null}
<div>
<span className="aik-label">{who} asks</span>
<b>{question}</b>
</div>
</div>
<div
className="aik-ap-opts"
role="radiogroup"
aria-label={question}
data-none={options.length === 0 ? "" : undefined}
tabIndex={picked ? undefined : 0}
onKeyDown={(event) => {
if (picked) return
if (event.key === "ArrowDown") {
event.preventDefault()
setOwn(row >= last ? 0 : row + 1)
} else if (event.key === "ArrowUp") {
event.preventDefault()
setOwn(row <= 0 ? last : row - 1)
} else if (event.key === "Enter" || event.key === " ") {
event.preventDefault()
choose(row)
} else if (/^[1-9]$/.test(event.key)) {
event.preventDefault()
choose(Number(event.key) - 1)
}
}}
>
<i
className="aik-ap-hl"
style={{ "--n": row } as React.CSSProperties}
/>
{options.map((option, index) => (
<button
key={option.id}
type="button"
role="radio"
aria-checked={picked && index === pickedIndex}
tabIndex={-1}
disabled={picked}
className="aik-ap-opt"
data-cur={index === row ? "" : undefined}
onMouseEnter={() => setOwn(index)}
onClick={() => choose(index)}
>
<kbd className="aik-kbd">{index + 1}</kbd>
<span>
<b>{option.label}</b>
{option.description ? <em>{option.description}</em> : null}
</span>
<Check size={16} className="aik-ap-ck" />
</button>
))}
</div>
<div className="aik-ap-qf">
<Roll>
{note ??
(picked
? `${who} is continuing with ${options[pickedIndex]?.label ?? "your choice"}`
: `${who} is waiting for you`)}
</Roll>
{onSkip && !picked ? (
<button type="button" className="aik-btn sm ghost" onClick={onSkip}>
Skip
</button>
) : null}
</div>
</div>
)
}
Installation
One command adds ai-approval and the shared AI Kit layer it is built on (tokens, faces, marks and brand icons). No animation library, light and dark built in.
$npx shadcn@latest add https://tweenui.dev/r/ai-approval.json
ai-approval-demo
"use client"
import * as React from "react"
import { Clock, FileDiff } from "lucide-react"
import { AiDemo } from "@/lib/ai-demo"
import { useAiLoop } from "@/lib/ai-kit"
import {
AiApproval,
AiHoldConfirm,
AiQuestion,
} from "@/registry/tween/ai-approval"
function Card() {
const root = React.useRef<HTMLDivElement>(null)
const [status, setStatus] = React.useState<"ask" | "approved" | "denied">(
"ask"
)
const [hands, setHands] = React.useState(false)
useAiLoop(
root,
async ({ sleep }) => {
setStatus("ask")
await sleep(2800)
setStatus("approved")
await sleep(2400)
},
{ gap: 400, enabled: !hands }
)
const answer = (next: "approved" | "denied") => {
setHands(true)
setStatus(next)
}
return (
<div
ref={root}
style={{ display: "grid", gap: 10, width: "min(100%, 380px)" }}
>
<AiApproval
status={status}
agent={{ name: "Mira" }}
title={
<>
Run <code>pnpm build:registry</code>?
</>
}
facts={[
{
icon: <FileDiff size={16} />,
text: (
<>
Rewrites 104 files in <code>public/r</code>
</>
),
},
{ icon: <Clock size={16} />, text: "Takes about 40 seconds" },
]}
resolution={
status === "approved"
? "Approved by you. Building now."
: "Denied by you. Nothing ran."
}
onApprove={() => answer("approved")}
onDeny={() => answer("denied")}
onAlways={() => answer("approved")}
/>
{hands && status !== "ask" ? (
<button
type="button"
className="aik-btn sm ghost"
style={{ justifySelf: "start" }}
onClick={() => setStatus("ask")}
>
Ask again
</button>
) : null}
</div>
)
}
function Hold() {
const root = React.useRef<HTMLDivElement>(null)
const [holding, setHolding] = React.useState(false)
const [confirmed, setConfirmed] = React.useState(false)
const [hands, setHands] = React.useState(false)
const [round, setRound] = React.useState(0)
useAiLoop(
root,
async ({ sleep }) => {
setConfirmed(false)
setHolding(false)
await sleep(1100)
setHolding(true)
await sleep(450)
setHolding(false)
await sleep(1500)
setHolding(true)
await sleep(1250)
setHolding(false)
setConfirmed(true)
await sleep(2200)
},
{ gap: 400, enabled: !hands }
)
return (
<div
ref={root}
style={{ display: "grid", gap: 10, width: "min(100%, 380px)" }}
onPointerDown={() => {
if (hands) return
setHands(true)
setRound((value) => value + 1)
}}
onKeyDown={() => setHands(true)}
>
<AiHoldConfirm
key={round}
title="Delete 3 preview deployments"
description="This cannot be undone. Production is not affected."
label="Hold to delete"
doneLabel="Deleted"
doneHint="3 preview deployments deleted"
holding={hands ? undefined : holding}
confirmed={hands ? undefined : confirmed}
/>
{hands ? (
<button
type="button"
className="aik-btn sm ghost"
style={{ justifySelf: "start" }}
onClick={() => setRound((value) => value + 1)}
>
Reset
</button>
) : null}
</div>
)
}
const OPTIONS = [
{ id: "out", label: "Out", description: "Fast start, soft landing" },
{
id: "move",
label: "Move",
description: "In and out, for a thumb changing place",
},
{
id: "linear",
label: "Linear",
description: "Constant speed, for progress only",
},
]
function Question() {
const root = React.useRef<HTMLDivElement>(null)
const [row, setRow] = React.useState(0)
const [value, setValue] = React.useState<string | null>(null)
const [hands, setHands] = React.useState(false)
useAiLoop(
root,
async ({ sleep }) => {
setValue(null)
setRow(0)
await sleep(1200)
for (const next of [1, 2, 1]) {
setRow(next)
await sleep(620)
}
await sleep(300)
setValue("move")
await sleep(2400)
},
{ gap: 400, enabled: !hands }
)
return (
<div
ref={root}
style={{ display: "grid", width: "min(100%, 380px)" }}
onPointerDown={() => {
if (hands) return
setHands(true)
setValue(null)
}}
onKeyDown={() => setHands(true)}
>
<AiQuestion
agent={{ name: "Juno", tone: "amber", shape: "arch" }}
question="Which easing should the pricing toggle use?"
options={OPTIONS}
value={value}
highlight={hands ? undefined : row}
onValueChange={setValue}
onSkip={() => setValue(null)}
/>
{hands && value ? (
<button
type="button"
className="aik-btn sm ghost"
style={{ justifySelf: "start", marginTop: 6 }}
onClick={() => setValue(null)}
>
Ask again
</button>
) : null}
</div>
)
}
export function AiApprovalDemo({ only }: { only?: string }) {
return (
<AiDemo
only={only}
tabs={[
{ name: "Card", node: <Card /> },
{ name: "Hold to confirm", node: <Hold /> },
{ name: "Question", node: <Question /> },
]}
/>
)
}
Installation
Usage
import {
AiApproval,
AiHoldConfirm,
AiQuestion,
} from "@/components/ui/ai-approval"const [status, setStatus] = useState<"ask" | "approved" | "denied">("ask")
<AiApproval
status={status}
agent={{ name: "Mira" }}
title={<>Run <code>pnpm build:registry</code>?</>}
facts={[{ text: "Rewrites 104 files in public/r" }]}
onApprove={() => setStatus("approved")}
onDeny={() => setStatus("denied")}
/>
<AiHoldConfirm
title="Delete 3 preview deployments"
description="This cannot be undone."
label="Hold to delete"
onConfirm={deletePreviews}
/>
<AiQuestion
question="Which easing should the pricing toggle use?"
options={[{ id: "out", label: "Out" }, { id: "move", label: "Move" }]}
value={choice}
onValueChange={setChoice}
/>With the AI SDK, show AiApproval for a tool part in the approval-requested state and answer it from onApprove and onDeny.
Versions
AiApprovalis the one amber surface on screen. It says what will run and what it changes. With the card focused, Enter approves and Escape denies. Once answered it settles into a neutral card that keeps the decision on record.AiHoldConfirmis for actions you cannot take back. The button fills while the pointer, Space or Enter is held and drains the moment you let go.onConfirmfires only when the fill completes.AiQuestionis for a choice, not permission. Arrow keys move the highlight, number keys or Enter pick, and the other options fade back.
Props
AiApproval
| Prop | Type | Default | Description |
|---|---|---|---|
status | "ask" | "approved" | "denied" | ask is the amber card. | |
title | ReactNode | What the agent wants to do. | |
facts | { icon?, text }[] | [] | What it will change, one line each. |
agent | { name, tone?, shape? } | Who is asking. | |
onApprove | () => void | Approve button and Enter. | |
onDeny | () => void | Deny button and Escape. | |
onAlways | () => void | Shows "Always allow" when set. | |
resolution | string | The line kept on the card once answered. |
AiHoldConfirm
| Prop | Type | Default | Description |
|---|---|---|---|
title | string | The action. | |
description | string | What it costs. | |
label | string | "Hold to confirm" | Button text before the hold. |
doneLabel | string | "Confirmed" | Button text once confirmed. |
holdMs | number | 1200 | How long the press must last. |
onConfirm | () => void | Fires once, when the fill completes. | |
confirmed | boolean | Controls the confirmed state. | |
doneHint | string | "Done." | The line under the button once confirmed. |
AiQuestion
| Prop | Type | Default | Description |
|---|---|---|---|
question | string | What the agent is asking. | |
options | { id, label, description? }[] | Up to nine options. | |
value | string | null | The chosen id, or null while open. | |
onValueChange | (id: string) => void | Called with the chosen id. | |
onSkip | () => void | Shows a Skip button when set. | |
agent | { name, tone?, shape? } | Who is asking. | |
highlight | number | Controls the highlighted row. |