From fea286353a9c48398ce613a410f63f25b68460ee Mon Sep 17 00:00:00 2001 From: Jinjing <6427696+AmethystLiang@users.noreply.github.com> Date: Sat, 25 Apr 2026 16:49:54 -0700 Subject: [PATCH] fix(shortcuts): stop Ctrl+PageUp/Down from leaking to xterm preventDefault on the window-capture listener does not block xterm's own keydown listener, which translates Ctrl+PageUp/PageDown into \e[5~ / \e[6~ and writes them to the shell (and trips the terminal activity indicator). Stop propagation so the event never reaches the focused terminal. Co-authored-by: Orca --- src/renderer/src/components/Terminal.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/renderer/src/components/Terminal.tsx b/src/renderer/src/components/Terminal.tsx index 8a13d61d7ef..da2eecd853d 100644 --- a/src/renderer/src/components/Terminal.tsx +++ b/src/renderer/src/components/Terminal.tsx @@ -771,7 +771,16 @@ function Terminal(): React.JSX.Element | null { !e.repeat ) { if (handleSwitchTerminalTab(e.code === 'PageDown' ? 1 : -1)) { + // Why: stop propagation in addition to preventDefault. Unlike + // Cmd+Shift+]/[ (xterm ignores Meta-modified keys by default), + // xterm actively translates plain Ctrl+PageUp/PageDown into the + // \e[5~ / \e[6~ escape sequences and writes them to the shell. + // preventDefault on the window-capture listener does not stop + // xterm's own keydown listener on its textarea, so we must stop + // the event before it reaches the focused terminal. e.preventDefault() + e.stopPropagation() + e.stopImmediatePropagation() } } }