Every post supports a threaded comment system with replies, @mentions, heart reactions, and moderation controls.
Creating Comments
Any authenticated user can comment on a post. Comments require:
Post ID — The post being commented on
Content — Non-empty text
Reply to (optional) — A parent comment ID for threaded replies
Threaded Replies
Comments can be replies to other comments via the reply_to_comment_id field. The UI renders these as nested threads. There is no depth limit on nesting.
@Mentions
Comments support @username mentions. When a comment is created:
A database trigger (hub_process_comment_mentions) parses the content for @word patterns
Matching usernames are looked up in the profiles table
Valid mentions are recorded in hub_comment_mentions
A mention notification is sent to each mentioned user (excluding self-mentions)
Heart Reactions
Users can heart-react to comments. Each user gets one heart per comment (toggle on/off). The comment API returns reactions: { hearts, hasHeart } for each comment, where hasHeart indicates whether the current user has hearted it.
Editing Comments
Only the comment owner can edit their own comments. Edits update the content and updated_at fields.
Deleting Comments
Comments are soft-deleted by setting visibility: false. The following users can delete a comment:
Who
Can delete?
Comment owner
✓
Space moderator / admin
✓
Global moderator (rank ≥ 80)
✓
Optimistic UI
The comment system uses optimistic updates for a snappy user experience:
New comments and replies appear instantly before the server confirms
Heart reactions toggle immediately with rollback on failure
Realtime Supabase channels keep comments in sync across clients
Comment Notifications
The hub_comment_notify_trigger fires on every new comment and:
Top-level comment → Notifies the post author (comment_on_post type)
Reply → Notifies the parent comment author (reply type)
All cases → Notifies all other participants in the post's comment thread (users who previously commented)
The commenter themselves is always excluded from notifications