Skip to content
Sign upPro
Chat layoutsThreaded chatMenu

Threaded chat (Pro)

ProIncluded in $99

Threads off any message, with the agent answering inside the thread, so side questions stop burying the main conversation.

ProA release check: a side question about one item opens a thread off the answer, and the agent replies inside it.

Installation

$ pnpm dlx shadcn@latest add @chatcn-pro/threaded-chat

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

tsx
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

ProA reply count with the last reply, the thread open beside the conversation, answering in the thread, and a failed reply.

Props

PropTypeNotes
messagesChatcnMessage[]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, onValueChangestringThe draft, controlled or not
onSend(text) => voidA message in the main conversation
threadsRecord<string, ChatcnMessage[]>Replies, keyed by the parent message id
openThread, defaultOpenThread, onOpenThreadChangestring | nullThe open thread
threadStatus, threadError, onThreadRetry, onThreadStopThe open thread's own state
onReply(parentId, text) => voidA reply in the open thread
replyValue, onReplyValueChangestringThe thread's draft, controlled or not
canThread(message) => booleanDefault: assistant messages
headerReactNodeAbove the main conversation
disabledboolean
labelsPartial<ThreadedChatLabels>Every string, for translation

Keyboard

KeyAction
Tab to a message's thread button, EnterOpen its thread, focus in the reply box
Escape in the threadClose it, focus back on the button that opened it
Enter, Shift EnterSend, 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.