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(install): defer optional browser setup on headless installs (#362)

Ruben Lütke5470338f44e2
diff --git a/install/installer.py b/install/installer.py
index 09c1436639..e76bde7d24 100644
--- a/install/installer.py
+++ b/install/installer.py
@@ -978,13 +978,16 @@ def main(argv: list[str] | None = None) -> int:
step_models(full_profile=with_desktop, dry_run=args.dry_run)
- browser_cmd = [str(venv_python()), "-m", "jarvis.society.browser.install"]
- if sys.platform.startswith("linux"):
- browser_cmd.append("--system-deps")
- if args.dry_run:
- note("managed browser: install and verify on first full installation")
+ if not with_desktop or args.headless:
+ note("Agent browser setup skipped (headless).")
else:
- run_noted(browser_cmd, label="preparing the agent browser", cwd=repo_root())
+ browser_cmd = [str(venv_python()), "-m", "jarvis.society.browser.install"]
+ if sys.platform.startswith("linux"):
+ browser_cmd.append("--system-deps")
+ if args.dry_run:
+ note("managed browser: install and verify on first full installation")
+ else:
+ run_noted(browser_cmd, label="preparing the agent browser", cwd=repo_root())
phase("6/6", "Finish & launch")
step_cli_links(dry_run=args.dry_run)
diff --git a/jarvis/ui/web/server.py b/jarvis/ui/web/server.py
index 7cc10e3560..54205135ee 100644
--- a/jarvis/ui/web/server.py
+++ b/jarvis/ui/web/server.py
@@ -98,7 +98,6 @@ class WebServer:
def __init__(self, cfg: JarvisConfig, bus: EventBus | None = None) -> None:
self.cfg = cfg
- self._browser_prepare_task: asyncio.Task[None] | None = None
self.bus = bus if bus is not None else get_default_bus()
self._clients: dict[str, WebSocket] = {}
self._client_send_locks: dict[str, asyncio.Lock] = {}
@@ -1048,9 +1047,6 @@ class WebServer:
# browser can paint after the full FastAPI app has already taken
# over, so the live app must accept the same POST as an idempotent
# no-op instead of returning FastAPI's 405 Method Not Allowed.
- from jarvis.society.browser.install import start_install
- browser_data = Path(getattr(self.cfg.memory, "data_dir", None) or "data")
- start_install(browser_data)
return Response(status_code=204)
@app.get("/api/config")
@@ -2886,18 +2882,9 @@ class WebServer:
# transport for it.
self._schedule_realtime_transport_warm()
self._schedule_appshot_shortcut()
- # Defer provisioning until the boot chain returns control to the server.
- # Only the install is prepared here: a Chromium costs hundreds of MB,
- # so an agent's browser launches when the agent first uses it or the
- # person opens its view, never pre-warmed at boot.
- async def prepare_browser() -> None:
- from jarvis.society.browser import install
- data_dir = Path(getattr(self.cfg.memory, "data_dir", None) or "data")
- try:
- install.start_install(data_dir)
- except Exception:
- logger.debug("Browser preparation deferred after failure", exc_info=True)
- self._browser_prepare_task = asyncio.create_task(prepare_browser(), name="browser-prepare")
+ # Browser provisioning includes a Chromium probe and may need Linux
+ # system libraries. Leave it to explicit browser use/setup; boot and
+ # shell-paint acknowledgements must keep headless installations usable.
# Existing Mars work recovers with zero clients. The deferred helper
# performs its existence probe and runtime composition after boot yields.
from .mars_routes import schedule_mars_resume
@@ -3845,10 +3832,6 @@ class WebServer:
mars_shutdown_failure = type(exc).__name__
logger.warning("Mars station cleanup incomplete ({})", mars_shutdown_failure)
registry_bootstraps_stopped = await self._stop_registry_bootstraps()
- if self._browser_prepare_task is not None:
- self._browser_prepare_task.cancel()
- await asyncio.gather(self._browser_prepare_task, return_exceptions=True)
- self._browser_prepare_task = None
society = getattr(self.app.state, "society", None)
society_shutdown_failure: str | None = None
if society is not None:
diff --git a/tests/contract/test_mars_restart_lifecycle.py b/tests/contract/test_mars_restart_lifecycle.py
index 86bdf99b78..c3fd94acfa 100644
--- a/tests/contract/test_mars_restart_lifecycle.py
+++ b/tests/contract/test_mars_restart_lifecycle.py
@@ -384,17 +384,17 @@ async def test_server_stop_finishes_independent_cleanup_after_mars_timeout(tmp_p
state.agent_chat = SimpleNamespace(cancel_all=async_cleanup("chat"))
state.mission_manager = SimpleNamespace(stop=async_cleanup("missions"))
- browser_started = asyncio.Event()
+ transport_started = asyncio.Event()
- async def prepare_browser():
- browser_started.set()
+ async def warm_transport():
+ transport_started.set()
try:
await asyncio.Event().wait()
finally:
- cleaned.append("browser-prepare")
+ cleaned.append("realtime-warm")
- server._browser_prepare_task = asyncio.create_task(prepare_browser())
- await browser_started.wait()
+ server._realtime_warm_task = asyncio.create_task(warm_transport())
+ await transport_started.wait()
server_exit = asyncio.Event()
class FixtureUvicorn:
@@ -416,7 +416,7 @@ async def test_server_stop_finishes_independent_cleanup_after_mars_timeout(tmp_p
):
await asyncio.wait_for(server.stop(), 2)
assert {
- "browser-prepare",
+ "realtime-warm",
"society-runtime",
"chat",
"marketplace-refresh",
@@ -431,7 +431,7 @@ async def test_server_stop_finishes_independent_cleanup_after_mars_timeout(tmp_p
"uvicorn-exit",
"codex-servers",
} <= set(cleaned)
- assert server._browser_prepare_task is None
+ assert server._realtime_warm_task is None
assert server._plugin_registry is None
assert server._server is server._serve_task is None
assert uvicorn.should_exit and serving.done()
diff --git a/tests/unit/install/test_installer_flow.py b/tests/unit/install/test_installer_flow.py
index 5766cc6636..9841bb2be9 100644
--- a/tests/unit/install/test_installer_flow.py
+++ b/tests/unit/install/test_installer_flow.py
@@ -37,6 +37,43 @@ def test_dry_run_prints_the_numbered_journey(monkeypatch, capsys) -> None:
assert "Finish & launch" in out
+ ("args", "auto_headless", "expected_browser"),
+ [
+ (["--headless"], False, False),
+ ([], True, False),
+ (["--with-desktop"], False, True),
+ (["--headless", "--with-desktop"], False, False),
+ ],
+)
+def test_browser_provisioning_respects_headless_profile(
+ monkeypatch, capsys, tmp_path, args, auto_headless, expected_browser
+) -> None:
+ """Headless installs must not launch Chromium or request system packages."""
+ commands: list[list[str]] = []
+ monkeypatch.setattr(installer, "repo_root", lambda: tmp_path)
+ monkeypatch.setattr(installer, "is_headless_linux", lambda: auto_headless)
+ monkeypatch.setattr(installer, "is_update_run", lambda: False)
+ monkeypatch.setattr(installer, "write_managed_marker", lambda **kwargs: None)
+ for step in (
+ "step_preflight", "step_pip_install", "step_models", "step_cli_links",
+ "step_worker_cli", "step_summary",
+ ):
+ monkeypatch.setattr(installer, step, lambda **kwargs: None)
+ monkeypatch.setattr(installer, "step_desktop_integration", lambda **kwargs: True)
+ monkeypatch.setattr(installer, "step_ui_bundle_check", lambda: True)
+ monkeypatch.setattr(
+ installer, "run_noted", lambda command, **kwargs: commands.append(command)
+ )
+
+ assert installer.main([*args, "--no-launch"]) == 0
+ browser_commands = [
+ command for command in commands if "jarvis.society.browser.install" in command
+ ]
+ assert bool(browser_commands) is expected_browser
+ assert ("Agent browser setup skipped" in capsys.readouterr().out) is not expected_browser
+
+
def test_installer_prompts_only_inside_missing_prerequisite_flow() -> None:
"""Design amendment 2026-07-11: Stage 1 may ask only when Python or Git
is missing. The normal path and all of Stage 2 remain prompt-free."""
diff --git a/tests/unit/ui/web/test_shell_painted_route.py b/tests/unit/ui/web/test_shell_painted_route.py
index ff65709901..21293837b6 100644
--- a/tests/unit/ui/web/test_shell_painted_route.py
+++ b/tests/unit/ui/web/test_shell_painted_route.py
@@ -1,5 +1,8 @@
-"""The shell-paint acknowledgement is valid before and after full-app handoff."""
+"""Shell acknowledgement and shared startup do not provision optional browsers."""
+import asyncio
+
+import pytest
from fastapi.testclient import TestClient
from jarvis.core.bus import EventBus
@@ -7,7 +10,11 @@ from jarvis.core.config import JarvisConfig
from jarvis.ui.web.server import WebServer
-def test_full_app_accepts_shell_painted_acknowledgement() -> None:
+def test_full_app_accepts_shell_painted_acknowledgement(monkeypatch) -> None:
+ from jarvis.society.browser import install
+
+ installs = []
+ monkeypatch.setattr(install, "start_install", lambda *args: installs.append(args))
server = WebServer(JarvisConfig(), bus=EventBus())
origin = "http://localhost:47821"
@@ -19,3 +26,49 @@ def test_full_app_accepts_shell_painted_acknowledgement() -> None:
assert response.status_code == 204
assert response.content == b""
+ assert installs == []
+
+
+async def test_shared_startup_does_not_provision_optional_browser(monkeypatch, tmp_path):
+ from jarvis.memory.learning import loop as learning
+ from jarvis.society.browser import install
+ from jarvis.ui.web import mars_routes
+
+ installs = []
+ monkeypatch.setattr(install, "start_install", lambda *args: installs.append(args))
+ monkeypatch.setattr(learning, "start_learning", lambda *args: None)
+ monkeypatch.setattr(mars_routes, "schedule_mars_resume", lambda *args: None)
+ cfg = JarvisConfig()
+ cfg.memory.data_dir = str(tmp_path)
+ server = WebServer(cfg, bus=EventBus())
+
+ async def noop_async():
+ return None
+
+ for name in (
+ "_init_mission_stack", "_init_screenshot_retention", "_init_flight_recorder",
+ "_init_wiki_integration", "_init_task_stack", "_init_channel_stack",
+ ):
+ monkeypatch.setattr(server, name, noop_async)
+ for name in (
+ "_init_wiki_boot_index", "_init_wiki_watcher", "_init_session_stack",
+ "_schedule_anyio_pool_warm", "_schedule_registry_bootstraps",
+ "_schedule_marketplace_refresh_scheduler", "_start_local_models_health_monitor",
+ "_schedule_local_models_autostart", "_schedule_realtime_transport_warm",
+ "_schedule_appshot_shortcut",
+ ):
+ monkeypatch.setattr(server, name, lambda **kwargs: None)
+ for name in (
+ "_skill_registry", "_doc_registry", "_cli_registry", "_plugin_registry",
+ "_board_aggregator", "_board_evaluator", "_bio_scheduler",
+ ):
+ setattr(server, name, None)
+ server._voice_ready = True
+ server._pending_reloads.clear()
+
+ await server.start(start_serving=False)
+ await server._channel_stack_task
+ await asyncio.sleep(0)
+
+ assert installs == []