From b8fb9270c4672e81e710c242e96ad1eaf60d18e0 Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Mon, 4 May 2026 14:49:38 -0700 Subject: [PATCH] refactor(cli): drop dead c-S-c key binding (follow-up to #19895) (#19919) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #19884 added a prompt_toolkit key binding for Ctrl+Shift+C to "prevent Hermes from intercepting the keystroke as an interrupt signal." #19895 then wrapped the binding in try/except after discovering it crashed startup with ValueError on every platform. Both PRs were based on a misreading of how terminal key events propagate: 1. Terminal emulators (GNOME Terminal, iTerm2, kitty, Windows Terminal, etc.) intercept Ctrl+Shift+C before the keystroke reaches the application's stdin. prompt_toolkit never sees it. The binding could never have intercepted anything. 2. prompt_toolkit's key spec parser doesn't recognise 'c-S-c' on any platform — the Shift modifier is meaningless on control-sequence keys. Verified: every prompt_toolkit version raises 'Invalid key: c-S-c' at registration time. The handler is dead code. Delete it and leave a comment explaining why no binding is needed here. Ctrl+Q alias (#19884's other addition) stays — that's a real prompt_toolkit key and a legitimate interrupt shortcut. Verified the CLI starts cleanly — key binding phase no longer raises and the subsequent chat flow reaches the provider setup check without error. --- cli.py | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/cli.py b/cli.py index 2c5df6fbc4..eefd14fe47 100644 --- a/cli.py +++ b/cli.py @@ -10484,19 +10484,14 @@ class HermesCLI: self._should_exit = True event.app.exit() - try: - @kb.add('c-S-c') # Ctrl+Shift+C — no-op, let terminal handle native copy - def handle_ctrl_shift_c(event): - """No-op: let the terminal handle Ctrl+Shift+C natively. - - Wrapped in try/except because prompt_toolkit raises ValueError - ("Invalid key: c-S-c") on platforms where this key spec is not - recognised. The binding is best-effort; if registration fails, - startup continues normally. - """ - return - except ValueError: - pass # prompt_toolkit on this platform/version doesn't support c-S-c + # Ctrl+Shift+C: no binding needed. Terminal emulators (GNOME Terminal, + # iTerm2, kitty, Windows Terminal, etc.) intercept Ctrl+Shift+C before + # the keystroke reaches the application's stdin — prompt_toolkit never + # sees it, and prompt_toolkit's key spec parser doesn't even recognise + # 'c-S-c' anyway (the Shift modifier is meaningless on control-sequence + # keys). #19884 added a handler for this; #19895 patched the resulting + # startup crash with try/except. Both were based on a misreading of how + # terminal key events propagate. Deleting the dead handler outright. @kb.add('c-q') # Ctrl+Q def handle_ctrl_q(event):