Load inline screenshots from Claude Code sessions - #271
mostafaseyedan wants to merge 2 commits into
Conversation
The Coding Moments gallery counts image-bearing Claude requests but can
never display them: every session shows "These sessions referenced
images, but the raw screenshots could not be loaded".
extractSessionImages dispatches on the .jsonl extension and assumes the
VS Code chat-session shape (kind/k/v envelopes, requests[].variableData
.variables). Claude Code also writes .jsonl, so its sessions take that
branch, match nothing and return an empty array. Claude stores images
inline on the user turn instead, as
message.content[].source = { type: 'base64', media_type, data }.
Add extractClaudeImagesFromJsonl and fall back to it when the VS Code
shape yields nothing. Matching is exact rather than heuristic: the
Claude parser already uses the entry uuid as the request id, so the
originating line can be located directly. The existing four-image cap
per request is preserved.
Verified against a real log set: 247 of 247 image-bearing requests now
resolve, where none did before.
|
Added a second commit: the extractor alone was not sufficient.
Verified through the RPC path rather than the extractor in isolation: Three assertions in |
Problem
The Coding Moments gallery counts image-bearing Claude Code requests, but cannot display a single one. Every Claude session lands on the empty state:
extractSessionImagesinsrc/core/parser-vscode-files.tsdispatches on the.jsonlextension and hands off toextractImagesFromJsonl, which assumes the VS Code chat-session shape —kind/k/venvelopes andrequests[].variableData.variables. Claude Code also writes.jsonl, so its sessions take that branch, match nothing, and return[].Claude stores images inline on the user turn instead:
{ "uuid": "…", "message": { "role": "user", "content": [ { "type": "text", "text": "what is wrong here?" }, { "type": "image", "source": { "type": "base64", "media_type": "image/png", "data": "…" } } ] } }Note the moments themselves are counted correctly —
parser-claude.tssetsvariableKinds.imageviacountClaudeImages— so the gallery advertises screenshots it can never render.Fix
Add
extractClaudeImagesFromJsonltoparser-claude.tsand fall back to it when the VS Code shape yields nothing.Matching is exact rather than heuristic:
parseClaudeRequestalready uses the entryuuidas the request id (parser-claude.ts), so the originating line is located directly by id rather than by scanning for image-shaped data. The existing four-image cap per request is preserved, as is the quickincludes(requestId)reject before parsing each line.Testing
Three unit tests added alongside the existing parser-claude tests: extraction by request id, the no-images and unknown-id cases, and the four-image cap. Verified they fail against a stubbed-out extractor (2 failed / 22 passed) and pass with it (24 passed).
Also verified end to end against a real log set spanning 17 project directories: 247 of 247 image-bearing requests now resolve, averaging 169 KB for the first image, where previously none did.
npm run typecheckandnpm run lintare clean (0 errors).