fix(cli): accept Alt+G as Ctrl+G fallback in VSCode/Cursor terminals

Same problem as the TUI: Cursor and VSCode bind Ctrl+G to "Find Next"
at the editor level, so the keystroke never reaches the terminal and
the prompt_toolkit-driven Hermes CLI sees nothing.

Register ('escape', 'g') alongside the existing 'c-g' on the same
handler so the editor handoff works inside Cursor/VSCode too. The
filter (no clarify/approval/sudo/secret prompt active) is unchanged.
This commit is contained in:
Brooklyn Nicholson
2026-04-25 20:01:03 -05:00
parent c58956a9a2
commit 4c797bfae9

18
cli.py
View File

@@ -4318,7 +4318,7 @@ class HermesCLI:
_cprint(f"\n {_DIM}Tip: Just type your message to chat with Hermes!{_RST}") _cprint(f"\n {_DIM}Tip: Just type your message to chat with Hermes!{_RST}")
_cprint(f" {_DIM}Multi-line: Alt+Enter for a new line{_RST}") _cprint(f" {_DIM}Multi-line: Alt+Enter for a new line{_RST}")
_cprint(f" {_DIM}Draft editor: Ctrl+G{_RST}") _cprint(f" {_DIM}Draft editor: Ctrl+G (Alt+G in VSCode/Cursor){_RST}")
if _is_termux_environment(): if _is_termux_environment():
_cprint(f" {_DIM}Attach image: /image {_termux_example_image_path()} or start your prompt with a local image path{_RST}\n") _cprint(f" {_DIM}Attach image: /image {_termux_example_image_path()} or start your prompt with a local image path{_RST}\n")
else: else:
@@ -9308,14 +9308,18 @@ class HermesCLI:
"""Ctrl+Enter (c-j) inserts a newline. Most terminals send c-j for Ctrl+Enter.""" """Ctrl+Enter (c-j) inserts a newline. Most terminals send c-j for Ctrl+Enter."""
event.current_buffer.insert_text('\n') event.current_buffer.insert_text('\n')
@kb.add( # VSCode/Cursor bind Ctrl+G to "Find Next" at the editor level, so
'c-g', # the keystroke never reaches the embedded terminal. Alt+G is unbound
filter=Condition( # in those IDEs and arrives here as ('escape', 'g') — register it as
lambda: not self._clarify_state and not self._approval_state and not self._sudo_state and not self._secret_state # a fallback so the editor handoff works inside Cursor/VSCode too.
), _editor_filter = Condition(
lambda: not self._clarify_state and not self._approval_state and not self._sudo_state and not self._secret_state
) )
@kb.add('c-g', filter=_editor_filter)
@kb.add('escape', 'g', filter=_editor_filter)
def handle_open_in_editor(event): def handle_open_in_editor(event):
"""Ctrl+G opens the current draft in an external editor.""" """Ctrl+G (or Alt+G in VSCode/Cursor) opens the current draft in an external editor."""
cli_ref._open_external_editor(event.current_buffer) cli_ref._open_external_editor(event.current_buffer)
@kb.add('tab', eager=True) @kb.add('tab', eager=True)