Plan a production launch.
Branching conversations for AI SDK.
Keep the useChat interface. Add a complete message tree, branch navigation, and concurrent responses that keep streaming when users move elsewhere.
- import { useChat }from "@ai-sdk/react";
+ import { useThread }from "@chatjs/thread/react";
- const chat = useChat({ transport });
+ const chat = useThread({ transport });
chat.messages; // selected path
chat.tree; // complete tree$ bun add @chatjs/thread ai @ai-sdk/reactThe package, not a mockup
Move through the tree while it streams.
Branch from any message, request parallel replies, switch paths mid-stream, and stop individual runs. The canvas reads directly from useThread state.
useThread playground
Real tree state with simulated local streams
0 active runs
Active conversation
messages = tree.getPath(cursorId)
Start with architecture, rollout, and observability as separate workstreams.
Make the plan technical.
Use staged environments, immutable builds, and progressive traffic shifting.
Add the deployment sequence.
A strict extension
Your chat stays linear. Its history does not.
Existing message lists and composers keep using the selected path. Tree-specific state is additive and namespaced under chat.tree.
Same AI SDK surface
Cursor navigation
Select any message and expose its root-to-node path as chat.messages.
Message topology
Read parents, children, siblings, leaves, and complete tree snapshots.
Independent runs
Stream, stop, and resume responses without coupling them to the visible path.
Parallel responses
Start multiple assistant runs from one user message and follow only the one you choose.
Why it keeps working
One tree. One AI SDK lifecycle per response.
A single linear chat engine cannot safely own several branch streams. useThread isolates each response while routing every update into its own assistant node once streaming begins.
Canonical messages, parent-child edges, and the selected cursor.
A useChat-compatible projection from the root to the cursor.
One isolated AI SDK request lifecycle and abort controller per response.
Your existing AI SDK ChatTransport, shared without a new wire protocol.
Headless by design
Own the experience. Choose how you integrate it.
Install the versioned package alongside AI SDK. Your conversation UI, branch controls, persistence, and server routes remain application-owned.