Expand description
Ported from Arc (MIT) © 2026 Elia Kuratli
Reference: Arc源码/arc-library/registry/components/comment-thread/comment-thread.tsx & .module.css
P6 Component #16: comment-thread
- Nested threaded discussion panel:
- Recursive replies capped at
max_depth(default2) hanging from a left rail; - Collapsible reply branches showing reply count and stacked participant avatars when folded;
- Inline
@Full Namemention highlighting for known participants (split_comment_mentions); - Reaction pills + inline reaction picker;
- Author-only inline edit (swaps body for edit composer) and two-step delete confirmation (soft-deletes to a quiet placeholder if replies exist, or removes leaf comments cleanly);
- Thread-level Resolve / Reopen morphing the full thread into a compact resolved chip.
- Recursive replies capped at
Structs§
- Comment
Author - Author metadata for a comment or current user.
- Comment
Reaction - Emoji reaction carrying the user ids who reacted.
- Comment
Thread - Arc
CommentThread— nested replies,@mentionhighlighting, inline edit/delete, and resolve chip. - Thread
Comment - One node in the comment tree.
Constants§
- COMMENT_
DEFAULT_ REACTIONS - Default emoji options in the comment reaction picker (
comment-thread.tsx).
Functions§
- append_
comment_ reply - Pure helper: attaches
replyunderreply_to_idclamped tomax_depth(or root ifNone). - collect_
comment_ authors - Pure helper: collects unique non-deleted authors in appearance order.
- count_
comment_ tree - Pure helper: counts all non-deleted comments in the tree.
- delete_
comment_ in_ tree - Pure helper: deletes a leaf comment, or soft-deletes a comment that still has replies.
- edit_
comment_ in_ tree - Pure helper: edits one comment body in place and marks
edited = true. - path_
to_ comment - Pure helper: finds the path of comment IDs from root to
target_id. - split_
comment_ mentions - Splits body text into
(segment, is_mention)slices matching@Full Nameof known authors. - toggle_
comment_ reaction - Pure helper: toggles
user_id’semojireaction on commentid.