Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: codu-code/codu
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: develop
Choose a base ref
...
head repository: codu-code/codu
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: fix/comment-reorder-on-vote
Choose a head ref
Checking mergeability… Don’t worry, you can still create the pull request.
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Aug 12, 2026

  1. fix(discussion): stop comments jumping around when you vote

    Voting refetched the thread, and "Top" re-sorts by score, so liking a
    comment yanked it up the page mid-read.
    
    A successful vote no longer refetches — VoteControl already updates
    optimistically — and each comment's sort score is now frozen the first
    time it is seen, so later data refreshes cannot reshuffle a thread
    somebody is reading. Ordering still updates, just on the next load, or
    immediately if the reader re-picks the sort.
    
    Two things fall out of that:
    
    - The global "a vote is in flight" guard is gone. It blocked votes on
      every other comment while one was pending, and swallowed the click
      after VoteControl had already toggled itself, leaving the UI showing a
      vote that was never sent.
    - With clicks no longer serialised, the vote mutation's read-then-write
      could race itself: two overlapping requests both saw "no vote" and both
      inserted, tripping comment_votes_comment_id_user_id_key. It is now a
      single delete-by-key or upsert, so whichever request lands last wins.
    
    Failed votes still resync: the refetch now completes before the controls
    are remounted, otherwise they would reseed from the pre-vote cache and
    strand earlier successful votes showing their old counts.
    NiallJoeMaher committed Aug 12, 2026
    Configuration menu
    Copy the full SHA
    bde9815 View commit details
    Browse the repository at this point in the history
  2. fix(discussion): drop the frozen sort snapshot, serialise votes per c…

    …omment
    
    Review of the first pass found the score-freezing approach was both more
    than the fix needed and wrong in its own right: displayed counts still
    updated on refetch while the ordering did not, so a thread could render a
    42-point comment below a 3-point one; and the "re-pick the sort to
    re-rank" escape hatch never fired, because selecting the already-selected
    option is a no-op. The added tiebreak also made Top identical to New on
    the common all-zero thread.
    
    Not refetching after a successful vote is the whole fix on its own — the
    new count lives in VoteControl, `discussions` is untouched, so nothing
    re-ranks under the reader. Ordering is once again derived from the data
    on screen, so it can never contradict the counts beside it.
    
    Votes are now serialised per comment, newest click replacing any queued
    one. Overlapping requests could otherwise land in either order and leave
    the stored vote disagreeing with the UI; eight rapid clicks now collapse
    to two requests instead of eight against the rate limit.
    
    The remount that resyncs a failed vote is also per comment now, so one
    failure no longer discards the optimistic state of votes on other
    comments, or of one still in flight. Server errors (rate limiting) reach
    the toast instead of being replaced by a generic message.
    NiallJoeMaher committed Aug 12, 2026
    Configuration menu
    Copy the full SHA
    8afe5f3 View commit details
    Browse the repository at this point in the history
Loading