Skip to content

Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.

fix(web): use capture-phase keydown listener so CTRL+J toggles terminal from terminal focus on Windows (#2113) (#2142)

Matt Van Horn0f184c28b056
diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsx
index 06d8e8db5..47dad09ea 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 2c968e6bc..683afbbfe 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", () => {