No.154 · AI & Chat
Branch Switcher
Editing a message starts a branch instead of overwriting it; step between versions and the question and answer slide together, with a tiny branch tree.
The prompt
The design brief behind this component — reuse it to regenerate, remix, or explain it.
Build message versioning for an AI chat. A user message bubble sits above an assistant answer; under the bubble, an edit button, a pager ("‹ 2 / 3 ›", disabled at the ends, the count announced politely) and a tiny SVG branch tree: a short trunk splitting into one curved branch per version, each ending in a dot, the current one filled in the accent (clickable to jump). Stepping to another version slides the bubble and answer in from the direction you moved (36px, with a 4px blur, 460ms; the answer 70ms behind) — only those two parts re-mount, so focus stays on the pager. Editing swaps the bubble for a textarea with Cancel and "Save as new branch"; saving appends a new version with a new answer and moves to it, so nothing is ever overwritten.
Notes
- Interaction
- Use ‹ › or the tree to move between versions; Edit to write a new version, which becomes a new branch.
- Motion
- Version change: slide and unblur 460ms, answer 70ms later.
- Accessibility
- The pager is a nav with labelled buttons and a polite position readout; the textarea is labelled; focus stays on the pager while switching. Reduced motion swaps versions without the slide.
- Responsive
- A card up to about 40rem wide that fills narrower screens; dense rows and side columns stack on phones.
- On touch
- Everything is tap-driven; hover hints have tap or focus equivalents.