Chat Thread
The conversation view of an AI chat. Handles replies that stream, edit and retry, and versions of a reply you can switch between.
- Category
- AI
- Components used
- 10
- Files
- 4
- Usage examples
- 2
- Access
- HextaUI Pro (55 blocks)
- Source updated
- Counted in
- UI component usage study
Part of HextaUI Pro, all 55 blocks, $79 one-time, Compare plans
Chat Thread is the conversation around the composer: your messages, the model’s replies, and what you can do with them. It starts with your empty state and the composer centered, then docks the composer at the bottom once there are messages, without remounting it, so focus and draft text stay put.
The message you just sent moves to the top while its answer streams underneath, and the view follows new text until you scroll away. A rail of checkpoints on the right lets you jump between your messages, with a preview on hover. Older history loads from the top without the view moving.
Hover a message to copy, edit or try again. Edits and retries become versions you can switch between, and nothing is lost. Failed replies offer Try again, stopped replies say so, and thumbs up or down are one click. Inside each reply, Reasoning, ToolCalls and Markdown from the other blocks slot straight in.
Checkpoints before your messages are restore points. Restore says exactly what goes, such as “Removes this message and 3 later messages, and reverts 3 files”, dims those messages while you decide, and lets you keep your code with Conversation only. The later messages fold away, your message goes back into the composer to edit, and a toast offers Undo.
Get HextaUI Pro
One payment unlocks every block, including future ones. See pricing.
Add the Pro registry to components.json
components.json Add your token
Create a token on your account page and put it in
.env.localasHEXTAUI_PRO_TOKEN.Add the block
pnpm dlx shadcn@latest add @hextaui-pro/chat-thread
With the AI SDK
Map useChat messages to the thread. Reasoning parts go to Reasoning, tool parts to ToolCalls and text to Markdown. Pin the latest user message, use regenerate for Try again, and send an edit again from that point.
Restore points
Write a data-checkpoint part ({ id, label, files }) from the server when a reply starts, and write it again with the same id as files change. getCheckpoints maps them to user messages, restoreMessages splits the history, and the returned undoRestore brings it all back.
Anatomy
The parts you compose, from the outside in.
| Part | Description |
|---|---|
ChatThread | The frame: scroller, checkpoints, empty state and composer slot. |
ChatUserMessage | Your message: attachments, bubble, time, versions, copy and edit. |
ChatAssistantMessage | A reply. Put Reasoning, ToolCalls and Markdown inside it; it adds the actions, error and stopped states. |
ChatCheckpoint | A restore point before a user message: a quiet line with the files that turn changed, and Restore with its confirm. ChatUserMessage renders it from checkpoint. |
ChatDivider | A labelled line between groups of messages. |
ChatAttachments, ChatAction, ChatCopy, ChatBranchSwitch, ChatEditor | The pieces the messages use, exported for custom layouts. |
| Prop | Type | Default |
|---|---|---|
childrenMessages and dividers, in order. | ReactNode | – |
composerUsually Prompt Input. Centered when empty, docked at the bottom otherwise. | ReactNode | – |
emptyShown above the composer when there are no messages. | ReactNode | – |
busyMarks the conversation busy for assistive technology while a reply streams. | boolean | false |
hasOlderShows “Load earlier messages” at the top. | boolean | false |
loadingOlderShows a spinner on that button. The scroll position is restored once it turns false. | boolean | false |
onLoadOlderPrepend older messages here. | () => void | – |
onRestoreShows Restore on checkpoints. Remove the later messages here and put the message back in the composer. Return a function to offer Undo in the toast, and mount Toaster once in your app. | (checkpointId: string, options: { code: boolean }) => void | (() => void) | – |
| Prop | Type | Default |
|---|---|---|
idStable id. Keep it the same across versions so the view doesn’t jump. | string | – |
textThe message. Also used for the checkpoint preview. | string | – |
pinScroll this message to the top when it appears. Set it on the message just sent. | boolean | false |
files{ id, name, size?, type?, url? }. Images with a url show as thumbnails. | ChatFile[] | – |
timeShown on hover, in the reader’s locale. | Date | – |
branch{ index, count, onChange } for the version arrows. | ChatBranch | – |
onEditShows Edit. Called with the new text when it changed. | (text: string) => void | – |
checkpoint{ id, label?, files? }. Shows a restore point before this message; files are the paths this turn changed. | ChatCheckpointData | – |
attachmentsCustom content above the bubble. | ReactNode | – |
| Prop | Type | Default |
|---|---|---|
idStable id. | string | – |
childrenReasoning, ToolCalls, Markdown or anything else. | ReactNode | – |
textPlain text for Copy. | string | – |
streamingHides the actions until the reply finishes. | boolean | false |
lastKeeps the actions visible instead of showing them on hover. | boolean | false |
metaRight side of the action row, such as the model and effort. | ReactNode | – |
branchVersion arrows for retries. | ChatBranch | – |
feedbackThe current rating. | "up" | "down" | null | null |
onFeedbackShows the thumbs. Called with null when a rating is undone. | (feedback) => void | – |
onRetryShows Try again. | () => void | – |
errorShows the message with Try again instead of the actions. | string | null | – |
stoppedMarks a reply that was stopped early. | boolean | false |
| Prop | Type | Default |
|---|---|---|
messageIdThe user message it sits before. | string | – |
checkpoint{ id, label?, files? }. | ChatCheckpointData | – |
labelFallback name for Restore and the toast, usually the message text. | string | – |
| Prop | Type | Default |
|---|---|---|
childrenThe label, such as Today or “Switched to Nova 3 Max”. | ReactNode | – |
| Prop | Type | Default |
|---|---|---|
messagesuseChat messages with data-checkpoint parts. | UIMessage[] | – |
checkpointIdReturns { kept, removed }: everything before the checkpoint’s user message, and that message onward. removed[0] is the message to put back in the composer. | string | – |
| Prop | Type | Default |
|---|---|---|
messagesReturns a Map from user message id to its checkpoint, for ChatUserMessage. A part written again with the same id updates it in place. | UIMessage[] | – |
| Key | Action |
|---|---|
| Tab | Moves through the messages’ actions. They appear on focus, not only on hover. |
| Enter | Sends an edited message. |
| ShiftEnter | Adds a line while editing. |
| Esc | Cancels an edit. |
| ↑↓PgUpPgDn | Scroll the conversation when it has focus. |
| Enter | Runs the focused choice in the restore confirm. Restore conversation and code is focused first. |
| Esc | Closes the restore confirm and returns focus to Restore. |
- The conversation is a labelled region holding a log, so new messages are announced as they arrive and the region is marked busy while a reply streams.
- Every icon action has a label and tooltip. Thumbs use aria-pressed, Copy and feedback confirm through a polite live region, and errors use role=alert.
- Checkpoints are a navigation landmark of buttons named “Message 2: …”, and the current one has aria-current.
- Version arrows are a group named “Version 1 of 2”.
- The editor focuses itself with the caret at the end and returns to the message on Cancel. Enter waits while an input method is composing.
- Focus rings are never clipped by the scroller, and actions stay visible on touch screens.
- Restore buttons are named “Restore checkpoint: …” after their message and described by the checkpoint line. The confirm is a dialog that says exactly what will be removed and reverted, and the messages that will go are dimmed while it is open.
- After a restore, focus moves to the composer with the caret at the end, and the toast announces what was restored with an Undo button. With reduced motion, later messages fade out instead of folding away.
Built with
The free HextaUI components Chat Thread is made from. Each one installs on its own.
Code
4 files, added to components/blocks/chat-thread.