CLI /resume hides VS Code sessions due to 16KB buffer truncation in session preview
Bug description
Terminal CLI /resume silently drops VS Code-originated sessions. On a project with 15 .jsonl session files, CLI shows only 3 (all CLI-created), while VS Code shows all sessions correctly.
Root cause
The by8 function reads only the first 16,384 bytes (AyR constant) of each .jsonl file to extract the session preview. The yy8 function then scans this buffer line-by-line for the first non-meta user message to populate firstPrompt.
VS Code sessions include base64-encoded images (screenshots, IDE context) in the first user message content array, making a single JSONL line ~61KB:
{
"type": "user",
"message": {
"content": [
{"type": "text", "text": "<ide_opened_file>...</ide_opened_file>"},
{"type": "image", "source": {"data": "...base64..."}},
{"type": "text", "text": "actual user prompt here"}
]
}
}
The preceding events (queue-operation + file-history-snapshot + progress) consume ~900 bytes, leaving ~15,400 bytes for the user message line. Since the line is ~61KB, it gets truncated at the buffer boundary. JSON.parse() fails on the partial line, yy8 returns "", and ky8 filters the session:
if (!_.firstPrompt && !_.customTitle) return null; // session silently dropped
Evidence
Tested on v2.1.42 (macOS, arm64). Reverse-engineered the compiled binary to trace the code path:
dpT(dir)— scans.jsonlfiles viareaddirSync(), validates UUID filenamesSNT(dir, limit, projectPath)— creates "lite" session entries sorted by mtimeV1T(sessions, startIndex, count)— callsky8per sessionky8(session, buffer)— callsby8to read first 16KB, then filtersby8(path, fileSize, buffer)—await B.read(A, 0, AyR, 0)whereAyR = 16384yy8(chunk)— line-by-line scan for first user message text
Session file analysis on one project:
| Origin | First user msg size | Fits in 16KB? | Shown in /resume? |
|--------|-------------------|---------------|-------------------|
| CLI | 472-496 bytes | Yes | Yes |
| VS Code (with image) | ~61,000 bytes | No — truncated | No |
| VS Code (no image) | untested | likely yes | likely yes |
All 4 VS Code sessions in the test project had exactly 15,443-byte first user messages (line 3 of the .jsonl), all truncated by the 16KB read.
Suggested fix
Replace the fixed-size buffer read with incremental line reading, or increase AyR significantly (e.g., 256KB+). The current 16KB is too small for any VS Code session that includes an image or large IDE context in the first message.
Alternatively, the ky8 filter could fall back to showing sessions without a firstPrompt rather than silently hiding them (VS Code already does this — it shows "No prompt" sessions).
Related issues
- #25032 — same symptom (sessions invisible in
/resume), attributed to stalesessions-index.jsonbut actual cause is this buffer truncation - #22723 — Desktop app not showing CLI sessions (different bug — Desktop app filtering)
- #12819 — VS Code
/resumeempty (possibly related, closed as stale)
Environment
- Claude Code v2.1.42
- macOS 14.6.1, arm64
- Binary:
~/.local/share/claude/versions/2.1.42(Mach-O, bundled JS)
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗