Skip to content
GitHub (opens in a new tab)

CommentThread

One conversation on a document, invoice or task, with replies, mentions and a composer.

stableOrganismcontracts/commentthread.json

Preview

CommentThread

One conversation on a document, invoice or task, with one level of replies.

Master

Write a comment and press Comment (or ⌘/Ctrl+Enter). Type @ to pick a member from the list above the field. @mentions of people in the thread read as brand text. Edit or Delete your own comments from the More menu; Reply focuses the composer.

Invoice INV-1842

· 3 comments
  • PS

    Priya ShahNov 20, 09:12

    @Daniel Okafor the card on file was declined twice. Can you check with Northwind AP before we retry on Nov 23?

    • DO

      Daniel OkaforNov 20, 10:03

      Spoke to Mara in AP. A new Visa goes on file today. @Priya Shah hold the retry.

    • PS

      Priya ShahNov 20, 10:26 · edited

      Holding. I'll retry once the new card is in.

⌘ Enter to send

Usage

Use CommentThread for people discussing a record. Comment is the solid primary on its own; pass submitAppearance soft when the page already has one (Retry payment on an invoice). Replies nest one level. Use Chat for the assistant and CommentsPanel for a page's threads.

Do's

  • people discuss a record (invoice, document, task) with replies and @mentions
  • show the thread for one line or the whole page
  • inside CommentsPanel for the selected thread

Don'ts

  • talking to an assistant — Chat
  • a list of threads on a page — CommentsPanel
  • an activity log — Timeline
<CommentThread
  title="Invoice INV-1842"
  comments={comments}
  currentUserId={me.id}
  members={team}
  value={draft}
  onValueChange={setDraft}
  onSubmit={post}
  onReply={reply}
  onEdit={edit}
  onDelete={remove}
/>

One conversation on a document, invoice or task: comments, one level of replies, @mentions shown as brand text, in-place edit and delete for your own comments (in a More menu), and a composer. Not the assistant Chat. Built on kit Avatar, Textarea, Button, DropdownMenu, Kbd and AlertDialog.

When to use

  • people discuss a record (invoice, document, task) with replies and @mentions
  • show the thread for one line or the whole page
  • inside CommentsPanel for the selected thread

When not to use

  • talking to an assistant — Chat
  • a list of threads on a page — CommentsPanel
  • an activity log — Timeline

What an agent reads

import { CommentThread } from "agentic-ds-kit";
must
  • section aria-labelledby the h3 title (or aria-label when untitled)
  • comments and replies are nested lists
  • Reply buttons say whom they reply to (described by the author name)
  • mentions are brand text at heading weight, inside the sentence, so they read in order
  • with members, the composer is a combobox: @ opens a listbox above it, arrow keys move, Enter inserts, Escape closes and keeps the typed text; each option reads name and role
  • Edit and Delete sit in a kit DropdownMenu named "More actions on your comment"
  • the composer and the edit field are labelled Textareas; the composer is described by its "⌘ Enter to send" hint (hidden on touch screens and below --grid-breakpoint-sm); ⌘/Ctrl+Enter posts, Enter saves an edit, Escape cancels and focus returns to More
  • Delete confirms with a kit AlertDialog
  • Sending is announced in a status region; aria-busy while sending or loading
  • new comments fade and rise in on transform and opacity, off under prefers-reduced-motion
defaults
  • submitAppearance solid
  • submitting false
  • placeholder Reply or @mention…
  • label Comments
  • emptyTitle No comments yet
  • loading false
stops if
  • Do not use Chat for people commenting on a record
  • Do not nest replies more than one level
  • Do not style Reply, Edit or Delete as text links: Reply is a ghost sm Button, Edit and Delete live in the More menu
  • Do not show more than one solid primary; Comment is it unless submitAppearance is soft
  • Do not use raw hex

From contracts/commentthread.json: must is the a11y requirements, defaults the prop defaults, stops if the doNot rules where the agent asks instead of inventing a cousin.

Props

NameTypeRequiredDefaultNotes
titlestringNo—Shows the card header with the count. Omit inside CommentsPanel.
commentsarrayYes—{ id, author: { id, name, initials?, avatarSrc? }, createdAt, body, edited?, parentId? }[]; replies nest one level. createdAt is shown in mono as given: use one format, e.g. "Nov 20, 10:03". "@Full Name" of anyone in the thread renders as a mention.
currentUserIdstringNo—Your comments get Edit and Delete.
membersarrayNo—{ id, name, initials?, avatarSrc?, role? }[]. Typing @ in the composer opens this list above the field (a combobox listbox): arrows move, Enter inserts "@Full Name ", Escape closes and keeps the text.
valuestringYes——
onValueChangefunctionYes——
onSubmitfunctionYes—Comment, an md Button on the composer row; ⌘/Ctrl+Enter posts.
submitAppearancesolid | softNosolidsoft when another solid primary shares the view (e.g. ChangeReview's Accept all).
submittingbooleanNofalse—
onReplyfunctionNo—(id) => void; one ghost sm Reply under each top-level thread; focus moves to the composer.
onEditfunctionNo—(id, body) => void. From the More menu. Enter saves, Escape cancels; focus returns to More.
onDeletefunctionNo—(id) => void, after a danger AlertDialog.
placeholderstringNoReply or @mention…—
labelstringNoComments—
emptyTitlestringNoNo comments yet—
emptyDescriptionstringNo——
loadingbooleanNofalse—
errorstringNo——
onRetryfunctionNo——
  • Component
    →

    Chat

    Assistant panel with a header, a thread, and a composer.

  • Component
    →

    CommentsPanel

    A side panel hosting the comment threads for a page: an Open / Resolved / All filter, thread previews, and the selected thread (pass a kit CommentThread as children) with Resolve.

  • Component
    →

    Timeline

    Vertical sequence of now, next, and later for ordered multi-stage work.

  • Component
    →

    AlertDialog

    Must-choose overlay that interrupts until the user cancels or confirms.