# Agent Run (Notchset): prompt.md (v1.0.0)

- id: `agent-run` · version 1.0.0 · block · pro (Pro)
- category: AI interfaces
- build: Base UI (one set of files; its dependencies follow the build)
- install (this build): `npx shadcn@latest add @beautiful-ui-pro/agent-run`
- npm dependencies: none
- registry dependencies: utils, https://beautiful-ui.dev/r/notchset-foundation.json
- docs: https://beautiful-ui.dev/components/agent-run
- The install command carries everything this item needs (files, CSS, tokens, npm and registry dependencies). Prefer it to copying source by hand.

A coding agent at work on one task: a status bar with live time, tokens and cost, a step ruler, steps that build their output as they run, a steer box, and a review gate where nothing merges until you approve.

## Build it
- Stack: React 19 (`ref` is a plain prop), TypeScript, Tailwind CSS v4 utilities, a shadcn-initialised project with the `@/*` alias.
- Packages: none beyond React.
- Files: `components/ui/notchset/blocks/agent-run.tsx`; shared code: `lib/beautiful-ui/notchset/instrument.tsx`, `lib/beautiful-ui/notchset/root.ts`.
- Registry dependencies, installed with it automatically: shadcn `utils` (cn), `notchset-foundation`.
- Builds: one set of files for both, but its dependencies come in Base UI and Radix builds. Install the one that matches the project (see Install): a free item's bare URL installs the Base UI build of it and its dependencies.
- Exports to keep: `AgentDiff`, `AgentPlan`, `AgentRead`, `AgentRun`, `AgentSearch`, `AgentTests`, and every exported type.
- CSS: the install adds the notchset foundation (tokens, keyframes, motion levels) to your global stylesheet once. Nothing to import by hand.
- Re-running `add` (or `--overwrite`) re-applies those rules: put overrides in your own CSS, never in the installed rules.
- Tokens: retheme with the `--notchset-*` custom properties (`--notchset-check`, `--notchset-control-edge`, `--notchset-draw-from`, `--notchset-ease-bloom`, `--notchset-ease-glide`, `--notchset-ease-key-down`, `--notchset-ease-key-up`, `--notchset-ease-travel`, `--notchset-fade`, `--notchset-focus-color`, `--notchset-focus-inset`, `--notchset-grow-to`, `--notchset-key-down`, `--notchset-key-up`, `--notchset-life-from`, `--notchset-life-ms`, `--notchset-node-blink`, `--notchset-node-bloom`, `--notchset-node-delay`, `--notchset-plate-color`, `--notchset-rise-from`, `--notchset-rule`, `--notchset-scan-to`, `--notchset-scroll`, `--notchset-signal`, `--notchset-sweep-to`, `--notchset-travel`). Never add Tailwind colour classes inside the component.

```tsx
import { AgentPlan, AgentRun, type AgentRunStatus, type AgentStep } from "@/components/ui/notchset/blocks/agent-run";
```

## Parts

| Part | data-slot | What it is for |
|---|---|---|
| `AgentRun` | `agent-run` | The block: header, status bar, ruler, steps, steer box. |
| `AgentPlan` | — | Numbered plan lines. |
| `AgentSearch` | — | A search command and its matches per file. |
| `AgentRead` | — | A file excerpt with a flagged line. |
| `AgentDiff` | — | A diff card per changed file. |
| `AgentTests` | — | Named tests passing one by one, with a rolling count. |

Style a part with `[data-slot="<slot>"]` selectors or its `className`; keep the attributes when editing.

## Sound
- Keep every `data-slot` and `data-sound` attribute: the sound layer reads them.
- Installing this item adds no audio. Nothing plays until the app mounts `SoundProvider` once (install: `npx shadcn@latest add https://beautiful-ui.dev/r/notchset-sound.json`, import from `@/components/ui/notchset/sound-provider`); `useSound()` gives `muted` and `setMuted` for a mute control. Without a provider the audio engine never loads.

## Match the original
- Read `components/ui/notchset/blocks/agent-run.tsx` as the reference implementation before changing or recreating anything, and match it: sizes, colours per theme, motion timings, copy and behaviour.
- If you deviate (a prop you can't honour, a style you changed, a dependency you swapped), say so in your reply, part by part.
- Keep the accessibility contract, the keyboard map and the motion levels listed below.

## Use it when
- agent run, coding agent, agent timeline, tool calls, run steps, steer agent, review gate, pull request, AI agent UI, Notchset
- Showing an agent's run on one task while it works, and the hand-off to a human at the end
- Any step-by-step automated job the user may want to pause, steer or approve

### Not when
- A list of many runs: use Data Table and link each row here
- A chat with an assistant: use Chat App

## Mistakes
- Keep every planned step in steps, started or not, so the ruler doesn't jump as steps arrive
- Pass finishedAt as soon as a step ends: a step without it reads as running
- Set status to opening while the pull request is created, then pr: the gate shows the scanner until you do

## Usage

```tsx
"use client";

import * as React from "react";
import { AgentPlan, AgentRun, type AgentRunStatus, type AgentStep } from "@/components/ui/notchset/blocks/agent-run";

// Fill these from your agent's step.started / step.output / step.finished events.
const steps: AgentStep[] = [
  { id: "plan", kind: "plan", label: "Planning the fix", pastLabel: "Planned the fix", startedAt: 0, finishedAt: 2200, body: <AgentPlan lines={["Find the retry", "Add an idempotency key"]} /> },
  { id: "edit", kind: "edit", label: "Editing 2 files", startedAt: 2200, estimate: 2000 },
  { id: "review", kind: "review", label: "Ready for review" },
];

export function RunView() {
  const [status, setStatus] = React.useState<AgentRunStatus>("working");
  return (
    <AgentRun
      author={{ name: "Maya Kerr", initials: "MK" }}
      repo="ACME/RELAY · MAIN"
      request="Make send_email idempotent and keep the tests green."
      steps={steps}
      status={status}
      elapsed={3100}
      tokens={4200}
      cost={0.03}
      onPause={() => setStatus("paused")}
      onResume={() => setStatus("working")}
      onSteer={(text) => console.log("send to the agent:", text)}
    />
  );
}
```

## Props

| Prop | Type | Default | What it does |
|---|---|---|---|
| `author / repo / request` | `{ name, initials } / string / ReactNode` |  | Who asked, where, and what. |
| `steps` | `{ id, kind, label, pastLabel?, rulerLabel?, startedAt?, finishedAt?, estimate?, body? }[]` |  | Every planned step. A step without startedAt sits on the ruler only; times are ms since the run began. |
| `status` | `"working" \| "paused" \| "review" \| "opening" \| "pr" \| "discarded"` |  | The run's state; review, opening, pr and discarded mean it has finished. |
| `elapsed / tokens / cost` | `number` |  | Ms since the run began, tokens used, dollars spent. Update them as often as you like; the clock rolls once a second. |
| `follow / defaultFollow / onFollowChange` | `boolean` | `true` | Following opens the running step and closes the rest; off hands the steps to the user. |
| `onPause / onResume / onRestart` | `() => void` |  | The status bar's controls. |
| `steers / onSteer` | `{ id, afterStep, text, at }[] / (text) => void` |  | Messages sent while it runs, shown after the step that was running. Marked applied once the next step starts. |
| `review` | `{ summary, stats, hint?, prMessage?, discardMessage? }` |  | The review step's summary and gate. |
| `onOpenPullRequest / onDiscard` | `() => void` |  | Set status to opening, then pr (or discarded) as your API answers. |
| `formatCost` | `(usd: number) => string` | `$0.00` | How cost reads. |

Full docs: https://beautiful-ui.dev/components/agent-run

## Customising
- Colours: the component reads your shadcn tokens (`--background`, `--foreground`, `--border` …), refined by the `--notchset-*` tokens. The signal colour is `--notchset-signal` (it falls back to `--destructive`). Set tokens on `:root`, or on any container to retheme one area.
- Dark mode follows the `.dark` class on an ancestor (the shadcn and next-themes convention).
- Update later by re-running the install with `--overwrite` (review the diff if you edited it). Changelog: https://beautiful-ui.dev/r/changelog.json

## Keyboard

| Keys | Action |
|---|---|
| Tab | Status controls, then each step, then the steer box |
| Enter / Space | Toggle FOLLOW, pause or resume, open or close a step |
| Enter (steer box) | Send the steer (ignored while composing with an IME) |

## Performance

- Plain DOM and CSS transitions; nothing animates per frame. Match dots per file are capped at 12.

## Responsive

- Fills its container; the status bar wraps its controls onto a second line under about 560px, and the review stats go two by two under 480px.

## Motion inventory

| Interaction | What moves |
|---|---|
| New row | Rises 4px and fades in (260ms) |
| Step body | Opens on grid rows (380ms), closes faster (260ms) |
| FOLLOW | The thumb stretches: leading edge first, trailing edge 85ms later (300ms) |
| Numbers | Clock, tokens, cost and the test count roll, ones digit first |
| Tests | Each node pops from hollow to filled as it passes (280ms) |

## Accessibility contract (preserve when editing)
- The status is a live status region; each step row is a button with aria-expanded controlling its body, and closed bodies are inert
- FOLLOW is a switch (role=switch, aria-checked); PAUSE is disabled once the run has finished
- The ruler is a pointer shortcut and hidden from assistive tech: the step rows carry the same action by keyboard
- Rolling numbers keep their plain value for screen readers; the gate's outcome is announced (aria-live)

## Install

```bash
npx shadcn@latest add @beautiful-ui-pro/agent-run
```

Pro item: needs the `@beautiful-ui-pro` registry in `components.json` and `BEAUTIFUL_UI_TOKEN` in `.env.local` (https://beautiful-ui.dev/account). Setup: https://beautiful-ui.dev/docs/pro. Your components.json `style` picks the build: radix-*, new-york and default get Radix, base-* gets Base UI.

## Credits
- Built on shadcn/ui (https://ui.shadcn.com)

The notchset foundation (the tokens listed above, keyframes and motion levels) installs once with the first component; its CSS is public at https://beautiful-ui.dev/r/notchset-foundation.json.
