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(desktop): say why a Start-Menu launch cannot boot

Harald871983b4567c
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 775880409a..30c457b81c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,13 @@ versioning per [SemVer](https://semver.org/).
### Fixed
+- **A Start-Menu click that cannot boot now says why.** A missing `click`
+ (uvicorn's import-time dependency) killed the backend thread, the window
+ waited 45 s for `/api/health`, and pythonw swallowed the traceback — so
+ Personal Jarvis in the Start recently-used list looked dead. The
+ launcher now refuses up front, a dead backend thread no longer waits
+ out the timeout, and the window's relaunch command points at
+ `PersonalJarvis.exe` like the shortcut.
- **A Gemini Live greeting no longer dies mid-sentence.** Vertex Live fires
an empty `interrupted` for our own steering text, then speaks the real
reply. The session used to treat the quiet after that reply's
diff --git a/jarvis/ui/desktop_app.py b/jarvis/ui/desktop_app.py
index e0a4ea787c..5ab8e25734 100644
--- a/jarvis/ui/desktop_app.py
+++ b/jarvis/ui/desktop_app.py
@@ -1389,6 +1389,10 @@ class DesktopApp:
self._backend_thread: threading.Thread | None = None
self._backend_loop: asyncio.AbstractEventLoop | None = None
+ # Set if the backend thread dies during bind (missing click, port
+ # collision, …). ``_wait_for_backend`` reads it so the main thread can
+ # name the reason instead of sitting on a 45 s health poll.
+ self._backend_boot_error: BaseException | None = None
# Monotonic stamp of the moment the backend loop began serving, and a
# one-shot latch — together they gate the automatic recovery in
# _note_backend_stopped so a crash-on-boot can never become a
@@ -1561,9 +1565,13 @@ class DesktopApp:
session_token=self.session_token,
vite_dev_url=(self.cfg.ui.vite_dev_url if self.cfg.ui.dev_mode else None),
)
- loop.run_until_complete(
- bootstrap.serve("127.0.0.1", self.cfg.ui.admin_api_port)
- )
+ try:
+ loop.run_until_complete(
+ bootstrap.serve("127.0.0.1", self.cfg.ui.admin_api_port)
+ )
+ except Exception as exc:
+ self._backend_boot_error = exc
+ raise
self._bootstrap = bootstrap
_db_boot_ready() # /api/health is servable now → window can appear
@@ -4695,11 +4703,38 @@ class DesktopApp:
# ---- Backend-ready check --------------------------------------------------
+ def _format_backend_boot_failure(self) -> str:
+ """A sentence the user can act on when the window never appears."""
+ exc = getattr(self, "_backend_boot_error", None)
+ python = sys.executable
+ if isinstance(exc, ModuleNotFoundError):
+ missing = exc.name or str(exc)
+ return (
+ f"{WINDOW_TITLE} cannot start: the package '{missing}' is "
+ f"missing from this Python install.\n\n"
+ f"Python: {python}\n\n"
+ f"Restore it with:\n"
+ f" {python} -m pip install -r requirements.txt"
+ )
+ if exc is not None:
+ return (
+ f"{WINDOW_TITLE} cannot start: {type(exc).__name__}: {exc}\n\n"
+ f"Python: {python}"
+ )
+ return (
+ f"{WINDOW_TITLE} cannot start: the backend did not become ready.\n\n"
+ f"Python: {python}"
+ )
+
def _wait_for_backend(self, timeout_s: float = 45.0) -> bool:
"""Polls ``/api/health`` until it returns 200 or the timeout expires.
45s default — Whisper/VAD models are loaded on first initialization
and block the event loop synchronously for up to ~20s.
+
+ If the backend thread has already died (missing import, bind error),
+ return immediately — waiting out the timeout just hides the reason
+ under pythonw for 45 seconds.
"""
import httpx
@@ -4708,6 +4743,9 @@ class DesktopApp:
# 100 ms startup buffer so the thread can set up the loop.
time.sleep(0.05)
while time.monotonic() - start < timeout_s:
+ thread = self._backend_thread
+ if thread is not None and not thread.is_alive():
+ return False
try:
r = httpx.get(url, timeout=0.5)
if r.status_code == 200:
@@ -4810,7 +4848,17 @@ class DesktopApp:
)
if not self._wait_for_backend():
- sys.stderr.write("Backend did not start within 45s — aborting.\n")
+ detail = self._format_backend_boot_failure()
+ reported = False
+ try:
+ from jarvis.ui.web.launcher import _report_startup_failure
+
+ _report_startup_failure(detail)
+ reported = True
+ except Exception: # noqa: BLE001, S110 — dialog is best-effort
+ pass
+ if not reported:
+ sys.stderr.write(detail + "\n")
return self.shutdown() or 2
# The frame is painted before the web view has loaded a single byte, so
diff --git a/jarvis/ui/icon_utils.py b/jarvis/ui/icon_utils.py
index 9b92fa7777..12b73d700c 100644
--- a/jarvis/ui/icon_utils.py
+++ b/jarvis/ui/icon_utils.py
@@ -1041,11 +1041,14 @@ def set_window_relaunch_properties(
store.SetValue(
(fmtid, _PID_RELAUNCH_NAME), propsys.PROPVARIANTType(display_name)
)
- pythonw = _pythonw_executable()
- if pythonw is not None:
+ # Same target as the Start-Menu shortcut. Pointing this at pythonw.exe
+ # made the Start recently-used list / a taskbar re-click a generic-host
+ # launch: Windows either refuses it or pythonw dies with nowhere to print.
+ target = _shortcut_launch_target()
+ if target is not None:
store.SetValue(
(fmtid, _PID_RELAUNCH_COMMAND),
- propsys.PROPVARIANTType(f'"{pythonw}" -m {_LAUNCHER_MODULE}'),
+ propsys.PROPVARIANTType(f'"{target}" -m {_LAUNCHER_MODULE}'),
)
store.Commit()
_RELAUNCH_STAMPED.add(hwnd)
diff --git a/jarvis/ui/web/launcher.py b/jarvis/ui/web/launcher.py
index f98fde1ea5..071534ee15 100644
--- a/jarvis/ui/web/launcher.py
+++ b/jarvis/ui/web/launcher.py
@@ -919,6 +919,36 @@ def _missing_window_toolkit() -> str | None:
)
+def _import_backend_server() -> None:
+ # Import, do not find_spec: uvicorn's import is what loads click, and a
+ # venv that lost click is a Start-Menu click that opens nothing.
+ import uvicorn as _uvicorn # noqa: F401
+
+
+def _missing_backend_server() -> str | None:
+ """Explain a missing uvicorn/click, or ``None`` when the backend can bind.
+
+ The window never appears until ``/api/health`` answers, and that bind is
+ ``import uvicorn`` — which itself ``import click``s. ``find_spec('uvicorn')``
+ stays green while click is gone, so the Start-Menu launch sits on a 45 s
+ health poll, writes the traceback into pythonw's null stderr, and exits.
+ Same shape as :func:`_missing_window_toolkit`; checked up front so the
+ reason is a dialog, not silence.
+ """
+ try:
+ _import_backend_server()
+ except ModuleNotFoundError as exc:
+ missing = exc.name or "uvicorn"
+ return (
+ f"{APP_DISPLAY_NAME} cannot start: the package '{missing}' is "
+ f"missing from this Python install.\n\n"
+ f"Python: {sys.executable}\n\n"
+ f"The window needs this package to serve its UI. Restore it with:\n"
+ f" {sys.executable} -m pip install -r requirements.txt"
+ )
+ return None
+
+
def _run_desktop(cfg, use_lock: bool) -> int:
"""Full desktop app with a pywebview window.
@@ -1243,6 +1273,14 @@ def main(argv: list[str] | None = None) -> int:
_report_startup_failure(_no_window)
return 4
+ # uvicorn (and its import-time click) — every mode, because headless also
+ # binds through FastBootstrap. Checked here so a missing dep is a sentence
+ # instead of a 45 s mute Start-Menu click.
+ _no_server = _missing_backend_server()
+ if _no_server is not None:
+ _report_startup_failure(_no_server)
+ return 4
+
# Drop administrator rights BEFORE booting, not after.
#
# An elevated window is unreachable for dictation apps, text expanders and
diff --git a/tests/unit/ui/test_desktop_backend_death.py b/tests/unit/ui/test_desktop_backend_death.py
index be6ec19d47..1539d82203 100644
--- a/tests/unit/ui/test_desktop_backend_death.py
+++ b/tests/unit/ui/test_desktop_backend_death.py
@@ -18,9 +18,11 @@ Two holes made that possible, and these tests pin both shut:
from __future__ import annotations
+import inspect
import sys
import threading
import time
+import types
from typing import Any
import pytest
@@ -269,3 +271,50 @@ def test_installing_twice_does_not_stack_hooks(monkeypatch: pytest.MonkeyPatch)
desktop_app._install_crash_hooks()
assert threading.excepthook is first
+
+
+# --- boot that never binds -------------------------------------------------
+
+
+def test_wait_stops_when_the_backend_thread_is_already_dead() -> None:
+ """A missing click used to sit on the 45 s health poll, then write the
+ reason into pythonw's null stderr — Start-Menu click, nothing happens."""
+ dead = threading.Thread(target=lambda: None)
+ dead.start()
+ dead.join()
+
+ class _Stub:
+ cfg = types.SimpleNamespace(ui=types.SimpleNamespace(admin_api_port=9))
+ _backend_thread = dead
+
+ started = time.monotonic()
+ assert DesktopApp._wait_for_backend(_Stub(), timeout_s=45.0) is False # type: ignore[arg-type]
+ assert time.monotonic() - started < 2.0
+
+
+def test_boot_failure_names_a_missing_package() -> None:
+ app = _FakeApp(_backend_boot_error=ModuleNotFoundError("No module named 'click'", name="click"))
+ msg = DesktopApp._format_backend_boot_failure(app) # type: ignore[arg-type]
+ assert "click" in msg
+ assert sys.executable in msg
+ assert "pip install -r requirements.txt" in msg
+
+
+def test_boot_failure_names_a_generic_exception() -> None:
+ app = _FakeApp(_backend_boot_error=OSError(10048, "address already in use"))
+ msg = DesktopApp._format_backend_boot_failure(app) # type: ignore[arg-type]
+ assert "OSError" in msg
+ assert sys.executable in msg
+
+
+def test_boot_failure_without_a_stored_exception_still_names_the_interpreter() -> None:
+ app = _FakeApp()
+ msg = DesktopApp._format_backend_boot_failure(app) # type: ignore[arg-type]
+ assert "did not become ready" in msg
+ assert sys.executable in msg
+
+
+def test_a_backend_that_never_binds_reports_visibly() -> None:
+ src = inspect.getsource(DesktopApp.run_window_only)
+ assert "_report_startup_failure" in src
+ assert "_format_backend_boot_failure" in src
diff --git a/tests/unit/ui/test_launcher_visible_startup_failure.py b/tests/unit/ui/test_launcher_visible_startup_failure.py
index 06d109efa7..7fb254d1f9 100644
--- a/tests/unit/ui/test_launcher_visible_startup_failure.py
+++ b/tests/unit/ui/test_launcher_visible_startup_failure.py
@@ -53,6 +53,35 @@ class TestWindowToolkitProbe:
assert launcher._missing_window_toolkit() is not None
+class TestBackendServerProbe:
+ def test_none_when_uvicorn_imports(self) -> None:
+ assert launcher._missing_backend_server() is None
+
+ def test_names_the_missing_package_and_the_interpreter(
+ self, monkeypatch: pytest.MonkeyPatch
+ ) -> None:
+ def _boom() -> None:
+ raise ModuleNotFoundError("No module named 'click'", name="click")
+
+ monkeypatch.setattr(launcher, "_import_backend_server", _boom)
+ msg = launcher._missing_backend_server()
+ assert msg is not None
+ assert "click" in msg, "the user must learn WHAT is missing"
+ assert "pip install -r requirements.txt" in msg
+ assert sys.executable in msg
+
+ def test_falls_back_to_uvicorn_when_the_exception_has_no_name(
+ self, monkeypatch: pytest.MonkeyPatch
+ ) -> None:
+ def _boom() -> None:
+ raise ModuleNotFoundError("broken install")
+
+ monkeypatch.setattr(launcher, "_import_backend_server", _boom)
+ msg = launcher._missing_backend_server()
+ assert msg is not None
+ assert "uvicorn" in msg
+
+
@pytest.fixture
def dialogs(monkeypatch: pytest.MonkeyPatch) -> list[tuple[str, str]]:
"""Intercept the modal box.
@@ -288,11 +317,17 @@ class TestLauncherRefusesEarly:
src = inspect.getsource(launcher.main)
gate_at = src.index("_missing_window_toolkit")
+ server_at = src.index("_missing_backend_server")
for later in ("load_config()", "ensure_control_key", "_run_desktop("):
- assert gate_at < src.index(later), (
+ later_at = src.index(later)
+ assert gate_at < later_at, (
f"the window check must run before {later}; otherwise the user "
"pays the full boot for an error that was knowable up front"
)
+ assert server_at < later_at, (
+ f"the uvicorn/click check must run before {later}; a missing "
+ "click is the same mute Start-Menu click as a missing pywebview"
+ )
def test_refusal_reports_a_failing_exit_code(
self,
@@ -306,3 +341,17 @@ class TestLauncherRefusesEarly:
rc = launcher.main([])
assert rc == 4, "a start that never happened must not report success"
assert "pywebview is missing" in capsys.readouterr().err
+
+ def test_missing_backend_dep_refuses_before_the_window(
+ self,
+ monkeypatch: pytest.MonkeyPatch,
+ capsys: pytest.CaptureFixture[str],
+ dialogs: list[tuple[str, str]],
+ ) -> None:
+ monkeypatch.setattr(launcher, "_missing_window_toolkit", lambda: None)
+ monkeypatch.setattr(
+ launcher, "_missing_backend_server", lambda: "the package 'click' is missing"
+ )
+ rc = launcher.main([])
+ assert rc == 4
+ assert "click" in capsys.readouterr().err
diff --git a/tests/unit/ui/test_relaunch_properties.py b/tests/unit/ui/test_relaunch_properties.py
index 503a917597..53801f9581 100644
--- a/tests/unit/ui/test_relaunch_properties.py
+++ b/tests/unit/ui/test_relaunch_properties.py
@@ -24,6 +24,18 @@ def test_relaunch_properties_api_is_importable() -> None:
assert callable(icon_utils.set_window_relaunch_properties)
+def test_relaunch_command_uses_the_shortcut_target() -> None:
+ """The Start recently-used list and a taskbar re-click use RelaunchCommand, not the .lnk.
+
+ Pointing it at pythonw.exe is the generic-host launch Windows will not
+ treat as an app — the same class of bug as the Start-Menu shortcut that
+ used to target pythonw (BUG-138).
+ """
+ src = inspect.getsource(icon_utils.set_window_relaunch_properties)
+ assert "_shortcut_launch_target" in src
+ assert "_PID_RELAUNCH_COMMAND" in src
+
+
def test_apply_icon_chokepoint_stamps_relaunch_properties() -> None:
"""Every icon path funnels through ``_apply_icon_to_hwnd`` — it must stamp
the relaunch properties, or MS-Store-Python installs regress to the Python