Skip to content

Commit 79ac1f5

Browse files
teknium1Ryan
authored andcommitted
refactor(cli): drop dead c-S-c key binding (follow-up to NousResearch#19895) (NousResearch#19919)
NousResearch#19884 added a prompt_toolkit key binding for Ctrl+Shift+C to "prevent Hermes from intercepting the keystroke as an interrupt signal." NousResearch#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 (NousResearch#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.
1 parent 2e2026f commit 79ac1f5

1 file changed

Lines changed: 8 additions & 13 deletions

File tree

cli.py

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10484,19 +10484,14 @@ def handle_ctrl_c(event):
1048410484
self._should_exit = True
1048510485
event.app.exit()
1048610486

10487-
try:
10488-
@kb.add('c-S-c') # Ctrl+Shift+C — no-op, let terminal handle native copy
10489-
def handle_ctrl_shift_c(event):
10490-
"""No-op: let the terminal handle Ctrl+Shift+C natively.
10491-
10492-
Wrapped in try/except because prompt_toolkit raises ValueError
10493-
("Invalid key: c-S-c") on platforms where this key spec is not
10494-
recognised. The binding is best-effort; if registration fails,
10495-
startup continues normally.
10496-
"""
10497-
return
10498-
except ValueError:
10499-
pass # prompt_toolkit on this platform/version doesn't support c-S-c
10487+
# Ctrl+Shift+C: no binding needed. Terminal emulators (GNOME Terminal,
10488+
# iTerm2, kitty, Windows Terminal, etc.) intercept Ctrl+Shift+C before
10489+
# the keystroke reaches the application's stdin — prompt_toolkit never
10490+
# sees it, and prompt_toolkit's key spec parser doesn't even recognise
10491+
# 'c-S-c' anyway (the Shift modifier is meaningless on control-sequence
10492+
# keys). #19884 added a handler for this; #19895 patched the resulting
10493+
# startup crash with try/except. Both were based on a misreading of how
10494+
# terminal key events propagate. Deleting the dead handler outright.
1050010495

1050110496
@kb.add('c-q') # Ctrl+Q
1050210497
def handle_ctrl_q(event):

0 commit comments

Comments
 (0)