fix(llc): keep reaction group while its count stays positive - #2859
Conversation
Message.deleteMyReaction dropped the entire ReactionGroup whenever the updated sumScores reached 0, even while the count was still greater than zero, so count-based reaction UIs lost other users' reactions during the optimistic delete until the next server event. Gate the group's survival on count alone, mirroring the backend which derives groups from the reaction count (sum of scores is an independent aggregate that may legitimately be zero). Port of #2858 to v9. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
The _maybeGetReactionGroups fallback that derives reaction groups from the old reaction_counts/reaction_scores maps dropped a group when its sum_scores was 0, discarding a still-populated group. Gate on count only, matching the delete-path fix; the score sum may legitimately be zero or negative. Also trims the reaction-group comments to one terse line each. Port of the review follow-up on #2858. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- Guard the legacy synthesizer on count <= 0 so a malformed negative count can't build an invalid ReactionGroup. - Use a realistic delete-path fixture (own score 1, other score -1) instead of unreachable score 0 reactions. - Derive the legacy-payload test from the deprecated reactionCounts/ reactionScores params (a real Message) covering a zero/negative total. Port of the review follow-up on #2858. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## v9 #2859 +/- ##
=====================================
Coverage ? 67.32%
=====================================
Files ? 431
Lines ? 27370
Branches ? 0
=====================================
Hits ? 18427
Misses ? 8943
Partials ? 0 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Port of #2858 to
v9.Summary
Messagedropped an entireReactionGroupin two places when a group's summed scores were non-positive, even though itscountwas still positive — so count-based reaction UIs lost other users' reactions:deleteMyReaction(optimistic delete) kept a group only whencount > 0 && sumScores > 0. A group whose scores net to zero/negative vanished during the optimistic delete until the next server event._maybeGetReactionGroups(derives groups from the deprecatedreactionCounts/reactionScores) discarded a group whensumScores == 0, dropping a still-populated group.Root cause / backend alignment
The backend derives reaction groups from the
reactionstable viacount(type)/sum(score)grouped by(message_id, type). A group exists iff at least one reaction row remains (count >= 1);sum(score)is an independent aggregate that may legitimately be0or negative and never gates whether the group exists.Both call sites now gate purely on the count.
Changes
deleteMyReaction: retain the group whileupdatedCount > 0._maybeGetReactionGroups: retain the group whilecount > 0(guardcount <= 0so a malformed negative count can't build an invalid group).score: 1, otherscore: -1) and a legacy-fields test (via the deprecated params) covering zero and negative score totals.stream_chatCHANGELOG entries.Testing
flutter test test/src/core/models/message_test.dart test/src/core/models/message_reaction_helper_test.dart— all pass.Fixes FLU-663
🤖 Generated with Claude Code