Repository navigation
Conversation
Greptile SummaryThis PR fixes image attachment loss across native-chat transcript refreshes for both Codex and Claude providers, and prevents native-chat file drops from leaking into other tabs, panes, or the workspace composer.
Confidence Score: 5/5Safe to merge — all three fix areas (Codex path parsing, Claude multi-image normalization, and per-pane drop routing) are exercised by focused regression tests, and the changes are internally consistent. The image path parser correctly handles POSIX, Windows drive-letter, and UNC concatenated paths, with whitespace as the intentional abort sentinel; the merge deduplication logic is simple and verified by property-based test cases. The normalizeImageTranscriptMessages refactor is conservative — it adds two new matching branches before the existing fallthrough, and the fallthrough itself (stripFirstImagePromptMarker) is a safe no-op for ordinary text. The tab/pane drop-scoping change is additive: workspace drops that previously passed the bare target check now go through isWorkspaceComposerNativeFileDrop, which uses the same target check plus null guards on the new fields, so no existing flow is disrupted. Files Needing Attention: No files require special attention.
|
| Filename | Overview |
|---|---|
| src/main/native-chat/codex-image-path-parser.ts | New module parsing concatenated Codex image paths from user_message text; handles POSIX, Windows drive-letter, and UNC paths with correct continuation logic for extension-like directory names and whitespace termination. Well-tested. |
| src/shared/native-chat-image-transcript-markers.ts | Extends normalizeImageTranscriptMessages to handle the prompt-first Claude schema and multiple source paths per turn; fixes imagePromptMarkerStartsMessage to check blocks[0] instead of find(isTextBlock), closing the latent false-match for Codex messages with leading image-ref blocks. |
| src/shared/native-file-drop.ts | Adds optional tabId/paneLeafId to NativeDropResolution and NativeFileDropPayload for the composer target; resolveNativeFileDropPath defers composer resolution to collect tab/pane identity; createNativeFileDropPayload and isNativeFileDropPayload correctly handle the new fields. |
| src/renderer/src/components/native-chat/use-native-chat-file-attachment-actions.ts | Adds terminalTabId and paneKey parameters; new nativeChatFileDropTargetsPane correctly extracts paneLeafId from the colon-delimited paneKey and enforces strict tab+pane identity matching, failing closed for malformed keys. |
| src/renderer/src/hooks/composer-native-file-drop.ts | New isWorkspaceComposerNativeFileDrop guard uses loose null check (== null) to exclude scoped native-chat drops from reaching the generic workspace composer, correctly matching both null and undefined. |
| src/main/native-chat/transcript-line-decoders-claude.ts | Allows [Image: source: ...] text blocks to pass through the injected-user-turn filter so image source records in meta/synthetic turns are preserved for normalizeImageTranscriptMessages to process. |
| src/main/native-chat/transcript-line-decoders-codex.ts | Wires codexUserMessageBlocks into user_message decoding, combining text-embedded path parsing with local_images field; codexLocalImagePaths defensively filters the unknown-typed field. |
| src/renderer/src/hooks/useComposerState.ts | Replaces the bare target check with isWorkspaceComposerNativeFileDrop, preventing scoped native-chat drops (with tabId/paneLeafId) from triggering the workspace composer handler. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Transcript refresh / remount] --> B{Provider?}
B -->|Codex| C[codexUserMessageBlocks]
C --> C1[parseLeadingCodexImagePaths]
C --> C2[codexLocalImagePaths]
C1 & C2 --> C3[mergeCodexImagePaths]
C3 --> C4[image-ref blocks + trimmed query text]
B -->|Claude| D[decodeClaudeTranscriptLine]
D -->|isMeta / isSynthetic| D1[allow Image source path blocks]
D1 --> D2[normalizeImageTranscriptMessages]
D2 --> E{Schema?}
E -->|source-first| F[merge source paths + strip marker from next]
E -->|prompt-first| G[merge source paths + strip marker from current]
E -->|lone source| H[lone image-ref block]
E -->|Codex image-ref + marker text| I[fallthrough stripFirstImagePromptMarker]
F & G & H & I --> J[Assembled NativeChatMessage]
K[Native file drop event] --> L{isWorkspaceComposerNativeFileDrop?}
L -->|yes| M[Workspace composer]
L -->|no| N[nativeChatFileDropTargetsPane]
N -->|match| O[Scoped NativeChatComposer]
N -->|no match| P[Rejected / other tab]
Reviews (3): Last reviewed commit: "Preserve root-level Codex image attachme..." | Re-trigger Greptile
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (19)
🚧 Files skipped from review as they are similar to previous changes (15)
Included review availability: Your plan includes up to 10 reviews per rolling hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe change restores multiple image references and associated prompt text in Claude and Codex transcripts. It adds path detection, local-image handling, and transcript normalization coverage. Native composer file drops now preserve terminal and pane context. Workspace and terminal composers use separate scope checks, with tests covering routing, payload creation, and validation. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/main/native-chat/transcript-line-decoders-codex.ts (1)
158-200: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winConsider extracting the Codex path-detection heuristics into their own module.
isAbsolutePathStart,firstImageExtensionEnd, andstartsWithNestedAbsoluteImagePathimplement a fairly intricate heuristic (POSIX, Windows, and UNC path detection, nested-path lookahead, ambiguous-suffix rejection) inside a transcript line decoder. These functions aren't exported, so they can only be exercised indirectly through full transcript-decoding tests.
Move this logic to a dedicated module (for examplecodex-image-path-parser.ts) with direct unit tests for the boundary cases already covered indirectly (directory names containing an extension-like substring, UNC vs. Windows vs. POSIX nested paths, ambiguous suffixes). This improves testability and keeps the decoder file focused on line decoding.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 5ea217d1-6dc6-493f-a06c-258605217570
📥 Commits
Reviewing files that changed from the base of the PR and between 94cf2f1 and bb48adc7e97aa3d2ea7406d4296be59e8cc14874.
📒 Files selected for processing (15)
src/main/native-chat/transcript-line-decoders-claude.tssrc/main/native-chat/transcript-line-decoders-codex.tssrc/main/native-chat/transcript-reader.test.tssrc/renderer/src/components/native-chat/NativeChatComposer.tsxsrc/renderer/src/components/native-chat/native-chat-pending.test.tssrc/renderer/src/components/native-chat/native-chat-session-assembler.test.tssrc/renderer/src/components/native-chat/use-native-chat-file-attachment-actions.test.tssrc/renderer/src/components/native-chat/use-native-chat-file-attachment-actions.tssrc/renderer/src/hooks/composer-native-file-drop.test.tssrc/renderer/src/hooks/composer-native-file-drop.tssrc/renderer/src/hooks/useComposerState.tssrc/shared/native-chat-image-transcript-markers.test.tssrc/shared/native-chat-image-transcript-markers.tssrc/shared/native-file-drop.test.tssrc/shared/native-file-drop.ts
|
@coderabbitai review |
|
@coderabbitai full review |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: f67eff9c-6274-4338-a5c1-20040a5203c4
📥 Commits
Reviewing files that changed from the base of the PR and between bb48adc7e97aa3d2ea7406d4296be59e8cc14874 and 02872cfdee260c21daf0b766f9717d7e7da8fe24.
📒 Files selected for processing (6)
src/main/native-chat/codex-image-path-parser.test.tssrc/main/native-chat/codex-image-path-parser.tssrc/main/native-chat/transcript-line-decoders-codex.tssrc/main/native-chat/transcript-reader.test.tssrc/shared/native-chat-image-transcript-markers.test.tssrc/shared/native-chat-image-transcript-markers.ts
🚧 Files skipped from review as they are similar to previous changes (4)
- src/shared/native-chat-image-transcript-markers.test.ts
- src/main/native-chat/transcript-line-decoders-codex.ts
- src/shared/native-chat-image-transcript-markers.ts
- src/main/native-chat/transcript-reader.test.ts
✅ Action performedReview finished.
|
✅ Action performedFull review finished. |
There was a problem hiding this comment.
♻️ Duplicate comments (1)
src/main/native-chat/codex-image-path-parser.ts (1)
75-84: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winHandle concatenated root-level POSIX paths (still unresolved).
directorySeparator > 1rejects a second path that has no further subdirectory, such as/b.pngin/a.png/b.pngcompare.value.indexOf('/', 1)returns-1for/b.pngcomparesince it contains no additional/, so the check fails and the parser folds two separate absolute paths into one invalid path/a.png/b.png.This is the same issue raised in a previous review round on this exact function; the code is unchanged and the problem persists. No regression test currently covers this case.
🐛 Proposed fix to drop the unnecessary nested-separator requirement
function startsWithNestedAbsoluteImagePath(value: string): boolean { if (value.startsWith('\\\\')) { return firstImageExtensionEnd(value) !== null } - if (!value.startsWith('/')) { - return false - } - const directorySeparator = value.indexOf('/', 1) - return directorySeparator > 1 && firstImageExtensionEnd(value) !== null + return value.startsWith('/') && firstImageExtensionEnd(value) !== null }Add a regression test for concatenated root-level paths, e.g.
parseLeadingCodexImagePaths('/a.png/b.pngcompare')should yieldimagePaths: ['/a.png', '/b.png']andquery: 'compare'.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 981823e1-c508-4aaf-b3b2-334da77c9940
📥 Commits
Reviewing files that changed from the base of the PR and between 94cf2f1 and 02872cfdee260c21daf0b766f9717d7e7da8fe24.
📒 Files selected for processing (17)
src/main/native-chat/codex-image-path-parser.test.tssrc/main/native-chat/codex-image-path-parser.tssrc/main/native-chat/transcript-line-decoders-claude.tssrc/main/native-chat/transcript-line-decoders-codex.tssrc/main/native-chat/transcript-reader.test.tssrc/renderer/src/components/native-chat/NativeChatComposer.tsxsrc/renderer/src/components/native-chat/native-chat-pending.test.tssrc/renderer/src/components/native-chat/native-chat-session-assembler.test.tssrc/renderer/src/components/native-chat/use-native-chat-file-attachment-actions.test.tssrc/renderer/src/components/native-chat/use-native-chat-file-attachment-actions.tssrc/renderer/src/hooks/composer-native-file-drop.test.tssrc/renderer/src/hooks/composer-native-file-drop.tssrc/renderer/src/hooks/useComposerState.tssrc/shared/native-chat-image-transcript-markers.test.tssrc/shared/native-chat-image-transcript-markers.tssrc/shared/native-file-drop.test.tssrc/shared/native-file-drop.ts
Preserve provider-specific transcript evidence while reconciling optimistic sends and routing native drops to their owning composer. Constraint: Codex 0.145 emits concatenated absolute paths while newer events may use local_images; Claude emits paired image markers. Rejected: Treat all provider transcripts as one shared schema | provider formats and ordering differ. Confidence: high Scope-risk: moderate Directive: Keep transcript schema handling provider-specific and require tab/pane scope for native chat composer drops. Tested: 7 targeted Vitest files (114 tests), typecheck, changed-code quality, max-lines ratchet, diff check, manual Codex before/after capture. Not-tested: Live remote SSH drag-and-drop on Linux or Windows. Co-authored-by: OmX <[email protected]>
Preserve duplicate Codex attachments across overlapping transcript schemas, isolate path heuristics behind direct tests, and require Claude prompt markers to occupy the first message block before pairing. Constraint: Codex may expose the same attachment through raw text and local_images while repeated paths remain distinct attachments. Rejected: Deduplicate all paths with a Set | it erases repeated attachments recorded by the authoritative local_images list. Confidence: high Scope-risk: narrow Directive: Merge Codex attachment schemas as multisets and keep provider pairing predicates anchored to the first block. Tested: pnpm lint; pnpm typecheck; pnpm build; 8 targeted Vitest files (120 tests); full Vitest suite with maxWorkers=1 (3,984 files, 42,158 tests passed); changed-code quality; max-lines ratchet; diff check. Not-tested: Live remote SSH drag-and-drop on Linux or Windows. Co-authored-by: OmX <[email protected]>
Constraint: Codex concatenates absolute attachment paths without delimiters. Rejected: Require a nested POSIX directory segment | loses root-level attachments. Confidence: high Scope-risk: narrow Directive: Keep root-level POSIX attachments covered alongside nested, Windows, UNC, and prose boundaries. Tested: pnpm lint; pnpm typecheck; changed-code quality; max-lines ratchet; pnpm build; 3,984 test files and 42,160 tests passed. Not-tested: Live Codex capture using files stored directly under the filesystem root. Co-authored-by: OmX <[email protected]>
Constraint: Latest main leaves NativeChatComposer at the max-lines boundary. Rejected: Merge adjacent source-only turns without a prompt marker | it duplicates later attachments into earlier messages Confidence: high Scope-risk: narrow Directive: Only collapse consecutive image-source turns when a matching prompt marker follows Tested: 8 targeted files, 164 tests; pnpm lint; changed-code quality; max-lines ratchet; git diff --check Not-tested: Full suite and build are blocked by unrelated current-main test fixture and runtime failures Co-authored-by: OmX <[email protected]>
34870cb to
a7e10e9
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
|
Rebased onto current |
|
|
Summary
local_imagestranscript fields.Screenshots
Before
The attachment is rendered twice: once as a raw file path and once as an attachment chip.
After
The attachment is preserved once in a single user message.
Testing
main(6ee265e57) and resolved transcript-normalization conflicts against the latest implementation.pnpm lintpnpm run check:code-quality:changed: 0 new findings across 19 changed files.pnpm run check:max-lines-ratchetgit diff --checkCurrent-main validation limitation
pnpm typecheckand thereforepnpm buildcurrently stop in unchangedopen-tab-search-retention.test.tsfixtures because the latestmainrequires adocumentfield onSearchableWorkspaceTabandSearchableBrowserPage. The PR does not modify those files or types. A full Vitest run was also attempted and stopped after unrelated current-main tab-search, terminal-emulator, browser-cookie, and runtime test failures appeared. The changed native-chat test surface remains green (164/164).AI Review Report
Greptile previously scored the change 5/5. CodeRabbit findings were addressed by extracting and directly testing the Codex path parser, preserving duplicate attachment multiplicity across overlapping schemas, anchoring Claude marker pairing to the first block, and covering root-level POSIX attachment paths. The refreshed branch also fixes a rebase-detected boundary where adjacent source-only image turns could otherwise be cross-merged. CodeRabbit's full review of rebased head
a7e10e91agenerated no actionable comments.The review surface covers provider schema boundaries, optimistic/transcript reconciliation, cross-tab and cross-pane ownership, workspace-composer isolation, pagination-window behavior, test adequacy, and maintainability. Path decoding covers POSIX, Windows drive-letter, and UNC paths. Folder-workspace and SSH execution boundaries remain unchanged; native drops fail closed unless their tab and pane identity matches.
CodeRabbit also reported a generic docstring-coverage warning. No docstrings were added solely for that external heuristic because the repository requires concise, non-obvious comments; the path/prose invariant is documented where it affects maintenance.
Security Audit
No auth, secrets, dependencies, command execution, or new IPC channels were added. Transcript paths are converted into local image references without file execution. Existing native-drop validation remains responsible for path count and byte limits, while the renderer narrows delivery to the exact tab/pane and prevents scoped native-chat drops from reaching the generic workspace composer.
Notes
Live remote SSH drag-and-drop on Linux and Windows was not manually exercised. Parser and routing behavior for those platforms is covered by unit tests.