mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-07 02:51:50 +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
|
self._should_exit = True
|
||||||
event.app.exit()
|
event.app.exit()
|
||||||
|
|
||||||
@kb.add('c-S-c') # Ctrl+Shift+C
|
try:
|
||||||
def handle_ctrl_shift_c(event):
|
@kb.add('c-S-c') # Ctrl+Shift+C — no-op, let terminal handle native copy
|
||||||
"""Copy text to clipboard (terminal-native).
|
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
|
Wrapped in try/except because prompt_toolkit raises ValueError
|
||||||
handle the actual copy operation when Ctrl+Shift+C is pressed.
|
("Invalid key: c-S-c") on platforms where this key spec is not
|
||||||
This binding prevents Hermes from intercepting the keystroke
|
recognised. The binding is best-effort; if registration fails,
|
||||||
as an interrupt signal.
|
startup continues normally.
|
||||||
|
"""
|
||||||
On macOS the standard copy shortcut is Cmd+C (no Hermes binding
|
return
|
||||||
needed). On Linux/Windows Ctrl+Shift+C is the conventional
|
except ValueError:
|
||||||
terminal copy shortcut.
|
pass # prompt_toolkit on this platform/version doesn't support c-S-c
|
||||||
"""
|
|
||||||
return # No-op — let the terminal perform native copy
|
|
||||||
|
|
||||||
@kb.add('c-q') # Ctrl+Q
|
@kb.add('c-q') # Ctrl+Q
|
||||||
def handle_ctrl_q(event):
|
def handle_ctrl_q(event):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue