refactor(cli): drop dead c-S-c key binding (follow-up to #19895) (#19919)

#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.
This commit is contained in:
Teknium 2026-05-04 14:49:38 -07:00 committed by GitHub
parent 56a78e74b2
commit b8fb9270c4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

21
cli.py
View file

@ -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):