fix(app): anchor virtual timeline to bottom#4
Merged
Hona merged 2 commits intoMay 13, 2026
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the session message timeline virtualization behavior to avoid an initial “top/zero-scroll” flicker by anchoring the virtualized list to the bottom on initial mount (only in normal follow-bottom scenarios), and improves cold-load estimation by supplying a better virtua itemSize hint when no row-key cache is available.
Changes:
- Add a bottom-anchor path in
MessageTimelinethat scrolls to the last row once per session key whenshouldAnchorBottom()allows it. - Thread a
shouldAnchorBottom()predicate fromsession.tsxto keep deep-link/hash/pending-message/user-scrolled cases out of the anchor path. - Provide
virtuaanitemSizefallback (60px) only when no virtualizer cache exists.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/app/src/pages/session/message-timeline.tsx | Adds one-time bottom anchoring logic per session and uses an itemSize hint only when cache is absent. |
| packages/app/src/pages/session.tsx | Supplies shouldAnchorBottom() based on URL hash, deep-link state, pending message, and user-scrolled state; adds useLocation() usage. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
virtua'sitemSizehint only when no exact row-key cache exists, so cold loads avoid the default ~40px estimate.Measurement setup
origin/perf/session-timeline-virtuaat5c0d9ed030after cache PR merge.http://127.0.0.1:3002.fix: Flicker on load/ses_1e62fb38dffegWEV7SJWQKxJXZ.reviewCounts: [0, 0].Revisit with cache: baseline vs PR
This measures the first candidate change. The PR path uses its own generated cache snapshot, so total
scrollHeightis not treated as an apples-to-apples truth metric here; the useful signal is whether a rendered frame exposes the temporary top/zero-scroll state.47ms111msscrollTop017239scrollTop=01088ms111ms12126only18237onlyvirtua-followup-static-baseline-trace.json.json.gzvirtua-followup-static-anchor-trace.json.json.gzCold load, no cache: baseline vs PR
This measures the second candidate change (
itemSizefallback) plus the anchor.2600px3900pxscrollTop02902scrollTop=0102600 -> 9969 -> 11488 -> 121263900 -> 8444807ms113msvirtua-followup-cold-baseline-trace.json.json.gzvirtua-followup-cold-final-trace.json.json.gzValidation
packages/app:bun typecheckbun turbo typecheckNotes
itemSize=60is an officialvirtuasize hint and is only active without a matching cache. It is still an estimate by design; exact row-key cache remains preferred when available.