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): route non-ASCII typing through xdotool on the Linux pyautogui fallback

Ruben Lütke0fd86648cfa0
diff --git a/jarvis/cu/actuate/posix.py b/jarvis/cu/actuate/posix.py
index 26862fcd70..e49d834fef 100644
--- a/jarvis/cu/actuate/posix.py
+++ b/jarvis/cu/actuate/posix.py
@@ -271,10 +271,14 @@ class PosixActuator(Actuator):
self._pyautogui.scroll(dy)
def key_combo(self, keys: list[str]) -> None:
- # Accept "ctrl+t" combined tokens like the Windows backend.
+ # Accept "ctrl+t" combined tokens like the Windows backend. The
+ # self_input stamp keeps a Jarvis-typed Esc from tripping the
+ # Escape-to-cancel listener (jarvis.cu.indicator).
from jarvis.cu.actuate.windows import expand_combo_keys # noqa: PLC0415
+ from jarvis.cu.indicator.self_input import stamp_if_escape # noqa: PLC0415
expanded = expand_combo_keys([str(k) for k in keys])
+ stamp_if_escape(expanded)
if self._keyboard is None:
aliases = {"cmd", "command", "meta", "super", "win", "windows", "lwin"}
mapped: list[str] = []
@@ -382,6 +386,20 @@ class PosixActuator(Actuator):
def type_text(self, text: str, *, delay_s: float = 0.02) -> None:
if self._keyboard is None:
+ # pyautogui.typewrite silently DROPS every non-ASCII character
+ # (umlauts, eszett, accents, CJK), and Linux always runs on this fallback (the
+ # desktop extras skip pynput there — evdev would compile against
+ # kernel headers). Route non-ASCII through `xdotool type`, which
+ # synthesizes arbitrary Unicode on X11 and is provisioned by the
+ # installer since deep-dive 2026-07-15 H-01.
+ if not text.isascii() and self._xdotool_type(text, delay_s=delay_s):
+ return
+ if not text.isascii():
+ logger.warning(
+ "[cu] typing non-ASCII text via pyautogui — characters "
+ "outside ASCII will be dropped (install xdotool or pynput "
+ "for Unicode input).",
+ )
self._pyautogui.typewrite(text, interval=delay_s)
return
if delay_s <= 0:
@@ -390,3 +408,31 @@ class PosixActuator(Actuator):
for char in text:
self._keyboard.type(char)
time.sleep(delay_s)
+
+ @staticmethod
+ def _xdotool_type(text: str, *, delay_s: float) -> bool:
+ """Type ``text`` via ``xdotool type`` on X11. Returns False when the
+ binary is missing or the call fails, so the caller can fall back."""
+ if not sys.platform.startswith("linux"):
+ return False
+ import shutil # noqa: PLC0415
+ import subprocess # noqa: PLC0415
+
+ if shutil.which("xdotool") is None:
+ return False
+ try:
+ from jarvis.core.process_utils import ( # noqa: PLC0415
+ NO_WINDOW_CREATIONFLAGS,
+ )
+
+ delay_ms = max(1, int(delay_s * 1000)) if delay_s > 0 else 1
+ proc = subprocess.run(
+ ["xdotool", "type", "--delay", str(delay_ms), "--", text],
+ capture_output=True,
+ timeout=max(30.0, 0.5 * len(text)),
+ creationflags=NO_WINDOW_CREATIONFLAGS,
+ )
+ except Exception: # noqa: BLE001 — fall back to pyautogui
+ logger.debug("xdotool type failed", exc_info=True)
+ return False
+ return proc.returncode == 0
diff --git a/tests/unit/cu/test_actuate.py b/tests/unit/cu/test_actuate.py
index 1d5ff49714..c19c90630b 100644
--- a/tests/unit/cu/test_actuate.py
+++ b/tests/unit/cu/test_actuate.py
@@ -538,3 +538,83 @@ def test_macos_quartz_drag_posts_down_dragged_endpoint_and_up(monkeypatch):
assert posted[0].point == (10, 20)
assert posted[-2].point == (30, 40)
assert posted[-1].point == (30, 40)
+
+
+# ---------------------------------------------------------------------------
+# POSIX pyautogui fallback: Unicode typing (deep-dive 2026-07-15 follow-up)
+# ---------------------------------------------------------------------------
+#
+# Linux always runs on the pyautogui fallback (the desktop extras skip pynput
+# there), and pyautogui.typewrite silently DROPS non-ASCII characters — so
+# German umlauts / accents would vanish from typed text. Non-ASCII must route
+# through `xdotool type` (Unicode-capable on X11) and only fall back to
+# pyautogui with a loud warning.
+
+
+def _pyautogui_only_actuator(monkeypatch):
+ """A PosixActuator forced onto the pyautogui fallback with a spy."""
+ from jarvis.cu.actuate import posix as posix_mod
+
+ calls: dict[str, list] = {"typewrite": []}
+
+ class _FakePyautogui:
+ FAILSAFE = True
+
+ @staticmethod
+ def typewrite(text, interval=0.0):
+ calls["typewrite"].append(text)
+
+ actuator = posix_mod.PosixActuator.__new__(posix_mod.PosixActuator)
+ actuator._mouse = None
+ actuator._keyboard = None
+ actuator._keys = {}
+ actuator._buttons = {}
+ actuator._pyautogui = _FakePyautogui()
+ return actuator, calls
+
+
+def test_posix_ascii_typing_stays_on_pyautogui(monkeypatch):
+ actuator, calls = _pyautogui_only_actuator(monkeypatch)
+ xdotool_calls: list[str] = []
+ monkeypatch.setattr(
+ type(actuator), "_xdotool_type",
+ staticmethod(lambda text, *, delay_s: xdotool_calls.append(text) or True),
+ )
+ actuator.type_text("hello world", delay_s=0)
+ assert calls["typewrite"] == ["hello world"]
+ assert xdotool_calls == []
+
+
+def test_posix_unicode_typing_prefers_xdotool(monkeypatch):
+ actuator, calls = _pyautogui_only_actuator(monkeypatch)
+ xdotool_calls: list[str] = []
+ monkeypatch.setattr(
+ type(actuator), "_xdotool_type",
+ staticmethod(lambda text, *, delay_s: xdotool_calls.append(text) or True),
+ )
+ actuator.type_text("Grüße aus München", delay_s=0) # i18n-allow: umlaut fixture under test
+ assert xdotool_calls == ["Grüße aus München"] # i18n-allow: umlaut fixture under test
+ assert calls["typewrite"] == [] # never reached pyautogui
+
+
+def test_posix_unicode_typing_falls_back_loudly(monkeypatch, caplog):
+ """xdotool absent/failed -> pyautogui still types, with a WARNING."""
+ import logging
+
+ actuator, calls = _pyautogui_only_actuator(monkeypatch)
+ monkeypatch.setattr(
+ type(actuator), "_xdotool_type",
+ staticmethod(lambda text, *, delay_s: False),
+ )
+ with caplog.at_level(logging.WARNING, logger="jarvis.cu.actuate.posix"):
+ actuator.type_text("Grüße", delay_s=0) # i18n-allow: umlaut fixture under test
+ assert calls["typewrite"] == ["Grüße"] # i18n-allow: umlaut fixture under test
+ assert any("non-ASCII" in r.message for r in caplog.records)
+
+
+def test_xdotool_type_refuses_off_linux():
+ """The xdotool path is X11-only; Windows/macOS must return False."""
+ from jarvis.cu.actuate.posix import PosixActuator
+
+ if not sys.platform.startswith("linux"):
+ assert PosixActuator._xdotool_type("text", delay_s=0.02) is False