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(local-models): a starting server says so instead of reading as stopped
rubenluetke10-beepe625fd4bd1b9
diff --git a/docs/BUGS.md b/docs/BUGS.mdindex 480cb2e968..bde08e3220 100644--- a/docs/BUGS.md+++ b/docs/BUGS.md@@ -14454,6 +14454,24 @@ changed nothing on the card. It now applies what it persists:16.3 after the switch-off path ran: the managed voice server, both residentmodels and the local server all gone, with a hosted voice still answering.+**The boot window, same session.** The other half the maintainer asked for:+"when the server is being set up I want a small indicator that it is still+setting up, and when it is up, that it shows that too." `runtime_status` knew+three states — not installed, installed-but-stopped, running — and an HTTP+probe cannot see the fourth: a server this install spawned that has not+answered its first request yet. The panel rendered that window as "Installed,+not running", so a Start click looked like it had done nothing, and a model+still loading read as ready.++- `_owned_process_alive()` — the pid-reuse guard `stop_server` already uses,+ without the stopping. Only OUR recorded process counts, so a server someone+ else started never shows a boot window this install cannot observe.+- `runtime_status` gains `starting` and its own sentence; `_server_from` and+ `ServerResponse` carry it out, `useLocalModels.ts` mirrors the field (AP-4's+ five layers), and the dot reads "Starting…" in all three locales.+- While it lasts, the server query polls every second instead of every+ fifteen. A boot is over in seconds; a stale "Starting" reads as a hang.+**Related.** BUG-174 (the other local-models defect whose symptom was "voice onlocal models is unusably slow after a restart" — same stack, different half).diff --git a/jarvis/brain/ollama_overview.py b/jarvis/brain/ollama_overview.pyindex 6532dc81da..309d91c6a0 100644--- a/jarvis/brain/ollama_overview.py+++ b/jarvis/brain/ollama_overview.py@@ -362,6 +362,7 @@ async def _server_from(status: dict[str, object], fallback_root: str) -> dict[st"installed": bool(status.get("installed")),"binary": str(status.get("binary") or ""),"running": bool(status.get("running")),+ "starting": bool(status.get("starting")),"version": str(status.get("version") or ""),"detail": str(status.get("detail") or ""),"base_url": root,diff --git a/jarvis/brain/ollama_runtime.py b/jarvis/brain/ollama_runtime.pyindex fa677d21fa..5f93528afa 100644--- a/jarvis/brain/ollama_runtime.py+++ b/jarvis/brain/ollama_runtime.py@@ -216,22 +216,49 @@ def models_dir(os_name: str | None = None) -> Path:return Path.home() / ".ollama" / "models"+def _owned_process_alive() -> bool:+ """Whether the ``ollama serve`` THIS install spawned is still a live Ollama.++ The pid-reuse guard :func:`stop_server` uses, without the stopping: a+ recorded pid the OS has handed to some other program is not ours.+ """+ pid = _recorded_pid()+ if pid is None:+ return False+ import psutil # lazy (AP-26)++ try:+ return _process_is_ollama(psutil.Process(pid))+ except psutil.Error:+ return False++def runtime_status() -> dict[str, object]:"""The honest runtime picture.- ``{installed, binary, running, version, detail, base_url, host_kind,- models_dir}``. A pure HTTP probe cannot tell "not installed" from- "installed but stopped" — and those two states need OPPOSITE buttons- (install vs start), so the distinction is the whole point of this- function. ``host_kind`` tells the panel whether install/start/stop/log- even apply here: a remote server is managed on its own machine.+ ``{installed, binary, running, starting, version, detail, base_url,+ host_kind, models_dir}``. A pure HTTP probe cannot tell "not installed"+ from "installed but stopped" — and those two states need OPPOSITE+ buttons (install vs start), so the distinction is the whole point of+ this function. ``host_kind`` tells the panel whether install/start/stop/+ log even apply here: a remote server is managed on its own machine.++ ``starting`` is the fourth state, and it is not cosmetic: a spawned+ server takes seconds to answer its first request, and reporting that+ window as "stopped" told the user their click did nothing — so they+ clicked again, or read a model as ready that was still loading+ (BUG-204). Our own process being alive while the port stays quiet IS+ the boot window; a server someone else started never shows it here."""binary = find_binary()version = _server_version()running = version is not Noneinstalled = bool(binary) or running+ starting = not running and _owned_process_alive()if running:detail = f"Ollama is running (version {version})."+ elif starting:+ detail = "Ollama is starting — it does not answer yet."elif installed:detail = "Ollama is installed but not running."else:@@ -241,6 +268,7 @@ def runtime_status() -> dict[str, object]:"installed": installed,"binary": binary,"running": running,+ "starting": starting,"version": version or "","detail": detail,"base_url": base_url,diff --git a/jarvis/ui/web/frontend/src/hooks/useLocalModels.ts b/jarvis/ui/web/frontend/src/hooks/useLocalModels.tsindex 67162959b8..3fd17e4846 100644--- a/jarvis/ui/web/frontend/src/hooks/useLocalModels.ts+++ b/jarvis/ui/web/frontend/src/hooks/useLocalModels.ts@@ -415,6 +415,8 @@ export interface ServerResponse {installed: boolean;binary: string;running: boolean;+ /** Spawned by this install and not answering yet — shown as "Starting". */+ starting: boolean;version: string;detail: string;base_url: string;@@ -1120,7 +1122,11 @@ export function useServer(providerId: string | undefined, enabled = true) {queryKey: localModelsKeys.server(providerId ?? ""),queryFn: () => getServer(providerId as string),enabled: enabled && !!providerId,- refetchInterval: 15_000,+ // A boot is over in seconds, so the "Starting" dot polls every second+ // while it lasts; a settled server goes back to the slow beat. Fifteen+ // seconds of a stale "Starting" reads as a hang (BUG-204).+ refetchInterval: (query) =>+ (query.state.data as ServerResponse | undefined)?.starting ? 1_000 : 15_000,staleTime: 5_000,gcTime: SECTION_GC_MS,});diff --git a/jarvis/ui/web/frontend/src/i18n/locales/local_models/de.json b/jarvis/ui/web/frontend/src/i18n/locales/local_models/de.jsonindex 41f1744ffa..53181028b4 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/local_models/de.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/local_models/de.json@@ -360,6 +360,7 @@"runtime_eyebrow": "Laufzeit","runtime_title": "Lokaler Prozess","status_running": "Läuft",+ "status_starting": "Startet…","status_stopped": "Installiert, läuft nicht","status_missing": "Nicht installiert","stop": "Stoppen",diff --git a/jarvis/ui/web/frontend/src/i18n/locales/local_models/en.json b/jarvis/ui/web/frontend/src/i18n/locales/local_models/en.jsonindex ceba9c4f2e..e1f11283f2 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/local_models/en.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/local_models/en.json@@ -360,6 +360,7 @@"runtime_eyebrow": "Runtime","runtime_title": "Local process","status_running": "Running",+ "status_starting": "Starting…","status_stopped": "Installed, not running","status_missing": "Not installed","stop": "Stop",diff --git a/jarvis/ui/web/frontend/src/i18n/locales/local_models/es.json b/jarvis/ui/web/frontend/src/i18n/locales/local_models/es.jsonindex ac0f705cc6..9a1759015b 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/local_models/es.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/local_models/es.json@@ -360,6 +360,7 @@"runtime_eyebrow": "Tiempo de ejecución","runtime_title": "Proceso local","status_running": "En marcha",+ "status_starting": "Arrancando…","status_stopped": "Instalado, no está en marcha","status_missing": "No instalado","stop": "Detener",diff --git a/jarvis/ui/web/frontend/src/views/local-models/OverviewPanel.test.tsx b/jarvis/ui/web/frontend/src/views/local-models/OverviewPanel.test.tsxindex c3377d4c68..1050fcdb12 100644--- a/jarvis/ui/web/frontend/src/views/local-models/OverviewPanel.test.tsx+++ b/jarvis/ui/web/frontend/src/views/local-models/OverviewPanel.test.tsx@@ -114,6 +114,7 @@ const SERVER = {installed: true,binary: "ollama",running: true,+ starting: false,version: "0.32.15",detail: "",base_url: "http://127.0.0.1:11434",diff --git a/jarvis/ui/web/frontend/src/views/local-models/ServerPanel.tsx b/jarvis/ui/web/frontend/src/views/local-models/ServerPanel.tsxindex 644a209466..0a10c9cce3 100644--- a/jarvis/ui/web/frontend/src/views/local-models/ServerPanel.tsx+++ b/jarvis/ui/web/frontend/src/views/local-models/ServerPanel.tsx@@ -398,12 +398,23 @@ export function ServerPanel({},];- const statusTone = data?.running ? "ok" : data?.installed ? "off" : "warn";+ // Four states, not three: a server this install spawned takes seconds to+ // answer, and calling that window "Stopped" made people click Start twice+ // or read a loading model as ready (BUG-204).+ const statusTone = data?.running+ ? "ok"+ : data?.starting+ ? "warn"+ : data?.installed+ ? "off"+ : "warn";const statusLabel = data?.running? t("local_models.server.status_running")- : data?.installed- ? t("local_models.server.status_stopped")- : t("local_models.server.status_missing");+ : data?.starting+ ? t("local_models.server.status_starting")+ : data?.installed+ ? t("local_models.server.status_stopped")+ : t("local_models.server.status_missing");return (<div className="space-y-4" data-testid="server-panel">diff --git a/jarvis/ui/web/frontend/src/views/local-models/localSetup.test.ts b/jarvis/ui/web/frontend/src/views/local-models/localSetup.test.tsindex e4e6997802..cf12cfac0d 100644--- a/jarvis/ui/web/frontend/src/views/local-models/localSetup.test.ts+++ b/jarvis/ui/web/frontend/src/views/local-models/localSetup.test.ts@@ -41,6 +41,7 @@ function overview(installed: true,binary: "ollama",running: true,+ starting: false,version: "0.32.15",detail: "",base_url: "http://127.0.0.1:11434",diff --git a/jarvis/ui/web/local_models_routes.py b/jarvis/ui/web/local_models_routes.pyindex 5d11de1327..2b4d4a9183 100644--- a/jarvis/ui/web/local_models_routes.py+++ b/jarvis/ui/web/local_models_routes.py@@ -825,6 +825,9 @@ class ServerResponse(BaseModel):installed: boolbinary: strrunning: bool+ #: Spawned by this install and not answering yet — the boot window the+ #: panel shows as "Starting" instead of the misleading "Stopped".+ starting: bool = Falseversion: strdetail: strbase_url: strdiff --git a/tests/unit/brain/test_ollama_runtime.py b/tests/unit/brain/test_ollama_runtime.pyindex dab4b52f07..529ae67cfd 100644--- a/tests/unit/brain/test_ollama_runtime.py+++ b/tests/unit/brain/test_ollama_runtime.py@@ -1,7 +1,7 @@"""Ollama runtime lifecycle: detect / install / start without a terminal.-What these tests pin: the three-state truth an HTTP probe cannot give-(not-installed vs installed-but-stopped vs running), the honest per-OS+What these tests pin: the four-state truth an HTTP probe cannot give+(not-installed vs installed-but-stopped vs starting vs running), the honest per-OSrefusals (no hidden password prompt, no unofficial download URL), and thepoll-shaped installer contract shared with the managed-server install."""@@ -26,7 +26,7 @@ def _fresh_state(monkeypatch, tmp_path):ollama_runtime._reset_for_tests()-# ── runtime_status: the three states ─────────────────────────────────────+# ── runtime_status: the four states ──────────────────────────────────────def test_running_server_reports_running(monkeypatch) -> None:monkeypatch.setattr(ollama_runtime, "find_binary", lambda: "/usr/bin/ollama")monkeypatch.setattr(ollama_runtime, "_server_version", lambda timeout=1.5: "0.9.1")@@ -69,6 +69,44 @@ def test_a_running_server_counts_as_installed_even_without_a_binary(assert status["running"] is True+def test_our_own_boot_window_is_starting_not_stopped(monkeypatch) -> None:+ """A spawned server takes seconds to answer; "Stopped" is a lie meanwhile.++ What would lie if it broke: the panel telling the user their Start click+ did nothing, so they click again — or read a model as ready while it is+ still loading (BUG-204).+ """+ monkeypatch.setattr(ollama_runtime, "find_binary", lambda: "C:\\x\\ollama.exe")+ monkeypatch.setattr(ollama_runtime, "_server_version", lambda timeout=1.5: None)+ monkeypatch.setattr(ollama_runtime, "_owned_process_alive", lambda: True)+ status = ollama_runtime.runtime_status()+ assert status["running"] is False+ assert status["starting"] is True+ assert "starting" in str(status["detail"])++ # Once it answers, the boot window is over.+ monkeypatch.setattr(ollama_runtime, "_server_version", lambda timeout=1.5: "0.9.1")+ settled = ollama_runtime.runtime_status()+ assert settled["running"] is True and settled["starting"] is False+++def test_a_server_we_did_not_spawn_never_shows_a_boot_window(monkeypatch) -> None:+ """Only OUR process can be "starting" — a foreign one we cannot observe."""+ monkeypatch.setattr(ollama_runtime, "find_binary", lambda: "C:\\x\\ollama.exe")+ monkeypatch.setattr(ollama_runtime, "_server_version", lambda timeout=1.5: None)+ monkeypatch.setattr(ollama_runtime, "_owned_process_alive", lambda: False)+ status = ollama_runtime.runtime_status()+ assert status["starting"] is False+ assert "not running" in str(status["detail"])+++def test_a_recycled_pid_is_not_a_boot_window(monkeypatch) -> None:+ """The pid-reuse guard: a recorded pid the OS handed to something else."""+ monkeypatch.setattr(ollama_runtime, "_recorded_pid", lambda: 4242)+ monkeypatch.setattr(ollama_runtime, "_process_is_ollama", lambda _proc: False)+ assert ollama_runtime._owned_process_alive() is False++# ── start_server ─────────────────────────────────────────────────────────def test_start_is_a_noop_when_already_running(monkeypatch) -> None:monkeypatch.setattr(ollama_runtime, "_server_version", lambda timeout=1.5: "0.9.1")