From 746b031870eb3bfb84214ea471f5e119bbc5a428 Mon Sep 17 00:00:00 2001 From: Kelvin Amoaba <97001695+AmoabaKelvin@users.noreply.github.com> Date: Sat, 14 Nov 2026 00:44:02 +0000 Subject: [PATCH] fix(terminal): keep the user's focus when an agent splits a terminal (#42204) --- .../events/runtime-notifier-contract.ts | 2 + .../runtime/terminal/launch/terminal-split.ts | 3 +- src/main/window/runtime-window-lifecycle.ts | 3 +- .../ui-bridge-terminal-and-session-tabs.ts | 2 + .../api/window-ui/ui-command-event-api.ts | 1 + .../mounting/terminal-pane-mount-events.ts | 3 +- src/renderer/src/constants/terminal.ts | 2 + .../ipc-events/app-lifetime-ipc-bridge.ts | 2 + .../terminal-presentation-ipc-bridge.ts | 29 +---- .../terminal-presentation-split-focus.test.ts | 105 ++++++++++++++++++ .../terminal-tab-mount-ipc-bridge.ts | 31 ++++++ .../terminal-ui-routing-ipc-bridge.ts | 3 +- .../pane-layout/pane-split-close.ts | 29 ++++- .../pane-layout/pane-subtree-split.ts | 2 + .../pane-manager-split-focus.test.ts | 49 ++++++++ .../pane-manager-tree-mutations.ts | 2 + .../lib/pane-manager/pane-manager-types.ts | 2 + 17 files changed, 234 insertions(+), 36 deletions(-) create mode 100644 src/renderer/src/hooks/ipc-events/terminal-presentation-split-focus.test.ts create mode 100644 src/renderer/src/hooks/ipc-events/terminal-tab-mount-ipc-bridge.ts create mode 100644 src/renderer/src/lib/pane-manager/pane-manager-split-focus.test.ts diff --git a/src/main/runtime/client/events/runtime-notifier-contract.ts b/src/main/runtime/client/events/runtime-notifier-contract.ts index 299078fa642..b92d0e77789 100644 --- a/src/main/runtime/client/events/runtime-notifier-contract.ts +++ b/src/main/runtime/client/events/runtime-notifier-contract.ts @@ -131,6 +131,8 @@ export type RuntimeNotifier = { sourceLeafId?: string telemetrySource?: TerminalPaneSplitSource newLeafId?: string + /** An agent's split: the new pane leaves the user's active pane and keyboard focus alone. */ + activate?: false } ): void /** `recordInteraction: false` marks a title the host applied, not one the user typed. */ diff --git a/src/main/runtime/terminal/launch/terminal-split.ts b/src/main/runtime/terminal/launch/terminal-split.ts index 328ddfe7b8e..1a82cd4ae3e 100644 --- a/src/main/runtime/terminal/launch/terminal-split.ts +++ b/src/main/runtime/terminal/launch/terminal-split.ts @@ -101,7 +101,8 @@ export abstract class OrcaRuntimeWithSplitTerminal extends OrcaRuntimeWithStopEx worktreeId: leaf.worktreeId, sourceLeafId: leaf.leafId, telemetrySource: opts.telemetrySource, - newLeafId + newLeafId, + ...(opts.activate === false ? { activate: false } : {}) }) return await this.awaitRendererSplit(split, newLeafId) } diff --git a/src/main/window/runtime-window-lifecycle.ts b/src/main/window/runtime-window-lifecycle.ts index f1bc293bfc6..478145e006f 100644 --- a/src/main/window/runtime-window-lifecycle.ts +++ b/src/main/window/runtime-window-lifecycle.ts @@ -176,7 +176,8 @@ export function registerRuntimeWindowLifecycle( worktreeId: opts.worktreeId, sourceLeafId: opts.sourceLeafId, telemetrySource: opts.telemetrySource, - newLeafId: opts.newLeafId + newLeafId: opts.newLeafId, + ...(opts.activate === false ? { activate: false } : {}) }) }, renameTerminal: (tabId, title, options) => diff --git a/src/preload/api/window-ui/ui-bridge-terminal-and-session-tabs.ts b/src/preload/api/window-ui/ui-bridge-terminal-and-session-tabs.ts index 11f75d66557..fa57dcf5c79 100644 --- a/src/preload/api/window-ui/ui-bridge-terminal-and-session-tabs.ts +++ b/src/preload/api/window-ui/ui-bridge-terminal-and-session-tabs.ts @@ -158,6 +158,7 @@ export const uiTerminalAndSessionTabsApi = { sourceLeafId?: string telemetrySource?: TerminalPaneSplitSource newLeafId?: string + activate?: false }) => void ): (() => void) => { const listener = ( @@ -171,6 +172,7 @@ export const uiTerminalAndSessionTabsApi = { sourceLeafId?: string telemetrySource?: TerminalPaneSplitSource newLeafId?: string + activate?: false } ) => callback(data) ipcRenderer.on('ui:splitTerminal', listener) diff --git a/src/preload/api/window-ui/ui-command-event-api.ts b/src/preload/api/window-ui/ui-command-event-api.ts index a39ca774733..d509efd2ef1 100644 --- a/src/preload/api/window-ui/ui-command-event-api.ts +++ b/src/preload/api/window-ui/ui-command-event-api.ts @@ -240,6 +240,7 @@ export type UiCommandEventApi = { sourceLeafId?: string telemetrySource?: TerminalPaneSplitSource newLeafId?: string + activate?: false }) => void ) => () => void onRenameTerminal: ( diff --git a/src/renderer/src/components/terminal-pane/mounting/terminal-pane-mount-events.ts b/src/renderer/src/components/terminal-pane/mounting/terminal-pane-mount-events.ts index eb6f008f232..fd5d6f5bc69 100644 --- a/src/renderer/src/components/terminal-pane/mounting/terminal-pane-mount-events.ts +++ b/src/renderer/src/components/terminal-pane/mounting/terminal-pane-mount-events.ts @@ -76,7 +76,8 @@ export function installTerminalPaneMountEvents(args: { } const splitOptions = { ...(detail.newLeafId ? { leafId: detail.newLeafId } : {}), - ...(detail.ptyId ? { ptyId: detail.ptyId } : {}) + ...(detail.ptyId ? { ptyId: detail.ptyId } : {}), + ...(detail.activate === false ? { activate: false } : {}) } if (detail.command) { const createdPane = splitPaneWithOneShotStartup(ptyDeps, { command: detail.command }, () => diff --git a/src/renderer/src/constants/terminal.ts b/src/renderer/src/constants/terminal.ts index 98b69d068fb..8dde47fee8b 100644 --- a/src/renderer/src/constants/terminal.ts +++ b/src/renderer/src/constants/terminal.ts @@ -48,6 +48,8 @@ export type SplitTerminalPaneDetail = { telemetrySource?: TerminalPaneSplitSource newLeafId?: string ptyId?: string + /** An agent's split: the new pane leaves the user's active pane and keyboard focus alone. */ + activate?: false } export type RequestActiveTerminalPaneSplitDetail = { diff --git a/src/renderer/src/hooks/ipc-events/app-lifetime-ipc-bridge.ts b/src/renderer/src/hooks/ipc-events/app-lifetime-ipc-bridge.ts index cba150db317..d5d16ff31fa 100644 --- a/src/renderer/src/hooks/ipc-events/app-lifetime-ipc-bridge.ts +++ b/src/renderer/src/hooks/ipc-events/app-lifetime-ipc-bridge.ts @@ -35,6 +35,7 @@ import { registerSettingsAndSidebarIpcBridge } from './settings-sidebar-ipc-brid import { registerQuitAndStopAllSessionsIpcBridge } from './quit-and-stop-all-sessions-ipc-bridge' import { registerTabLifecycleIpcBridge } from './tab-lifecycle-ipc-bridge' import { registerTerminalPresentationIpcBridge } from './terminal-presentation-ipc-bridge' +import { registerTerminalTabMountIpcBridge } from './terminal-tab-mount-ipc-bridge' import { registerPtySourceDisownedIpcBridge } from './pty-source-disowned-ipc-bridge' import { registerTerminalRequestIpcBridge } from './terminal-request-ipc-bridge' import { registerAgentLaunchTabIpcBridge } from './agent-launch-tab-ipc-bridge' @@ -133,6 +134,7 @@ export function installAppLifetimeIpcEvents(): () => void { ) registerTerminalPresentationIpcBridge(unsubs) + registerTerminalTabMountIpcBridge(unsubs) registerTerminalRequestIpcBridge(unsubs) registerAgentLaunchTabIpcBridge(unsubs) registerPtySourceDisownedIpcBridge(unsubs) diff --git a/src/renderer/src/hooks/ipc-events/terminal-presentation-ipc-bridge.ts b/src/renderer/src/hooks/ipc-events/terminal-presentation-ipc-bridge.ts index 1135e643686..61fbdd112c7 100644 --- a/src/renderer/src/hooks/ipc-events/terminal-presentation-ipc-bridge.ts +++ b/src/renderer/src/hooks/ipc-events/terminal-presentation-ipc-bridge.ts @@ -1,7 +1,6 @@ import { presentAgentLaunchTab } from '@/lib/agent-session/launch/pane/agent-launch-tab-presentation' import { requestBackgroundTerminalWorktreeMount } from '@/components/terminal/background-terminal-worktree-mount' import { hasRegisteredRuntimeTerminalTab } from '@/runtime/hosted-terminals/mounted-surfaces/mounted-terminal-tab-registry' -import { planMobileTerminalTabMount } from '@/components/terminal-pane/mounting/mobile-terminal-tab-mount' import { resolveTerminalTabPtyOwnership } from '@/lib/workspace/tabs/terminal-tab-for-pty-id' import { dispatchTerminalPaneSplitRequest, @@ -202,7 +201,8 @@ export function registerTerminalPresentationIpcBridge(unsubs: (() => void)[]): v sourcePtyId: existingLayout?.ptyIdsByLeafId?.[splitFromLeafId], telemetrySource: splitTelemetrySource, newLeafId: leafId, - ptyId + ptyId, + ...(shouldActivate ? {} : { activate: false }) } const targetMounted = hasRegisteredRuntimeTerminalTab(tab.id, worktreeId) if (!targetMounted) { @@ -289,30 +289,5 @@ export function registerTerminalPresentationIpcBridge(unsubs: (() => void)[]): v ) ) - // Why: background-mount a mobile-subscribed tab's PTY without navigating the desktop (STA-1840). - unsubs.push( - window.api.ui.onRequestTerminalTabMount(({ worktreeId, tabId, ptyId }) => { - if (!worktreeId) { - return - } - // Why: synthetic pty handles need persisted-tab resolution; a miss must not mount every saved tab in a hidden worktree. - const mount = planMobileTerminalTabMount( - useAppStore.getState(), - { - worktreeId, - ...(tabId ? { tabId } : {}), - ...(ptyId ? { ptyId } : {}) - }, - { - isTabMounted: (tabId, targetWorktreeId) => - hasRegisteredRuntimeTerminalTab(tabId, targetWorktreeId) - } - ) - if (mount) { - requestBackgroundTerminalWorktreeMount(mount) - } - }) - ) - // Why: CLI-driven terminal creation waits for the tabId reply so it can hand the caller a usable handle immediately. } diff --git a/src/renderer/src/hooks/ipc-events/terminal-presentation-split-focus.test.ts b/src/renderer/src/hooks/ipc-events/terminal-presentation-split-focus.test.ts new file mode 100644 index 00000000000..f8ddb73b8cf --- /dev/null +++ b/src/renderer/src/hooks/ipc-events/terminal-presentation-split-focus.test.ts @@ -0,0 +1,105 @@ +import { beforeEach, describe, expect, it, vi } from 'vitest' +import { createTestStore, seedStore } from '../../store/testing/app-store-test-fixture' +import { makeTab } from '../../store/terminals/testing/terminal-tab.test-fixture' +import { makeWorktree } from '../../store/slices/worktrees/worktree.test-fixture' +import { createStoreSessionMockApi } from '../../store/testing/app-store-session-api.test-fixture' + +const mocks = vi.hoisted(() => { + const store: { current: ReturnType | null } = { current: null } + return { store, dispatchSplit: vi.fn() } +}) + +vi.mock('sonner', () => ({ toast: { info: vi.fn(), success: vi.fn(), error: vi.fn() } })) +vi.mock('../../../../shared/layout-owner-switch', () => ({ ORCA_LAYOUT_OWNER_IS_MAIN: false })) +vi.mock('../../store', () => ({ + useAppStore: { + getState: () => mocks.store.current!.getState(), + setState: (...args: Parameters['setState']>) => + mocks.store.current!.setState(...args), + subscribe: () => () => {} + } +})) +vi.mock( + '@/runtime/hosted-terminals/mounted-surfaces/mounted-terminal-tab-registry', + async (importOriginal) => ({ + ...(await importOriginal()), + hasRegisteredRuntimeTerminalTab: () => true + }) +) +vi.mock('@/components/terminal-pane/layout/split/terminal-pane-split-request-routing', () => ({ + dispatchTerminalPaneSplitRequest: mocks.dispatchSplit, + queueTerminalPaneSplitRequest: vi.fn() +})) +vi.mock('@/components/terminal-pane/input/focus/focus-terminal-tab-surface', () => ({ + focusTerminalTabSurface: vi.fn() +})) + +import { registerTerminalPresentationIpcBridge } from './terminal-presentation-ipc-bridge' + +const WORKTREE = 'repo1::/repo1/main' +const TAB = 'aaaaaaaa-bbbb-4ccc-8ddd-eeeeeeeeeeee' +const SOURCE_LEAF = '11111111-1111-4111-8111-111111111111' +const NEW_LEAF = '22222222-2222-4222-8222-222222222222' + +type Listener = (payload: Record) => void + +function revealBackgroundSplit(): void { + const listeners = new Map() + const ui = new Proxy( + {}, + { + get: (_target, name) => + typeof name === 'string' && name.startsWith('on') + ? (listener: Listener) => { + listeners.set(name, listener) + return () => {} + } + : vi.fn() + } + ) + vi.stubGlobal('window', { dispatchEvent: vi.fn(), api: { ...createStoreSessionMockApi(), ui } }) + const store = createTestStore() + mocks.store.current = store + seedStore(store, { + worktreesByRepo: { + repo1: [makeWorktree({ id: WORKTREE, repoId: 'repo1', path: '/repo1/main' })] + }, + tabsByWorktree: { + [WORKTREE]: [makeTab({ id: TAB, worktreeId: WORKTREE, ptyId: 'pty-1' })] + }, + terminalLayoutsByTabId: { + [TAB]: { + root: { type: 'leaf', leafId: SOURCE_LEAF }, + activeLeafId: SOURCE_LEAF, + expandedLeafId: null, + ptyIdsByLeafId: { [SOURCE_LEAF]: 'pty-1' } + } + } + }) + registerTerminalPresentationIpcBridge([]) + listeners.get('onCreateTerminal')?.({ + worktreeId: WORKTREE, + ptyId: 'pty-2', + tabId: TAB, + leafId: NEW_LEAF, + splitFromLeafId: SOURCE_LEAF, + splitDirection: 'vertical', + activate: false, + presentation: 'background' + }) +} + +beforeEach(() => { + vi.unstubAllGlobals() + mocks.dispatchSplit.mockReset() +}) + +describe('a runtime split revealed in the window', () => { + it('asks the pane not to take focus when the split is in the background', () => { + revealBackgroundSplit() + + expect(mocks.dispatchSplit).toHaveBeenCalledExactlyOnceWith( + expect.objectContaining({ newLeafId: NEW_LEAF, activate: false }) + ) + }) +}) diff --git a/src/renderer/src/hooks/ipc-events/terminal-tab-mount-ipc-bridge.ts b/src/renderer/src/hooks/ipc-events/terminal-tab-mount-ipc-bridge.ts new file mode 100644 index 00000000000..11d6c5d8de4 --- /dev/null +++ b/src/renderer/src/hooks/ipc-events/terminal-tab-mount-ipc-bridge.ts @@ -0,0 +1,31 @@ +import { requestBackgroundTerminalWorktreeMount } from '@/components/terminal/background-terminal-worktree-mount' +import { hasRegisteredRuntimeTerminalTab } from '@/runtime/hosted-terminals/mounted-surfaces/mounted-terminal-tab-registry' +import { planMobileTerminalTabMount } from '@/components/terminal-pane/mounting/mobile-terminal-tab-mount' +import { useAppStore } from '../../store/index' + +export function registerTerminalTabMountIpcBridge(unsubs: (() => void)[]): void { + // Why: background-mount a mobile-subscribed tab's PTY without navigating the desktop (STA-1840). + unsubs.push( + window.api.ui.onRequestTerminalTabMount(({ worktreeId, tabId, ptyId }) => { + if (!worktreeId) { + return + } + // Why: synthetic pty handles need persisted-tab resolution; a miss must not mount every saved tab in a hidden worktree. + const mount = planMobileTerminalTabMount( + useAppStore.getState(), + { + worktreeId, + ...(tabId ? { tabId } : {}), + ...(ptyId ? { ptyId } : {}) + }, + { + isTabMounted: (tabId, targetWorktreeId) => + hasRegisteredRuntimeTerminalTab(tabId, targetWorktreeId) + } + ) + if (mount) { + requestBackgroundTerminalWorktreeMount(mount) + } + }) + ) +} diff --git a/src/renderer/src/hooks/ipc-events/terminal-ui-routing-ipc-bridge.ts b/src/renderer/src/hooks/ipc-events/terminal-ui-routing-ipc-bridge.ts index 9b723b2ae41..9a71d58341d 100644 --- a/src/renderer/src/hooks/ipc-events/terminal-ui-routing-ipc-bridge.ts +++ b/src/renderer/src/hooks/ipc-events/terminal-ui-routing-ipc-bridge.ts @@ -120,7 +120,8 @@ export function routeRuntimeTerminalSplitRequest(request: RuntimeTerminalSplitRe command: request.command, sourceLeafId: request.sourceLeafId, telemetrySource: request.telemetrySource, - newLeafId: request.newLeafId + newLeafId: request.newLeafId, + ...(request.activate === false ? { activate: false } : {}) } if (hasRegisteredRuntimeTerminalTab(request.tabId, worktreeId)) { dispatchTerminalPaneSplitRequest(detail) diff --git a/src/renderer/src/lib/pane-manager/pane-layout/pane-split-close.ts b/src/renderer/src/lib/pane-manager/pane-layout/pane-split-close.ts index 71d262c8f6e..59f715d2850 100644 --- a/src/renderer/src/lib/pane-manager/pane-layout/pane-split-close.ts +++ b/src/renderer/src/lib/pane-manager/pane-layout/pane-split-close.ts @@ -47,6 +47,7 @@ type SplitManagedPaneArgs = { spawnHints?: Parameters>[1] ) => void getDragCallbacks: () => DragReorderCallbacks + activePaneId: number | null setActivePaneId: (paneId: number | null) => void isDestroyed: () => boolean } @@ -66,13 +67,24 @@ export function splitManagedPane(args: SplitManagedPaneArgs): ManagedPane | null const divider = args.createDivider(isVertical) const movedPaneStates = prepareMovedPanesForSplit(existingContainer, existing, args.panes) + const activate = args.opts?.activate !== false + const focusedBefore = activate ? null : document.activeElement wrapInSplit(existingContainer, newPane.container, isVertical, divider, { ratio: args.opts?.ratio, newPaneFirst: args.newPaneFirst }) - args.setActivePaneId(newPane.id) - openSplitPane(args, newPane, existing.leafId, args.opts?.cwd) + if (activate) { + args.setActivePaneId(newPane.id) + } else if ( + focusedBefore instanceof HTMLElement && + focusedBefore.isConnected && + document.activeElement !== focusedBefore + ) { + // Reparenting the source pane drops its focus; give the user's keyboard back. + focusedBefore.focus({ preventScroll: true }) + } + openSplitPane(args, newPane, existing.leafId, activate) for (const movedPaneState of movedPaneStates) { scheduleSplitScrollRestore( @@ -143,15 +155,22 @@ function openSplitPane( args: SplitManagedPaneArgs, newPane: ManagedPaneInternal, parentLeafId: string, - cwd?: string + activate: boolean ): void { + const cwd = args.opts?.cwd openTerminal(newPane, { ligatures: args.managerOptions.terminalLigaturesEnabled?.(), inlineImages: args.managerOptions.terminalInlineImagesEnabled?.() }) - applyPaneOpacity(args.panes.values(), newPane.id, args.styleOptions) + applyPaneOpacity( + args.panes.values(), + activate ? newPane.id : args.activePaneId, + args.styleOptions + ) applyDividerStyles(args.root, args.styleOptions) - newPane.terminal.focus() + if (activate) { + newPane.terminal.focus() + } updateMultiPaneState(args.getDragCallbacks()) // Forward creation hints to inherit local cwd or adopt the runtime-spawned PTY in web splits. args.publishPaneCreated(newPane, { diff --git a/src/renderer/src/lib/pane-manager/pane-layout/pane-subtree-split.ts b/src/renderer/src/lib/pane-manager/pane-layout/pane-subtree-split.ts index d71ae6a77c9..7697d52b049 100644 --- a/src/renderer/src/lib/pane-manager/pane-layout/pane-subtree-split.ts +++ b/src/renderer/src/lib/pane-manager/pane-layout/pane-subtree-split.ts @@ -33,6 +33,7 @@ type SplitPaneAroundLeafIdsArgs = { spawnHints?: Parameters>[1] ) => void getDragCallbacks: () => DragReorderCallbacks + activePaneId: number | null setActivePaneId: (paneId: number | null) => void isDestroyed: () => boolean } @@ -61,6 +62,7 @@ export function splitPaneAroundMountedSubtree( createDivider: args.createDivider, publishPaneCreated: args.publishPaneCreated, getDragCallbacks: args.getDragCallbacks, + activePaneId: args.activePaneId, setActivePaneId: args.setActivePaneId, isDestroyed: args.isDestroyed }) diff --git a/src/renderer/src/lib/pane-manager/pane-manager-split-focus.test.ts b/src/renderer/src/lib/pane-manager/pane-manager-split-focus.test.ts new file mode 100644 index 00000000000..b4881ae83d9 --- /dev/null +++ b/src/renderer/src/lib/pane-manager/pane-manager-split-focus.test.ts @@ -0,0 +1,49 @@ +// @vitest-environment happy-dom +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' +import { Terminal } from '@xterm/xterm' + +// Why: happy-dom has no canvas, so xterm cannot open; focus is what this checks. +vi.mock('./pane-lifecycle', async (importOriginal) => { + const actual: object = await importOriginal() + return { ...actual, openTerminal: vi.fn() } +}) + +const { PaneManager } = await import('./pane-manager') + +const LEAF_A = '11111111-1111-4111-8111-111111111111' +const LEAF_B = '22222222-2222-4222-8222-222222222222' + +describe('PaneManager split focus', () => { + let root: HTMLDivElement + let manager: InstanceType + + beforeEach(() => { + vi.stubGlobal('requestAnimationFrame', () => 1) + vi.stubGlobal('cancelAnimationFrame', () => {}) + root = document.createElement('div') + document.body.appendChild(root) + manager = new PaneManager(root, { linkOpenHint: () => '' }) + }) + + afterEach(() => { + manager.destroy() + root.remove() + vi.unstubAllGlobals() + vi.restoreAllMocks() + }) + + it('leaves the active pane and keyboard focus alone for a split that must not activate', () => { + const source = manager.createInitialPane({ leafId: LEAF_A, focus: false }) + // Stands in for xterm's input, which the split reparents along with its pane. + const input = source.container.appendChild(document.createElement('textarea')) + input.focus() + const focus = vi.spyOn(Terminal.prototype, 'focus') + + const created = manager.splitPane(source.id, 'vertical', { leafId: LEAF_B, activate: false }) + + expect(created?.leafId).toBe(LEAF_B) + expect(manager.getActivePane()?.leafId).toBe(LEAF_A) + expect(focus).not.toHaveBeenCalled() + expect(document.activeElement).toBe(input) + }) +}) diff --git a/src/renderer/src/lib/pane-manager/pane-manager-tree-mutations.ts b/src/renderer/src/lib/pane-manager/pane-manager-tree-mutations.ts index 3193f622ae0..79001dc12f6 100644 --- a/src/renderer/src/lib/pane-manager/pane-manager-tree-mutations.ts +++ b/src/renderer/src/lib/pane-manager/pane-manager-tree-mutations.ts @@ -27,6 +27,7 @@ export function splitPaneOnManager( createDivider: (isVertical) => host.createDivider(isVertical), publishPaneCreated: (pane, spawnHints) => host.publishPaneCreated(pane, spawnHints), getDragCallbacks: () => host.getDragCallbacks(), + activePaneId: host.getActivePaneId(), setActivePaneId: (id) => { host.setActivePaneId(id) }, @@ -55,6 +56,7 @@ export function splitPaneAroundLeafIdsOnManager( createDivider: (isVertical) => host.createDivider(isVertical), publishPaneCreated: (pane, spawnHints) => host.publishPaneCreated(pane, spawnHints), getDragCallbacks: () => host.getDragCallbacks(), + activePaneId: host.getActivePaneId(), setActivePaneId: (id) => { host.setActivePaneId(id) }, diff --git a/src/renderer/src/lib/pane-manager/pane-manager-types.ts b/src/renderer/src/lib/pane-manager/pane-manager-types.ts index 04922abb8fa..54b6b1aca1a 100644 --- a/src/renderer/src/lib/pane-manager/pane-manager-types.ts +++ b/src/renderer/src/lib/pane-manager/pane-manager-types.ts @@ -27,6 +27,8 @@ export type PaneSpawnHints = { export type PaneSplitOptions = Omit & { ratio?: number leafId?: string + /** False for a split the user did not ask for: the active pane and keyboard focus stay put. */ + activate?: boolean } export type ClosedPaneInfo = {