Skip to content

fix(comments): show vote counts optimistically - #75

Merged
tomcasaburi merged 4 commits into
masterfrom
fix/instant-vote-scores
Jul 23, 2026
Merged

fix(comments): show vote counts optimistically#75
tomcasaburi merged 4 commits into
masterfrom
fix/instant-vote-scores

Conversation

@tomcasaburi

@tomcasaburi tomcasaburi commented Jul 23, 2026

Copy link
Copy Markdown
Member

Summary

  • apply the selected account's pending vote to counts returned by useComment, useComments, and useReplies
  • preserve the canonical vote baseline across rapid vote transitions and stop the optimistic adjustment after a newer canonical update
  • cover posts, replies, account comments, and loaded page/update stores with regression tests and documentation

Verification

  • yarn build
  • yarn test (1,142 passed, 6 skipped)
  • manually verified in Seedit

yarn test:coverage:hooks-stores completed its test run, but the repository-wide 100% verifier reports pre-existing coverage gaps in unrelated hooks and stores.

Closes #74


Note

Medium Risk
Vote count logic spans multiple stores and rapid vote transitions; incorrect reconciliation could show wrong scores until the next update, but behavior is heavily tested and scoped to display-layer adjustments.

Overview
useComment, useComments, and useReplies now bump upvoteCount / downvoteCount as soon as the active account’s pending vote is stored, instead of waiting for the network comment to refresh.

A new optimistic-vote-counts helper records baseline and transition metadata on publishVote, reconciles counts against stale copies of the same comment in different stores, and drops the adjustment once a canonical update already reflects the latest vote. getFreshestLoadedComment picks the newest loaded comment snapshot when recording that metadata.

Docs note the behavior; hook, store, and utility tests cover rapid vote changes and reply/comment lists.

Reviewed by Cursor Bugbot for commit f79e9de. Bugbot is set up for automated code reviews on this repo. Configure here.

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@tomcasaburi, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 46 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 0f65c5d2-7482-4df0-9581-3439561cead2

📥 Commits

Reviewing files that changed from the base of the PR and between 37ad180 and f79e9de.

📒 Files selected for processing (12)
  • README.md
  • llms-full.txt
  • src/hooks/comments.test.ts
  • src/hooks/comments.ts
  • src/hooks/replies.test.ts
  • src/hooks/replies.ts
  • src/lib/utils/optimistic-vote-counts.test.ts
  • src/lib/utils/optimistic-vote-counts.ts
  • src/stores/accounts/accounts-actions.test.ts
  • src/stores/accounts/accounts-actions.ts
  • src/stores/accounts/utils.test.ts
  • src/stores/accounts/utils.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/instant-vote-scores

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Comment thread src/stores/accounts/accounts-actions.ts
Comment thread src/lib/utils/optimistic-vote-counts.ts

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 1ef8342. Configure here.

Comment thread src/lib/utils/optimistic-vote-counts.ts
@tomcasaburi
tomcasaburi merged commit cca63b2 into master Jul 23, 2026
8 checks passed
@tomcasaburi
tomcasaburi deleted the fix/instant-vote-scores branch July 23, 2026 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Vote scores lag after publishing

1 participant