From 34c3fbe9e0aba18963f5cfc40e2e8cf1cbc10764 Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Tue, 24 Mar 2026 00:33:45 -0700 Subject: [PATCH] feat: drag files from explorer sidebar to terminal (#82) Co-authored-by: Claude Opus 4.6 --- src/preload/index.ts | 5 ++++ .../components/right-sidebar/FileExplorer.tsx | 5 ++++ .../components/terminal-pane/TerminalPane.tsx | 28 +++++++++++++++++++ 3 files changed, 38 insertions(+) diff --git a/src/preload/index.ts b/src/preload/index.ts index cd62ea707..875deefeb 100644 --- a/src/preload/index.ts +++ b/src/preload/index.ts @@ -20,6 +20,11 @@ document.addEventListener( document.addEventListener( 'drop', (e) => { + // Let in-app drags (e.g. file explorer → terminal) through to React handlers + if (e.dataTransfer?.types.includes('text/x-orca-file-path')) { + return + } + e.preventDefault() e.stopPropagation() const files = e.dataTransfer?.files diff --git a/src/renderer/src/components/right-sidebar/FileExplorer.tsx b/src/renderer/src/components/right-sidebar/FileExplorer.tsx index 055874709..90fb5bdba 100644 --- a/src/renderer/src/components/right-sidebar/FileExplorer.tsx +++ b/src/renderer/src/components/right-sidebar/FileExplorer.tsx @@ -209,6 +209,11 @@ export default function FileExplorer(): React.JSX.Element { isActive && !node.isDirectory && 'bg-accent text-accent-foreground' )} style={{ paddingLeft: `${node.depth * 16 + 8}px` }} + draggable + onDragStart={(e) => { + e.dataTransfer.setData('text/x-orca-file-path', node.path) + e.dataTransfer.effectAllowed = 'copy' + }} onClick={() => handleClick(node)} > {node.isDirectory ? ( diff --git a/src/renderer/src/components/terminal-pane/TerminalPane.tsx b/src/renderer/src/components/terminal-pane/TerminalPane.tsx index 7443582c4..bdc37e9fb 100644 --- a/src/renderer/src/components/terminal-pane/TerminalPane.tsx +++ b/src/renderer/src/components/terminal-pane/TerminalPane.tsx @@ -10,6 +10,7 @@ import { import type { PaneManager } from '@/lib/pane-manager/pane-manager' import TerminalSearch from '@/components/TerminalSearch' import type { PtyTransport } from './pty-transport' +import { shellEscapePath } from './pane-helpers' import { EMPTY_LAYOUT, serializeTerminalLayout } from './layout-serialization' import { createExpandCollapseActions } from './expand-collapse' import { useTerminalKeyboardShortcuts, useTerminalFontZoom } from './keyboard-handlers' @@ -218,6 +219,33 @@ export default function TerminalPane({ className="absolute inset-0 min-h-0 min-w-0" style={terminalContainerStyle} onContextMenuCapture={contextMenu.onContextMenuCapture} + onDragOver={(e) => { + if (e.dataTransfer.types.includes('text/x-orca-file-path')) { + e.preventDefault() + e.dataTransfer.dropEffect = 'copy' + } + }} + onDrop={(e) => { + const filePath = e.dataTransfer.getData('text/x-orca-file-path') + if (!filePath) { + return + } + e.preventDefault() + e.stopPropagation() + const manager = managerRef.current + if (!manager) { + return + } + const pane = manager.getActivePane() ?? manager.getPanes()[0] + if (!pane) { + return + } + const transport = paneTransportsRef.current.get(pane.id) + if (!transport) { + return + } + transport.sendInput(shellEscapePath(filePath)) + }} /> {activePane?.container && createPortal(