Skip to content

feat(native-chat): show a drop target on the whole chat pane - #20561

Merged
brennanb2025 merged 3 commits into
mainfrom
brennanb2025/native-chat-pane-drop-target
Sep 14, 2026
Merged

brennanb2025 merged 3 commits into
mainfrom
brennanb2025/native-chat-pane-drop-target

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

You can drag a file into a chat, but only if you hit the small input box, and nothing on screen told
you that. Now the whole chat pane accepts the file and shows you so while you are dragging.

What Changed

The chat view is the drop surface. While a drag carrying files is over it, the pane dims behind a
card naming what the drop will do, and a drop anywhere in the pane attaches to that chat's composer.

The composer's attach logic is unchanged — the same workspace, execution-host and SSH-owner checks
run, just from a wider element. The mounted composer publishes its current handlers and scope key to
the surface around it; nothing validates a path in the new code.

Two routes reach the composer and they are widened differently:

  • In-app drags (File Explorer, diff tree) are claimed in the renderer, so the surface calls the
    composer's existing handlers.
  • OS drags (Finder/Explorer) are delivered by the preload route, which consumes the drop at
    document before React sees it. The pane widens that route by publishing the composer's scope key
    as the nearest drop marker, and learns the drag ended from document drop/dragend listeners instead
    of a React drop. That asymmetry is deliberate and is why the surface does not mirror one set of
    handlers for both.

The surface lives in NativeChatView, which is the common entry point for both chat surfaces:
terminal-backed chat panes and standalone structured-session tabs (the pane overlay layer). An
earlier revision of this PR mounted it in the terminal-pane portal and therefore missed standalone
structured chats entirely; review caught that and moved it.

Behavior change worth calling out

Dropping a file on the transcript used to fall through to the terminal behind the chat, which
pastes the paths into the hidden TUI. It now attaches to the composer. That is the point of the
change, but it is a change in behavior, not only a new visual.

States that stay as they are

  • No composer mounted (a question card owns the input region): no marker, no overlay, the drag stays
    the terminal's.
  • Guarded composer: it still answers for the drag — that refusal is what keeps the drop out of the
    terminal behind the chat — but the pane does not invite a drop it will refuse, and a composer that
    becomes guarded mid-drag clears the invitation.

Why

#20494 added the capability; this makes it discoverable. The input box sits at the bottom of the
pane, so someone dragging out of the File Explorer never looks there, and a drag aimed at the
transcript silently did something else entirely.

Linked Issue

No separate issue. This follows up #20494, which added the drag-and-drop capability, and #15782, the
silent-failure bug behind it.

Visual Proof

After — real chat pane in a background Electron instance: the invitation while dragging, and the
attached path after the drop.

Drop invitation

Explorer drop completed

Before — nothing appeared while dragging and only the input box accepted a drop, so a before
shot of this surface is the pane with no drag in flight: visually identical to idle.

Full QA coverage, including a native absolute-path CDP drop and the stale-invitation sequences, is
in this comment. What that
does not cover: a physical Finder gesture, and Windows/Linux desktop gestures.

Testing

  • All 28 CI checks resolved: 17 pass, 11 skipped, 0 failing, 0 pending (includes typecheck, static
    analysis, all eight test shards, packaging on macOS and Windows, and pullfrog).
  • Locally at head 83d3315cbf: the four drop-related suites pass (38 tests) — pane routing, the
    standalone structured-view surface, composer workspace drops, and composer drop scope.
  • pnpm test src/renderer/src/components/native-chat/ and .../terminal-pane/ both pass.
  • New tests cover: a drop on the transcript routing to the composer that claimed the pane, the OS
    route marker, the no-composer case, the guarded composer, guard transitions mid-drag, child
    boundary flicker, drop-completion listeners being live before the hover renders, and listener
    cleanup following composer ownership.
  • pnpm run check:code-quality:changed, React Doctor, max-lines ratchet, and the four localization
    gates pass.

Platforms exercised: macOS. No platform-conditional code — the drag types and the preload marker
route are identical on all three.

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

AI Disclosure

Review

Reviewed with a same-model review loop until clean, plus start/end readiness passes and rendered
Electron QA. Review fixes on this branch:

  • Moved the surface from the terminal-only portal into the common chat view, so standalone
    structured chat tabs get the drop target too.
  • Cleared a stale invitation when the composer's guard state changes mid-drag.
  • Registered the drop-completion listeners before the hover renders, so a fast drop cannot leave a
    late overlay behind.
  • Removed a render-time ref mutation that static analysis flagged.

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Security: no new IPC and no new path handling; every authorization and ownership check the
    composer already ran is untouched.
  • Cross-platform: no platform branches added; not exercised on Windows/Linux desktops.
  • Remote SSH: the SSH-owner check and upload path are the composer's existing ones; the surface
    only changes which element the drag is read on.
  • Mobile: untouched; this is desktop chat-pane chrome.
  • Backwards compatibility: no wire contract, persisted data, or schema touched.
  • Performance: two stable document listeners per registered surface, no polling and no dragover
    subscription churn; repeated dragover sets the same state value, so React bails out rather than
    re-rendering the transcript.

Checklist

  • This PR is small and focused
  • I explained what changed and why (including ELI5)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

Dropping a file into a chat only worked if you hit the input box, and nothing
on screen said so. A drag aimed at the transcript fell through to the terminal
behind the chat, which pastes the paths into the hidden TUI.

The chat pane shell is now the drop surface. While a drag carrying files is
over it, the pane dims behind a card naming what the drop will do; the
composer's existing attach logic — workspace, execution-host and SSH-owner
checks included — runs unchanged from the wider element.

Two routes reach the composer and they are widened differently:

- an in-app drag is claimed in the renderer, so the pane calls the composer's
  handlers through a claim the composer publishes to the surface around it.
- an OS drag is delivered by the preload drop route, which consumes the event
  at `document` before React sees it. The pane widens that route by publishing
  the composer's scope key as the nearest drop marker, and learns the drag
  ended from a document-level listener rather than a React drop.

The surface lives in the chat portal because that is the one place wrapping
both the bridge and structured panes, so neither pane root grows a second copy
of this wiring.

No composer mounted (a question card owns the input region) means no marker and
no overlay, so that drag stays the terminal's. A guarded composer still answers
for the drag — that refusal is what keeps it out of the terminal — but the pane
does not invite a drop it will refuse.

@pullfrog pullfrog Bot 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.

Important

The drop surface is mounted in only one of the two production places a chat composer renders. StructuredAgentSessionPaneOverlayLayer (agent-session tabs) renders NativeChatView mode="structured" with no surface ancestor, and the composer field no longer attaches the workspace-drop handlers itself — so in-app file drags onto those composers now silently do nothing. See the inline comment.

Reviewed changes

  • New pane-wide drop surface (NativeChatPaneFileDropSurface.tsx) — context that lets a mounted composer publish a drop claim; the shell div then owns the composer drop marker, the React capture handlers, and the dimming overlay.
  • Drag classification (native-chat-pane-file-drop.ts) — distinguishes in-app workspace drags (claimed in the renderer) from os drags (delivered by the preload route), plus a child-boundary flicker guard for dragleave.
  • Composer publishes its claim (use-native-chat-workspace-file-drop.ts) — useNativeChatPaneFileDropClaim({ scopeKey: paneKey, disabled, … }) replaces the directly-attached handlers; the field prop workspaceFileDropHandlers is removed.
  • Portal becomes the surface (TerminalPaneNativeChatPortal.tsx) — the shell <div> is replaced by NativeChatPaneFileDropSurface.
  • New tests + i18n — native-chat-pane-file-drop.test.tsx (9 cases) and updated composer-drop probe; components.native-chat.drop.{title,subtitle} added to en.json.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@coderabbitai

coderabbitai Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 34c04c76-2301-4fd7-9e96-15716249e7c1

📥 Commits

Reviewing files that changed from the base of the PR and between 4f5d25c and 83d3315.

📒 Files selected for processing (2)
  • src/renderer/src/components/native-chat/NativeChatPaneFileDropSurface.tsx
  • src/renderer/src/components/native-chat/native-chat-pane-file-drop.test.tsx

Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

Native chat now supports pane-wide file drops. The pane classifies workspace and OS drags, routes workspace drops to the registered composer, and leaves OS drops to the preload route. It displays a localized overlay during eligible drags and clears it during drop and drag-end events. Composer registration now includes a pane scope key. Tests cover routing, disabled composers, overlay lifecycle, and structured chat view integration.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 83d33

The pane-wide drop routing and cleanup paths are covered by the supplied focused tests, with no actionable merge risk identified.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 29.41% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 17 functions across 10 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description explains the behavior, implementation, scope, testing, and known validation limits. However, it does not follow the required template headings and omits the required linked issue. It a… Add the required template sections, include a valid issue reference under Linked Issue, and attach the required before-and-after visual proof or provide N/A with a reason if the change has no visual impact.
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely describes the main change: adding a drop target across the native chat pane.
Full details: Description check

Explanation

The description explains the behavior, implementation, scope, testing, and known validation limits. However, it does not follow the required template headings and omits the required linked issue. It also references visual evidence in a review comment instead of providing the required visual proof in the pull request description.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pullfrog pullfrog Bot 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.

✅ No new issues found.

Reviewed changes

  • Drop surface moved into NativeChatView — both the terminal portal and the agent-session overlay path now get a surface, fixing the previously reported silent no-op for in-app drags on overlay composers.
  • Portal shell restored — TerminalPaneNativeChatPortal goes back to a plain native-chat-pane-shell <div>; the surface is no longer nested there, so there is exactly one surface per pane.
  • Guard transition clears the overlay — adding disabled to the claim-registration effect deps tears the hover down before the next paint when a composer becomes guarded.
  • Handler wiring simplified — dropped the registrationRef; the handler factory is memoized on [registration] and reads the live claim through registration.getClaim().
  • Regression coverage — new native-chat-view-file-drop.test.tsx proves a standalone structured session owns pane drops without a terminal portal, plus a guard-transition case in the pane drop tests.

Verified the moved surface is layout-safe for both hosts: both session roots are flex h-full min-h-0 w-full flex-col bg-background, so the added relative flex … h-full w-full wrapper fills as before. Ran native-chat-pane-file-drop, native-chat-view-file-drop, and native-chat-composer-workspace-file-drop — 26 passed.

ℹ️ Nitpicks

  • The PR description still says the surface "lives in TerminalPaneNativeChatPortal.tsx"; it now lives in NativeChatView.tsx. Worth a one-line update so the next reader isn't sent to the wrong file.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@brennanb2025

brennanb2025 commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor Author

Electron evidence — updated after review fixes

Grok QA exercised the final source committed as 83d3315cbf, using a background Electron app and Playwright CDP. These results replace the earlier incomplete standalone-session/native-drop observations.

  • A healthy standalone Claude session accepted an explorer-file drop onto its transcript. The invitation appeared, exactly one path was appended, and the invitation cleared.
  • Chromium Input.dispatchDragEvent with absolute data.files paths also appended one path and cleared the invitation, without an unresolved-path error. The last screenshot contains two path mentions because it follows two separate drops (one explorer drop and one native CDP drop).
  • Same-task and spaced synthetic native-type event sequences left no stale invitation. The same-task case is also covered by a regression test.
  • Earlier terminal-backed chat checks covered transcript/composer drops, cancellation/leave, and sibling-terminal isolation.

This validates Chromium native-path delivery, not a physical Finder gesture. The earlier Playwright helper constructed pathless JavaScript File objects; that method's limitation does not apply to the successful absolute-path CDP probe. No Windows/Linux desktop gesture validation was performed.

Healthy structured chat: invitation

Drop invitation

After explorer drop: one path, invitation cleared

Explorer drop completed

After a second, native CDP drop: one additional path, invitation cleared

Native CDP drop completed

@pullfrog pullfrog Bot 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.

✅ No new issues found.

Reviewed changes

  • Native drop completion listeners subscribed at claim time — the surface's document drop/dragend teardown now attaches whenever a composer registration exists rather than only after the hover render commits, so an OS drop the preload consumes before that commit still clears the overlay. The listener set and guard-transition behavior are otherwise unchanged; the effect now runs for the composer's lifetime and is removed on unmount.
  • Regression coverage — new tests prove a native drop that ends before the hover commit clears the overlay, and that the end listeners stay stable across drags and are removed with the composer. Both fail against the previous [isDragActive] effect and pass at the new head.

Confirmed the fix rests on the preload route (preload-runtime-support.ts:105-157) consuming the OS drop on the same document node with stopPropagation, which does not suppress the surface's own document-capture listener. pnpm test native-chat-pane-file-drop.test.tsx native-chat-view-file-drop.test.tsx — 13 passed.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review complete at 83d3315cbfb6e6b3e5d7a9147250fa5183ceb3b0; fixes are pushed to this PR branch.

  • Functional correctness: Fixed missing standalone-chat coverage, stale invitation when composer guards change, and the fast native-drop completion race. Removed the render-time ref mutation flagged by static analysis. Final same-model review returned clean; no further meaningful in-scope fixes remain.
  • Architecture and performance: The common chat view owns the drop surface, and completion listeners follow composer registration. Existing composer validation and scoped preload delivery remain authoritative. Two stable completion listeners per registered surface; no new polling, IPC, or dragover subscription churn.
  • Readiness and validation: Start/end readiness reviews completed; final review reported no P0/P1/P2 findings. All 61 focused tests, renderer typecheck, changed code-quality checks, React Doctor, formatting, and commit hooks passed. GitHub Actions static analysis, typecheck, all eight test shards, packaging (including Windows), and aggregate verify passed. Pullfrog is still in progress at this update.
  • Rendered QA: Grok validated healthy standalone chat using explorer drags and Chromium native absolute-path drops; attachments arrived and the overlay cleared. Screenshots and exact coverage. Physical Finder gestures and Windows/Linux desktop gestures were not exercised. No mobile or remote execution behavior changed.

Working tree is clean. No new PR was opened and this PR was not merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant