Comments

Threaded comments on a record or a document.

Ben Okafor

Card retries fail with declined since the 5 PM deploy. Logs point at the idempotency key.

Ada Lovelace(edited)

Confirmed on staging. @Ben Okafor can you roll back while we look?

Mira Patel

Rolling back now. I'll post when it's done.

Markdown · @ to mention · Command Return to post
Markdown · @ to mention · Command Return to post

Installation

pnpm dlx shadcn@latest add checkfu/uicontext/comments

Usage

import type { Actor } from "./ui/uicontext/components/domain/Actor.ts"import type { Outcome } from "./ui/uicontext/components/domain/Outcome.ts"import { Comments, type CommentThread } from "./ui/uicontext/components/kit/Comments.ts"
const Message = UiSchema.TaggedEnum({	RequestedPostComment: { request: Schema.String, thread: Schema.NullOr(Schema.String), body: Schema.String },	RequestedEditComment: { request: Schema.String, comment: Schema.String, body: Schema.String },	RequestedDeleteComment: { request: Schema.String, comment: Schema.String },	RequestedResolveThread: { thread: Schema.String, resolved: Schema.Boolean },	RequestedReaction: { comment: Schema.String, emoji: Schema.String, on: Schema.Boolean },})// posts, edits and deletes carry a request id: answer each through `outcomes`export const IssueComments = (	h: Html.H<typeof Message.Type>,	issue: { readonly threads: ReadonlyArray<CommentThread>; readonly me: Actor; readonly outcomes: ReadonlyArray<Outcome> },) =>	Comments(h, {		props: { label: "Comments", threads: issue.threads, me: issue.me, outcomes: issue.outcomes },		onEmit: {			RequestedPost: ({ request, thread, body }) => Message.RequestedPostComment({ request, thread, body }),			RequestedEdit: ({ request, comment, body }) => Message.RequestedEditComment({ request, comment, body }),			RequestedDelete: ({ request, comment }) => Message.RequestedDeleteComment({ request, comment }),			RequestedResolve: ({ thread, resolved }) => Message.RequestedResolveThread({ thread, resolved }),			RequestedReaction: ({ comment, emoji, on }) => Message.RequestedReaction({ comment, emoji, on }),			RequestedStop: () => undefined,		},	})

Examples

Discussions on a page

Each thread quotes the text it's about; resolving tucks it under "Show 1 resolved", where it can be reopened.

Retries reuse the first attempt's idempotency key.
Mira Patel

Should the key include the attempt number, or a fresh UUID?

Ben Okafor

Attempt number. Support can then match retries to the first charge.

Markdown · @ to mention · Command Return to post
Roll out to 10% of EU workspaces first.
Ada Lovelace

10% feels slow. Can we start at 25%?

Markdown · @ to mention · Command Return to post

A long thread

Past fold comments (6 by default), the middle replies fold behind one button.

Ben Okafor

Proposal: drop the nightly export and stream changes to the warehouse instead.

Ben Okafor

Added. Anything else before we announce it?

Mira Patel

Finance is on board if we keep the file until January 15.

Ada Lovelace

Agreed. I'll write the announcement.

Markdown · @ to mention · Command Return to post

Read-only and empty

With an empty can, reactions are shown but can't be pressed and cannotComment says why. With no threads, the box invites the first comment.

Mira Patel

Launch date moves to February 3 so support can staff up.

Ben Okafor

Updated the timeline to match.

You're a guest with view access. Ask Mira Patel to let you comment.

No comments yet

Ask a question or leave feedback. Type @ to bring someone in.

Markdown · @ to mention · Command Return to post

API reference

Props

Comments props
NameTypeDefaultDescription
labelrequiredstring—What the comments are on, for screen readers and agents: "Comments on ENG-12"
agentIdstringcomments:<label>This list's id for agents, unique on the page; comments:<label> by default
threadsrequiredCommentThread[]—The threads to show, each with its comments in order
mentionablesActor[]—Who can be mentioned: people and agents
merequiredActor—The reader, for the optimistic comment
canCommentsCan—What the reader may do; every action when left out
cannotCommentstring—Why the reader can't comment ("You can view this page, not comment"); hides the boxes
newThreadbooleantrueA box for a new thread at the end; true by default (one running thread, as an issue has)
emptystring—What shows when there's no open discussion; an empty string shows nothing
foldnumber6A thread longer than this folds its middle replies behind "Show N more replies"; 6 by default
outcomesOutcome[]—The app's answer to each RequestedPost, RequestedEdit and RequestedDelete, by its request id
nowstring—Now, as an ISO timestamp, for "5 minutes ago"; absolute dates when absent
localestring—The locale numbers and dates are formatted in; the browser's by default
timeZonestring—The time zone times are shown in; the reader's when left out
macbooleantrue⌘ on a Mac, Ctrl elsewhere, for the keycaps; true by default

Events

Comments events
EventPayloadDescription
RequestedPost{ request: string; thread: string | null; body: string; mentions: string[] }A new comment (thread null: a new thread); answer through outcomes with the same request
RequestedEdit{ request: string; comment: string; body: string }The person changed the text of their comment; answer through outcomes with the same request
RequestedDelete{ request: string; comment: string }The person deleted their comment; answer through outcomes with the same request
RequestedReaction{ comment: string; emoji: string; on: boolean }Add the reader's reaction (on) or take it back; toggleReaction applies it optimistically
RequestedResolve{ thread: string; resolved: boolean }The person resolved the thread, or reopened it
RequestedStop{ comment: string }Stop an agent's reply that is still streaming

Agent actions

What agents can do with Comments
ActionDescription
PostedCommentPost a comment: thread id to reply, or null for a new thread. Mention with "@Name" (see mentionable); mentioning an agent starts its work
EditedCommentChange the text of one of the reader's own comments
ConfirmedDeleteasks firstDelete one of the reader's own comments
ClickedResolveResolve a thread (resolved: true) or reopen it (false)
PickedReactionReact to a comment with an emoji (on: true), or take the reader's reaction back (on: false)
ClickedStopStop an agent's reply that is still being written

Accessibility

  • Comments are a named region; each thread is a section named for the text it's about, and each comment an article named for its author, with a <time>.
  • Mod+Enter posts. Typing @ opens a list of people and agents: Up and Down move, Enter or Tab picks, Escape closes, and the count of matches is announced.
  • While editing, Escape cancels and Mod+Enter saves. A refused post puts the draft back with the reason as an alert.
  • Agents post, edit, delete, resolve and stop, only on comments the reader owns; deleting is marked as consequential.

Source