affectUI › Components › Agents
Rewind Branches
An agent run with checkpoints, drawn like a git graph – rewind to one and the run forks into a new attempt while the old future stays as a gray dashed line.
Part of affectUI Pro. Install: npx shadcn@latest add https://www.affectui.com/r/rewind-branches.json · Import from @/components/ui/rewind-branches
When to use
- Showing an agent run that failed, was rewound to a checkpoint and tried again from there – as often as it took
- Making clear what a rewind throws away: the old future turns gray, its context is dropped, the retry starts from the checkpoint
- Explaining checkpoints and retries in an agent product, or reviewing why a run needed three attempts
When not to use
- Sub-agents working side by side and joining back – use Agent Branches
- A list of saved checkpoints to pick one and restore – use Agent Checkpoints
- Several attempts at the same task run in parallel and compared – use Parallel Attempts
Usage
import { RewindBranches, type RewindBranch } from "@/components/ui/rewind-branches";
const branches: RewindBranch[] = [
{
id: "main",
name: "Attempt 1",
tasks: [
{ id: "read", label: "Read schema", start: 0, end: 6, tokens: 18000 },
{ id: "write", label: "Write migration", start: 6, end: 14, tokens: 12000 },
{ id: "drop", label: "Drop old table", start: 14, end: 20, failed: true, tokens: 7000 },
],
checkpoints: [{ id: "written", at: 14, label: "Migration written" }],
result: { ok: false, label: "12 tests fail" },
},
{
id: "retry",
name: "Attempt 2",
parent: "main",
checkpoint: "written",
tasks: [
{ id: "backfill", label: "Add backfill", start: 14, end: 21, tokens: 8000 },
{ id: "test", label: "Run tests", start: 21, end: 26, tokens: 12000 },
],
result: { ok: true, label: "Tests pass" },
},
];
export function Migration() {
return <RewindBranches title="Migrate billing to Stripe v2" branches={branches} agentId="migrator" />;
}Props
| Name | Type | Default | Description |
|---|---|---|---|
title | string | The run's name, in the bar | |
branches | RewindBranch[] | { id, name, parent?, checkpoint?, tasks, checkpoints?, result?, tone?, base? } – in the order they ran; the first is the run itself, every other one a rewind | |
tasks | RewindTask[] | { id, label, start, end, failed?, tool?, tokens? } – seconds on the run's clock; a retry carries on from its checkpoint's time | |
checkpoints | RewindCheckpoint[] | { id, at, label } – where the run was saved; a retry names one with checkpoint | |
result | { ok: boolean; label: string } | How an attempt ended – a small red or green tag after its last task | |
agentId | string | The agent that runs it – its pixel mark is drawn from it | |
contextLimit | number | The context window in tokens – 200k by default | |
speed | number | How much faster than real time it plays – 5 by default | |
autoPlay | boolean | Plays the run, the rewinds and the retries again and again – on by default; off, or with reduced motion, it shows the end | |
className | string | An extra class on the root |
Keyboard
- Tab: Pause or Play, then each attempt's name that's on the card
Accessibility
- Every attempt's name is a button – focusing it lights the attempt and those it came from, like pointing at it; its label says where it started from and how it ended
- Each context bar is labelled with its tokens, what was restored from the checkpoint and what a rewind dropped
- A polite live region announces each rewind and how the run ended
- A focus ring shows only for the keyboard
- The run reads left to right in any page; names and labels keep their own direction
Responsive
- Fills its container's width; one lane per attempt, so the card is as tall as the attempts
- Below 560px the names step back to the agent's mark and the blocks lose their labels
- Long names and labels end in …, the full text on hover; tokens read 2k, 119k or 1.3M
- Dark mode built in: switches when an ancestor (usually <html>) has the class dark or data-theme="dark"
- The classic style puts it all in one soft gray tray – the bar on top, the lanes on a white card, the context bars below – with pill-shaped tags and firmer type; the same behavior as the clean one
Requirements
- React 19
Related
- Agent Branches – One agent run that forks into sub-agents and joins back, drawn like a git graph – lanes curve out in their own colour, work runs in parallel, the lead waits at the join
- Agent Checkpoints – An agent's run as a line of checkpoints, like git for agents – rewind to any of them and a new attempt branches out of it, while the one it left fades back but stays
- Parallel Attempts – An agent tries the same task several ways at once and the best one wins – every attempt races as a row with its model and live bar, gets a score, and the best is picked
- Run Controls – Every control a running agent needs, in one composer – stop it, resume from the word it stopped at, retry, steer it mid-answer or queue what's next, with Chat or Act