The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(cli): convert Alt key shortcuts to sequence tuple for prompt_toolkit (#74169)
Moisés Valerofef9c537d7f0
diff --git a/cli.py b/cli.pyindex 01ed9a87a2d..38fa410060e 100644--- a/cli.py+++ b/cli.py@@ -17420,6 +17420,7 @@ class HermesCLI(CLIAgentSetupMixin, CLICommandsMixin, CLIBillingMixin):from hermes_cli.config import load_configfrom hermes_cli.voice import (normalize_voice_record_key_for_prompt_toolkit,+ pt_key_to_sequence,voice_record_key_from_config,)_raw_key = voice_record_key_from_config(load_config())@@ -17445,7 +17446,7 @@ class HermesCLI(CLIAgentSetupMixin, CLICommandsMixin, CLIBillingMixin):# voice.record_key mid-session (Copilot round-13 on #19835).self.set_voice_record_key_cache(_raw_key)- @kb.add(_voice_key)+ @kb.add(*pt_key_to_sequence(_voice_key))def handle_voice_record(event):"""Toggle voice recording when voice mode is active.diff --git a/hermes_cli/voice.py b/hermes_cli/voice.pyindex 5cde3604f4d..3c4cddbb08d 100644--- a/hermes_cli/voice.py+++ b/hermes_cli/voice.py@@ -183,6 +183,17 @@ def normalize_voice_record_key_for_prompt_toolkit(raw: Any) -> str:return f"{normalized_mod}{named}"+def pt_key_to_sequence(pt_key: str) -> tuple[str, ...]:+ """Convert a prompt_toolkit key specifier (e.g. 'c-b' or 'a-v') to a sequence tuple.++ prompt_toolkit's ``@kb.add`` rejects 'a-x' strings directly (raises ValueError),+ expecting ('escape', 'x') instead for Alt-modifier shortcuts.+ """+ if isinstance(pt_key, str) and pt_key.startswith("a-"):+ return ("escape", pt_key[2:])+ return (pt_key,)++def format_voice_record_key_for_status(raw: Any) -> str:"""Render ``voice.record_key`` for ``/voice status`` in CLI-friendly form.diff --git a/tests/hermes_cli/test_voice_wrapper.py b/tests/hermes_cli/test_voice_wrapper.pyindex fdfa9c1ab68..c30637cc4bd 100644--- a/tests/hermes_cli/test_voice_wrapper.py+++ b/tests/hermes_cli/test_voice_wrapper.py@@ -73,6 +73,13 @@ class TestNormalizeVoiceRecordKeyForPromptToolkit:# configs like ``option+c`` don't bind Alt+C in the CLI while the# TUI falls back to Ctrl+B.+ def test_pt_key_to_sequence(self):+ from hermes_cli.voice import pt_key_to_sequence++ assert pt_key_to_sequence("c-b") == ("c-b",)+ assert pt_key_to_sequence("a-v") == ("escape", "v")+ assert pt_key_to_sequence("a-space") == ("escape", "space")+class TestVoiceRecordKeyFromConfig:"""Round-11 Copilot review regression on #19835.