[FIX] Rewind picker shows no pre-compact messages for sessions > 5 MB
Summary
When a session JSONL exceeds 5 MB and has been compacted at least once, the \"Rewind\" message picker shows no pre-compact messages — only post-compact messages and \"(current)\" are listed. The orphaned pre-compact branch is silently discarded before the picker ever reads it.
Root Cause
loadTranscriptFile has a two-stage size optimization for files over 5 MB (SKIP_PRECOMPACT_THRESHOLD):
Stage 1: readTranscriptForLoad is called, which returns only the post-compact-boundary bytes as buf. The entire pre-compact portion of the file is never loaded into memory.
Stage 2: walkChainBeforeParse walks the post-boundary DAG and strips any messages not on the main chain (orphaned nodes) before JSON parsing.
The keepAllLeaves option only gates Stage 2. Stage 1 fires unconditionally for large files, so even callers that pass keepAllLeaves: true receive a buffer that already has the pre-compact branch removed.
The rewind picker and the rewind execution path both call loadTranscriptFile to find orphaned pre-compact messages. On files > 5 MB, both get back a map that contains only post-compact messages, so the orphaned branch is never found.
Repro
- Start a session and exchange enough messages that the JSONL grows past 5 MB.
- Allow auto-compact to fire (or trigger it manually).
- Continue the post-compact session with a few more messages.
- Open the Rewind picker (
Ctrl+R/Cmd+R). - Observe: only post-compact messages and \"(current)\" are listed. Pre-compact messages are absent.
Expected Behavior
The Rewind picker should show user messages from before the compact boundary, allowing the user to rewind to any point in the full conversation history.
Fix
The keepAllLeaves option should also suppress Stage 1 (the readTranscriptForLoad truncation), not just Stage 2. When keepAllLeaves: true is passed, both optimizations should be bypassed so the full file is read.
Additionally, both call sites that populate the picker and execute the rewind should pass keepAllLeaves: true.
Environment
- Affects all platforms
- Trigger condition: session JSONL > 5 MB with at least one compact boundary
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗