fix(wires): re-sort documents on subscription update so new versions count as new time (ELELOG-745)#2686
Open
dannelundqvist wants to merge 1 commit into
Open
Conversation
…count as new time Live subscription updates patched changed fields in place without re-sorting, so a wire receiving a new version kept the slot its previous version had instead of moving to the top by its new modified time. - add mergeSubscriptionUpdates helper (patch matched fields, then re-sort by the active sort) with tests - useDocuments threads sort into pollSubscriptions and uses the helper - Stream re-sorts the paginated merge branch too ELELOG-745
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The Wire view sometimes shows wires in the wrong order (reported by the Swedish desk on Sydney hours - long sessions with many incoming updates). When a wire already in the list receives a new version, it keeps the slot its previous version had instead of moving to the top by its new modified time.
Root cause
Live subscription updates (
pollSubscriptionsinuseDocuments) patch changed fields in place and callmutate(updatedData, false)without re-sorting. The updated wire'smodifiedbecomes newer but its position doesn't change. The server sort (modified desc) only runs on a full refetch, which the in-place update path skips. Not timezone-related; the long-session correlation is just accumulation of out-of-order in-place updates.Fix
mergeSubscriptionUpdateshelper: patches matched fields, then re-sorts by the activesort(date-aware comparator, stable sort). Also exportssortHits.useDocumentsthreadssortintopollSubscriptionsand uses the helper.Stream.tsxre-sorts its paginated (page 2+) merge branch too.Status-only updates (read/saved/used) don't change
modified, so those wires keep their position (no jumping when marked read).Tests
Added
__tests__/mergeSubscriptionUpdates.test.ts(TDD - written to fail against the old behaviour first): a new version moves to the top; an update older than others re-sorts down; a status-only update keeps position; fields are patched; no-sort leaves order untouched.ELELOG-745
🤖 Generated with Claude Code