mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-06 02:41:48 +00:00
fix(cli): guard c-S-c key binding with try/except to prevent startup crash (#19895)
PR #19884 added @kb.add('c-S-c') unconditionally. prompt_toolkit raises ValueError("Invalid key: c-S-c") during HermesCLI.__init__ on platforms where this key spec is not recognised — the process exits before reaching the prompt loop. Reported on macOS (#19894) and Linux (#19896) immediately after #19884 landed. Fix: wrap the registration in try/except ValueError so that startup continues cleanly on any platform/version that rejects the spec. Where the spec is accepted the binding is registered normally as a no-op, allowing the terminal to handle Ctrl+Shift+C natively as before. Fixes #19894 Fixes #19896
This commit is contained in:
parent
e493b1c482
commit
429b8eceb4
1 changed files with 12 additions and 13 deletions
25
cli.py
25
cli.py
|
|
@ -10484,20 +10484,19 @@ class HermesCLI:
|
|||
self._should_exit = True
|
||||
event.app.exit()
|
||||
|
||||
@kb.add('c-S-c') # Ctrl+Shift+C
|
||||
def handle_ctrl_shift_c(event):
|
||||
"""Copy text to clipboard (terminal-native).
|
||||
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.
|
||||
|
||||
This is a no-op at the application level. Terminal emulators
|
||||
handle the actual copy operation when Ctrl+Shift+C is pressed.
|
||||
This binding prevents Hermes from intercepting the keystroke
|
||||
as an interrupt signal.
|
||||
|
||||
On macOS the standard copy shortcut is Cmd+C (no Hermes binding
|
||||
needed). On Linux/Windows Ctrl+Shift+C is the conventional
|
||||
terminal copy shortcut.
|
||||
"""
|
||||
return # No-op — let the terminal perform native copy
|
||||
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
|
||||
|
||||
@kb.add('c-q') # Ctrl+Q
|
||||
def handle_ctrl_q(event):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue