Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

fix(cu): per-backend Escape key name — the cancel hotkey never fired

Ruben Lütke32d4602dab28
diff --git a/jarvis/cu/indicator/controller.py b/jarvis/cu/indicator/controller.py
index db9d77b9ff..8cbc4221f0 100644
--- a/jarvis/cu/indicator/controller.py
+++ b/jarvis/cu/indicator/controller.py
@@ -51,6 +51,15 @@ _QUIT_GRACE_S = 1.5
_BLANK_ACK_TIMEOUT_S = 0.15
+def _esc_binding() -> list[str]:
+ """The Escape key's name differs per hotkey backend (live 2026-07-16):
+ Windows ``global-hotkeys`` only accepts ``"escape"`` (``"esc"`` raises
+ "not a valid virtual keystroke" and disables the whole registration),
+ while the pynput backend (macOS/Linux-X11) canonicalizes the key event
+ to ``Key.esc.name == "esc"`` and would never match ``"escape"``."""
+ return ["escape"] if sys.platform == "win32" else ["esc"]
+
+
def _screen_indicator_enabled() -> bool:
try:
from jarvis.core.config import load_config # noqa: PLC0415
@@ -295,10 +304,11 @@ class CUIndicatorController:
try:
from jarvis.trigger.hotkey import HotkeyTrigger # noqa: PLC0415
- # Bare "esc" is intentionally NOT run through validate_hotkey():
- # that guard protects user-configured push-to-talk combos; this
- # binding exists only while Jarvis itself is typing/clicking.
- trigger = HotkeyTrigger({"cu_cancel": ["esc"]})
+ # The bare Escape key is intentionally NOT run through
+ # validate_hotkey(): that guard protects user-configured
+ # push-to-talk combos; this binding exists only while Jarvis
+ # itself is typing/clicking.
+ trigger = HotkeyTrigger({"cu_cancel": _esc_binding()})
async with trigger:
async for event_name in trigger.events():
if event_name != "cu_cancel":
diff --git a/tests/unit/cu/indicator/test_controller.py b/tests/unit/cu/indicator/test_controller.py
index 69adf745f5..b2e316ffaf 100644
--- a/tests/unit/cu/indicator/test_controller.py
+++ b/tests/unit/cu/indicator/test_controller.py
@@ -124,6 +124,20 @@ async def test_escape_cancels_missions_without_suppression(
assert seen == {"reason": "user_escape", "suppress_new": False}
+def test_esc_binding_matches_each_backend_vocabulary(
+ monkeypatch: pytest.MonkeyPatch,
+) -> None:
+ """Live 2026-07-16: global-hotkeys (win32) only accepts "escape" — "esc"
+ raises and disables the registration; pynput canonicalizes the key to
+ "esc" and never matches "escape". The binding must be per-platform."""
+ monkeypatch.setattr(controller_mod.sys, "platform", "win32")
+ assert controller_mod._esc_binding() == ["escape"]
+ monkeypatch.setattr(controller_mod.sys, "platform", "darwin")
+ assert controller_mod._esc_binding() == ["esc"]
+ monkeypatch.setattr(controller_mod.sys, "platform", "linux")
+ assert controller_mod._esc_binding() == ["esc"]
+
+
def test_hint_table_covers_every_supported_locale() -> None:
"""Repo language rule: a phrase table carries ALL supported locales and
resolves through the one resolver."""