# 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.

- Category: AI & Agents · Published: 2026-09-18 · Updated: 2026-11-22 · Reading time: 10 min read
- Canonical URL: https://hazeui.com/guides/designing-ai-agent-interfaces-tool-approvals-traces-diffs
- Tags: agent-ui, ai-ux, hitl, diff-review, accessibility

## Executive Summary

Production AI agent interfaces require structured human-in-the-loop controls rather than endless chat streams. Haze UI includes 55 AI and agent blocks—covering inline tool approvals with press-and-hold destructive guards, multi-file diff review, execution traces, context window meters, and cited answers—built with accessible keyboard controls and live status announcements.

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](/blocks/ai-tool-approval) |
| **Destructive write / SQL / deploy** | Press-and-hold confirmation (`Space`/`Enter` or pointer hold) | [AI Tool Approval](/blocks/ai-tool-approval) |
| **Multi-agent background backlog** | Batched approval queue with scope & requester badges | [Agent Approvals](/blocks/agent-approvals) |
| **Completed command execution** | Collapsible trace fold preserving command stdout | [AI Tool Calls](/blocks/ai-tool-calls) |

Two accessibility details in [AI Tool Approval](/blocks/ai-tool-approval) are easy to miss when building press-and-hold guards from scratch:

1. **Keyboard hold and Escape cancellation.** Holding `Space` or `Enter` fills the confirmation bar alongside mouse/touch press, and pressing `Escape` cancels before completion.
2. **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 a `role="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](/blocks/ai-diff-review):

- **Header line summary:** Displays total `+14 −6` counts across touched files with `tabular-nums`.
- **Per-file `Accept` / `Reject` / `Undo`:** Decided rows collapse into compact status bars automatically so attention stays focused on remaining unreviewed files—while `Undo` restores any file in one click.
- **Color + symbol pairing:** Added and removed lines pair `bg-success/8` / `bg-destructive/8` with 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](/ui/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](/ui/trace) & [Agent Run](/blocks/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](/blocks/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](/blocks/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 `--warning` and `--destructive` paired 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](/blocks/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:

```bash
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](/browse?kind=block&cat=ai) and [Agents](/browse?kind=block&cat=agents) catalog groups, or pair your workspace UI with our companion guide on [llms.txt, Markdown twins, and shadcn MCP](/guides/llms-txt-markdown-twins-shadcn-mcp-for-coding-agents).

## Mentioned Haze UI Entries

- [AI chat](https://hazeui.com/blocks/ai-chat.md): Conversational AI workspace with thread switcher, collapsible reasoning, tool chips, source cards, feedback actions and stop control.
- [AI tool approval](https://hazeui.com/blocks/ai-tool-approval.md): Inline chat tool approval card with standard Allow/Deny controls, session trust toggle, press-and-hold destructive guard and trace fold.
- [AI tool calls](https://hazeui.com/blocks/ai-tool-calls.md): Sequential chat tool-call trace with live per-step timers that collapses into a summary row above the final recommendation.
- [AI diff review](https://hazeui.com/blocks/ai-diff-review.md): Multi-file coding agent diff review with live line stats, Accept/Reject/Undo controls, collapsible decided rows and stream replay.
- [AI context meter](https://hazeui.com/blocks/ai-context-meter.md): Floating context breakdown popover above a model pill with stacked token bar, 80% compaction mark, SVG ring and Compact now action.
- [AI inline citations](https://hazeui.com/blocks/ai-citations.md): Borderless grounded AI prose with inline domain pills that highlight sentences, open a source preview card and toggle all sources.
- [Agent run](https://hazeui.com/blocks/agent-run.md): Single coding-agent run card with expandable step log, two-file diff approval gate and collapsible completed PR summary.
- [Trace](https://hazeui.com/ui/trace.md): An AI agent's steps as a list: an icon per kind, a title, status text, duration and expandable tool input and output.

## Frequently Asked Questions

### 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.
