Skip to content

fix(web): F3 defer parked tabs' cache replay to first activation (WI-127) - #669

Closed
thedancingdeveloper wants to merge 1 commit into
feat/terminal-attach-f1-bound-replayfrom
feat/terminal-attach-f3-lazy-cache-replay
Closed

thedancingdeveloper wants to merge 1 commit into
feat/terminal-attach-f1-bound-replayfrom
feat/terminal-attach-f3-lazy-cache-replay

Conversation

@thedancingdeveloper

Copy link
Copy Markdown
Contributor

Third PR of the terminal-attach-budget initiative (WI-121). Stacked on #668 (F1) so the diff is F3-only; all land on feat/terminal-attach-budget.

The bug (WI-127)

On reload, every retained terminal tab replayed its cached tail (≤ 1 MiB each) immediately, through the single global replay FIFO, round-robin with the active pane. With N retained tabs the visible pane got 1/N of the parser — the "reload is slow" half of the terminal budget bug — then pre-warm cold-attached up to 8 more sessions on top.

The fix

A parked pane (retained-but-not-active, or the unfocused half of a split) now keeps its prepared cache tail in memory and replays it lazily on first activation (resumeSocket, before connect()), instead of scheduling into the shared FIFO on load. The active pane still replays immediately, so its restore is no longer time-sliced against tabs the user cannot see. The cache position is adopted at load time, so a warm reattach resumes correctly even if a re-park cancels the deferred replay before it runs.

The decision is a pure helper shouldDeferCacheReplay(parked, hasCachedBytes), unit-tested here. The six-cached-tabs end-to-end assertion (active pane replay unaffected by other tabs) lands with H3's mocked Playwright spec (WI-124) — that is F3's stated acceptance.

Verification

  • pnpm typecheck clean; pnpm vitest909 passed (incl. new shouldDeferCacheReplay.test.ts).

🤖 Generated with Claude Code

https://claude.ai/code/session_01UtEFLJAhLiq4NfZCN2vuBb

On reload every retained terminal tab replayed its cached tail (up to 1 MiB)
immediately, through the single global replay FIFO, round-robin with the active
pane. With N retained tabs the pane the user is actually looking at got 1/N of
the parser — the reload-is-slow half of the terminal budget bug.

A parked pane (a retained tab that is not active, or the unfocused half of a
split) now keeps its prepared cache tail in memory and replays it lazily on
first activation in resumeSocket(), before connect(), instead of scheduling it
into the shared FIFO on load. The active pane still replays immediately, so its
restore is no longer time-sliced against tabs the user cannot see. The cache
position is adopted at load time so a warm reattach resumes correctly even if
the deferred replay is later cancelled by a re-park.

The decision is a pure helper, shouldDeferCacheReplay(parked, hasCachedBytes),
unit-tested here; the six-cached-tabs end-to-end assertion lands with H3's
mocked Playwright spec (WI-124).

Verification: pnpm typecheck clean; pnpm vitest 909 passed. WI-127.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UtEFLJAhLiq4NfZCN2vuBb
@thedancingdeveloper

Copy link
Copy Markdown
Contributor Author

Cleanup: superseded by the single promotion PR #676. All of this work is already integrated into feat/terminal-attach-budget and is reviewable there per-commit (each commit is one initiative item with a full message). Closing to keep the initiative to one PR; the commit is preserved.

@thedancingdeveloper
thedancingdeveloper deleted the feat/terminal-attach-f3-lazy-cache-replay branch September 9, 2026 20:59
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