# Agent playback

> Your AI product working, hands-off and on a loop: the hero demo built from the real components.

A screen recording of your product goes stale the day you ship, and a static mock looks like one. This plays a scripted conversation through the real components instead. The prompt types itself into the composer with a person’s uneven rhythm, then lifts out and glides into the message bubble. The agent’s work arrives block by block, each opening its own room so everything above glides up: a thinking trace ticking off steps, web research stacking its sources, a tool call filling in its arguments. The answer streams in with its citations, holds a beat, then the conversation dissolves and the next prompt starts. It pauses off-screen and in a background tab, has its own pause button, and with reduced motion shows the finished conversation, still.

## Install

```bash
npx shadcn@latest add https://hairlineui.com/r/agent-playback.json
```

Needs React 19, Tailwind CSS v4 and shadcn/ui theme variables (any style, light and dark). Icons from lucide-react.

- npm: `lucide-react`
- Hairline UI components it needs (the CLI installs them too): `prompt-composer`, `number-roll`, `thinking-trace`, `text-morph`, `web-research`, `tool-call`, `streaming-answer`
- Docs and live preview: https://hairlineui.com/ui/agent-playback
- Registry item (source): https://hairlineui.com/r/agent-playback.json

## Usage

```tsx
import { AgentPlayback, type PlaybackTurn } from "@/components/agent-playback";

const turns: PlaybackTurn[] = [
  {
    prompt: "Summarise this week's churn",
    steps: [
      { type: "thinking", steps: ["Reading the events", "Grouping by plan"] },
      { type: "tool", name: "run_query", input: { table: "events", since: "7d" }, output: { rows: 1284 } },
      { type: "answer", content: "Churn fell to 2.1% this week, mostly on the Starter plan." },
    ],
  },
];

<AgentPlayback turns={turns} header="Acme" />
```

## In a hero section

Beside your headline it shows the product doing the job, so the page explains itself.

```tsx
import { AgentPlayback } from "@/components/agent-playback";
import { turns } from "./demo-script";

export function Hero() {
  return (
    <section className="mx-auto grid max-w-6xl items-center gap-12 px-6 py-24 lg:grid-cols-2">
      <div>
        <h1 className="text-5xl font-medium tracking-[-0.04em]">Answers your ops team can act on</h1>
        <p className="mt-4 text-lg text-muted-foreground">Ask in plain words. Relay reads, checks and does the work.</p>
      </div>
      <AgentPlayback turns={turns} header="Relay" height={560} />
    </section>
  );
}
```

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `turns` | `PlaybackTurn[]` | – | Each a prompt and its steps: thinking, search, tool and answer, in any order and number. |
| `speed` | `number` | `1` | Pace; 2 plays twice as fast. |
| `hold` | `number` | `4200` | How long a finished answer stays before the next prompt (ms). |
| `loop` | `boolean` | `true` | Start again after the last turn. |
| `paused` | `boolean` | `false` | Pause from outside, e.g. while a dialog is open. |
| `header / placeholder` | `ReactNode / string` | – | A title bar (your product’s name) and the composer’s placeholder. |
| `height` | `number` | `540` | Fixed, so the page around it never moves; the conversation grows up from the composer and fades at the top. |

## States

- **typing**: The prompt types in at 26–60ms a character, pausing after words and punctuation.
- **sent**: The text glides from the composer into its bubble (620ms) as Send becomes a spinner.
- **working**: Each step’s block opens its own height (520ms) and blurs in: thinking, search, tool call, in your script’s order.
- **answering**: The answer streams a few words at a time; its actions fold in once it’s done.
- **next**: After hold ms the conversation lifts and dissolves (480ms) and the next turn begins; it loops unless loop is false.
- **paused**: Off-screen, in a hidden tab, with the pause button or the paused prop. Waits resume exactly where they stopped.

## What it handles

A screen recording is out of date the day you ship, and a mock-up looks like one. This plays a script through the real components, so the demo is the interface people will actually use.

- **A script, not a video**: Each turn is a prompt and its steps: thinking, search, tool call and answer, in any order.
- **Typed like a person**: The prompt types at an uneven pace, pausing after words and punctuation, then glides into its bubble.
- **Blocks open their own room**: Each step opens its own height, so everything above glides up instead of jumping.
- **Pauses when it should**: Off-screen, in a hidden tab, or with the pause button, and it resumes at the exact moment it stopped.
- **Loops, or stops**: Set the speed, how long a finished answer stays, and whether it starts again.
- **Still for reduced motion**: It shows the first conversation finished and holds still, and a sentence describes it for screen readers.

## Replaces

a screen recording, a GIF or Lottie file, a hand-built animation timeline, a typing effect, an off-screen pause

## Where it fits

- **Landing page heroes**: Show the product doing a real job next to the headline instead of a screenshot.
- **Feature sections**: A short scripted run beside the feature it explains.
- **Product launch pages**: A looping demo that shows what the first minute with the product looks like.
- **Docs and sales pages**: A demo that stays accurate because it is drawn by the same components as the product.

## Notes

- The moving copy is inert and hidden from screen readers; a sentence describes what the demo shows instead. The pause button meets the rule that anything moving for more than five seconds can be paused.
- It pauses when less than 15% is on screen or the tab is hidden, and resumes from the exact moment it stopped; live timers skip the paused time.
- The script restarts only when its prompts change, so an inline array in a component that re-renders is fine.
- With reduced motion it shows the first conversation finished and holds still.
- Installs the composer, thinking trace, web research, tool call and streaming answer it plays.

License: MIT (https://hairlineui.com/license#components)
