Agent approvals
Human-in-the-loop approval queue for pending agent tool calls with priority badges, JSON arguments and Deny/Always allow/Approve controls.
pnpm dlx shadcn@latest add @haze/agent-approvals---
import { Check, ShieldCheck, ShieldQuestion, Terminal, X } from "@lucide/astro";
import { cn } from "../../../lib/haze/utils";
interface ApprovalItem {
id: string;
agent: string;
priority: "High" | "Standard";
tool: string;
rationale: string;
args: string;
}
interface Props {
id?: string;
heading?: string;
queue?: ApprovalItem[];
class?: string;
}
const {
id = "haze-agent-approvals",
heading = "Pending tool approvals",
queue = [
{
id: "ap1",
agent: "Release bot",
priority: "High",
tool: "stripe.refunds.create",
rationale: "Issue duplicate-charge refund of $149.00 requested in ticket 8812.",
args: '{ "charge": "ch_3Q9aK1", "amount": 14900, "reason": "duplicate" }',
},
{
id: "ap2",
agent: "Repo maintainer",
priority: "Standard",
tool: "github.merge_pull_request",
rationale: "All 6 CI checks passed on PR 492 (token contrast audit).",
args: '{ "repo": "haze/ui", "pull_number": 492, "merge_method": "squash" }',
},
],
class: className,
} = Astro.props;
---
<section aria-labelledby={`${id}-title`} data-haze-agent-approvals class={cn("bg-background px-4 py-10 sm:px-6 sm:py-14", className)}>
<div class="mx-auto max-w-3xl rounded-2xl border border-border bg-card p-5 sm:p-6">
<header class="flex flex-wrap items-center justify-between gap-2 border-b border-border pb-4">
<div class="flex items-center gap-2">
<ShieldQuestion class="size-4 text-muted-foreground" aria-hidden="true" />
<h2 id={`${id}-title`} class="text-base/6 font-semibold tracking-tight text-foreground">{heading}</h2>
</div>
<span data-ap-count class="rounded-full border border-frame-warning bg-warning/10 px-2.5 py-0.5 text-xs font-medium text-warning tabular-nums">{queue.length} pending</span>
</header>
<ul role="list" data-ap-list class="mt-4 space-y-3">
{
queue.map((item) => (
<li data-ap-card class="rounded-xl border border-border bg-muted/40 p-4">
<div class="flex flex-wrap items-center justify-between gap-2">
<div class="flex flex-wrap items-center gap-2">
<span class="text-xs font-semibold text-foreground">{item.agent}</span>
<span class={cn(
"rounded-md border px-2 py-0.5 text-[0.6875rem]/4 font-medium",
item.priority === "High" ? "border-frame-destructive bg-destructive/10 text-destructive" : "border-frame bg-card text-muted-foreground",
)}>{item.priority} priority</span>
</div>
<span class="inline-flex items-center gap-1.5 rounded-md border border-frame bg-muted px-2 py-0.5 font-mono text-[0.6875rem] text-foreground">
<Terminal class="size-3" aria-hidden="true" />
{item.tool}
</span>
</div>
<p class="mt-2 text-sm/6 text-pretty text-foreground">{item.rationale}</p>
<pre class="mt-2.5 overflow-x-auto rounded-lg border border-border bg-card px-3 py-2 font-mono text-xs/5 text-muted-foreground">{item.args}</pre>
<div class="mt-3 flex flex-wrap items-center justify-end gap-2">
<button type="button" data-ap-act="Denied" data-ap-tool={item.tool} class="inline-flex h-8 cursor-pointer items-center gap-1 rounded-lg border border-frame bg-field px-3 text-xs font-medium text-muted-foreground hover:border-destructive-border hover:text-destructive focus-visible:outline-2 focus-visible:outline-ring transition-[background-color,border-color,color,opacity,scale] duration-150 ease-snappy active:scale-[0.97] active:duration-75">
<X class="size-3.5" aria-hidden="true" />
Deny
</button>
<button type="button" data-ap-act="Always allowed" data-ap-tool={item.tool} class="inline-flex h-8 cursor-pointer items-center gap-1.5 rounded-lg border border-frame bg-field px-3 text-xs font-medium text-foreground hover:border-frame-strong hover:bg-accent focus-visible:outline-2 focus-visible:outline-ring transition-[background-color,border-color,color,opacity,scale] duration-150 ease-snappy active:scale-[0.97] active:duration-75">
<ShieldCheck class="size-3.5 text-muted-foreground" aria-hidden="true" />
Always allow
</button>
<button type="button" data-ap-act="Approved" data-ap-tool={item.tool} class="inline-flex h-8 cursor-pointer items-center gap-1.5 rounded-lg bg-primary px-3.5 text-xs font-medium text-primary-foreground hover:opacity-90 focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-ring transition-[background-color,border-color,color,opacity,scale] duration-150 ease-snappy active:scale-[0.97] active:duration-75">
<Check class="size-3.5" aria-hidden="true" />
Approve
</button>
</div>
</li>
))
}
</ul>
<p data-ap-empty hidden class="mt-4 rounded-xl border border-dashed border-border py-8 text-center text-xs text-muted-foreground">All queued tool calls have been reviewed.</p>
<p data-ap-status role="status" class="mt-3 min-h-4 text-xs/4 text-muted-foreground"></p>
</div>
</section>
<script>
function initApprovals() {
document.querySelectorAll<HTMLElement>("[data-haze-agent-approvals]").forEach((root) => {
if (root.hasAttribute("data-enhanced")) return;
root.setAttribute("data-enhanced", "");
const count = root.querySelector<HTMLElement>("[data-ap-count]");
const empty = root.querySelector<HTMLElement>("[data-ap-empty]");
const status = root.querySelector<HTMLElement>("[data-ap-status]");
root.querySelector<HTMLElement>("[data-ap-list]")?.addEventListener("click", (ev) => {
const btn = (ev.target as HTMLElement | null)?.closest<HTMLButtonElement>("[data-ap-act]");
if (!btn) return;
const action = btn.dataset.apAct ?? "Reviewed";
const tool = btn.dataset.apTool ?? "tool";
btn.closest("[data-ap-card]")?.remove();
const left = root.querySelectorAll("[data-ap-card]").length;
if (count) count.textContent = `${left} pending`;
if (empty) empty.hidden = left > 0;
if (status) status.textContent = `${action} ${tool}.`;
});
});
}
initApprovals();
document.addEventListener("astro:page-load", initApprovals);
</script>When to use
- Reviewing high-impact agent tool calls (refunds, merges, deploys) before execution
- Offering Deny, Always allow and one-time Approve actions in a structured queue
When not to use
- Showing a single inline code diff inside one coding run; use agent-run
Installation
Add the Haze registry to components.json once, then install Agent approvals with the shadcn CLI. Works in any Astro project with Tailwind CSS v4.
pnpm dlx shadcn@latest add @haze/agent-approvalsnpx shadcn@latest add @haze/agent-approvalsyarn dlx shadcn@latest add @haze/agent-approvalsbunx --bun shadcn@latest add @haze/agent-approvalsFirst time? Registry and theme setup
1. Add to components.json:
{
"registries": {
"@haze": "http://localhost:4329/r/{name}.json"
}
}2. Install the theme once: npx shadcn@latest add @haze/theme, then import it after Tailwind in your global CSS:@import "./haze.css";
API reference
| Prop | Type | Default | Description |
|---|---|---|---|
| id | string | "haze-agent-approvals" | Unique prefix for section heading IDs. |
| heading | string | "Pending tool approvals" | Queue heading. |
| queue | ApprovalItem[] | 2 pending tool calls | Queued tool requests with agent, priority, rationale and JSON args. |
| class | string | – | Extra classes on the outer section. |
Keyboard interactions
- Tab
- Move across Deny, Always allow and Approve buttons for each pending request
- EnterSpace
- Deny, always allow or approve the focused tool call
Accessibility
- Tool arguments render inside a horizontally scrollable pre block so long payloads never break mobile layouts.
- Reviewing an item updates the pending counter, reveals an empty state when clear and announces the decision via role="status".
Notes for AI
Copy into Claude Code, Cursor, Codex or any coding agent. Agents can also read the Markdown version of this page.
Install and use
Install the Haze UI block "Agent approvals" with `npx shadcn@latest add @haze/agent-approvals`. If components.json has no "@haze" registry yet, add "registries": { "@haze": "http://localhost:4329/r/{name}.json" }. If src/styles/haze.css does not exist yet, run `npx shadcn@latest add @haze/theme` once and import it from the global stylesheet after Tailwind. The CLI stops at an overwrite question when a Haze file already exists and differs, even with --yes, and then installs nothing after it: read its output. If the user has not edited their Haze files, re-run with --overwrite to take the registry versions; if they have, ask them before overwriting. Then import AgentApprovals from "@/components/haze/blocks/agent-approvals.astro" (or the relative path) and render it where it fits the page. Keep Haze token classes (bg-background, text-muted-foreground, border-border...) and never hardcode colors. Docs: http://localhost:4329/blocks/agent-approvals.md
Customize with real content
Adapt the Haze agent-approvals block for our product. Replace the demo values of these props with our real content: id, heading, queue, class. Keep the layout, the heading level rules and these accessibility details: Tool arguments render inside a horizontally scrollable pre block so long payloads never break mobile layouts. Reviewing an item updates the pending counter, reveals an empty state when clear and announces the decision via role="status". Do not add raw color classes; use the Haze tokens.
Choose the right block
Before using agent-approvals, check it fits: use it when reviewing high-impact agent tool calls (refunds, merges, deploys) before execution; offering deny, always allow and one-time approve actions in a structured queue. Avoid it when showing a single inline code diff inside one coding run; use agent-run. Alternatives: @haze/agent-run, @haze/alert-dialog.
Dependencies
- npm: @lucide/astro
- @haze/utils
- @haze/theme (one-time setup)
Source · Original Haze UI work.