No.240 · 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
Written for the variant you picked above: Paper
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. Selected variant — Paper (paper): Apply the paper theme. Where the brief above gives no colour values for it, choose a restrained paper palette with text at 4.5:1 contrast or better. Keep the geometry, states and motion described above unchanged. This selection takes precedence over references to other themes or options in the general brief. Implement this selected appearance; do not add a variant picker or alternative appearances unless requested. Implementation requirements: Use React and TypeScript. Keep the component self-contained, with uniquely scoped CSS and no animation libraries. Include required imports, styles and font setup in the result. 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 behavior: A card up to about 40rem wide that fills narrower screens; dense rows and side columns stack on phones. Touch: Everything is tap-driven; hover hints have tap or focus equivalents. Preserve keyboard access, visible focus and reduced-motion behavior. Keep fictional demo data and simulated service calls in a separate usage example; expose callbacks for real actions and recover from rejected requests. Keep usage-example links inside the demo: use local buttons or prevent navigation. Demonstration links must not navigate to Vitrine routes or open other pages; preserve real URL support in the reusable component itself. Verify the result at narrow and wide viewport sizes, with keyboard input and reduced motion enabled.
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.