Skip to content

fix(timeline,shell): close memo, fade, multi-window, and tab-close cache gaps - #2427

Merged
kitlangton merged 1 commit into
devfrom
perf/row-memo-cache-audit-fixes
Dec 4, 2026
Merged

kitlangton merged 1 commit into
devfrom
perf/row-memo-cache-audit-fixes

Conversation

@kitlangton

Copy link
Copy Markdown
Collaborator

Closing a tab, running multiple windows, or searching and folding timeline rows no longer stales caches or drops row memoization.
Timeline rows, turn status tails, per-session transcript stamps, and the navigation sidebar now track their exact visual and multi-window inputs without invalidating unrelated open tabs. Visual layout and behavior stay the same aside from fixing stale highlights, clipped footer fades, and multi-window redraw loops.

❌ Before

  1. Timeline row memos duplicated partial key tuples: find-in-session highlights missed tool groups and events, open tool groups missed copied ticks, file-change action state, async diagram/math updates, and trailing script output placement.
  2. Turn tail rows mutated fade state inside the memoized build closure, skipping fade transitions on cache hits, dropping model/elapsed metadata mid-fade, and invalidating on background session timer churn.
  3. Retry countdowns and shell followable-call scans lived in thread-locals shared across windows, causing multi-window redraw ping-pong and repeated full-transcript scans.
  4. Closing one tab rotated the shared transcript base epoch for every other open tab, shown_transcript_stamp hashed evicted unrelated transcripts whose session metadata was gone, and the sidebar cache missed server-source, unread-mark, hidden-server, and draft attachment/quote changes.

✅ After

  1. A shared row memo context stamps find highlights, palette/readability, geometry, and tool auxiliary state uniformly across row kinds, bypasses row caching while open groups render async diagrams/math or live calls, and forwards script change placement.
  2. Turn tail fade transitions advance up front on every frame, fading footers keep their metadata and sources until hidden, and working transition counters only advance when the active session changes state.
  3. Retry countdowns live on per-window working state and shell followable scans use a per-window keyed LRU cache.
  4. Closing a tab rotates only the absent-session epoch so sibling tabs stay warm, shown_transcript_stamp hashes only confirmed descendants, and the sidebar cache tracks and stamps every Tracked, Slot, and store generation read by collect_input.
- memo(turn_tail_key_with_stale_fades, || advance_fades_and_build_tail())
+ fades_mask = sync_fades_before_memo()
+ memo(row_memo_context + fades_mask, || build_tail_keeping_fading_footer_meta())

- on tab close: base_epoch = next_epoch() // invalidates every open tab
+ on tab close: absent_epoch = next_epoch() // open tabs keep base_epoch

📊 Cases

Case Before After
Find highlights, copied ticks, async math/diagrams, and script output placement in open tool groups ❌ Missed or stale under row memoization ✅ Covered via shared RowMemoContext
Turn tail fade transitions and fading reply footer metadata ❌ Skipped on memo hit; metadata vanished mid-fade ✅ Synced ahead of memo; metadata stays visible through fade
Multi-window retry countdowns and shell followable scans ❌ Shared thread-locals ping-ponged across windows ✅ Isolated per window (8-entry keyed LRU for shells)
Closing one session tab while other tabs stay open ❌ Rotated base_epoch for all loaded tabs ✅ Rotates absent_epoch only; sibling tabs stay warm
Sidebar cache on server switch, unread toggle, server hide, or draft attachment/quote edit ❌ Missed untracked inputs ✅ Tracked and stamped end to end

👀 Read: TranscriptEdits in apps/desktop/src/session/events/edits.rs (absent_epoch keeps removed sessions monotonic without tombstones while leaving base_epoch untouched for open tabs) and sync_fades in crates/session-view/src/timeline/tail.rs (running fade transitions ahead of TurnTail memo lookup). The rest is routine.

🔍 Found in a code audit · no user reports

Checks run
  • cargo check --bin opencode-desktop: pass
  • cargo check -p session-view --examples: pass
  • cargo check -p session-view --examples --features open-bench: pass
  • bash scripts/guardrails.sh: 11/11 passed
  • bun scripts/web-clock.ts: pass

…che gaps

- Unify timeline row memo keys via RowMemoContext so find highlights,
  forced palette mode, open-group auxiliary stamps, async Markdown/math
  bypasses, and script change placement stay consistent across row kinds.
- Advance TurnTail fade state before memo lookup and retain reply footer
  metadata/sources while fading out; scope Working::transitions bumps to
  active-session transitions.
- Move turn retry countdown and shell followable caches from process-wide
  thread-locals onto per-window state.
- Keep TranscriptEdits::base_epoch stable across single-tab closes via a
  separate absent_epoch, guard shown_transcript_stamp against absent
  session entries, and cover all sidebar inputs in NavState::cached_view.
@kitlangton
kitlangton merged commit 8725cd2 into dev Dec 4, 2026
8 checks passed
@kitlangton
kitlangton deleted the perf/row-memo-cache-audit-fixes branch December 4, 2026 14:38
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.

1 participant