StealThis .dev

Chat Branching Tree

A branching chat transcript where every assistant turn can be regenerated into sibling versions, an inline pager flips between them, editing a user message forks a fresh branch, and a live SVG minimap renders the whole conversation as a navigable tree.

Open in Lab
vanilla-js css
Targets: JS HTML

Code

Chat Branching Tree models a conversation the way modern AI chat apps do: not as a flat list, but as a tree. Every message is a node with a parent and children. When you regenerate an assistant reply, a new sibling is appended and the turn shows a 2/3 pager so you can flip between alternative answers without losing any of them. Editing a user message forks a new branch from that point and drafts a fresh reply, leaving the original path intact.

The transcript renders only the currently active path through the tree. A compact minimap on the side draws the full conversation graph as an inline SVG — active path highlighted, dots colored by role — and every node is clickable, retargeting the active path in one tap. Prev/next pagers, edit forks, and minimap clicks all mutate the same tree and trigger a single re-render.

The demo leans on the platform: an inline SVG graph laid out with a small recursive tree algorithm, contenteditable-free inline editing via a swapped <textarea>, and keyboard-accessible controls with visible focus. No frameworks, no build — just a tree data structure and vanilla DOM.