fix(llc): Don't upsert out-of-window messages on message.updated/message.deleted events#2815
fix(llc): Don't upsert out-of-window messages on message.updated/message.deleted events#2815VelikovPetar wants to merge 1 commit into
message.updated/message.deleted events#2815Conversation
…essage.deleted` events Co-Authored-By: Claude Opus 4.8 <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 Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## v9 #2815 +/- ##
=====================================
Coverage ? 66.91%
=====================================
Files ? 430
Lines ? 27143
Branches ? 0
=====================================
Hits ? 18162
Misses ? 8981
Partials ? 0 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Submit a pull request
Linear: FLU-560
Github Issue: #
CLA
Description of the pull request
Backport of #2794 (FLU-560) from
mastertov9.message.updatedand softmessage.deletedevents were being unconditionally upserted intoChannelState.messages(and thread reply lists). When the target message wasn't in the currently loaded window — e.g. it lived on an older page the client hadn't paged in yet — this created a phantom entry in the sorted list, leaving a visible gap between the loaded slice and history.Manual port (not a clean cherry-pick)
The original master change lives on
bug/FLU-560_fix_message_updated_event_inserting_messages(earliest commit9f39525). It could not be cherry-picked:master'supdateMessage/deleteMessagewere refactored into an_updateMessages/_updateThreadMessages/_mergeMessagesIntoExistingfamily that doesn't exist onv9, where these methods are still monolithic. The same intent was re-implemented against the v9 architecture.What changed on v9
_listenMessageUpdated(which on v9 also handlesreaction.updated) now passesupsert: false.ChannelClientState.updateMessagegains a{bool upsert = true}flag. Withupsert: false, an out-of-window message (id not already inmessages) is not inserted into the sorted list, but pinned-message maintenance still runs.deleteMessage's soft-delete path now usesupsert: false(hard deletes are unchanged). Since the publicdeleteMessagealso backs the optimistic delete flow, two existing optimistic-delete tests were updated to seed the message first.ChannelClientState.updateThreadInfogains a{bool upsert = true}flag that guards against creating a phantomthreads[parentId]entry for a thread that was never paged in, and against inserting unknown replies into a loaded thread.The guard is id-based and independent of
isUpToDate— even at the latest page we may have paginated past older history and receive an event for a message no longer in memory.Tests
Ported the applicable coverage from #2794:
ChannelClientState.updateMessagegroup (upsert true/false, in-window update).messageUpdated→ "outside loaded window": no phantom insert, out-of-window pin still lands, unknown reply not inserted into a thread, no phantom thread entry.messageDeletedgroup: soft delete doesn't insert a phantom record, in-window soft delete marks as deleted, hard delete is a no-op out of window.Three tests from the master PR were skipped because the underlying features don't exist on v9: the two
activeLiveLocationstests (no live-location feature on v9) and the_pinIsValidunpin test (no_pinIsValidon v9).Full
stream_chatsuite passes locally.Screenshots / Videos
No UI changes.