Agent run rewind
Shown as Tern, a made-up product
A coding agent's run as a thread of plain sentences. Rewind to any step to see what it read or wrote, then message it from the composer: the replaced steps fold off into a twig and a new run streams in.
Installation
pnpm dlx shadcn@latest add "https://propui.dev/r/tern-rewind.json?token=…"Adds the piece to components/propui/01-tern-rewind/ and installs motion. Needs a free account: sign in and the command includes your token. Fonts load from Prop UI; download the zip to self-host them.
When to use
Reach for it when
- Showing a coding agent's run step by step: what it read, searched, changed and ran.
- Letting a person redirect an agent from any finished step instead of starting over.
- Reviewing a finished run, with the code and test results each step produced.
Something else fits when
- A plain chat with an assistant and no tool steps: use a message thread.
- Many agents running at once: AI agent runs shows every run and its approval queue.
- A run you can only watch, never change: a read-only log is lighter.
Usage
Fills a full window: give it a container with a definite height.
import Piece from "@/components/propui/01-tern-rewind/Section";
export default function Page() {
return (
<main className="h-dvh w-full overflow-hidden">
<Piece />
</main>
);
}Replace MAIN and BRANCHES in data.ts with your agent's steps, and call your agent from redirect() in Section.tsx. Durations, the thread, the counts in the header and the folded twigs are all computed from the steps.
Your data
Replace these and everything on screen follows.
MAINStep[]- The run on the thread, in order; each step's dur sets when it arrives.
Step{ id; kind; title; now; dur; call?; text?; path?; lines?; add?; del?; result? }- One step: its sentence (title when done, now while running) and what it opens to.
BRANCHES{ id; label; ask; steps: Step[] }[]- The runs a redirect starts; label is the suggestion under the composer.
TASK, REPOstring- The heading and the line above it.
adaptBranch()(steps, kept) => Step[]- Rewrites a branch's diffs to start from what the kept steps already changed.
Interactions
- Watch the run arrive step by step; the running step says what it is doing and fills in as it goes.
- Click any finished step to rewind to it: it opens to the code, search hits or test results it produced, and later steps dim.
- Type in the composer and send: from a picked step it redirects there, otherwise it interrupts from the last finished step.
- Pick a suggestion under the composer to fill it in.
- Open a folded twig to see the steps a redirect replaced.
Keyboard
- ↑or↓
- Move between steps on the thread.
- EnterorSpace
- Open the focused step, or close it.
- Esc
- Go back to the live run (or the end) and clear the redirect.
- Enter
- In the composer, send.
- Shift+Enter
- In the composer, add a line.
Behaviour
Read from the code: roles, motion, breakpoints and what runs.
Accessibility
- Steps are buttons in an ordered list with aria-expanded, so a screen reader hears which step is open.
- The status line is a polite live region: it announces working time, then the finished time and line counts.
- Added and removed lines and passed and failed tests carry hidden text, so the meaning never rests on colour.
- The composer has a label, and send is disabled until there is something to send or a step to redirect from.
- Colour pairs meet WCAG AA contrast in both themes.
Motion
- New steps grow in from zero height with a short fade; while growing they clip only their bottom edge, so the live dot is never cut.
- The running step's sentence shimmers and the live dot breathes; both stop when the run finishes.
- A step opens and closes with a height and opacity change; a redirect folds the replaced steps into a twig whose branch line draws in.
- Reduced motion turns the shimmer and breathing off and keeps changes instant.
Responsive
- The card is 600px wide and shrinks with the screen; its height fits the window, and the thread scrolls inside it.
- Below 640px the padding tightens, step times are hidden and the card leaves a strip at the top for page controls.
- Code lines wrap rather than scroll sideways.
Performance
- One animation frame loop runs only while a run is live, and stops when it ends.
- The run clock re-renders the card at most twice a second; continuous values live in a motion value.
- No canvas, no images: two local font files and inline SVG.
Notes for AI
Give your coding assistant the Markdown, not a screenshot.
- Keep steps in data.ts; derive counts, the header and twigs from them rather than hard-coding text.
- A redirect keeps the steps up to the fork and appends new ones; keep step ids unique per run (redirect() prefixes them).
- Light and dark follow the nearest data-theme attribute, or the system setting. Keep colours in the tokens at the top of post.css.
/p/tern-rewind/markdownThe whole library for assistants: llms.txt, or the MCP server in AI tools and MCP.