From 5ffb946d89d921fb6780dfa92797a3e6b94bc281 Mon Sep 17 00:00:00 2001 From: Matt Van Horn <455140+mvanhorn@users.noreply.github.com> Date: Fri, 17 Apr 2026 18:46:15 -0400 Subject: [PATCH] fix(web): use capture-phase keydown listener so terminal toggle works while terminal has focus Fixes #2113 --- apps/web/src/components/ChatView.tsx | 4 ++-- apps/web/src/keybindings.test.ts | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsx index 06d8e8db5d8..47dad09ea29 100644 --- a/apps/web/src/components/ChatView.tsx +++ b/apps/web/src/components/ChatView.tsx @@ -2290,8 +2290,8 @@ export default function ChatView(props: ChatViewProps) { event.stopPropagation(); void runProjectScript(script); }; - window.addEventListener("keydown", handler); - return () => window.removeEventListener("keydown", handler); + window.addEventListener("keydown", handler, true); + return () => window.removeEventListener("keydown", handler, true); }, [ activeProject, terminalState.terminalOpen, diff --git a/apps/web/src/keybindings.test.ts b/apps/web/src/keybindings.test.ts index 2c968e6bc32..683afbbfe44 100644 --- a/apps/web/src/keybindings.test.ts +++ b/apps/web/src/keybindings.test.ts @@ -131,6 +131,15 @@ describe("isTerminalToggleShortcut", () => { isTerminalToggleShortcut(event({ ctrlKey: true }), DEFAULT_BINDINGS, { platform: "Win32" }), ); }); + + it("matches Ctrl+J on non-macOS while terminalFocus is true", () => { + assert.isTrue( + isTerminalToggleShortcut(event({ ctrlKey: true }), DEFAULT_BINDINGS, { + platform: "Win32", + context: { terminalFocus: true }, + }), + ); + }); }); describe("split/new/close terminal shortcuts", () => {