Thinking UI

Agent RunPRO

An agent working a task: plan, live feed of reasoning, tools, approvals and diffs, progress and files changed.

Code

16 files · 2,578 lines of TypeScriptPRO

Agent Run is part of Pro

Get its source, the one-paste agent prompt and all 113 components, for a one-time $99.

Motion notes

  • Everything is derived from `useChat` messages: `useAgentRun` names the current action for the orb and status pill, reasoning parts become Thinking, tool parts become ToolCall, and the final text streams into a Summary card. A tool whose input is `{ path, lines }` renders as a DiffView that applies when the tool succeeds.
  • Feed items rise in as they arrive, in stream order, and the feed stays pinned to the newest step until you scroll up. Changed files fade into the side panel as diffs land, and their dot fills once applied.
  • A tool with a pending entry in `approvals` shows as Queued with an ApprovalCard under it; the header switches to “Waiting for approval” and the plan holds on that step, so attention goes to the one thing that needs you.
  • Stop sits in the header with Esc as its shortcut; pause appears when you handle `onPauseChange`. The layout responds to its own width: three columns, then the details panel drops below, then the plan folds away. Reduced motion keeps every state but drops the travel.

Usage

Example
const { messages, status, stop } = useChat();
  const [approvals, setApprovals] = useState({});

  <AgentRun
    title="Fix off-by-one invoice due dates"
    subtitle="acme/billing"
    messages={messages}
    status={status}
    approvals={approvals}
    onApproval={(id, decision) => {
      setApprovals((a) => ({ ...a, [id]: { ...a[id], decision } }));
      // then run the tool (or not) and send its result back to your route
    }}
    onStop={stop}
  />

  // Your /api/chat route proxies the Claude Messages API stream unchanged
  // (client.messages.create({ ..., stream: true }).asResponse()). For tools
  // that need permission, end the turn on the tool_use block, add an entry
  // to `approvals` keyed by its id, and continue the loop after the user decides.
  // Have your edit tool take { path, lines: DiffLine[] } to get the diff view.

Props

PropTypeDefaultDescription
titlestring—The task as a short headline.
subtitleReactNode—Context under the title: repo, branch, ticket.
messagesChatMessage[]—From your own useChat(). Pass with `status`.
status"idle" | "submitted" | "streaming" | "error"—From useChat.
transportChatTransport—Without `messages`, the block runs its own useChat with this transport.
promptstring—Built-in mode: the task, sent once on mount.
planAgentStep[]—The plan. Defaults to one step per tool call.
approvalsRecord<toolId, AgentRunApproval>—{ title, description?, args?, risk?, decision? } per tool call that needs permission.
onApproval(toolId, decision) => void—Called with deny, once or always.
progressnumber—0–100. Defaults to finished plan steps (or tools), 100 when the summary is done.
stagesstring[]["Plan", "Edit", "Verify", "Report"]Stage labels for the progress card.
filesAgentRunFile[]—Files changed. Defaults to every diff tool's path with +/− counts.
paused / onPauseChangeboolean / (paused) => void—Shows a pause / resume control.
onStop() => void—Stop button and Esc. Defaults to stopping the built-in stream.
renderPart(part, ctx) => ReactNode | undefined—Custom renderers per part.
classNamestring—Classes for the root. Give it a height.