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.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
fix(desktop): the "cannot start" dialog now reaches macOS and Linux too
Harald97b578573923
diff --git a/jarvis/ui/web/launcher.py b/jarvis/ui/web/launcher.pyindex 0c2862ec16..805e3a1577 100644--- a/jarvis/ui/web/launcher.py+++ b/jarvis/ui/web/launcher.py@@ -774,19 +774,71 @@ async def _run_headless(args) -> int:def _show_error_dialog(title: str, message: str) -> None:- """Last-resort visible surface: a native modal box. Windows-only, no-op else.+ """Last-resort visible surface: a native modal box, on every desktop OS.- Separated from ``_report_startup_failure`` so tests can assert the decision- to show a box without a real one ever opening — an unattended dialog blocks- the process until someone clicks it, which in CI means a hung run.+ Reached only when the message provably went nowhere else (see+ ``_report_startup_failure``), because a GUI launch is mute on all three+ platforms: Windows ``pythonw`` has no streams at all, a macOS ``.app`` and a+ Linux ``.desktop`` with ``Terminal=false`` bury stderr in Console.app and+ the journal. Same failure, same class of user, so all three get a dialog.++ Windows uses Win32 directly; macOS uses ``osascript``, which every install+ has; Linux tries the two desktop dialog helpers in turn and honestly gives+ up if the distro ships neither — stderr and the log still carry the reason.++ Separated from its caller so tests can assert the DECISION to show a box+ without a real one opening: an unattended modal blocks until someone clicks+ it, which in CI is a hung run."""- if sys.platform != "win32":+ if sys.platform == "win32":+ with contextlib.suppress(Exception):+ import ctypes++ MB_ICONERROR = 0x10+ ctypes.windll.user32.MessageBoxW(None, message, title, MB_ICONERROR)return- with contextlib.suppress(Exception):- import ctypes- MB_ICONERROR = 0x10- ctypes.windll.user32.MessageBoxW(None, message, title, MB_ICONERROR)+ import subprocess++ from jarvis.core.process_utils import NO_WINDOW_CREATIONFLAGS++ def _run(cmd: list[str]) -> bool:+ try:+ subprocess.run( # noqa: S603 — fixed argv, no shell, no user input in argv[0]+ cmd,+ check=False,+ encoding="utf-8",+ errors="replace",+ creationflags=NO_WINDOW_CREATIONFLAGS,+ )+ return True+ except (OSError, ValueError):+ return False # helper not installed → try the next one++ if sys.platform == "darwin":+ # AppleScript string literals: backslash first, then the quote.+ def _as(text: str) -> str:+ return text.replace("\\", "\\\\").replace('"', '\\"')++ _run(+ [+ "osascript",+ "-e",+ f'display dialog "{_as(message)}" with title "{_as(title)}" '+ 'buttons {"OK"} default button "OK" with icon stop',+ ]+ )+ return++ # Linux: no shell, so the text is an argument and needs no escaping.+ if not (os.environ.get("DISPLAY") or os.environ.get("WAYLAND_DISPLAY")):+ return # no graphical session — a dialog has nowhere to appear+ for cmd in (+ ["zenity", "--error", f"--title={title}", f"--text={message}"],+ ["kdialog", "--title", title, "--error", message],+ ):+ if _run(cmd):+ returndef _report_startup_failure(message: str) -> None:diff --git a/tests/unit/ui/test_launcher_visible_startup_failure.py b/tests/unit/ui/test_launcher_visible_startup_failure.pyindex 77dfe66103..06d109efa7 100644--- a/tests/unit/ui/test_launcher_visible_startup_failure.py+++ b/tests/unit/ui/test_launcher_visible_startup_failure.py@@ -110,9 +110,129 @@ class TestFailureIsVisible:monkeypatch.setattr("loguru.logger.error", _explode)launcher._report_startup_failure("still has to survive this")- @pytest.mark.skipif(sys.platform == "win32", reason="tests the non-Windows no-op")- def test_dialog_is_a_noop_off_windows(self) -> None:- launcher._show_error_dialog("title", "body")+class TestDialogOnEveryDesktopOS:+ """A GUI launch is mute on all three platforms, so all three get a dialog.++ ``sys.platform`` is patched rather than skipped on, so the macOS and Linux+ branches are exercised wherever the suite runs — including the maintainer's+ Windows box, which is the only machine most of this code is written on. A+ fake ``subprocess.run`` keeps real dialogs closed and needs no helper binary+ installed.+ """++ @pytest.fixture+ def spawned(self, monkeypatch: pytest.MonkeyPatch) -> list[list[str]]:+ import subprocess++ calls: list[list[str]] = []++ def _fake_run(cmd: list[str], **kwargs: object) -> object:+ calls.append(cmd)+ assert kwargs.get("encoding") == "utf-8", "subprocesses must be UTF-8"+ return object()++ monkeypatch.setattr(subprocess, "run", _fake_run)+ return calls++ @staticmethod+ def _as_platform(monkeypatch: pytest.MonkeyPatch, name: str) -> None:+ monkeypatch.setattr(launcher.sys, "platform", name)++ def test_macos_uses_osascript(+ self, spawned: list[list[str]], monkeypatch: pytest.MonkeyPatch+ ) -> None:+ self._as_platform(monkeypatch, "darwin")+ launcher._show_error_dialog("Title", "Body")+ assert spawned and spawned[0][0] == "osascript"+ assert "display dialog" in spawned[0][-1]++ def test_macos_escapes_applescript_string_literals(+ self, spawned: list[list[str]], monkeypatch: pytest.MonkeyPatch+ ) -> None:+ """An unescaped quote turns the message into a syntax error, i.e. silence."""+ self._as_platform(monkeypatch, "darwin")+ launcher._show_error_dialog('Ti"tle', 'say \\ and "quote"')+ script = spawned[0][-1]+ assert '\\"quote\\"' in script and "\\\\" in script++ def test_linux_prefers_zenity_and_passes_text_as_an_argument(+ self, spawned: list[list[str]], monkeypatch: pytest.MonkeyPatch+ ) -> None:+ self._as_platform(monkeypatch, "linux")+ monkeypatch.setenv("DISPLAY", ":0")+ launcher._show_error_dialog("Title", "Body; rm -rf /")+ assert spawned and spawned[0][0] == "zenity"+ # No shell anywhere, so shell metacharacters are inert data.+ assert "--text=Body; rm -rf /" in spawned[0]++ def test_linux_falls_back_to_kdialog(self, monkeypatch: pytest.MonkeyPatch) -> None:+ import subprocess++ calls: list[list[str]] = []++ def _fake_run(cmd: list[str], **kwargs: object) -> object:+ calls.append(cmd)+ if cmd[0] == "zenity":+ raise FileNotFoundError("zenity is not installed")+ return object()++ monkeypatch.setattr(subprocess, "run", _fake_run)+ self._as_platform(monkeypatch, "linux")+ monkeypatch.setenv("DISPLAY", ":0")+ launcher._show_error_dialog("Title", "Body")+ assert [c[0] for c in calls] == ["zenity", "kdialog"]++ def test_linux_without_a_graphical_session_stays_quiet(+ self, spawned: list[list[str]], monkeypatch: pytest.MonkeyPatch+ ) -> None:+ """A headless host has nowhere to show a box; stderr and the log carry it."""+ self._as_platform(monkeypatch, "linux")+ monkeypatch.delenv("DISPLAY", raising=False)+ monkeypatch.delenv("WAYLAND_DISPLAY", raising=False)+ launcher._show_error_dialog("Title", "Body")+ assert not spawned++ def test_wayland_counts_as_a_graphical_session(+ self, spawned: list[list[str]], monkeypatch: pytest.MonkeyPatch+ ) -> None:+ self._as_platform(monkeypatch, "linux")+ monkeypatch.delenv("DISPLAY", raising=False)+ monkeypatch.setenv("WAYLAND_DISPLAY", "wayland-0")+ launcher._show_error_dialog("Title", "Body")+ assert spawned, "a Wayland desktop can show a dialog"++ def test_linux_survives_a_distro_with_neither_helper(+ self, monkeypatch: pytest.MonkeyPatch+ ) -> None:+ import subprocess++ def _missing(cmd: list[str], **kwargs: object) -> object:+ raise FileNotFoundError(cmd[0])++ monkeypatch.setattr(subprocess, "run", _missing)+ self._as_platform(monkeypatch, "linux")+ monkeypatch.setenv("DISPLAY", ":0")+ launcher._show_error_dialog("Title", "Body") # must not raise++ def test_no_dialog_helper_ever_runs_through_a_shell(+ self, monkeypatch: pytest.MonkeyPatch+ ) -> None:+ """The message is attacker-influenced only in theory, but shell=True here+ would turn a diagnostic into command execution. Pin it closed."""+ import subprocess++ seen: list[dict[str, object]] = []++ def _fake_run(cmd: list[str], **kwargs: object) -> object:+ seen.append(kwargs)+ return object()++ monkeypatch.setattr(subprocess, "run", _fake_run)+ monkeypatch.setenv("DISPLAY", ":0")+ for platform_name in ("darwin", "linux"):+ self._as_platform(monkeypatch, platform_name)+ launcher._show_error_dialog("T", "B")+ assert seen and all(not kw.get("shell") for kw in seen)class TestStandardErrorVisibility: