Skip to content

fix(app): restore virtual timeline cache#3

Merged
Hona merged 1 commit into
perf/session-timeline-virtuafrom
fix/virtual-timeline-cache-1778638381
May 13, 2026
Merged

fix(app): restore virtual timeline cache#3
Hona merged 1 commit into
perf/session-timeline-virtuafrom
fix/virtual-timeline-cache-1778638381

Conversation

@Hona
Copy link
Copy Markdown
Owner

@Hona Hona commented May 13, 2026

Summary

  • Restore virtua cache snapshots for the session timeline when revisiting a previously measured session.
  • Cache is scoped by session key and exact virtual row keys; mismatches discard the entry.
  • Keeps the cache small with a 16-session in-memory limit.

Baseline vs PR

Measured against perf/session-timeline-virtua after merging latest upstream/dev, same origin/port http://127.0.0.1:3002, review panel closed/unmounted, with heavy timeline settings enabled: reasoning summaries, shell expanded, edit/write/patch expanded.

Metric Baseline This PR
Settings verified reasoning/shell/edit on reasoning/shell/edit on
Review panel mounted during run reviewCounts: [0] reviewCounts: [0]
First virtualizer remount total height 4160px 11477px
First virtualizer remount mounted rows 0 0
Time to bottom rows after session route ~2417ms ~612ms
Bottom scrollTop / scrollHeight 12624 / 13622 10479 / 11477
Major height correction after remount 4160 -> 10306 -> 12598 -> 13622 11477 stable

Trace files from local run:

  • baseline: C:\Users\Lukem\AppData\Local\Temp\opencode\virtua-baseline-heavy-trace.json.json.gz
  • PR: C:\Users\Lukem\AppData\Local\Temp\opencode\virtua-cache-heavy-trace-final.json.json.gz

Validation

  • bun typecheck from packages/app
  • push hook: bun turbo typecheck

Notes

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.

Copilot AI review requested due to automatic review settings May 13, 2026 03:09
@Hona Hona merged commit 5c0d9ed into perf/session-timeline-virtua May 13, 2026
5 of 10 checks passed
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 by sessionKey + 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 })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants