Repository navigation
fix(native-chat): scope composer file drops to the pane that received them - #19328
Conversation
… them A native OS file drop resolving to `target: 'composer'` carried no pane identity, so the window-wide payload was attached by every mounted composer. Because inactive chat tabs stay mounted (hidden), one drop populated every chat pane's attachment cache, and those chips replayed whenever the user returned to a tab they never dropped into. The workspace-creation composer and chat composers also leaked into each other, since neither could tell which surface actually received the drop. Composer drops now carry a `scopeKey` the way a terminal drop carries its tab and pane leaf id: the composer publishes its pane key as `data-composer-scope-key`, the preload harvests it during the composedPath walk, and each composer attaches only its own. The workspace composer's last-wins ownership stack now claims unscoped payloads only.
…oping test The repro that landed on main asserts the pre-fix behavior (a drop reaching every mounted composer), so it fails once drops are scoped to the pane that received them. Its scoping cases now live in native-chat-composer-drop-scope.test.tsx, which keeps its editor-target control case verbatim and adds coverage for unscoped composers and a scope key published inside the drop-target marker.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 10 included reviews per hour; 0 remain after this review. 📝 WalkthroughWalkthroughNative file-drop paths and payloads now carry an optional composer scope key. Native chat composers publish their pane key on the drop target and pass it to the attachment hook. The hook accepts drops only when the payload scope matches its composer. Local paths require authorization before attachment, while SSH paths bypass local authorization. Tests cover scope propagation, validation, pane isolation, attachment authorization, and SSH uploads. Merge Risk: ⚪ Minimal · up to Native file drops are scoped to the receiving chat composer, while workspace drops remain unscoped and local attachment paths are authorized before use. Current coverage indicates the intended isolation and attachment behavior is ready to merge. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description is detailed and covers the change, motivation, testing, visual proof, security, compatibility, and checklist items. However, the required Linked Issue section is incomplete because it contains
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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.
ℹ️ No critical issues — one minor coverage gap suggested inline.
Reviewed changes
- Drop-path scoping —
resolveNativeFileDropPathnow carries the receiving composer'sscopeKey, accumulated innermost-first liketerminalPaneLeafId. - Payload plumbing — the composer variants of
NativeDropResolution/NativeFileDropPayloadgain an optionalscopeKey;createNativeFileDropPayloadforwards it andisNativeFileDropPayloadvalidates it as an optional string. - Chat composer gating —
NativeChatComposerFieldpublishespaneKeyasdata-composer-scope-keyon the drop-target marker;useNativeChatFileAttachmentActionsattaches only whenpayload.scopeKeymatches. - Workspace composer gating —
useComposerDropListenernow claims only unscoped composer payloads. - Tests — a full-pipeline scoping test supersedes the bug-asserting repro, plus unit coverage for resolution, payload creation, and payload validation.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Workspace-composer drop isolation test —
native-chat-composer-drop-scope.test.tsxnow mounts aWorkspaceComposerProbeagainst the realuseComposerDropListener, asserting that a scoped native-chat drop is ignored by the workspace stack while an unscoped drop still reaches it.
This closes the one coverage gap from the prior review. The new test asserts exact behavior on both sides of the split (workspaceDrop not called for a scoped payload, called exactly once with the paths for an unscoped one), so it genuinely fails if either half of the fix regresses.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
|
Review session complete at The scoped review is clean after two review/fix rounds and an independent final The existing infrastructure is the right fit: the composed-path resolver identifies the recipient, the validated single IPC batch preserves that identity, and each composer enforces ownership before attachment/cache/upload work. No production refactor was warranted. Pushed one focused regression improvement: a mounted workspace composer and sibling chat cannot consume the receiving chat's drop, while ordinary workspace drops still work. Validation:
Limits: the workspace modal prevents a real chat drop while it is open; simultaneous listener isolation is proven by the regression test. Attachment tiles and backing paths were verified, but thumbnail/full-size preview rendering was not established (valid PNGs displayed placeholders in the hidden session). Native picker, agent submission, and physical Windows/Linux/SSH/mobile runs were not exercised. Grok could not run because its weekly usage limit was exhausted; Codex performed Electron QA. The latest commit's typecheck and static analysis are green; test shards and packaging are still running. Working tree is clean. No merge performed. |
|
Follow-up fixed at Native chat now uses the existing selected-path authorization API before adding local attachments. Grants remain limited to supplied paths; no temporary-directory blanket grant or generic preview-reader bypass. SSH upload routing is unchanged. 80 focused tests, web typecheck, and changed-code quality gates passed. The regression fails against the original intake. Independent high-effort review and readiness/performance checks are clean. Fresh isolated hidden Electron proof: an external PNG read was denied before the actual native CDP drop; afterward both thumbnails decoded at 96×96 and the full-size preview displayed real pixels. An undropped neighboring file stayed denied. Chat B stayed empty, and a reverse drop into B left A unchanged. This resolves the earlier preview-rendering caveat—it was an authorization bug, not a hidden-window limitation. No merge performed. User's manual instance was left running; automated instance was cleaned up. Native picker, submission, and live SSH/other-platform execution remain untested in this follow-up. |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes since the prior pullfrog review at 423cd1a (e8bf3ea, the "authorize external attachment paths before preview" commit):
- Local-path authorization before attach —
useNativeChatExternalAttachmentsnow authorizes each non-SSH path viawindow.api.fs.authorizeExternalPathbefore callingattachResolvedPaths, mirroring the workspace composer'sapplyLocalComposerDropso out-of-roots dropped images can actually read into the preview. - Disabled-state recheck across the await — the authorize loop bails on
disabledRef.currentand a final check gates the attach, so a composer flipped disabled mid-authorization never receives attachments. - Integration + unit coverage — the drop-scope test now drives the real
NativeChatImageAttachmentPreview(asserting authorize order/count and rejecting an un-authorized sibling read), anduse-native-chat-external-attachments.test.tsxgains cases for skip-rejected, disabled-mid-authorization, and SSH no-local-authorization.
The change faithfully follows the existing workspace-composer pattern (authorizeExternalPath then skip unreadable paths on failure), the sequential loop preserves order, and the new tests would fail without the fix rather than assert tautologically.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
|
Additional independent review completed at The fix reuses the existing drop pipeline and workspace-composer pattern: route to the receiving pane, authorize each selected local path through the existing filesystem API, then publish attachments for preview. No additional infrastructure or broader refactor is needed. CI is now green: all eight test shards, typecheck, static analysis, macOS/Windows packaging, and the final The existing Electron preview/isolation screenshots and validation remain in the previous status comment: #19328 (comment). This additional review did not repeat live platform UI QA. Working tree is clean; no further changes were needed and the PR has not been merged. |








ELI5
Dropping an image into one Chat composer put that image into every open Chat composer. Background chat tabs stay loaded (just hidden), so they silently collected images you never dropped on them, and the images were still sitting there when you came back to the tab. Now a dropped image only lands in the composer you actually dropped it on.
What Changed
A native OS file drop that resolves to
target: 'composer'now carries the identity of the composer that received it.NativeChatComposerFieldpublishes its pane key asdata-composer-scope-key, on the same element that already carriesdata-native-file-drop-target="composer".composedPath()walk and stamps it onto the payload asscopeKey(src/shared/native-file-drop.ts,src/preload/preload-runtime-support.ts).payload.scopeKeymatches its own (use-native-chat-file-attachment-actions.ts).scopeKey, so the two composer families stop stealing each other's drops (composer-drop-listener.ts).This mirrors what the
terminaltarget already does — it carriestabId/paneLeafIdand each pane discards payloads that aren't its own.scopeKeyaccumulates innermost-first exactly liketerminalPaneLeafId.paneKeywas already the pane's identity (it keys the draft and attachment caches), so nothing new was invented.Why
The drop payload is broadcast window-wide (preload → main → every renderer subscriber). Every other target disambiguates itself;
composerwas{ paths, target }with no identity, so all subscribers took it.That mattered because
StructuredAgentSessionPaneOverlayLayermounts every agent-session tab and hides inactive ones withdisplay: none. One drop therefore wrote into every mounted chat pane's attachment cache, which replays on mount — hence images reappearing in a tab that never received a drop.Failure modes are safe: an unscoped payload routes to the workspace stack rather than a wrong pane, and the composer branch still sits after path-count/size validation so oversized drops keep rejecting.
Linked Issue
No GitHub issue exists — reported internally as a P0 in Slack with a reproduction script attached. That script is now a test (see below).
Fixes #
Visual Proof
Same Codex Chat tab in both shots — an untouched session ("Start a chat with Codex", never used) after an image was dropped into a different chat tab.
Before — two images the user never added:
After — composer is clean:
Testing
Verified end-to-end in the running app (macOS) on an isolated dev profile with two real Codex Chat tabs, using CDP
Input.dispatchDragEventwith real on-disk PNGs so Chromium's actual drag machinery runs andwebUtils.getPathForFileresolves genuine paths. A synthetic DOMdropcannot test this —getPathForFilereturns'', the handler bails atpaths.length === 0, and "nothing happened" looks identical to a pass.Chip counts on the two panes, dropping into the visible one:
The ablated row is the pre-fix bug reproduced live. Both directions of the cross-surface leak are covered.
Automated: 6967 tests pass across native-chat, hooks, shared, preload, main/window and terminal-pane;
tscclean on web, node and cli; changed-code quality gate reports 0 new findings.The repro script from the Slack thread landed on main as
native-chat-cross-pane-image-drop-repro.test.tsx, asserting the pre-fix behavior. It is superseded here bynative-chat-composer-drop-scope.test.tsx, which keeps its editor-target control case verbatim and adds: correct per-pane scoping, unscoped-composer drops reaching no chat pane, and a scope key published inside the drop-target marker. A separate test asserts the real component renders the scope key on the marker element itself — the walk stops there, so a key anywhere else would silently never reach the payload.Platforms: exercised on macOS. The change is platform-neutral (no paths, no shell, no OS APIs); the web preload shim's
onFileDropis a no-op stub, and no mobile code constructs composer payloads.Review
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
scopeKeyis optional. A payload without one behaves as before for the workspace composer and is ignored by chat composers, so no drop can land in a wrong pane during a mixed state.isNativeFileDropPayload), and the relay is already gated to the window's ownwebContents. Length is uncapped, matching the existingtabId/paneLeafIdposture.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)