Skip to content

fix: load Coding Moments images across all harnesses - #293

Merged
Sanjay Singh (san360) merged 7 commits into
mainfrom
fix/coding-moments-all-harnesses
Oct 21, 2026
Merged

Sanjay Singh (san360) merged 7 commits into
mainfrom
fix/coding-moments-all-harnesses

Conversation

@san360

@san360 Sanjay Singh (san360) commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Description

Fix Coding Moments showing image-bearing turns but no loadable screenshots, and fill the missing image-counting and source-loading paths for the other supported harnesses.

  • Dispatch image loading by the recorded harness source rather than the .jsonl extension.
  • Support VS Code/Insiders and remote variants, Copilot CLI/App, Claude (including merged and orphan subagents), Codex, OpenCode legacy JSON/current SQLite, and Xcode.
  • Match screenshots to the exact normalized turn, including Copilot assistant IDs versus user-event attachments, image-only turns, and mirrored Codex events.
  • Preserve source indexing across cold parsing and cache refresh/reload paths; invalidate older caches.
  • Extract on demand in the existing parse worker. Limit extraction to four images per turn and 10 MB per image, validate local file paths and image bytes, never fetch remote URLs/network shares, and never modify session logs or retain image payloads in the analytics cache.
  • Scope gallery caches to both session and request IDs so overlapping request IDs cannot mix up screenshots.
  • Add parser, source-index, image-limit, worker-lifecycle, Xcode SQLite, RPC, and browser regressions; document harness image support and limits.

Validation (Windows):

  • npm run check — passed: 82 test files; 1,625 tests passed, 5 skipped (Windows; Ubuntu CI also passed the POSIX-only regressions). Typecheck, lint, spellcheck, knip, and lockfile-lint also passed. Existing lint warnings remain non-blocking.
  • npm run test:e2e — passed: 110 tests passed, 7 skipped on the preceding implementation. Latest backend-only follow-up: npm run test:e2e -- image-gallery — passed, 3 tests.
  • npm run build — passed.
  • npm run check-size — passed: extension bundle 1.63 MB, below the 2 MB budget.
  • git diff --check — passed.
  • Native Xcode SQLite -> bundled parse worker -> image data URI smoke test — passed.

The full check required a checksum-verified official SQLite CLI on the validation process's temporary PATH for the existing GitHub App tests. The session-local tools were removed afterward; no dependency manifests or machine-wide settings were changed.

Review follow-up:

  • Addressed the remaining findings in d300d7c: nonblocking POSIX image opens with native FIFO/replacement regressions, and path-relative containment for Windows drive-root and POSIX-root workspaces. Local full check and Ubuntu CI both pass.

  • Addressed all seven Copilot review findings in 3b12b79: reject resolved/canonical network paths, support serialized file URIs and fsPath, preserve sibling image bytes, retain richer Codex mirror payloads, keep consecutive image-only turns distinct, and move full session reloads off the extension host with session-scoped OpenCode reads.

  • Addressed the four additional findings from the follow-up Copilot review in 1700b4e: fallback value bytes, canonical local roots, stable user identities for growing logs, and targeted early-stopping CLI/Codex extraction (zero normalized-request builds for 30 moments).

  • Addressed the final Claude lookup finding in 31a1a67 with targeted streaming UUID/generated-ID matching, transcript-relative roots, and zero normalized-request builds for 30 Claude images; removed obsolete full-parser collectors.

  • Addressed the final three reported edge cases in 01cd35d: matched-turn cwd, recursive inline/file fallbacks, and transcript-scoped generated Claude IDs with cache invalidation.

  • Addressed the additional Code Quality guard diagnostic in c37a69d, with malformed-worker-request coverage.

  • Addressed all fifteen actionable findings reported across the Copilot reviews, plus the Code Quality diagnostic, with regression tests and follow-up pushes. Inline review threads have been answered and resolved. The complete validation gate and build pass; human review remains requested.

Related Issues

Fixes #292.
Fixes #266.

Supersedes #271: this includes the Claude image-extraction/source-index fix and extends it to all supported harnesses. #271 is now closed in favor of this replacement.

Checklist

  • npm run check passes (typecheck + lint + spellcheck + knip + tests)
  • Changes are covered by tests (if applicable)
  • Documentation updated (if applicable)

Wire harness-aware source indexing, image counts, exact turn matching, bounded local decoding, and off-thread extraction through the existing parse worker. Preserve cache reloads and isolate gallery entries by session and request.

Fixes #292

Fixes #266

Supersedes #271.

Co-authored-by: Copilot <[email protected]>
@san360
Sanjay Singh (san360) requested review from Aymen (aymenfurter) and a balanced review from Copilot October 19, 2026 11:37
@github-actions
github-actions Bot requested a review from TamasBoncz October 19, 2026 11:38
@github-actions

Copy link
Copy Markdown

⚠️ Deprecation Warning: The deny-licenses option is deprecated for possible removal in the next major release. For more information, see issue 997.

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

Comment thread src/core/parse-worker.ts Fixed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Network-path validation, image selection, Codex turn matching, and blocking session reloads remain unresolved.

7 open issues
What changed in this PR

Extends Coding Moments image counting and loading across supported harnesses, addressing #292 and #266.

Changes:

  • Adds harness-aware extraction and session-source indexing.
  • Introduces worker-based image loading, size limits, and session-scoped gallery caching.
  • Adds regression coverage and documents supported image formats.
File Description
tests/​e2e/​image-gallery.spec.ts Tests gallery rendering and overlapping request IDs.
tests/​e2e/​harness.html Adds gallery navigation and mocks.
src/​webview/​panel-rpc.ts Validates ownership and dispatches image loading.
src/​webview/​panel-rpc.test.ts Tests dispatch and ownership checks.
src/​webview/​page-image-gallery.ts Scopes image caches by session and request.
src/​core/​session-images.ts Dispatches source-specific extraction and reloads.
src/​core/​session-images.test.ts Tests cross-harness extraction and indexing.
src/​core/​session-images-xcode.test.ts Tests Xcode image queries.
src/​core/​session-image-loader.ts Manages queued image-worker requests.
src/​core/​session-image-loader.test.ts Tests worker lifecycle and protocol.
src/​core/​parser.ts Preserves source indexing across parsing paths.
src/​core/​parser-xcode.ts Adds image counting and read-only extraction.
src/​core/​parser-vscode.ts Records workspace roots for attachments.
src/​core/​parser-vscode-files.ts Reconstructs image patches for extraction.
src/​core/​parser-vscode-cli.ts Associates attachments with normalized turns.
src/​core/​parser-shared.ts Supports additional trusted roots.
src/​core/​parser-opencode.ts Adds image counting, indexing, and readers.
src/​core/​parser-main.test.ts Updates source-index propagation tests.
src/​core/​parser-harnesses.ts Refreshes external source registrations.
src/​core/​parser-codex.ts Adds image counting and mirror handling.
src/​core/​parser-claude.ts Supports image-only turns and subagent sources.
src/​core/​parse-worker.ts Handles image-extraction requests.
src/​core/​image-data.ts Normalizes and validates image references.
src/​core/​image-data.test.ts Tests representations, limits, and path checks.
src/​core/​cache.ts Expands source types and invalidates older caches.
docs/​content/​getting-started/​supported-tools.md Documents image support and limits.
cspell.json Allows test-related vocabulary.
CHANGELOG.md Records the Coding Moments update.

Review effort: Balanced

Comment thread src/core/image-data.ts Resolved
Comment thread src/core/cache.ts Resolved
Comment thread src/core/image-data.ts Resolved
Comment thread src/core/image-data.ts Resolved
Comment thread src/core/image-data.ts Resolved
Comment thread src/core/parser-codex.ts Resolved
Comment thread src/core/parser-codex.ts Resolved
Preserve serialized URI and sibling-byte image variables, reject resolved network paths, and reconcile Codex image mirrors without merging distinct image-only user events.

Reload full session details in the existing parse worker and restrict OpenCode detail queries to the requested session. Add regression coverage for all seven Copilot review comments.

Refs #293, #292, #266.

Co-authored-by: Copilot <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 19, 2026 12:00
Comment thread src/core/parse-worker.ts Fixed
Rely on the dispatcher's existing non-null object check at the typed session-source predicate boundary, removing the redundant comparison reported by Code Quality. Verify malformed source descriptors are rejected and subsequent worker jobs still succeed.

Refs #293.

Co-authored-by: Copilot <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Valid symlinked-root images are rejected, and repeated full-session parsing can stall image and detail loading.

No open issues 🎉

2 previously missed issues

In code that hasn't changed since last review

Medium severity Canonicalize trusted roots before validating image paths

src/​core/​image-data.ts:200

This checks a canonicalized filename against noncanonical trusted roots. If a workspace root is a symlink or junction to a directory outside the default trusted roots (for example, /work/project → /mnt/project), the first check accepts its images but this check rejects them, so valid screenshots cannot load. Symlinked home or temporary roots have the same problem. Compare the canonical image path against consistently canonicalized allowed roots, preserving network-share rejection and protection against child symlinks escaping those roots. Add a symlinked-root regression.

Medium severity Avoid reparsing entire sessions for each image request

src/​core/​session-images.ts:80

Each image request fully reparses the CLI/Codex session, including unrelated responses and tool activity, even after collecting the requested turn. Loading 30 moments from one session therefore scans and rebuilds that session 30 times. The CLI parser explicitly supports multi-GB logs, and these jobs run serially in the same queue as detail reloads. This delays both features and can exceed the webview's 120-second RPC timeout, after which the gallery caches the images as unavailable. Use targeted extraction backed by turn offsets or a bounded per-source index, preserving normalized request IDs and keeping image payloads out of the analytics cache.

7 resolved since last review

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 19, 2026 12:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Image fallback, canonical-path validation, changing turn identities, and repeated full-session parsing remain unresolved.

No open issues 🎉

4 previously missed issues

In code that hasn't changed since last review

Medium severity Fallback to value bytes when sibling data is empty or invalid

src/​core/​image-data.ts:67

A valid byte dictionary in value is discarded whenever sibling data is present, even if data is an empty array. The previous value-first extractor loaded this representation; now it returns no image despite the recorded screenshot bytes. Keep data first to preserve the sibling-bytes fix, but retain value as a fallback when decoding data fails. Add a regression with valid value bytes and empty data.

Medium severity Canonicalize trusted roots before validating image paths

src/​core/​image-data.ts:200

The canonical image path is checked against noncanonical trusted roots. For a workspace such as ~/project pointing to /mnt/projects/project, the first check passes but this check rejects the screenshot when the target is outside the other trusted roots. The same mismatch affects macOS temporary paths when /var/folders/... resolves under /private/var/folders/.... Canonicalize the allowed local roots for this comparison, while retaining network-path rejection and rejecting attachment symlinks that escape those roots. Add regressions for both cases.

Medium severity Use stable userEventId for exact attachment matching

src/​core/​session-images.ts:71

CLI/App request IDs can change while a turn is active: a cached turn may have session:cli:0, but replaying the log after an assistant reply uses that reply's ID instead. The RPC still sends the cached ID, so this comparison misses the unchanged attachment and the gallery caches an empty result. Additional assistant messages can also replace an earlier assistant ID. Pass the cached turn's stable userEventId through the worker protocol for exact attachment matching, with an explicit fallback for records without that ID. Add a regression that appends a reply between parsing and extraction.

Medium severity Avoid rebuilding entire sessions for every image request

src/​core/​session-images.ts:80

Every image request rebuilds the entire CLI or Codex session, including unrelated responses and tool analysis. Thirty moments from one log therefore trigger thirty full parses. SessionImageLoader serializes these jobs, so gallery prefetching does not reduce that work and session-detail requests on the same queue must wait behind it. Batch extraction by source or use a targeted extraction path that preserves normalized turn matching without rebuilding every Session for each screenshot.

Review effort: Balanced

Retain value-byte fallbacks and canonicalize allowed local image roots without permitting network paths or escaping links. Match active Copilot turns by their cached user-event identity, with explicit index fallback for older records.

Use early-stopping CLI and Codex image scans instead of rebuilding full normalized sessions for every screenshot. Add parity, growing-log, canonical-root, and 30-image request-build regressions for the four follow-up Copilot findings.

Refs #293, #292, #266.

Co-authored-by: Copilot <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 19, 2026 12:36
@san360

Copy link
Copy Markdown
Contributor Author

Follow-up to Copilot review 5571409865: all four additional findings are fixed in 1700b4e.

Finding Fix and regression evidence
Valid value bytes lost when sibling data is empty/invalid Preserve value/URI alternatives and use them when primary data cannot decode; three concrete sibling-data regressions pass.
Canonical local root aliases rejected Validate against canonical forms of the matching trusted local roots; workspace/temp aliases load, and escaping attachment links and network paths remain rejected.
Active CLI/App turn IDs change after parsing Pass the cached userEventId and explicit turn index through RPC/worker matching; append-between-parse-and-extract regressions pass for CLI, App, and older ID-less turns.
Full session rebuilt for each image request Use targeted early-stopping CLI/Codex image scans with shared turn-matching semantics. Thirty-image regressions now build zero normalized requests, versus 900 before the change. Complex Codex tool/token/mirror/abort parity and streaming early-stop tests also pass.

Validation: npm run check passed (82 files; 1,612 passed, 3 skipped), npm run build passed, npm run check-size passed (1.63 MB), git diff --check passed, and npm run test:e2e -- image-gallery passed (3 tests). Requesting a fresh Copilot review and re-running the full browser suite on this head.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Claude image lookups repeatedly rebuild entire transcripts, delaying image and session-detail requests on the shared worker queue.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Avoid reparsing the full session for each Claude image lookup

src/​core/​session-images.ts:83

Each Claude image lookup invokes the full session parser, rebuilding every normalized request and repeating assistant/tool analysis even after the requested image is collected. Loading 30 moments from an N-turn transcript therefore performs 30 × N request builds; merged subagents also require reparsing preceding files. Image and session-detail jobs share a serialized queue, so this unnecessary work delays both. Add a targeted Claude image scan that stops at the matching user UUID, preserves generated-ID matching, and resolves relative images using the transcript's workspace root. Extend the existing no-request-rebuild regression to cover Claude.

Review effort: Balanced

Scan directly to Claude user UUIDs or exact generated request IDs, retaining transcript workspace roots for relative images and merged subagent sources. Extend the 30-image zero-request-build regression to Claude and cover roots recorded after image turns.

Remove obsolete full-parser image collectors now that all JSONL image paths use targeted extraction. Refs #293, #292, #266.

Co-authored-by: Copilot <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 19, 2026 12:53
@san360

Copy link
Copy Markdown
Contributor Author

Addressed the remaining Claude lookup finding from review 5571709256 in 31a1a67.

Claude screenshots now use a targeted streaming user-turn scan, preserving native UUID and exact generated-ID matching, including merged/orphan subagent sources. Relative image paths use the transcript workspace, including when cwd is first recorded after the image turn. The scan never builds normalized session requests or analyzes assistant/tool output. Removed the now-unused full-parser image collectors.

The 30-image zero-request-build regression now covers Copilot CLI, Codex, and Claude; all three previously produced 900 request builds and now produce zero. The full gate passed: 82 test files, 1,615 tests passed, 3 skipped. Build, 1.63 MB bundle budget, and whitespace checks passed. The full browser suite also passed on the preceding extraction commit (110 passed, 7 skipped); running it again alongside the final review.

All twelve actionable Copilot findings reported across the reviews have now been fixed and pushed on this branch.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unresolved image identity, directory selection, and fallback handling defects can display incorrect screenshots or hide available images.

1 open issue
2 previously missed issues

In code that hasn't changed since last review

Medium severity Fall back to fileUrl when inline attachment data is invalid

src/​core/​image-data.ts:65

An Xcode reference containing both a valid fileUrl and empty or invalid data loses its file location here. For example, { fileUrl: 'file:///.../screen.png', data: '' } is counted, but extraction rejects the empty payload without trying the existing file. Preserve the location as a fallback after the inline data, and add a regression for this combination.

Medium severity Prevent ID collisions across UUID-less parent and subagent turns

src/​core/​session-images.ts:82

UUID-less parent and subagent turns sharing a sessionId both generate IDs such as <sessionId>:claude:0: buildClaudeRequest restarts the index for each transcript, and merging preserves those IDs. This loop then returns the parent's screenshot for both image-bearing turns, and the gallery's session/request cache key also collides. Make generated IDs transcript-scoped and use the same identity during extraction. Add a regression with distinct parent and subagent images without UUIDs.

Review effort: Balanced

Comment thread src/core/parser-claude.ts Resolved
Use the matched Claude turn cwd for relative attachments and scope generated request IDs to their transcript to keep UUID-less parent/subagent images distinct. Invalidate older cache identities.

Preserve local-file alternatives when inline attachment data is empty or invalid, including nested image variables. Add regressions for all three remaining Copilot findings. Refs #293, #292, #266.

Co-authored-by: Copilot <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 19, 2026 13:09
@san360

Copy link
Copy Markdown
Contributor Author

All findings in Copilot review 5571915759 are addressed in 01cd35d:

  • Relative Claude attachments now prefer the matched user turn's cwd. A two-directory/two-image regression prevents loading the earlier turn's screenshot.
  • Inline attachment data retains fileUrl/local-location alternatives even when empty or invalid. This also preserves nested image-variable fallbacks; four new regressions cover these paths.
  • UUID-less Claude request IDs now include deterministic transcript identity, shared by normalization and extraction, so merged parent/subagent turns cannot collide. Distinct-image parent/subagent coverage passes, native UUIDs are unchanged, and older caches are invalidated.

All fifteen actionable findings reported across the Copilot reviews, plus the additional Code Quality diagnostic, now have fixes pushed to this branch. Inline review threads have been answered and resolved.

Final local validation: npm run check passed (82 files; 1,621 tests passed, 3 skipped), npm run build passed, npm run check-size passed (1.63 MB), and git diff --check passed. Waiting for final-head CI and the complete browser-suite rerun; human review from Aymen (@aymenfurter) remains requested.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Cross-platform path handling and shared worker lifecycle still need corrections and final human verification.

1 open issue
1 previously missed issue

In code that hasn't changed since last review

Medium severity Root workspace paths fail attachment containment checks

src/​core/​parser-shared.ts:36

A drive-root workspace such as D:\ already ends in a separator. Appending another separator makes D:\Screenshots\screen.png fail this prefix check. If no other trusted root covers the attachment, Coding Moments counts it but cannot load it. Use path-relative containment and add a drive-root regression; the same issue affects a POSIX / workspace.

1 resolved since last review

Review effort: Balanced

Comment thread src/core/image-data.ts Resolved
Use nonblocking POSIX file opens before descriptor regular-file validation, including when an attachment is replaced by a FIFO before opening. Use path-relative trusted-root containment so filesystem-root workspaces and Windows drive roots do not fail prefix checks.

Add bounded native FIFO/race regressions, descriptor cleanup checks, and root/sibling/traversal coverage. Refs #293, #292.

Co-authored-by: Copilot <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 20, 2026 11:34
@san360

Copy link
Copy Markdown
Contributor Author

Addressed the two remaining findings from Copilot review 5572107727 in d300d7c:

  • FIFO attachments: use nonblocking POSIX opens before descriptor regular-file checks. Rejected descriptors close cleanly and other image candidates still load. Real FIFO and file-to-FIFO replacement regressions run in bounded subprocesses and passed in Ubuntu CI.
  • Filesystem-root workspaces: replace separator-appending prefix checks with path-relative containment. Windows drive roots (including differing case), POSIX /, exact roots, different drives, sibling directories, and traversal rejection have regression coverage.

Validation:

  • npm run check — passed on Windows: 82 files, 1,625 tests passed, 5 skipped (including the two POSIX-only FIFO tests).
  • Ubuntu CI verify — passed, including the native FIFO/replacement tests and POSIX root containment. All latest-head CI checks passed.
  • npm run test:e2e -- image-gallery — passed, 3 tests.
  • npm run build, npm run check-size (1.63 MB), and git diff --check — passed.

No runtime dependencies or user-session data were changed. The existing test suite needed a checksum-verified SQLite CLI temporarily on the local validation process PATH; it has not been added to the project or machine-wide settings.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Filesystem-root image resolution remains incorrect, and the cross-platform parser, filesystem, and worker changes warrant final human review.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Filesystem-root workspaces lose separators, breaking relative image resolution

src/​core/​parser-vscode.ts:247

Filesystem-root workspaces lose their root before this assignment. workspaceLocationFromJson strips all trailing slashes, so parseWorkspaceFolderPath returns null for file:/// and D: for file:///D:/. path.normalize cannot restore the missing root separator. Relative screenshots then resolve against the transcript directory or a drive-relative directory instead of the workspace root, leaving images unavailable or selecting the wrong file. Preserve root separators in the JSON and CLI workspace-folder helpers, and add source-registration tests that load a relative image from a filesystem-root workspace; the existing assertTrustedPath tests bypass these helpers.

1 resolved since last review

Review effort: Balanced

@san360
Sanjay Singh (san360) merged commit f3a25fe into main Oct 21, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants