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): closing the window now quits everything, not minimise-to-tray
Ruben Lütkea1f4920b3c46
diff --git a/jarvis/ui/desktop_app.py b/jarvis/ui/desktop_app.pyindex 593c8d5a57..0b00bf8c9d 100644--- a/jarvis/ui/desktop_app.py+++ b/jarvis/ui/desktop_app.py@@ -2726,7 +2726,25 @@ class DesktopApp:gui=gui,debug=debug,)- return self.shutdown()+ # webview.start returns once the window is destroyed. A real quit (the+ # X, tray "Quit", or a restart) has set ``_user_requested_quit``; in that+ # case tear every surface down AND guarantee the process dies, so nothing+ # lingers — the user's "close = close EVERYTHING" mandate. The daemon+ # timer is the backstop for a wedged teardown; the ``os._exit`` right+ # after ``shutdown()`` is the fast path for the common case (forensic+ # 2026-06-27: a hung shutdown kept the old process — and its tray icon —+ # alive ~30 min). On a boot-failure exit ``_user_requested_quit`` is+ # False → normal return, so callers still get an exit code.+ if self._user_requested_quit:+ self._arm_force_exit(after_s=20.0)+ code = self.shutdown()+ if self._user_requested_quit:+ with suppress(Exception):+ sys.stdout.flush()+ with suppress(Exception):+ sys.stderr.flush()+ os._exit(code)+ return codedef _start_icon_setter_thread(self) -> None:"""Polling thread: sets the taskbar/titlebar icon once the HWND exists.@@ -2885,23 +2903,24 @@ class DesktopApp:# ---- Window close (X) = minimise to tray + clear overlay ---------------def _on_window_closing(self) -> bool:- """pywebview ``closing`` callback: the X minimises to tray, not quit.-- Returns ``True`` to allow the destroy — a genuine tray "Quit", where the- real :meth:`shutdown` tears everything down — and ``False`` to veto it- and hide the window instead. On a minimise we ALSO take the overlay bar- off the screen so the desktop is actually clean; it returns on the next- window-show or voice session.+ """pywebview ``closing`` callback: the X (close) fully QUITS Jarvis.++ User mandate (2026-07-01): closing the desktop window must tear+ EVERYTHING down — tray icon, JarvisBar overlay, voice pipeline, backend+ server, child subprocesses and the process itself — not merely hide to+ tray. To keep Jarvis running in the background (so "Hey Jarvis" stays+ live) the user MINIMISES the window instead of closing it.++ We mark the quit and return ``True`` so pywebview destroys the window;+ ``webview.start()`` then returns and :meth:`run_window_only` runs+ :meth:`shutdown` (stops every surface) followed by a hard-exit backstop+ that guarantees the process actually dies even if a native thread+ (WebView2/Tk teardown, a wedged ctranslate2 transcribe — AP-24) would+ otherwise keep it — and its tray icon — alive (forensic 2026-06-27: a+ hung shutdown kept the old process ~30 min)."""- if self._user_requested_quit:- return True- try:- self._window.hide()- self._window_visible = False- self._suppress_overlay_for_hidden_window()- except Exception: # noqa: BLE001- return True- return False+ self._user_requested_quit = True+ return Truedef _suppress_overlay_for_hidden_window(self) -> None:"""Take a NON-persistent overlay bar off the screen on minimise — but@@ -2974,6 +2993,28 @@ class DesktopApp:# ---- Shutdown ----------------------------------------------------------+ def _arm_force_exit(self, *, after_s: float = 20.0) -> None:+ """Daemon backstop: hard-kill the process if the clean shutdown wedges.++ The mandate is that closing the window closes EVERYTHING. ``shutdown()``+ is bounded by per-step timeouts, but history shows a teardown can still+ hang (BUG-031 window-destroy; a pending asyncio task; a wedged native+ transcribe — AP-24) and leave a windowless process holding the tray icon+ + admin port for minutes (forensic 2026-06-27). This timer guarantees+ death regardless. The normal path never reaches it: ``run_window_only``+ ``os._exit()``s the instant ``shutdown()`` returns, so this daemon dies+ with the process first. ``after_s`` sits comfortably above ``shutdown()``'s+ bounded worst case, so it only fires on a genuine infinite hang.+ """++ def _kill() -> None:+ time.sleep(after_s)+ os._exit(0)++ threading.Thread(+ target=_kill, name="jarvis-force-exit", daemon=True+ ).start()+def shutdown(self) -> int:"""Idempotent. Stops the server + backend loop, cleans the meta file."""if self._shutdown_done:diff --git a/tests/unit/ui/test_desktop_minimize_to_tray_overlay.py b/tests/unit/ui/test_desktop_minimize_to_tray_overlay.pyindex 7bd5809722..c117aad443 100644--- a/tests/unit/ui/test_desktop_minimize_to_tray_overlay.py+++ b/tests/unit/ui/test_desktop_minimize_to_tray_overlay.py@@ -1,21 +1,20 @@-"""Closing the window (X) = minimise to tray; the OVERLAY follows the user's-"show bar at all times" choice.+"""Closing the window (X) = QUIT EVERYTHING; MINIMISE keeps Jarvis running.-The X on the main window is wired to "minimise to tray", not "quit" (the app-keeps running so voice stays live).+User mandate (2026-07-01): the X on the main window must tear the WHOLE app+down — tray icon, JarvisBar overlay, voice pipeline, backend server, child+processes and the process itself — not merely hide to tray. To keep Jarvis+alive in the background (so "Hey Jarvis" stays live) the user MINIMISES the+window instead of closing it.Contract:-- ``_on_window_closing`` vetoes the destroy (returns False) and hides the window.-- ``_suppress_overlay_for_hidden_window`` takes a NON-persistent bar off the- screen on minimise, but NEVER touches a bar the user set to "show at all- times" (``bar_persistent``). Forcing an always-on bar into hide-at-idle here- was the "the bar vanishes after a while and only the wake word brings it back"- regression — the user's explicit always-on preference must win.-- a genuine quit (``_user_requested_quit``) is allowed through untouched; the- real ``shutdown()`` tears the bar down there.-- ``_restore_overlay_for_visible_window`` puts the bar back into the user's- configured persistence regime when the window is shown again.-- both helpers no-op on a headless host (no overlay / no bridge).+- ``_on_window_closing`` marks the quit and returns True → pywebview destroys+ the window → ``run_window_only`` runs ``shutdown()`` (tears every surface+ down) and then a hard-exit backstop that guarantees the process dies even if+ teardown wedges.+- ``_suppress_overlay_for_hidden_window`` / ``_restore_overlay_for_visible_window``+ still govern the bar's persistence regime when the window is HIDDEN/SHOWN via+ the tray "Open" or a focus request — ``bar_persistent`` (the "show bar at all+ times" choice) is honoured, never overridden. Both no-op on a headless host."""from __future__ import annotations@@ -140,11 +139,13 @@ def test_restore_keeps_mascot_hide_on_idle() -> None:assert bar.shown is None # not force-shown-# --- the X / closing callback ------------------------------------------------+# --- the X / closing callback = FULL QUIT -------------------------------------def test_window_closing_minimises_but_keeps_persistent_bar() -> None:- """The X minimises to tray, but an always-on bar stays on screen."""+def test_window_closing_quits_and_does_not_minimise() -> None:+ """User mandate: the X fully quits — it no longer hides to tray. It marks+ the quit and allows the destroy; ``shutdown()`` (run by ``run_window_only``)+ tears every surface — tray, bar, voice, server — down afterwards."""bar = FakeBar()bridge = SimpleNamespace(_hide_on_idle=False)app = _app(persistent=True, orb=bar, bridge=bridge)@@ -154,16 +155,15 @@ def test_window_closing_minimises_but_keeps_persistent_bar() -> None:result = app._on_window_closing()- assert result is False # destroy vetoed → minimise to tray- assert app._window.hidden is True- assert app._window_visible is False- assert bar.hidden is False # always-on bar is NOT cleared- assert bridge._hide_on_idle is False- assert app.cfg.ui.bar_persistent is True # preference untouched+ assert result is True # destroy allowed → full shutdown, not minimise+ assert app._user_requested_quit is True+ assert app._window.hidden is False # NOT hidden — the window is destroyed+ # The bar is torn down in shutdown(), never on the closing callback itself.+ assert bar.hidden is False-def test_window_closing_clears_non_persistent_bar() -> None:- """A non-persistent bar is cleared on minimise (clean desktop)."""+def test_window_closing_quits_regardless_of_bar_persistence() -> None:+ """A non-persistent bar quits exactly the same way — closing always quits."""bar = FakeBar()bridge = SimpleNamespace(_hide_on_idle=False)app = _app(persistent=False, orb=bar, bridge=bridge)@@ -173,13 +173,13 @@ def test_window_closing_clears_non_persistent_bar() -> None:result = app._on_window_closing()- assert result is False- assert app._window.hidden is True- assert bar.hidden is True- assert bridge._hide_on_idle is True+ assert result is True+ assert app._user_requested_quit is True+ assert app._window.hidden is Falsedef test_window_closing_allows_genuine_quit() -> None:+ """An already-marked quit (tray 'Quit' / restart) still returns True."""bar = FakeBar()app = _app(persistent=True, orb=bar, bridge=SimpleNamespace(_hide_on_idle=False))app._window = FakeWindow()