fix(app): restore virtual timeline cache#3
Merged
Hona merged 1 commit intoMay 13, 2026
Conversation
There was a problem hiding this comment.
Pull request overview
Restores virtua virtualizer cache snapshots for the session message timeline to reduce revisit flicker and speed up returning to previously measured sessions, using an in-memory cache keyed by session and exact row-key lists.
Changes:
- Added a module-level LRU-ish cache (16-entry limit) for
VirtualizerHandle.cache, scoped bysessionKey+ exact virtual row keys. - Wired cache restore into
<Virtualizer cache={...}>and persisted snapshots on unmount and session transitions.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+717
to
+727
| createEffect( | ||
| on( | ||
| () => [sessionKey(), timelineRowKeys()] as const, | ||
| (next, prev) => { | ||
| if (prev && prev[0] !== next[0]) writeTimelineCache(prev[0], prev[1], virtualizer) | ||
| cacheSessionKey = next[0] | ||
| cacheRowKeys = next[1] | ||
| if (virtualizer) { | ||
| virtualizerSessionKey = cacheSessionKey | ||
| virtualizerRowKeys = cacheRowKeys | ||
| } |
| function writeTimelineCache(id: string, keys: readonly string[], handle: VirtualizerHandle | undefined) { | ||
| if (!handle || keys.length === 0) return | ||
| timelineCache.delete(id) | ||
| timelineCache.set(id, { keys: keys.slice(), cache: handle.cache }) |
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
virtuacache snapshots for the session timeline when revisiting a previously measured session.Baseline vs PR
Measured against
perf/session-timeline-virtuaafter merging latestupstream/dev, same origin/porthttp://127.0.0.1:3002, review panel closed/unmounted, with heavy timeline settings enabled: reasoning summaries, shell expanded, edit/write/patch expanded.reviewCounts: [0]reviewCounts: [0]4160px11477px002417ms612ms12624 / 1362210479 / 114774160 -> 10306 -> 12598 -> 1362211477stableTrace files from local run:
C:\Users\Lukem\AppData\Local\Temp\opencode\virtua-baseline-heavy-trace.json.json.gzC:\Users\Lukem\AppData\Local\Temp\opencode\virtua-cache-heavy-trace-final.json.json.gzValidation
bun typecheckfrompackages/appbun turbo typecheckNotes
This improves revisit flicker by avoiding the cold unmeasured-height estimate. It does not solve first-ever cold load or the brief zero-mounted-row phase; those should be measured/fixed separately.