Skip to content

Move aggregate triggers from write to relay confirmation#315

Draft
Copilot wants to merge 4 commits into
mainfrom
copilot/fix-comment-count-sync-issue
Draft

Move aggregate triggers from write to relay confirmation#315
Copilot wants to merge 4 commits into
mainfrom
copilot/fix-comment-count-sync-issue

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Dec 22, 2025

Aggregate counts (comment/vote counts) were being incremented when records were written with status: "pending", but the UI filters out pending records. This caused mismatches where "1 comment" displayed but no comment appeared.

Changes

Modified createComment, createPostVote, createCommentVote:

  • Aggregate triggers now only fire when status === "live"
  • Pending records no longer affect counts until confirmed by relay

Modified updateComment, updatePostVote, updateCommentVote:

  • Added detection of pendinglive status transitions
  • Triggers fire when relay confirms the record

Flow

// API layer: User creates comment
await createComment({ status: "pending", ... });
// → No aggregate trigger, count stays 0

// Receive hook: Relay confirms
await updateComment(repo, rkey, { status: "live" });
// → Detects pending → live transition, trigger fires, count becomes 1

Counts now reflect only what's visible to users.

Original prompt

This section details on the original issue you should resolve

<issue_title>Comment counts are out of sync with comment view while record is pending</issue_title>
<issue_description>Describe the bug

Comment count says 1, but no comment appears. This is because the record is pending and our aggregate rows don't take this into account.

To Reproduce

  1. Revoke access to frontpage at https://bsky.social/account (this is the easiest way to get record writes to fail)
  2. Make a comment

Now the post has +1 comment count but the comment doesn't show for anyone except the author.

Expected behavior

Comment count to be consistent with comment thread view.

This is pretty hard to do for both the comment author and everyone else (would require keeping track of multiple counts, or discarding our aggregate system altogether for something else). So I suggest we fix by having the count reflective of live comments only, not pending ones.

Screenshots

Image

Additional context

The fix here involves moving the create comment trigger into the receive hook ie. after we receive the record back from the relay. We should move all triggers to the receive hook as this makes more sense architecturally.
</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@vercel vercel Bot temporarily deployed to Preview – frontpage-oauth-preview-client December 22, 2025 14:49 Inactive
@vercel
Copy link
Copy Markdown

vercel Bot commented Dec 22, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
frontpage Ready Ready Preview, Comment Dec 22, 2025 3:02pm
1 Skipped Deployment
Project Deployment Review Updated (UTC)
atproto-browser Skipped Skipped Dec 22, 2025 3:02pm

@vercel vercel Bot temporarily deployed to Preview – atproto-browser December 22, 2025 14:49 Inactive
@vercel vercel Bot temporarily deployed to Preview – frontpage December 22, 2025 14:49 Inactive
@vercel vercel Bot temporarily deployed to Preview – unravel December 22, 2025 14:49 Inactive
@vercel vercel Bot temporarily deployed to Preview – atproto-browser December 22, 2025 14:57 Inactive
@vercel vercel Bot temporarily deployed to Preview – frontpage-oauth-preview-client December 22, 2025 14:57 Inactive
@vercel vercel Bot temporarily deployed to Preview – unravel December 22, 2025 14:57 Inactive
@vercel vercel Bot temporarily deployed to Preview – frontpage-oauth-preview-client December 22, 2025 14:59 Inactive
@vercel vercel Bot temporarily deployed to Preview – atproto-browser December 22, 2025 14:59 Inactive
@vercel vercel Bot temporarily deployed to Preview – unravel December 22, 2025 14:59 Inactive
Co-authored-by: tom-sherman <[email protected]>
@vercel vercel Bot temporarily deployed to Preview – atproto-browser December 22, 2025 15:01 Inactive
@vercel vercel Bot temporarily deployed to Preview – frontpage-oauth-preview-client December 22, 2025 15:01 Inactive
@vercel vercel Bot temporarily deployed to Preview – unravel December 22, 2025 15:01 Inactive
Copilot AI changed the title [WIP] Fix comment counts sync issue with pending records Move aggregate triggers from write to relay confirmation Dec 22, 2025
Copilot AI requested a review from tom-sherman December 22, 2025 15:02
@will-corrigan will-corrigan removed the fix label Mar 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Comment counts are out of sync with comment view while record is pending

3 participants