From 0fd3b59ba16838a7c43be7d382f75e1439f0c7d9 Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Sun, 29 Mar 2026 15:47:55 -0700 Subject: [PATCH] feat(cli): add Ctrl+Z process suspend support (#3802) Adds a Ctrl+Z key binding to suspend the hermes CLI to background using standard Unix job control. Uses prompt_toolkit's run_in_terminal() to properly save/restore terminal state, then sends SIGTSTP to the process group. Prints a branded message with resume instructions. Shows a not-supported notice on Windows. Co-authored-by: CharlieKerfoot --- cli.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/cli.py b/cli.py index f642894ae..b09a17355 100644 --- a/cli.py +++ b/cli.py @@ -6500,6 +6500,24 @@ class HermesCLI: self._should_exit = True event.app.exit() + @kb.add('c-z') + def handle_ctrl_z(event): + """Handle Ctrl+Z - suspend process to background (Unix only).""" + import sys + if sys.platform == 'win32': + _cprint(f"\n{_DIM}Suspend (Ctrl+Z) is not supported on Windows.{_RST}") + event.app.invalidate() + return + import os, signal as _sig + from prompt_toolkit.application import run_in_terminal + from hermes_cli.skin_engine import get_active_skin + agent_name = get_active_skin().get_branding("agent_name", "Hermes Agent") + msg = f"\n{agent_name} has been suspended. Run `fg` to bring {agent_name} back." + def _suspend(): + os.write(1, msg.encode()) + os.kill(0, _sig.SIGTSTP) + run_in_terminal(_suspend) + # Voice push-to-talk key: configurable via config.yaml (voice.record_key) # Default: Ctrl+B (avoids conflict with Ctrl+R readline reverse-search) # Config uses "ctrl+b" format; prompt_toolkit expects "c-b" format.