From ea918cf69964e5787668d3a3df2080f7f92a7401 Mon Sep 17 00:00:00 2001 From: orca-bug-scan-bot Date: Mon, 8 Jun 2026 12:51:41 -0700 Subject: [PATCH] fix: address pr-bug-scan validated finding from #4850 Effect cleanup now clears every local pane transport's renderer-active flag on hide, not just the single captured ptyId, so an onActivePaneChange-focused pane (ptyB) cannot leak active. --- .../use-terminal-pane-global-effects.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/renderer/src/components/terminal-pane/use-terminal-pane-global-effects.ts b/src/renderer/src/components/terminal-pane/use-terminal-pane-global-effects.ts index a3dd61a9b2a..87df346af6b 100644 --- a/src/renderer/src/components/terminal-pane/use-terminal-pane-global-effects.ts +++ b/src/renderer/src/components/terminal-pane/use-terminal-pane-global-effects.ts @@ -147,7 +147,18 @@ export function useTerminalPaneGlobalEffects({ // Why: main uses this as a scheduler hint only, so the foreground pane's // renderer output gets first chance at the bounded ACK reserve. window.api.pty.setActiveRendererPty?.(ptyId, true) - return () => window.api.pty.setActiveRendererPty?.(ptyId, false) + return () => { + // Why: split-pane focus can move to another pane via onActivePaneChange + // after this effect captured ptyId, flagging that pane's PTY active + // without re-running this effect. Clear every local pane transport on + // hide so a focus-changed pane's PTY cannot stay flagged active in main. + for (const transport of paneTransportsRef.current.values()) { + const cleanupPtyId = transport.getPtyId() + if (cleanupPtyId && !cleanupPtyId.startsWith('remote:')) { + window.api.pty.setActiveRendererPty?.(cleanupPtyId, false) + } + } + } }, [isActive, isVisible, managerRef, paneTransportsRef]) useEffect(() => {