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
feat(onboarding): stdlib-only fast-path handler shared with the API routes
Ruben Lütkee3226148d5c6
diff --git a/jarvis/ui/web/onboarding_routes.py b/jarvis/ui/web/onboarding_routes.pyindex c60338cc33..39606dd7b9 100644--- a/jarvis/ui/web/onboarding_routes.py+++ b/jarvis/ui/web/onboarding_routes.py@@ -9,20 +9,14 @@ not on blocking.from __future__ import annotationsimport logging-import osfrom pathlib import Pathfrom fastapi import APIRouterfrom pydantic import BaseModel-from jarvis.core.config import is_first_runfrom jarvis.setup import state as st-from jarvis.setup.onboarding_meta import (- CURRENT_TERMS_VERSION,- ONBOARDING_STEPS,- WAKE_WORD_LEGAL_REFERENCES,- read_terms_text,-)+from jarvis.setup.onboarding_fastpath import state_payload as _shared_state_payload+from jarvis.setup.onboarding_meta import CURRENT_TERMS_VERSION, read_terms_textlog = logging.getLogger(__name__)@@ -42,45 +36,11 @@ class StepBody(BaseModel):skipped: list[str] | None = None-def _force_onboarding() -> bool:- return bool(os.environ.get("JARVIS_FORCE_ONBOARDING"))--def _safe_state_payload() -> dict:- """Build the GET /state payload. Never raises — fails open to 'incomplete'."""- try:- s = st.get_onboarding_state(_path())- except Exception as exc: # noqa: BLE001 — UI must keep working- log.warning("onboarding_get_state_failed: %s", exc, exc_info=True)- s = {- "completed_at": None, "current_step": None, "skipped_steps": [],- "terms_accepted_at": None, "terms_version": None,- "wake_word_acknowledged_at": None,- }-- legacy_done = False- try:- legacy_done = not is_first_run()- except Exception as exc: # noqa: BLE001- log.debug("onboarding: is_first_run failed: %s", exc)-- completed = (s["completed_at"] is not None) or legacy_done- if _force_onboarding():- completed = False-- return {- "completed": completed,- "current_step": s["current_step"],- "skipped_steps": s["skipped_steps"],- "terms": {- "accepted": s["terms_accepted_at"] is not None,- "accepted_version": s["terms_version"],- "current_version": CURRENT_TERMS_VERSION,- },- "wake_word_acknowledged": s["wake_word_acknowledged_at"] is not None,- "legal_references": WAKE_WORD_LEGAL_REFERENCES,- "steps": ONBOARDING_STEPS,- }+ """Build the GET /state payload — shared with the fast-boot handler+ (jarvis.setup.onboarding_fastpath) so the warming window and the real app+ can never disagree. Never raises — fails open to 'incomplete'."""+ return _shared_state_payload(_path())@router.get("/state")diff --git a/tests/unit/ui/test_onboarding_routes.py b/tests/unit/ui/test_onboarding_routes.pyindex 65e66bb71f..8032f1bfed 100644--- a/tests/unit/ui/test_onboarding_routes.py+++ b/tests/unit/ui/test_onboarding_routes.py@@ -2,14 +2,21 @@ import pytestfrom fastapi import FastAPIfrom fastapi.testclient import TestClient+from jarvis.setup import state as setup_statefrom jarvis.ui.web import onboarding_routes@pytest.fixture-def client(tmp_path, monkeypatch):+def state_dir(tmp_path, monkeypatch):+ # The legacy .setup-complete marker resolves next to the state file, so a+ # tmp state path isolates BOTH stores (see setup_complete_marker_path).monkeypatch.setattr(onboarding_routes, "_STATE_PATH_OVERRIDE", tmp_path / "s.json")- monkeypatch.setattr(onboarding_routes, "is_first_run", lambda: True)monkeypatch.delenv("JARVIS_FORCE_ONBOARDING", raising=False)+ return tmp_path+++def client(state_dir):app = FastAPI()app.include_router(onboarding_routes.router)return TestClient(app)@@ -46,22 +53,22 @@ def test_accept_then_complete(client):assert body["current_step"] == "finish"-def test_legacy_install_is_migrated(client, monkeypatch):- monkeypatch.setattr(onboarding_routes, "is_first_run", lambda: False)+def test_legacy_install_is_migrated(client, state_dir):+ (state_dir / ".setup-complete").write_text("done\n", encoding="utf-8")assert client.get("/api/onboarding/state").json()["completed"] is True-def test_force_env_overrides(client, monkeypatch):- monkeypatch.setattr(onboarding_routes, "is_first_run", lambda: False)+def test_force_env_overrides(client, state_dir, monkeypatch):+ (state_dir / ".setup-complete").write_text("done\n", encoding="utf-8")monkeypatch.setenv("JARVIS_FORCE_ONBOARDING", "1")assert client.get("/api/onboarding/state").json()["completed"] is False-def test_migration_fail_open_when_is_first_run_raises(client, monkeypatch):- def boom() -> bool:+def test_migration_fail_open_when_marker_probe_raises(client, monkeypatch):+ def boom(path=None) -> bool:raise RuntimeError("marker check failed")- monkeypatch.setattr(onboarding_routes, "is_first_run", boom)+ monkeypatch.setattr(setup_state, "setup_complete_marker_exists", boom)r = client.get("/api/onboarding/state")assert r.status_code == 200assert r.json()["completed"] is False # safe default, not a 500