Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.
TypeScript adhdagent-orchestrationai-agentscanvasclaude-codecodexcoding-agentsdeveloper-toolselectrongeminilinuxmacosmultiplexeropencodeparallel-agentsterminalterminal-emulatorterminal-multiplexertmuxworkspace-manager
fix(terminal): refocus the app window after a file is dropped in
enes4245402dc7a1
diff --git a/src/main/index.ts b/src/main/index.tsindex 2f60772f1..bd8bfa342 100644--- a/src/main/index.ts+++ b/src/main/index.ts@@ -533,6 +533,21 @@ app.whenReady().then(async () => {ipcMain.on(IPC.appCloseWindow, () => BrowserWindow.getFocusedWindow()?.close())+ // Bring the window forward after a file is dropped into a terminal. On macOS a drag-drop from+ // another app does NOT activate the destination app, so without this the drag-source keeps OS+ // keyboard focus and the user types into the wrong application. `getMainWindow()` (not the+ // focused window — there may be none) restores + shows + focuses.+ ipcMain.on(IPC.appFocusWindow, () => {+ const w = getMainWindow()+ if (!w) return+ if (w.isMinimized()) w.restore()+ w.show()+ // On macOS `win.focus()` alone won't pull us in front of the still-active drag-source app —+ // app-level focus with `steal` is what actually activates us across apps.+ if (process.platform === 'darwin') app.focus({ steal: true })+ w.focus()+ })+// Dock badge: number of Claude nodes with unread output (macOS only). '' clears it.ipcMain.on(IPC.appSetBadge, (_e, count: number) => {if (process.platform !== 'darwin' || !app.dock) returndiff --git a/src/preload/index.ts b/src/preload/index.tsindex 513f9e6ae..26145e76c 100644--- a/src/preload/index.ts+++ b/src/preload/index.ts@@ -498,6 +498,7 @@ const api: NodeTerminalApi = {onMarkdownToggle: subscribe(IPC.appToggleMarkdown),onCloseNode: subscribe(IPC.appCloseNode),closeWindow: () => ipcRenderer.send(IPC.appCloseWindow),+ focusWindow: () => ipcRenderer.send(IPC.appFocusWindow),setBadgeCount: (count) => ipcRenderer.send(IPC.appSetBadge, count),// Absolute path of a dropped/picked File (File.path was removed in Electron 30+).getPathForFile: (file: File) => webUtils.getPathForFile(file),diff --git a/src/renderer/bridge/stubs.ts b/src/renderer/bridge/stubs.tsindex 4448c4ff7..149767850 100644--- a/src/renderer/bridge/stubs.ts+++ b/src/renderer/bridge/stubs.ts@@ -306,6 +306,15 @@ export function buildStubApi(): Omit<onMarkdownToggle: noopUnsub,onCloseNode: noopUnsub,closeWindow: noop,+ // Best-effort: a browser tab can't force itself frontmost the way the desktop BrowserWindow+ // can, but `window.focus()` still helps when the page is merely blurred (not another OS app).+ focusWindow: () => {+ try {+ window.focus()+ } catch {+ /* focus is a no-op in some embeddings — never throw into a drop handler */+ }+ },setBadgeCount: noop,getPathForFile: (): string => '',notify: async (payload: NotifyPayload): Promise<'shown' | 'failed' | 'skipped'> => {diff --git a/src/renderer/components/kanban/ModalTerminal.tsx b/src/renderer/components/kanban/ModalTerminal.tsxindex f06cf6821..dd85adf2c 100644--- a/src/renderer/components/kanban/ModalTerminal.tsx+++ b/src/renderer/components/kanban/ModalTerminal.tsx@@ -288,6 +288,10 @@ export function ModalTerminal({ nodeId, spawn, searchOpen, onCloseSearch }: Modapaths = await droppedPaths(files, { sshRemoteTmux: false, projectId: '' })}if (!paths.length) return+ // A drag-drop from another OS app doesn't bring our window forward (esp. macOS), so the+ // drag-source keeps keyboard focus — the user's next keystrokes would land in the wrong app.+ // Raise our window FIRST, then focus the terminal, so typing after the drop reaches it.+ window.nodeTerminal.focusWindow()term.focus()term.paste(paths.join(' ') + ' ')}diff --git a/src/renderer/nodes/TerminalNode.tsx b/src/renderer/nodes/TerminalNode.tsxindex 599a899c2..271dade5b 100644--- a/src/renderer/nodes/TerminalNode.tsx+++ b/src/renderer/nodes/TerminalNode.tsx@@ -1493,6 +1493,9 @@ export function TerminalNode({ id, data, selected, parentId }: NodeProps<CanvasN// Enter the terminal and paste the path(s) like a real drop (trailing space to continue).if (dwellRef.current) clearTimeout(dwellRef.current)setArmed(false)+ // A drag-drop from another OS app doesn't bring our window forward (esp. macOS), so raise it+ // FIRST — otherwise the drag-source keeps keyboard focus and the user types into the wrong app.+ window.nodeTerminal.focusWindow()term.focus()term.paste(paths.join(' ') + ' ')useAgentStatus.getState().setActive(id, true)diff --git a/src/shared/ipc.ts b/src/shared/ipc.tsindex 0ff49d857..3c1d47aaf 100644--- a/src/shared/ipc.ts+++ b/src/shared/ipc.ts@@ -33,6 +33,7 @@ export const IPC = {appToggleMarkdown: 'app:toggle-markdown',appCloseNode: 'app:close-node',appCloseWindow: 'app:close-window',+ appFocusWindow: 'app:focus-window',appNotify: 'app:notify',appOpenNotificationSettings: 'app:open-notification-settings',appFocusNode: 'app:focus-node',diff --git a/src/shared/types.ts b/src/shared/types.tsindex dc6a6b212..ea8c4dcc2 100644--- a/src/shared/types.ts+++ b/src/shared/types.ts@@ -1745,6 +1745,12 @@ export interface NodeTerminalApi {onCloseNode(listener: () => void): () => void/** Close the application window (Cmd/Ctrl+W fallback when no node is selected). */closeWindow(): void+ /** Bring the app window to the foreground (show + OS focus). Called after a file is DROPPED+ * into a terminal: on macOS a drag-drop from another app (Finder/browser) does not activate+ * the destination app, so the drag-source keeps keyboard focus and the user's next keystrokes+ * land in the WRONG application — `term.focus()` (DOM-only) can't fix that. Desktop raises the+ * BrowserWindow; the browser bridge does a best-effort `window.focus()`. */+ focusWindow(): void/** Set the macOS Dock badge to the unread-message count (0 clears it). */setBadgeCount(count: number): void/** Absolute filesystem path for a dropped/picked File (for drag-into-terminal). */