affectUI › Components › Chat

Comment Thread

One comment with replies – an assistant reports what it did, folds open details and answers @mentions.

Free and open source (MIT). Install: npx shadcn@latest add https://www.affectui.com/r/comment-thread.json · Import from @/components/ui/comment-thread

When to use

  • A single conversation attached to a selection, a cell or a line of text
  • Showing what an assistant did after someone asked for a change

When not to use

  • A feed of many comments – use the Comments Panel

Usage

import { AssistantMark, CommentThread } from "@/components/ui/comment-thread";

const atlas = { name: "Atlas", avatar: <AssistantMark />, assistant: true };

export function Thread({ messages, me }) {
  return (
    <CommentThread
      messages={messages}
      currentUser={me}
      assistant={atlas}
      onReply={async (text) => (text.includes("@Atlas") ? await api.ask(text) : undefined)}
    />
  );
}

Props

NameTypeDefaultDescription
messagesThreadMessage[]id, author, createdAt, text – assistant replies can add a status line with folding details
currentUserThreadAuthorAuthor of new replies
assistantThreadAuthorShown with a thinking state while an answer is on its way
onReply(text) => ThreadMessage | Promise<ThreadMessage | void> | voidReturn a message (or a promise) for the assistant to answer, nothing to just post
onClose() => voidShows a close button
titlestring"Comment"Heading in the gray tray

Keyboard

  • Enter: Send the reply
  • Tab: Reach the status lines to fold their details open

Accessibility

  • Status lines are buttons with aria-expanded; folded details are inert
  • The thread announces new replies politely

Responsive

  • Dark mode built in: switches when an ancestor (usually <html>) has the class dark or data-theme="dark"

Requirements

  • React 19

Related

  • Comments Panel – Comment feed with filters, runnable /edit commands, resolve and a composer
  • Chat Composer – Prompt composer with model picker, voice input, app connections and approval request