Threaded chat (Pro)
ProIncluded in $99Threads off any message, with the agent answering inside the thread, so side questions stop burying the main conversation.
On this page
Installation
Needs chatcn Pro
This command works with a Pro license, along with every Pro component.
Or start free: sign up and get three Pro components on us, with a new one every month.
Usage
import { ThreadedChat } from "@/components/ui/chatcn/pro/threaded-chat"
<ThreadedChat
messages={messages}
status={status}
onSend={send}
threads={threads}
threadStatus={threadStatus}
onReply={(parentId, text) => askInThread(parentId, text)}
/>A side question about one part of an answer goes into a thread instead of the main conversation. Hovering or focusing an assistant message offers Reply in thread; once a thread has replies, the message shows the count and the last reply, and clicking it opens the thread again. The thread opens beside the conversation with the message it came from pinned at the top, and the agent answers there. Main and thread keep their own status, so the reader can keep using one while the other answers. On a host narrower than 720 px the thread takes the whole view, with a way back. canThread decides which messages offer a thread.
Examples
States
Props
| Prop | Type | Notes |
|---|---|---|
messages | ChatcnMessage[] | The thread, in the kit's message contract |
status, error, onStop, onRetry | "ready" | "submitted" | "streaming" | "error" | Send becomes Stop while it streams; an error offers Try again |
value, defaultValue, onValueChange | string | The draft, controlled or not |
onSend | (text) => void | A message in the main conversation |
threads | Record<string, ChatcnMessage[]> | Replies, keyed by the parent message id |
openThread, defaultOpenThread, onOpenThreadChange | string | null | The open thread |
threadStatus, threadError, onThreadRetry, onThreadStop | The open thread's own state | |
onReply | (parentId, text) => void | A reply in the open thread |
replyValue, onReplyValueChange | string | The thread's draft, controlled or not |
canThread | (message) => boolean | Default: assistant messages |
header | ReactNode | Above the main conversation |
disabled | boolean | |
labels | Partial<ThreadedChatLabels> | Every string, for translation |
Keyboard
| Key | Action |
|---|---|
| Tab to a message's thread button, Enter | Open its thread, focus in the reply box |
| Escape in the thread | Close it, focus back on the button that opened it |
| Enter, Shift Enter | Send, new line |
Accessibility
- Thread buttons report whether their thread is open and point at the thread panel.
- The thread is a labelled region; while it covers a narrow screen, the conversation behind it is inert.
- Reply counts are words, not badges.
- Main and thread each announce their own answers politely.
Motion
The thread enters with a short rise and fade; the reply button fades in on hover. Under reduced motion the thread appears in place.