Designing AI Agent UIs Beyond Chat Bubbles: Tool Approvals, Traces, Context Meters, and Diff Review
Interface patterns for real agentic workflows—moving past raw chat streams to tool approvals, diffs, traces, and token budgets.
A scrolling markdown textarea with a blinking cursor worked when LLM products only answered quick questions. The moment an AI assistant can run shell commands, query production databases, edit four TypeScript files, or burn through a 200k-token context window, plain chat bubbles break down completely.
Users need to audit what the model did, interrupt dangerous actions before they fire, and inspect code diffs cleanly—without drowning in unformatted JSON dumps.
After designing 39 AI blocks and 16 Agent orchestration blocks in Haze UI, four interface patterns consistently separate calm, trustworthy agent tools from noisy chat demos.
1. Tiered Human-in-the-Loop Tool Approvals
Treating git status and DROP TABLE sessions; with the exact same “Approve” button trains users into clicking Allow automatically within ten minutes. Effective agent UIs match confirmation friction to blast radius:
| Operation risk | Recommended control pattern | Haze UI block |
|---|---|---|
| Routine read / test command | Single-click Allow / Deny + optional session trust toggle |
AI Tool Approval |
| Destructive write / SQL / deploy | Press-and-hold confirmation (Space/Enter or pointer hold) |
AI Tool Approval |
| Multi-agent background backlog | Batched approval queue with scope & requester badges | Agent Approvals |
| Completed command execution | Collapsible trace fold preserving command stdout | AI Tool Calls |
Two accessibility details in AI Tool Approval are easy to miss when building press-and-hold guards from scratch:
- Keyboard hold and Escape cancellation. Holding
SpaceorEnterfills the confirmation bar alongside mouse/touch press, and pressingEscapecancels before completion. - Reduced motion fallback. Under
prefers-reduced-motion: reduce, holding triggers immediately or uses an explicit confirm toggle rather than forcing users with motor or vestibular sensitivity to track a sweep animation, while arole="status"region announces the decision clearly.
2. Multi-File Diff Review with Per-File Undo
When a coding agent edits three files at once, dumping raw unified diffs into the chat stream forces the engineer to scroll back across fifty chat messages to verify what changed.
Look at the anatomy of AI Diff Review:
- Header line summary: Displays total
+14 −6counts across touched files withtabular-nums. - Per-file
Accept/Reject/Undo: Decided rows collapse into compact status bars automatically so attention stays focused on remaining unreviewed files—whileUndorestores any file in one click. - Color + symbol pairing: Added and removed lines pair
bg-success/8/bg-destructive/8with literal+and-prefixes inside horizontally scrollable code hunks, preserving accessibility for color-blind engineers.
For read-only comparisons outside agent review loops, swap in Diff Viewer.
3. Execution Traces and Live Citations
Users lose trust in agent answers when either nothing updates for fifteen seconds or fifty verbose tool payloads flood the viewport.
Two lightweight structures solve both extremes:
- Foldable step traces (Trace & Agent Run): Group each tool step (search, file read, test run) into a compact bordered row showing duration in
tabular-nums, status dot + label, and an expandable<details>disclosure for raw arguments and output. - Grounded inline citations (AI Citations): Attach numbered source badges that open a clean popover or source tray with domain title, excerpt, and direct link rather than hiding URLs inside footnotes.
4. Surfacing Context Window Budgets Before Truncation Hits
Long agent sessions degrade quietly when system prompts, attached files, and large tool outputs silently push early instructions out of the context window.
AI Context Meter sits discreetly inside the composer footer as a compact model pill paired with a circular SVG ring (aria-expanded, aria-controls):
- Clicking opens a breakdown popover segmenting System instructions, Conversation turns, Attached files, and Tool outputs.
- Crossing the 80% compaction marker transitions the status ring from neutral/brand into
--warningand--destructivepaired with exact percentage text (tabular-nums). - An explicit Compact now action lets users reclaim tokens intentionally before starting the next complex turn, announcing exact reclaimed token counts through
role="status".
And when connecting external tools via Model Context Protocol, MCP Servers applies the exact same budget visibility to connected tool schemas (budgetTokens, per-server Connect/Pause, and per-tool checkboxes).
Assembling an Agent Workspace in Astro
Install the core primitives together and connect their state containers to your streaming backend or Cloudflare Workers endpoint:
npx shadcn@latest add @haze/ai-chat @haze/ai-tool-approval @haze/ai-diff-review @haze/ai-context-meter @haze/mcp-servers
Browse all 55 entries across the AI and Agents catalog groups, or pair your workspace UI with our companion guide on llms.txt, Markdown twins, and shadcn MCP.
Frequently asked questions
How should an agent interface protect users against destructive tool calls?
Differentiate routine read or test commands from destructive operations like SQL DROP TABLE or file deletion. In Haze UI's ai-tool-approval block, routine calls allow single-click Allow/Deny while destructive calls require a press-and-hold confirmation supporting pointer press, holding Space/Enter, Escape cancellation, and instant fallback under reduced motion.
What is the best way to present coding agent file edits to engineers?
Group changes by file path inside a diff-review surface with live +additions / -deletions line counts, explicit + and - symbols alongside semantic success/destructive colors, independent Accept/Reject/Undo controls per file, and collapsible completed rows.
Why show an interactive context window meter inside an AI composer?
Users cannot tell when silent prompt truncation is about to degrade model accuracy. Surfacing a circular meter with breakdown buckets (system instructions, conversation turns, attached files, tool outputs) and a Compact now action prevents silent context overflow.
Are Haze UI's AI and agent blocks tied to any specific LLM SDK?
No. Every AI and agent block installs as plain .astro HTML/CSS with minimal progressive TypeScript, making it straightforward to connect to Vercel AI SDK, OpenAI, Anthropic, Cloudflare Workers, or custom streaming endpoints.
Components & blocks mentioned
Browse all entries- AI chatBlock
Conversational AI workspace with thread switcher, collapsible reasoning, tool chips, source cards, feedback actions and stop control.
npx shadcn@latest add @haze/ai-chat - AI tool approvalBlock
Inline chat tool approval card with standard Allow/Deny controls, session trust toggle, press-and-hold destructive guard and trace fold.
npx shadcn@latest add @haze/ai-tool-approval - AI tool callsBlock
Sequential chat tool-call trace with live per-step timers that collapses into a summary row above the final recommendation.
npx shadcn@latest add @haze/ai-tool-calls - AI diff reviewBlock
Multi-file coding agent diff review with live line stats, Accept/Reject/Undo controls, collapsible decided rows and stream replay.
npx shadcn@latest add @haze/ai-diff-review - AI context meterBlock
Floating context breakdown popover above a model pill with stacked token bar, 80% compaction mark, SVG ring and Compact now action.
npx shadcn@latest add @haze/ai-context-meter - AI inline citationsBlock
Borderless grounded AI prose with inline domain pills that highlight sentences, open a source preview card and toggle all sources.
npx shadcn@latest add @haze/ai-citations - Agent runBlock
Single coding-agent run card with expandable step log, two-file diff approval gate and collapsible completed PR summary.
npx shadcn@latest add @haze/agent-run - TraceUI
An AI agent's steps as a list: an icon per kind, a title, status text, duration and expandable tool input and output.
npx shadcn@latest add @haze/trace
Continue reading
AI & Agents
Making Your Component Library Readable by AI Coding Agents: llms.txt, Markdown Twins, and shadcn MCP
10 min read
10 min read
9 min read