fix(desktop): bound initial timeline retention - #5603
Merged
Conversation
Let Virtua own the initial visible range instead of passing every loaded message through keepMounted. Populate the stable retention window after the virtualizer reports its first settled viewport. Add a hook regression test covering a 10,000-row timeline: no indices are retained initially, then the bounded reader neighborhood and visual tail are retained after scroll end. Co-authored-by: Carl <c7ebe626f000404285d3686e1dc74cc07cc60a9754a150041ba132e14bd3e2ec@buzz.block.builderlab.xyz> Signed-off-by: Wes <wesbillman@users.noreply.github.com>
wesbillman
commented
Aug 11, 2026
| // seeding every key here turns `keepMounted` into an all-history mount. | ||
| const [retainedKeys, setRetainedKeys] = React.useState<ReadonlySet<string>>( | ||
| () => new Set(keys), | ||
| () => new Set(), |
Collaborator
Author
There was a problem hiding this comment.
Is this it!?!?! Crazy
Keep a bounded 100-row visual tail mounted during initial positioning, then refresh retention from the measured viewport after the first painted frame. This preserves bottom and reading-state initialization without returning to the pathological all-history mount. Co-authored-by: Carl <c7ebe626f000404285d3686e1dc74cc07cc60a9754a150041ba132e14bd3e2ec@buzz.block.builderlab.xyz> Signed-off-by: Wes <wesbillman@users.noreply.github.com>
wpfleger96
approved these changes
Aug 11, 2026
wpfleger96
left a comment
Member
There was a problem hiding this comment.
Reviewed at 3f7d6ebe3b8062ffd3fcf91cdfc61098eb05539d. The bounded initial tail fixes the all-history keepMounted regression while preserving initial bottom positioning, and the post-paint refresh correctly reuses the existing viewport/tail retention policy and prepend guard. The 10,000-row regression covers both the initial bounded state and the measured steady state. I found no blocking or non-blocking issues.
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.
Summary
keepMountedWhy
useTimelineRetentioninitialized its retained-key set with every loaded timeline key. Those indices were passed to Virtua'skeepMounted, effectively defeating virtualization during initial channel positioning untilonScrollEndpruned the set.On a large real channel this grew WebContent into multiple gigabytes and blocked the renderer main thread for 20+ seconds while WebKit laid out and painted the retained rows. Starting with no retained rows restores Virtua's visible-range mount; the existing reader-neighborhood and visual-tail retention is populated once the viewport is measured.
Validation
node --import ./test-loader.mjs --experimental-strip-types --test src/features/messages/ui/useTimelineRetention.test.mjs8e86a189de7e9a8f2cb119396c8f912ed9dacd6e: branch-skew, desktop-check, desktop-typecheck, and all 4,671 desktop tests passedAuthorship disclosure
Carl implemented and is posting this change on Wes's behalf.