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(agent-chat): keep thread turns alive across the background hand-off (#1113)

Ruben Lütkec48d6f66b7c6
diff --git a/dodaios/ui/web/launcher.py b/dodaios/ui/web/launcher.py
index e0d7923835..76c0678c29 100644
--- a/dodaios/ui/web/launcher.py
+++ b/dodaios/ui/web/launcher.py
@@ -628,6 +628,15 @@ async def _run_headless(args) -> int:
_lx_mark("imports")
+ # Before anything can build the agent-chat service: the init chain in
+ # ``server.start`` may build it, and a service built with the host switch
+ # still off finds no turn host and closes every thread turn the host kept
+ # running as "The app restarted" (the background hand-off, 2026-11-02).
+ # The desktop shell turns the same switch on before its API answers.
+ from dodaios.agentic_ide import host_mode
+
+ host_mode.enable()
+
server = WebServer(cfg)
_lx_mark("webserver_ctor")
diff --git a/tests/unit/agent_chat/test_launcher_turn_host_order.py b/tests/unit/agent_chat/test_launcher_turn_host_order.py
new file mode 100644
index 0000000000..e49f1a2088
--- /dev/null
+++ b/tests/unit/agent_chat/test_launcher_turn_host_order.py
@@ -0,0 +1,22 @@
+"""The web launcher turns the host switch on before the agent-chat service can exist.
+
+The background service (``launcher --headless``) takes over when the desktop
+app closes. Its init chain in ``server.start`` can build the agent-chat
+service; built while ``host_mode`` was still off, the service saw no turn host
+and closed every thread turn the host was still running as "The app
+restarted" (2026-11-02). The desktop shell already turned the switch on early.
+"""
+
+from __future__ import annotations
+
+import inspect
+
+from dodaios.ui.web import launcher
+
+
+def test_headless_launcher_enables_host_mode_before_the_server_exists() -> None:
+ source = inspect.getsource(launcher._run_headless)
+ enable = source.find("host_mode.enable()")
+ assert enable != -1, "the headless launcher must turn host_mode on itself"
+ assert enable < source.find("WebServer(cfg)")
+ assert enable < source.find("await server.start(")