You
Plan a production launch.
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 "@chat-js/thread/react";
- const chat = useChat();
+ const chat = useThread();
chat.messages; // selected path
chat.tree; // complete tree$ bun add @chat-js/threadThe package, not a mockup
Branch from any message, request parallel replies, switch paths mid-stream, and stop individual runs. The canvas reads directly from useThread state.
✦ One conversation. Every possibility.
Real tree state with simulated local streams
Chat
Deployment follow-up
A strict extension
Existing message lists and composers keep using the selected path. Tree-specific state is additive and namespaced under chat.tree.
Select any message and expose its root-to-node path as chat.messages.
Read parents, children, siblings, leaves, and complete tree snapshots.
Stream, stop, and resume responses without coupling them to the visible path.
Start multiple assistant runs from one user message and follow only the one you choose.
Why it keeps working
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
Install the versioned package alongside AI SDK. Your conversation UI, branch controls, persistence, and server routes remain application-owned.