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): the set-up is proven and saved — a real check, and the server starts with Jarvis
rubenluetke10-beep16f59a99cbe6
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex fcc7e4feed..20f6f2a82e 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -25,6 +25,22 @@ versioning per [SemVer](https://semver.org/).use it, which role it is the pick for, whether it sits in memory — with"Manage" opening the full ledger. Nothing hides behind the Advanced switchany more.+- **Local models: the set-up is proven, then saved for next time.** "Set up+ everything" ends with three real round trips — the server answers, the+ chat pick answers, the embedding pick embeds — shown one line each with+ how long they took (`POST …/local-models/verify`, also the sidebar badge's+ new source), and then switches "Start with Jarvis" on. The Server tab+ carries both: the switch, with the backend's own sentence on what the next+ start would do, and "Run a check". From a terminal:+ `jarvis local-models server verify` and `… server autostart on|off`.+- **Local models: the server starts with Jarvis.** A few seconds after the+ web server is ready, an installed-but-stopped local server is started and+ the chat pick is loaded into memory, so the first answer does not pay the+ load time — only while local models are actually in use (the active brain,+ or a configured role), and only while `[brain.providers.ollama].autostart`+ (on by default) says so. Switching the brain to the local server readies+ it the same way at once, from every switch path (REST, voice, CLI, brain+ tool). Nothing is ever installed without the click that names the install.### Changeddiff --git a/docs/jarvis-cli-reference.md b/docs/jarvis-cli-reference.mdindex dad7834a96..54bfa7c3c0 100644--- a/docs/jarvis-cli-reference.md+++ b/docs/jarvis-cli-reference.md@@ -130,11 +130,13 @@ _Generated from the curated command tree by `scripts/ci/gen_cli_reference.py`- `jarvis local-models options suggest <name> --provider` — An advisory profile for this machine, with one reason per knob.- `jarvis local-models roles list --provider` — Every role with its pick, what qualifies, and the recommendation.- `jarvis local-models roles set <role> <model> --provider --dry-run` — Assign a model to a role (written through the config writers).+- `jarvis local-models server autostart <state> --provider --dry-run` — Show or flip "start the server with Jarvis" (fires only while local models are in use).- `jarvis local-models server env-guide --os --provider` — Copyable per-OS commands for the server's environment variables.- `jarvis local-models server log --lines --provider` — The last lines of the server log Jarvis writes when it starts the server.- `jarvis local-models server status --provider` — Runtime picture plus what is loaded and how much disk the downloads take.- `jarvis local-models server stop --provider --yes --dry-run` — Stop the server Jarvis itself started (never one started elsewhere).- `jarvis local-models server test <base_url> --provider` — Probe a host before saving it: version and latency, or why it failed.+- `jarvis local-models server verify --provider` — Prove the setup works: the server, one real chat answer, one real embedding.## marketplacediff --git a/docs/jarvis-cli.md b/docs/jarvis-cli.mdindex 3340cc3f50..dfc23e78be 100644--- a/docs/jarvis-cli.md+++ b/docs/jarvis-cli.md@@ -139,6 +139,8 @@ jarvis local-models hf files bartowski Llama-3.1-8B-Instruct-GGUFjarvis local-models hf pull bartowski Llama-3.1-8B-Instruct-GGUF --quant Q4_K_Mjarvis local-models server statusjarvis local-models server test http://127.0.0.1:11434+jarvis local-models server verify # the server, one real chat answer, one real embedding+jarvis local-models server autostart off # on by default; fires only while local models are in usejarvis local-models server log --lines 80jarvis local-models server env-guide --os linuxjarvis local-models server stop --yes # only a server Jarvis itself starteddiff --git a/jarvis/brain/app_control.py b/jarvis/brain/app_control.pyindex 89b21918ac..15907f1de7 100644--- a/jarvis/brain/app_control.py+++ b/jarvis/brain/app_control.py@@ -619,6 +619,7 @@ async def _switch_brain(persisted = _persist_brain_primary(provider)_set_in_memory(cfg, ["brain", "primary"], provider)+ _ready_local_server(provider, cfg)return {"ok": True,"tier": "brain",@@ -630,6 +631,24 @@ async def _switch_brain(}+def _ready_local_server(provider: str, cfg: Any) -> None:+ """After a switch to the local model server: start it and warm the chat pick.++ Fire-and-forget through :func:`jarvis.local_models.autostart.kick`, so+ "choose local models" is followed by local models answering — not by a+ two-second connect failure and the fallback on the first turn. Every+ switch path (REST, voice gate, CLI, brain tool) lands here.+ """+ try:+ from jarvis.local_models.autostart import SERVER_PROVIDER_ID, kick # lazy (AP-26)++ if provider != SERVER_PROVIDER_ID:+ return+ kick(cfg)+ except Exception: # noqa: BLE001 — the switch already landed; only the first answer is slower+ log.debug("local server ready-up after the switch was not scheduled", exc_info=True)++def _switch_tts(provider: str, *, cfg: Any, persist: bool, old: str | None) -> dict[str, Any]:persisted = _persist(lambda: _import_writer().set_tts_provider(provider)) if persist else False_set_in_memory(cfg, ["tts", "provider"], provider)diff --git a/jarvis/cli_ctl/command_index.py b/jarvis/cli_ctl/command_index.pyindex 48893a5d6b..cb5606150b 100644--- a/jarvis/cli_ctl/command_index.py+++ b/jarvis/cli_ctl/command_index.py@@ -153,6 +153,8 @@ COMMAND_INDEX: dict[str, tuple[str, ...]] = {"server status","server stop --yes","server test <url>",+ "server verify",+ "server autostart [on|off]","server log [--lines]","server env-guide [--os]",),diff --git a/jarvis/cli_ctl/commands/local_models.py b/jarvis/cli_ctl/commands/local_models.pyindex 8e290e71a2..7f0fb466a0 100644--- a/jarvis/cli_ctl/commands/local_models.py+++ b/jarvis/cli_ctl/commands/local_models.py@@ -385,6 +385,34 @@ def server_test()+@server_app.command("verify")+def server_verify(provider: str = _PROVIDER) -> None:+ """Prove the setup works: the server, one real chat answer, one real embedding."""+ invoke.run("POST", f"{_base(provider)}/verify", dangerous=False, request_timeout_s=120.0)+++@server_app.command("autostart")+def server_autostart(+ state: str = typer.Argument("", help="on | off; empty shows the current switch."),+ provider: str = _PROVIDER,+ dry_run: bool = options.dry_opt(),+) -> None:+ """Show or flip "start the server with Jarvis" (fires only while local models are in use)."""+ choice = state.strip().lower()+ if not choice:+ invoke.run("GET", f"{_base(provider)}/runtime/autostart")+ return+ if choice not in {"on", "off"}:+ raise typer.BadParameter("expected 'on' or 'off'")+ invoke.run(+ "PUT",+ f"{_base(provider)}/runtime/autostart",+ body={"enabled": choice == "on"},+ dangerous=False,+ dry_run=dry_run,+ )++@server_app.command("log")def server_log(lines: int = typer.Option(40, "--lines", min=1, max=500),diff --git a/jarvis/core/config.py b/jarvis/core/config.pyindex d538305492..29102a6d28 100644--- a/jarvis/core/config.py+++ b/jarvis/core/config.py@@ -866,6 +866,12 @@ class BrainProviderConfig(BaseModel):# Cadence of the Local models self-check (badge only, no toasts), in# hours; read by :func:`jarvis.local_models.health_monitor.interval_hours`.health_check_hours: float = 6.0+ # Start the local server with Jarvis and warm the chat pick — only while+ # local models are actually in use (the active brain, or a configured+ # role). ON by default so "choose local models" survives a restart; the+ # Server tab switches it off. Read via :func:`ollama_autostart` by+ # :mod:`jarvis.local_models.autostart`.+ autostart: bool = True@field_validator("models", mode="before")@classmethod@@ -5541,6 +5547,17 @@ def ollama_hf_enabled(config: JarvisConfig | None = None) -> bool:conf = config or load_config()provider = conf.brain.providers.get("ollama")return bool(provider is not None and provider.hf_enabled)+def ollama_autostart(config: JarvisConfig | None = None) -> bool:+ """Whether the local server starts with Jarvis when local models are in use.++ The ONE reader of ``[brain.providers.ollama].autostart`` (AP-31), for+ :func:`jarvis.local_models.autostart.should_autostart`. A card that was+ never configured answers the default (on): the boot task still starts+ nothing unless a role or the active brain actually uses the server.+ """+ conf = config or load_config()+ provider = conf.brain.providers.get("ollama")+ return True if provider is None else bool(provider.autostart)def resolve_provider_endpoint(diff --git a/jarvis/core/config_writer.py b/jarvis/core/config_writer.pyindex 322ba9e92c..79d5b51bca 100644--- a/jarvis/core/config_writer.py+++ b/jarvis/core/config_writer.py@@ -2289,7 +2289,7 @@ def set_provider_base_url(#: Closed list of per-provider boolean flags :func:`set_provider_flag` may#: write. Each entry is a real field on ``BrainProviderConfig`` with a reader;#: adding one here without a reader is the AP-31 shape.-PROVIDER_FLAG_KEYS: tuple[str, ...] = ("hf_enabled",)+PROVIDER_FLAG_KEYS: tuple[str, ...] = ("hf_enabled", "autostart")def _provider_block(doc: TOMLDocument, provider: str) -> tomlkit.items.Table:@@ -2445,6 +2445,15 @@ def set_ollama_hf_enabled(enabled: bool, *, path: Path = DEFAULT_CONFIG_FILE) ->set_provider_flag("ollama", "hf_enabled", bool(enabled), path=path)+def set_ollama_autostart(enabled: bool, *, path: Path = DEFAULT_CONFIG_FILE) -> None:+ """Switch "start the local server with Jarvis" on or off.++ Thin wrapper over :func:`set_provider_flag`; read by+ :func:`jarvis.core.config.ollama_autostart`.+ """+ set_provider_flag("ollama", "autostart", bool(enabled), path=path)++def set_local_realtime_launch_command(launch_command: str, *, path: Path = DEFAULT_CONFIG_FILE) -> None:diff --git a/jarvis/local_models/autostart.py b/jarvis/local_models/autostart.pynew file mode 100644index 0000000000..6d78279080--- /dev/null+++ b/jarvis/local_models/autostart.py@@ -0,0 +1,249 @@+"""Start the local model server with Jarvis — when it is wanted and in use.++The Ollama brain fails fast on an unreachable server (two seconds, then the+fallback answers) and nothing used to start that server: a machine set up+for local models still began every day with a cloud answer until someone+opened the Server tab. This module is the ONE place that decides whether+the local server comes up with Jarvis, and does it:++* :func:`should_autostart` — ``[brain.providers.ollama].autostart`` is on+ (the default) AND local models are actually in use: the active brain is+ the local server, or a role (chat, voice, tools & screen, deep, embedding)+ has a configured pick. An install that never chose local models starts+ nothing and spawns nothing.+* :func:`run_once` — start an installed-but-stopped local server (never+ install it: that is a click behind the dangerous-flagged route), then load+ the chat pick with its keep-alive so the first answer does not pay the+ load time — "connects fast". A remote server is only warmed.+* :func:`schedule` — the boot task: :func:`run_once` a few seconds after+ the web server is ready, off the boot path (AP-26), never raising.+* :func:`kick` — the same run, fire-and-forget, right after the brain was+ switched to the local server, so "choose local models" means "local+ models answer" without a second click.+"""++from __future__ import annotations++import asyncio+import logging+from collections.abc import Awaitable, Callable+from typing import Any++log = logging.getLogger(__name__)++__all__ = [+ "BOOT_DELAY_S",+ "DEFAULT_KEEP_ALIVE",+ "SERVER_PROVIDER_ID",+ "in_use",+ "kick",+ "run_once",+ "schedule",+ "should_autostart",+]++#: The provider card whose server this module starts. The Local models+#: section is gated on the ``supports_model_pull`` capability; today exactly+#: one card declares it, and its runtime (``ollama serve``) is the one+#: :mod:`jarvis.brain.ollama_runtime` knows how to spawn — hence an id here+#: rather than a capability probe, spelled out once.+SERVER_PROVIDER_ID = "ollama"++#: Seconds after the web server is ready before the boot run starts. Long+#: enough for the ready signal and the first paint to be out of the way.+BOOT_DELAY_S = 5.0++#: Residency the warm ping asks for when the chat pick has no keep-alive of+#: its own (a Go duration, what Ollama's own default is anyway).+DEFAULT_KEEP_ALIVE = "30m"++StatusFn = Callable[[], dict[str, object]]+StartFn = Callable[[], tuple[bool, str]]+WarmFn = Callable[[str, str, str | int], Awaitable[bool]]+RunFn = Callable[[Any], Awaitable[dict[str, Any]]]++#: Live task references — a fire-and-forget task must be held somewhere or+#: the loop may drop it mid-run.+_tasks: set[asyncio.Task[None]] = set()+++def _provider(cfg: Any) -> Any:+ providers = getattr(getattr(cfg, "brain", None), "providers", None) or {}+ return providers.get(SERVER_PROVIDER_ID) if isinstance(providers, dict) else None+++def in_use(cfg: Any) -> tuple[bool, str]:+ """``(used, why)`` — whether anything in this install runs on the local server.++ True when the active brain is the local server, or when any writable+ role has a configured pick (the voice server's brain, the wiki's+ embedder and the deep model are local-model interfaces even while a+ cloud brain answers the chat).+ """+ from jarvis.brain.ollama_roles import WRITABLE_ROLE_IDS, current_pick # lazy (AP-26)++ primary = str(getattr(getattr(cfg, "brain", None), "primary", "") or "").strip()+ if primary == SERVER_PROVIDER_ID:+ return True, "the active brain"+ roles: list[str] = []+ for role in WRITABLE_ROLE_IDS:+ try:+ model, _note = current_pick(cfg, role)+ except Exception: # noqa: BLE001 — an unreadable pick is "not in use" for this decision+ log.debug("local-models autostart: pick of %s unreadable", role, exc_info=True)+ continue+ if model:+ roles.append(role)+ if roles:+ noun = "role" if len(roles) == 1 else "roles"+ return True, f"the {', '.join(roles)} {noun}"+ return False, "no role uses local models and the active brain is elsewhere"+++def should_autostart(cfg: Any) -> tuple[bool, str]:+ """``(start, why)`` — the boot decision, in one sentence either way."""+ from jarvis.core.config import ollama_autostart # lazy (AP-26)++ if not ollama_autostart(cfg):+ return False, "autostart is switched off in the Server tab"+ used, why = in_use(cfg)+ if not used:+ return False, why+ return True, f"local models serve {why}"+++def _chat_model(cfg: Any) -> str:+ """The pick worth warming: chat, else deep, else tools & screen."""+ from jarvis.brain.ollama_roles import current_pick # lazy (AP-26)++ for role in ("chat", "deep", "tools_screen"):+ try:+ model, _note = current_pick(cfg, role)+ except Exception: # noqa: BLE001 — an unreadable pick is simply not warmed+ log.debug("local-models autostart: pick of %s unreadable", role, exc_info=True)+ continue+ if model:+ return model+ return ""+++def _keep_alive(cfg: Any, model: str) -> str | int:+ provider = _provider(cfg)+ models = getattr(provider, "models", None) if provider is not None else None+ opts = models.get(model) if isinstance(models, dict) else None+ keep_alive = getattr(opts, "keep_alive", None)+ return keep_alive if keep_alive is not None else DEFAULT_KEEP_ALIVE+++async def _default_warm(root: str, model: str, keep_alive: str | int) -> bool:+ from jarvis.brain.ollama_profiles import warm # lazy (AP-26)++ return await warm(root, model, keep_alive)+++async def run_once(+ cfg: Any,+ *,+ status: StatusFn | None = None,+ start: StartFn | None = None,+ warm: WarmFn | None = None,+) -> dict[str, Any]:+ """Start the server when it is installed and stopped, then warm the chat pick.++ Returns ``{"started", "warmed", "detail"}`` — ``started`` when this run+ spawned the server, ``warmed`` the model now resident (``""`` when none),+ ``detail`` the runtime's own sentence. The probes are injectable; never+ raises on a server that will not come up — the sentence says why.+ """+ from jarvis.brain import ollama_runtime # lazy (AP-26)+ from jarvis.local_models.health_monitor import server_root # lazy (AP-26)++ record: dict[str, Any] = {"started": False, "warmed": "", "detail": ""}+ root = server_root(cfg)+ state = await asyncio.to_thread(status or ollama_runtime.runtime_status)+ if not state.get("running"):+ if ollama_runtime.host_kind(root) == "remote":+ record["detail"] = (+ f"The server at {root} is remote and does not answer; nothing to start here."+ )+ return record+ if not state.get("installed"):+ record["detail"] = "Ollama is not installed; install it from the Server tab."+ return record+ ok, detail = await asyncio.to_thread(start or ollama_runtime.start_server)+ record["detail"] = detail+ if not ok:+ return record+ record["started"] = True+ model = _chat_model(cfg)+ if model and await (warm or _default_warm)(root, model, _keep_alive(cfg, model)):+ record["warmed"] = model+ return record+++def _remember(task: asyncio.Task[None]) -> asyncio.Task[None]:+ _tasks.add(task)+ task.add_done_callback(_tasks.discard)+ return task+++def schedule(+ cfg_fn: Callable[[], Any],+ *,+ delay_s: float = BOOT_DELAY_S,+ sleep: Callable[[float], Awaitable[None]] | None = None,+ run: RunFn | None = None,+) -> asyncio.Task[None]:+ """The boot task: wait ``delay_s``, decide, run. Logs; never raises."""++ async def _boot() -> None:+ await (sleep or asyncio.sleep)(delay_s)+ try:+ cfg = cfg_fn()+ wanted, why = should_autostart(cfg)+ if not wanted:+ log.info("local-models autostart: skipped — %s.", why)+ return+ record = await (run or run_once)(cfg)+ log.info(+ "local-models autostart (%s): started=%s warmed=%r %s",+ why,+ record.get("started"),+ record.get("warmed"),+ record.get("detail") or "",+ )+ except asyncio.CancelledError:+ raise+ except Exception: # noqa: BLE001 — a failed autostart is a log line, never a boot error+ log.warning("local-models autostart failed", exc_info=True)++ return _remember(asyncio.create_task(_boot(), name="local-models-autostart"))+++def kick(cfg: Any, *, run: RunFn | None = None) -> asyncio.Task[None] | None:+ """After a switch to the local server: start and warm now, fire-and-forget.++ ``None`` outside a running loop (the CLI's synchronous callers) — the+ boot task covers the next start, and the first turn still starts the+ server itself through the runtime revive.+ """+ try:+ loop = asyncio.get_running_loop()+ except RuntimeError:+ return None++ async def _now() -> None:+ try:+ record = await (run or run_once)(cfg)+ log.info(+ "local-models: server readied after the brain switch — started=%s warmed=%r %s",+ record.get("started"),+ record.get("warmed"),+ record.get("detail") or "",+ )+ except asyncio.CancelledError:+ raise+ except Exception: # noqa: BLE001 — the switch already landed; this only delays the first answer+ log.warning("local-models: readying the server after the switch failed", exc_info=True)++ return _remember(loop.create_task(_now(), name="local-models-kick"))diff --git a/jarvis/local_models/health_monitor.py b/jarvis/local_models/health_monitor.pyindex 6ac31954fa..437357b7ed 100644--- a/jarvis/local_models/health_monitor.py+++ b/jarvis/local_models/health_monitor.py@@ -40,6 +40,8 @@ __all__ = ["interval_hours","load_last_report","read_health_record",+ "server_root",+ "verify_setup","write_health_record",]@@ -148,6 +150,11 @@ def write_health_record(status: str, reason: str, *, checked_at: str | None = No# ── one check ─────────────────────────────────────────────────────────────+def server_root(cfg: Any) -> str:+ """The local server's root: the card's ``base_url`` override, else the default."""+ return _server_root(cfg)++def _server_root(cfg: Any) -> str:providers = getattr(getattr(cfg, "brain", None), "providers", None) or {}ollama = providers.get("ollama") if isinstance(providers, dict) else None@@ -237,6 +244,154 @@ async def check_once(return record+# ── the on-demand proof ───────────────────────────────────────────────────++EmbedFn = Callable[[str, str], Awaitable[int]]+++async def _default_embed(root: str, model: str) -> int:+ from jarvis.brain.ollama_inventory import embed_probe++ return await embed_probe(root, model)+++def _step(+ step_id: str, ok: bool | None, *, model: str = "", detail: str = "", ms: int = 0+) -> dict[str, Any]:+ return {"id": step_id, "ok": ok, "model": model, "detail": detail, "ms": ms}+++async def verify_setup(+ cfg: Any,+ *,+ root: str | None = None,+ probe: ProbeFn | None = None,+ generate: GenerateFn | None = None,+ embed: EmbedFn | None = None,+ persist: bool = True,+) -> dict[str, Any]:+ """Prove the setup works, step by step, and write the health record.++ :func:`check_once` is the quiet schedule; this is the answer to a click+ ("Set up everything", "Run a check"). Three steps, each with how long it+ took: the server answers, the chat pick produces one real answer, the+ embedding pick produces one real vector. A step whose role is not+ configured is reported as not run (``ok: None``) rather than as a pass,+ so "it is set up" is a sentence that was tested, not assumed. Returns+ ``{"ok", "status", "reason", "steps"}``; ``status`` uses the badge's+ vocabulary (``ok`` / ``needs_setup`` / ``error``).+ """+ import time++ root = root or _server_root(cfg)+ roles = _configured_roles(cfg)+ steps: list[dict[str, Any]] = []++ server = await (probe or _default_probe)(root)+ server_ok = bool(server.get("ok"))+ steps.append(+ _step(+ "server",+ server_ok,+ detail=str(server.get("detail") or "")+ if not server_ok+ else f"Ollama {server.get('version') or 'unknown'}",+ ms=int(server.get("latency_ms") or 0),+ )+ )++ chat_model = roles.get("chat") or roles.get("deep") or roles.get("tools_screen") or ""+ embed_model = roles.get("embedding") or ""+ not_run = "Not tested — the server did not answer."+ if not server_ok:+ steps.append(_step("chat", None, model=chat_model, detail=not_run))+ steps.append(_step("embedding", None, model=embed_model, detail=not_run))+ else:+ if chat_model:+ started = time.monotonic()+ try:+ result = await asyncio.wait_for(+ (generate or _default_generate)(cfg, chat_model), timeout=GENERATION_CAP_S+ )+ ms = int((time.monotonic() - started) * 1000)+ if getattr(result, "status", "") == "ok":+ steps.append(_step("chat", True, model=chat_model, detail="Answered.", ms=ms))+ else:+ detail = getattr(result, "detail", "") or getattr(result, "status", "error")+ steps.append(_step("chat", False, model=chat_model, detail=str(detail), ms=ms))+ except TimeoutError:+ steps.append(+ _step(+ "chat",+ False,+ model=chat_model,+ detail=f"No answer within {GENERATION_CAP_S:.0f} s.",+ ms=int(GENERATION_CAP_S * 1000),+ )+ )+ except Exception as exc: # noqa: BLE001 — the step says so, the log keeps it+ log.info("verify: generation on %s failed", chat_model, exc_info=True)+ steps.append(+ _step("chat", False, model=chat_model, detail=f"{type(exc).__name__}: {exc}")+ )+ else:+ steps.append(_step("chat", None, detail="No chat role is configured."))+ if embed_model:+ started = time.monotonic()+ try:+ dims = await asyncio.wait_for(+ (embed or _default_embed)(root, embed_model), timeout=GENERATION_CAP_S+ )+ ms = int((time.monotonic() - started) * 1000)+ if dims > 0:+ steps.append(+ _step(+ "embedding",+ True,+ model=embed_model,+ detail=f"{dims} dimensions.",+ ms=ms,+ )+ )+ else:+ steps.append(+ _step(+ "embedding",+ False,+ model=embed_model,+ detail="The server answered without a vector.",+ ms=ms,+ )+ )+ except TimeoutError:+ steps.append(+ _step(+ "embedding",+ False,+ model=embed_model,+ detail=f"No vector within {GENERATION_CAP_S:.0f} s.",+ )+ )+ except Exception as exc: # noqa: BLE001 — same as the chat step+ log.info("verify: embedding on %s failed", embed_model, exc_info=True)+ steps.append(_step("embedding", False, model=embed_model, detail=str(exc)))+ else:+ steps.append(_step("embedding", None, detail="No embedding role is configured."))++ failed = next((s for s in steps if s["ok"] is False), None)+ if failed is not None:+ status = "error"+ who = failed["model"] or "The server"+ reason = f"{who}: {failed['detail']}" if failed["detail"] else f"{who} failed."+ elif not roles:+ status, reason = "needs_setup", "Ollama runs, but no role is configured."+ else:+ status, reason = "ok", ""+ if persist:+ write_health_record(status, reason)+ return {"ok": status == "ok", "status": status, "reason": reason, "steps": steps}++# ── the schedule ──────────────────────────────────────────────────────────diff --git a/jarvis/ui/web/frontend/src/hooks/useLocalModels.ts b/jarvis/ui/web/frontend/src/hooks/useLocalModels.tsindex 60ae1228b6..0035186545 100644--- a/jarvis/ui/web/frontend/src/hooks/useLocalModels.ts+++ b/jarvis/ui/web/frontend/src/hooks/useLocalModels.ts@@ -157,6 +157,33 @@ export interface RolesResponse {error: string | null;}+/** Mirror of `AutostartResponse` (`GET/PUT …/runtime/autostart`). */+export interface AutostartResponse {+ /** `[brain.providers.ollama].autostart` — start the server with Jarvis. */+ enabled: boolean;+ /** Something in this install runs on the local server right now. */+ in_use: boolean;+ /** One backend sentence: what the boot task would do and why. */+ reason: string;+}++/** One step of `POST …/verify`; `ok: null` = not run (role unset / server down). */+export interface VerifyStep {+ id: "server" | "chat" | "embedding" | string;+ ok: boolean | null;+ model: string;+ detail: string;+ ms: number;+}++/** Mirror of `VerifyResponse` (`POST …/verify`). */+export interface VerifyResponse {+ ok: boolean;+ status: "ok" | "needs_setup" | "error" | string;+ reason: string;+ steps: VerifyStep[];+}+export interface RoleSetBody {/** "" = back to discovery (brain roles only). */model: string;@@ -492,6 +519,34 @@ export async function setIdleRelease();}+export async function getAutostart(+ providerId: string,+): Promise<AutostartResponse> {+ return request(`${base(providerId)}/runtime/autostart`);+}++export async function setAutostart(+ providerId: string,+ enabled: boolean,+): Promise<AutostartResponse> {+ return request(+ `${base(providerId)}/runtime/autostart`,+ json("PUT", { enabled }),+ WRITE_TIMEOUT_MS,+ );+}++/** Three real round trips: the server, a chat answer, an embedding. */+const VERIFY_TIMEOUT_MS = 120_000;++export async function verifySetup(providerId: string): Promise<VerifyResponse> {+ return request(+ `${base(providerId)}/verify`,+ { method: "POST" },+ VERIFY_TIMEOUT_MS,+ );+}+export async function setRole(providerId: string,role: LocalModelRole,@@ -731,6 +786,7 @@ export const localModelsKeys = {["local-models", p, "inventory", name] as const,roles: (p: string) => ["local-models", p, "roles"] as const,idleRelease: (p: string) => ["local-models", p, "idle-release"] as const,+ autostart: (p: string) => ["local-models", p, "autostart"] as const,options: (p: string, name: string) =>["local-models", p, "options", name] as const,suggested: (p: string, name: string) =>@@ -1191,6 +1247,33 @@ export function useSetIdleRelease(providerId: string | undefined) {});}+export function useAutostart(providerId: string | undefined) {+ return useQuery({+ queryKey: localModelsKeys.autostart(providerId ?? ""),+ queryFn: () => getAutostart(providerId as string),+ enabled: !!providerId,+ gcTime: SECTION_GC_MS,+ });+}++export function useSetAutostart(providerId: string | undefined) {+ const qc = useQueryClient();+ return useMutation({+ mutationFn: (enabled: boolean) =>+ setAutostart(providerId as string, enabled),+ onSuccess: (data) => {+ qc.setQueryData(localModelsKeys.autostart(providerId ?? ""), data);+ },+ });+}++/** The on-demand proof; the sidebar badge follows the health record it writes. */+export function useVerifySetup(providerId: string | undefined) {+ return useMutation({+ mutationFn: () => verifySetup(providerId as string),+ });+}+export function useTestServer(providerId: string | undefined) {return useMutation({mutationFn: (baseUrl: string) => testServer(providerId as string, baseUrl),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 ffc8274073..264c5579b6 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@@ -215,8 +215,12 @@"setup_pulling": "{model} wird heruntergeladen","setup_assigning": "{role} wird zugewiesen: {model}…","setup_tuning": "Einstellungen für {model} werden gewählt…",- "setup_done": "Alles ist eingerichtet.",- "setup_done_nothing": "Alles war schon eingerichtet; nichts geändert.",+ "setup_verifying": "Prüft die Einrichtung — Server, eine Chat-Antwort, eine Einbettung…",+ "setup_saving": "Speichert — der Server startet ab jetzt mit Jarvis…",+ "setup_done": "Alles ist eingerichtet und getestet.",+ "setup_done_nothing": "Alles war schon eingerichtet; die Prüfung ist bestanden.",+ "setup_done_problem": "Eingerichtet, aber die Prüfung fand ein Problem: {reason}",+ "setup_autostart_on": "Der Server startet ab jetzt mit Jarvis; im Reiter „Server“ lässt sich das abschalten.","setup_assigned": "{role} → {model}","setup_kept_one": "1 Rolle behält ihre Wahl.","setup_kept": "{count} Rollen behalten ihre Wahl.",@@ -240,6 +244,22 @@"unknown_caps": "Fähigkeiten unbekannt","recommended_for": "Empfohlen für {role}"},+ "verify": {+ "eyebrow": "Prüfung",+ "title": "Einrichtung prüfen",+ "subtitle": "Je ein echter Aufruf: der Server antwortet, das Chat-Modell antwortet, das Einbettungsmodell bettet ein. Aktualisiert auch das Abzeichen in der Seitenleiste.",+ "run": "Prüfung starten",+ "running": "Prüft…",+ "server": "Server",+ "chat": "Chat",+ "embedding": "Einbettungen",+ "ok": "OK",+ "failed": "fehlgeschlagen",+ "skipped": "nicht geprüft",+ "result_ok": "Alles hat geantwortet.",+ "result_problem": "Problem: {reason}",+ "ms": "{ms} ms"+ },"roles": {"title": "Rollen","subtitle": "Welcher Download für welche Aufgabe antwortet. Ein Knopf pro Zeile.",@@ -338,7 +358,13 @@"idle_never": "= alles geladen lassen","idle_save": "Speichern","idle_saving": "Speichern…",- "idle_hint": "0 lässt die Modelle geladen, solange Jarvis läuft. Gilt ab der nächsten Prüfung, kein Neustart nötig."+ "idle_hint": "0 lässt die Modelle geladen, solange Jarvis läuft. Gilt ab der nächsten Prüfung, kein Neustart nötig.",+ "autostart_eyebrow": "Start",+ "autostart_title": "Mit Jarvis starten",+ "autostart_subtitle": "Beim Start von Jarvis kommt der lokale Server hoch und das Chat-Modell wird geladen, damit die erste Antwort schnell kommt — nur solange lokale Modelle in Gebrauch sind (das aktive Gehirn oder eine Rolle).",+ "autostart_label": "Server mit Jarvis starten",+ "autostart_now": "Aktuell: {reason}.",+ "autostart_saving": "Speichert…"},"tune": {"aria": "{model} feinjustieren",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 335b6f9f1c..380a3a0f5d 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@@ -215,8 +215,12 @@"setup_pulling": "Downloading {model}","setup_assigning": "Assigning {role}: {model}…","setup_tuning": "Choosing the settings for {model}…",- "setup_done": "Everything is set up.",- "setup_done_nothing": "Everything was already set up; nothing changed.",+ "setup_verifying": "Testing the setup — the server, one chat answer, one embedding…",+ "setup_saving": "Saving — the server will start with Jarvis from now on…",+ "setup_done": "Everything is set up and tested.",+ "setup_done_nothing": "Everything was already set up; the check passed.",+ "setup_done_problem": "Set up, but the check found a problem: {reason}",+ "setup_autostart_on": "The server starts with Jarvis from now on; switch that off on the Server tab.","setup_assigned": "{role} → {model}","setup_kept_one": "1 role kept its pick.","setup_kept": "{count} roles kept their pick.",@@ -240,6 +244,22 @@"unknown_caps": "capabilities unknown","recommended_for": "Recommended for {role}"},+ "verify": {+ "eyebrow": "Check",+ "title": "Check the setup",+ "subtitle": "One real round trip each: the server answers, the chat model answers, the embedding model embeds. Also refreshes the badge in the sidebar.",+ "run": "Run a check",+ "running": "Checking…",+ "server": "Server",+ "chat": "Chat",+ "embedding": "Embeddings",+ "ok": "OK",+ "failed": "failed",+ "skipped": "not tested",+ "result_ok": "Everything answered.",+ "result_problem": "Problem: {reason}",+ "ms": "{ms} ms"+ },"roles": {"title": "Roles","subtitle": "Which download answers for which job. One button each.",@@ -338,7 +358,13 @@"idle_never": "= keep everything loaded","idle_save": "Save","idle_saving": "Saving…",- "idle_hint": "0 keeps the models loaded while Jarvis runs. Applies on the next check, no restart needed."+ "idle_hint": "0 keeps the models loaded while Jarvis runs. Applies on the next check, no restart needed.",+ "autostart_eyebrow": "Start-up",+ "autostart_title": "Start with Jarvis",+ "autostart_subtitle": "When Jarvis starts, the local server comes up and the chat model is loaded, so the first answer is quick — only while local models are in use (the active brain, or a role).",+ "autostart_label": "Start the server with Jarvis",+ "autostart_now": "Right now: {reason}.",+ "autostart_saving": "Saving…"},"tune": {"aria": "Tune {model}",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 de3dbbe6f3..dec5d1d2e2 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@@ -215,8 +215,12 @@"setup_pulling": "Descargando {model}","setup_assigning": "Asignando {role}: {model}…","setup_tuning": "Eligiendo los ajustes para {model}…",- "setup_done": "Todo está configurado.",- "setup_done_nothing": "Todo ya estaba configurado; nada cambió.",+ "setup_verifying": "Probando la configuración: el servidor, una respuesta de chat, una incrustación…",+ "setup_saving": "Guardando: el servidor arrancará con Jarvis a partir de ahora…",+ "setup_done": "Todo está configurado y probado.",+ "setup_done_nothing": "Todo ya estaba configurado; la comprobación pasó.",+ "setup_done_problem": "Configurado, pero la comprobación encontró un problema: {reason}",+ "setup_autostart_on": "El servidor arranca con Jarvis a partir de ahora; se desactiva en la pestaña Servidor.","setup_assigned": "{role} → {model}","setup_kept_one": "1 rol mantiene su elección.","setup_kept": "{count} roles mantienen su elección.",@@ -240,6 +244,22 @@"unknown_caps": "capacidades desconocidas","recommended_for": "Recomendado para {role}"},+ "verify": {+ "eyebrow": "Comprobación",+ "title": "Comprobar la configuración",+ "subtitle": "Una llamada real de cada: el servidor responde, el modelo de chat responde, el modelo de incrustaciones incrusta. También actualiza la insignia de la barra lateral.",+ "run": "Ejecutar una comprobación",+ "running": "Comprobando…",+ "server": "Servidor",+ "chat": "Chat",+ "embedding": "Incrustaciones",+ "ok": "OK",+ "failed": "falló",+ "skipped": "sin probar",+ "result_ok": "Todo respondió.",+ "result_problem": "Problema: {reason}",+ "ms": "{ms} ms"+ },"roles": {"title": "Roles","subtitle": "Qué descarga responde a qué tarea. Un botón por fila.",@@ -338,7 +358,13 @@"idle_never": "= mantener todo cargado","idle_save": "Guardar","idle_saving": "Guardando…",- "idle_hint": "0 mantiene los modelos cargados mientras Jarvis funciona. Se aplica en la siguiente comprobación, sin reiniciar."+ "idle_hint": "0 mantiene los modelos cargados mientras Jarvis funciona. Se aplica en la siguiente comprobación, sin reiniciar.",+ "autostart_eyebrow": "Arranque",+ "autostart_title": "Arrancar con Jarvis",+ "autostart_subtitle": "Al iniciar Jarvis, el servidor local arranca y se carga el modelo de chat para que la primera respuesta sea rápida, solo mientras los modelos locales estén en uso (el cerebro activo o un rol).",+ "autostart_label": "Arrancar el servidor con Jarvis",+ "autostart_now": "Ahora mismo: {reason}.",+ "autostart_saving": "Guardando…"},"tune": {"aria": "Ajustar {model}",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 ca977bcc8b..b3bb5e70c5 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@@ -215,6 +215,29 @@ function installFetchMock(fx: Fixture = {}) {});if (url === "/api/brain/switch" && method === "POST")return ok({ ok: true, active: "ollama" });+ if (url === `${BASE}/verify` && method === "POST")+ return ok({+ ok: true,+ status: "ok",+ reason: "",+ steps: [+ { id: "server", ok: true, model: "", detail: "Ollama 0.32.15", ms: 12 },+ { id: "chat", ok: true, model: "qwen3.8:27b", detail: "Answered.", ms: 1800 },+ {+ id: "embedding",+ ok: null,+ model: "",+ detail: "No embedding role is configured.",+ ms: 0,+ },+ ],+ });+ if (url === `${BASE}/runtime/autostart`)+ return ok({+ enabled: true,+ in_use: true,+ reason: "local models serve the chat role",+ });if (url === "/api/providers/ollama/pull" && method === "POST")return ok({state: "running",@@ -661,6 +684,19 @@ describe("OverviewPanel", () => {expect(progress.textContent).toContain("local_models.overview.setup_kept_one",);+ // The proof and the boot switch are part of "done".+ expect(progress.textContent).toContain(+ "local_models.verify.server — local_models.verify.ok · local_models.verify.ms12",+ );+ expect(progress.textContent).toContain(+ "local_models.verify.chat — local_models.verify.ok · qwen3.8:27b · 1.8 s",+ );+ expect(progress.textContent).toContain(+ "local_models.verify.embedding — local_models.verify.skipped · No embedding role is configured.",+ );+ expect(progress.textContent).toContain(+ "local_models.overview.setup_autostart_on",+ );const puts = fetchMock.mock.calls.filter(([u, i]) =>diff --git a/jarvis/ui/web/frontend/src/views/local-models/OverviewPanel.tsx b/jarvis/ui/web/frontend/src/views/local-models/OverviewPanel.tsxindex 8181b01f3a..af5682b49d 100644--- a/jarvis/ui/web/frontend/src/views/local-models/OverviewPanel.tsx+++ b/jarvis/ui/web/frontend/src/views/local-models/OverviewPanel.tsx@@ -37,6 +37,7 @@ import { formatExpiry } from "./localModelsFormat";import type { SetupStep, SetupSummary } from "./localSetup";import { RolesPanel, type RolesPanelProps } from "./RolesPanel";import { useLocalSetup } from "./useLocalSetup";+import { verifyLines } from "./verifyLines";export interface OverviewPanelProps extends RolesPanelProps {/** Opens the catalogue ("Browse models"); the button hides without it. */@@ -438,25 +439,39 @@ function SetupProgress({case "tuning":text = fill(k("setup_tuning"), { model: step.model });break;+ case "verifying":+ text = k("setup_verifying");+ break;+ case "saving":+ text = k("setup_saving");+ break;case "error":tone = "error";text = fill(k("setup_error"), { message: step.message });summary = step.summary;break;- case "done":- tone = "ok";+ case "done": {summary = step.summary;- text =- summary.assigned.length === 0 &&- summary.pulled.length === 0 &&- !summary.serverStarted- ? k("setup_done_nothing")- : k("setup_done");+ const changed =+ summary.assigned.length > 0 ||+ summary.pulled.length > 0 ||+ summary.serverStarted;+ if (summary.verify && !summary.verify.ok) {+ // Set up, yes — but the proof failed, and that is the headline.+ tone = "error";+ text = fill(k("setup_done_problem"), { reason: summary.verify.reason });+ } else {+ tone = "ok";+ text = changed ? k("setup_done") : k("setup_done_nothing");+ }break;+ }}const lines: string[] = [];if (summary) {+ for (const line of verifyLines(summary.verify, t)) lines.push(line);+ if (summary.autostart) lines.push(k("setup_autostart_on"));if (summary.assigned.length > 0)lines.push(summary.assigneddiff --git a/jarvis/ui/web/frontend/src/views/local-models/ServerPanel.test.tsx b/jarvis/ui/web/frontend/src/views/local-models/ServerPanel.test.tsxindex 12c5e169a1..a47a5b634e 100644--- a/jarvis/ui/web/frontend/src/views/local-models/ServerPanel.test.tsx+++ b/jarvis/ui/web/frontend/src/views/local-models/ServerPanel.test.tsx@@ -147,6 +147,39 @@ function installFetch(server: Json, extra: Record<string, Json> = {}) {message: "Unloaded qwen3.5:4b.",});}+ if (url.endsWith("/runtime/autostart")) {+ const enabled =+ method === "PUT"+ ? Boolean(JSON.parse(String(init?.body)).enabled)+ : true;+ return respond({+ enabled,+ in_use: true,+ reason: enabled+ ? "local models serve the chat role"+ : "autostart is switched off in the Server tab",+ });+ }+ if (url.endsWith("/verify") && method === "POST") {+ return respond(+ extra.verify ?? {+ ok: false,+ status: "error",+ reason: "embeddinggemma: /api/embed failed",+ steps: [+ { id: "server", ok: true, model: "", detail: "Ollama 0.32.15", ms: 9 },+ { id: "chat", ok: true, model: "qwen3.5:4b", detail: "Answered.", ms: 2400 },+ {+ id: "embedding",+ ok: false,+ model: "embeddinggemma",+ detail: "/api/embed failed",+ ms: 30,+ },+ ],+ },+ );+ }return respond({ detail: `unexpected ${method} ${url}` }, 404);}),);@@ -292,6 +325,57 @@ describe("ServerPanel", () => {).toBeNull();expect(screen.queryByText("local_models.server.log_title")).toBeNull();expect(screen.getByText("local_models.server.host_remote")).toBeDefined();+ // Nothing can be started on a remote host; the check still can run.+ expect(screen.queryByTestId("autostart")).toBeNull();+ expect(screen.getByTestId("verify")).toBeDefined();+ });++ it("flips 'start with Jarvis' and says what the next start would do", async () => {+ installFetch(serverBody());+ renderPanel();++ const box = (await screen.findByRole("checkbox", {+ name: "local_models.server.autostart_label",+ })) as HTMLInputElement;+ await waitFor(() => expect(box.checked).toBe(true));+ expect(screen.getByTestId("autostart-now").textContent).toContain(+ "local_models.server.autostart_now:local models serve the chat role",+ );++ fireEvent.click(box);+ await waitFor(() =>+ expect(+ calls.some(+ (c) =>+ c.url.endsWith("/runtime/autostart") &&+ c.method === "PUT" &&+ (c.body as { enabled?: boolean } | null)?.enabled === false,+ ),+ ).toBe(true),+ );+ await waitFor(() => expect(box.checked).toBe(false));+ expect(screen.getByTestId("autostart-now").textContent).toContain(+ "switched off",+ );+ });++ it("runs the check on demand and names the failing step", async () => {+ installFetch(serverBody());+ renderPanel();++ fireEvent.click(+ await screen.findByRole("button", { name: "local_models.verify.run" }),+ );+ const result = await screen.findByTestId("verify-result");+ expect(result.textContent).toContain(+ "local_models.verify.result_problem:embeddinggemma: /api/embed failed",+ );+ expect(result.textContent).toContain(+ "local_models.verify.chat — local_models.verify.ok · qwen3.5:4b · 2.4 s",+ );+ expect(result.textContent).toContain(+ "local_models.verify.embedding — local_models.verify.failed · embeddinggemma · /api/embed failed",+ );});it("switches the environment guide per OS and copies a command", async () => {diff --git a/jarvis/ui/web/frontend/src/views/local-models/ServerPanel.tsx b/jarvis/ui/web/frontend/src/views/local-models/ServerPanel.tsxindex 1ada119d3b..644a209466 100644--- a/jarvis/ui/web/frontend/src/views/local-models/ServerPanel.tsx+++ b/jarvis/ui/web/frontend/src/views/local-models/ServerPanel.tsx@@ -18,7 +18,9 @@ import {ChevronDown,ChevronRight,Copy,+ Loader2,RefreshCw,+ ShieldCheck,Square,} from "lucide-react";import {@@ -41,14 +43,17 @@ import {OllamaRuntimePanel,} from "@/components/providers/ProviderTierSection";import {+ useAutostart,useEnvGuide,useIdleRelease,useServer,+ useSetAutostart,useSetIdleRelease,useServerLog,useStopServer,useTestServer,useUnloadModel,+ useVerifySetup,type EnvGuideOs,type RunningModelRow,type ServerProbeResponse,@@ -59,6 +64,8 @@ import { useEventStore } from "@/store/events";import { fill, useT } from "@/i18n";import { cn } from "@/lib/utils";+import { verifyLines } from "./verifyLines";+/** Ollama's shipped default when OLLAMA_KEEP_ALIVE is not set. */const KEEP_ALIVE_DEFAULT = "5m";const LOG_LINES = 40;@@ -101,6 +108,106 @@ function guessOs(): EnvGuideOs | undefined {return undefined;}+/**+ * "Start with Jarvis" as one checkbox, with the backend's own sentence on+ * what the next start would do ("local models serve the chat role" / "no+ * role uses local models …"), so the switch never promises more than the+ * boot task will keep.+ */+function AutostartControl({ providerId }: { providerId: string }) {+ const t = useT();+ const current = useAutostart(providerId);+ const save = useSetAutostart(providerId);+ const enabled = current.data?.enabled ?? true;+ return (+ <div className="space-y-2" data-testid="autostart">+ <label className="flex flex-wrap items-center gap-2 text-sm text-foreground">+ <input+ type="checkbox"+ checked={enabled}+ disabled={current.isLoading || save.isPending}+ onChange={(e) => save.mutate(e.target.checked)}+ aria-label={t("local_models.server.autostart_label")}+ className="h-4 w-4 rounded border-border accent-primary"+ />+ {t("local_models.server.autostart_label")}+ {save.isPending && (+ <span className="text-xs text-muted-foreground">+ {t("local_models.server.autostart_saving")}+ </span>+ )}+ </label>+ {current.data && (+ <p className="text-xs text-muted-foreground" data-testid="autostart-now">+ {fill(t("local_models.server.autostart_now"), {+ reason: current.data.reason,+ })}+ </p>+ )}+ {save.isError && (+ <p className="text-sm text-destructive" role="alert">+ {save.error instanceof Error ? save.error.message : String(save.error)}+ </p>+ )}+ </div>+ );+}++/**+ * "Run a check" — the same proof the set-up flow ends with (the server, one+ * real chat answer, one real embedding), on demand, one line per step.+ */+function VerifyControl({ providerId }: { providerId: string }) {+ const t = useT();+ const verify = useVerifySetup(providerId);+ const result = verify.data;+ return (+ <div className="space-y-2" data-testid="verify">+ <SoftButton+ primary+ onClick={() => verify.mutate()}+ disabled={verify.isPending}+ ariaLabel={t("local_models.verify.run")}+ >+ {verify.isPending ? (+ <Loader2 className="h-3.5 w-3.5 animate-spin" />+ ) : (+ <ShieldCheck className="h-3.5 w-3.5" />+ )}+ {verify.isPending+ ? t("local_models.verify.running")+ : t("local_models.verify.run")}+ </SoftButton>+ {result && (+ <div className="space-y-1 text-xs" data-testid="verify-result">+ <StatusDot+ tone={result.ok ? "ok" : "error"}+ label={+ result.ok+ ? t("local_models.verify.result_ok")+ : fill(t("local_models.verify.result_problem"), {+ reason: result.reason,+ })+ }+ />+ {verifyLines(result, t).map((line, i) => (+ <p key={i} className="ml-4 text-muted-foreground">+ {line}+ </p>+ ))}+ </div>+ )}+ {verify.isError && (+ <p className="text-sm text-destructive" role="alert">+ {verify.error instanceof Error+ ? verify.error.message+ : String(verify.error)}+ </p>+ )}+ </div>+ );+}+/*** Minutes of voice idleness before the local voice stack frees the* accelerator (0 = keep loaded). Saved on click; the supervisor reads it on@@ -431,6 +538,32 @@ export function ServerPanel({</Panel>)}+ {/* Start with Jarvis ----------------------------------------------------- */}+ {!remote && (+ <Panel>+ <div className="space-y-3 p-4">+ <p className={EYEBROW}>{t("local_models.server.autostart_eyebrow")}</p>+ <PanelHeader+ title={t("local_models.server.autostart_title")}+ subtitle={t("local_models.server.autostart_subtitle")}+ />+ <AutostartControl providerId={providerId} />+ </div>+ </Panel>+ )}++ {/* Check the setup -------------------------------------------------------- */}+ <Panel>+ <div className="space-y-3 p-4">+ <p className={EYEBROW}>{t("local_models.verify.eyebrow")}</p>+ <PanelHeader+ title={t("local_models.verify.title")}+ subtitle={t("local_models.verify.subtitle")}+ />+ <VerifyControl providerId={providerId} />+ </div>+ </Panel>+{/* Loaded now ------------------------------------------------------------ */}<Panel><div className="p-4 pb-2">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 7cecbe97b3..e4e6997802 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@@ -180,6 +180,19 @@ function installFetch(script: Script) {return ok({ state: "running", model: "", message: "" });if (url.startsWith("/api/providers/ollama/pull/status"))return ok({ state: "done", model: "", message: "", percent: 100 });+ if (url === `${BASE}/verify` && method === "POST")+ return ok({+ ok: true,+ status: "ok",+ reason: "",+ steps: [+ { id: "server", ok: true, model: "", detail: "Ollama 0.32.15", ms: 12 },+ { id: "chat", ok: true, model: "gemma4:12b-it-qat", detail: "Answered.", ms: 1800 },+ { id: "embedding", ok: null, model: "", detail: "No embedding role is configured.", ms: 0 },+ ],+ });+ if (url === `${BASE}/runtime/autostart` && method === "PUT")+ return ok({ enabled: true, in_use: true, reason: "local models serve the chat role" });throw new Error(`unexpected fetch: ${method} ${url}`);});vi.stubGlobal("fetch", fetchMock);@@ -218,14 +231,15 @@ describe("runLocalSetup", () => {"ornith:9b": "ornith:9b tuned","qwen3.5:4b": "qwen3.5:4b tuned",});- expect(calls.filter((c) => c.startsWith("PUT"))).toEqual([+ expect(calls.filter((c) => c.startsWith(`PUT ${BASE}/roles/`))).toEqual([`PUT ${BASE}/roles/voice`,`PUT ${BASE}/roles/tools_screen`,`PUT ${BASE}/roles/deep`,]);expect(calls).not.toContain("POST /api/providers/ollama/ollama-runtime/start");expect(steps.at(-1)?.phase).toBe("done");- // One download, three writes, two tunes (ornith:9b serves two roles).+ // One download, three writes, two tunes (ornith:9b serves two roles),+ // then the proof and the boot switch.expect(steps.map((s) => s.phase)).toEqual(["planning","pulling",@@ -234,8 +248,36 @@ describe("runLocalSetup", () => {"assigning","tuning","assigning",+ "verifying",+ "saving","done",]);+ expect(calls).toContain(`POST ${BASE}/verify`);+ expect(calls).toContain(`PUT ${BASE}/runtime/autostart`);+ expect(summary.verify?.ok).toBe(true);+ expect(summary.verify?.steps.map((s) => s.id)).toEqual(["server", "chat", "embedding"]);+ expect(summary.autostart).toBe(true);+ });++ it("proves the setup even when nothing changed, and never saves autostart for a remote server", async () => {+ const remote = overview(+ [role({ id: "chat", current: "qwen3.5:4b", installed: true, recommended: "qwen3.5:4b" })],+ ["qwen3.5:4b"],+ { host_kind: "remote", base_url: "http://box.lan:11434" },+ );+ const { calls } = installFetch({ overviews: [remote] });+ const summary = await runLocalSetup({+ providerId: "ollama",+ report: () => undefined,+ alive: () => true,+ tune: async () => "",+ pollMs: 0,+ });+ expect(summary.kept).toEqual([{ role: "chat", model: "qwen3.5:4b" }]);+ expect(summary.verify?.ok).toBe(true);+ expect(summary.autostart).toBeUndefined();+ expect(calls).toContain(`POST ${BASE}/verify`);+ expect(calls).not.toContain(`PUT ${BASE}/runtime/autostart`);});it("starts a stopped local server first and reads the plan from the server that answers", async () => {diff --git a/jarvis/ui/web/frontend/src/views/local-models/localSetup.ts b/jarvis/ui/web/frontend/src/views/local-models/localSetup.tsindex 25ed6e3bb5..400cbb2a2d 100644--- a/jarvis/ui/web/frontend/src/views/local-models/localSetup.ts+++ b/jarvis/ui/web/frontend/src/views/local-models/localSetup.ts@@ -18,6 +18,10 @@* 3. pull — every recommended model that is missing is downloaded once.* 4. assign — each writable role that is not already on its pick is set.* 5. tune — the suggested options are written for every model assigned.+ * 6. verify — three real round trips (`POST …/verify`): the server, one+ * chat answer, one embedding — so "set up" is a tested sentence.+ * 7. save — "start the server with Jarvis" is switched on for a local+ * server, so the next start needs no click at all.** A role that is served elsewhere (the wiki embedding on a cloud provider,* the voice server not installed) or has no pick is skipped and named in@@ -35,11 +39,14 @@ import {import {getOverview,modelPullStatus,+ setAutostart,setRole,startModelPull,+ verifySetup,type LocalModelRole,type OverviewResponse,type RoleRow,+ type VerifyResponse,} from "@/hooks/useLocalModels";/** The five slots the flow writes, in the order the rows show them. */@@ -62,6 +69,8 @@ export type SetupStep =| { phase: "pulling"; model: string; percent?: number; message?: string }| { phase: "assigning"; role: LocalModelRole; model: string }| { phase: "tuning"; model: string }+ | { phase: "verifying" }+ | { phase: "saving" }| { phase: "done"; summary: SetupSummary }| { phase: "error"; message: string; summary?: SetupSummary };@@ -78,6 +87,10 @@ export interface SetupSummary {readbacks: Record<string, string>;/** The server was started (or installed and started) by this run. */serverStarted: boolean;+ /** The proof: the server, one chat answer, one embedding. */+ verify?: VerifyResponse;+ /** "Start with Jarvis" was switched on (local servers only). */+ autostart?: boolean;}export interface RunLocalSetupOptions {@@ -296,6 +309,26 @@ export async function runLocalSetup({summary.readbacks[model] = await tune(model);if (!alive()) return summary;}++ // The proof — always, even when nothing changed: "set up" must be a+ // sentence that was tested this very minute.+ report({ phase: "verifying" });+ summary.verify = await verifySetup(providerId);+ if (!alive()) return summary;++ // Saved for next time: a local server comes up with Jarvis from now on.+ if (overview.server.host_kind !== "remote") {+ report({ phase: "saving" });+ try {+ await setAutostart(providerId, true);+ summary.autostart = true;+ } catch (err) {+ // The roles and the proof stand; only the boot convenience is unsaved.+ console.warn("[local-models] autostart not saved", err);+ summary.autostart = false;+ }+ if (!alive()) return summary;+ }report({ phase: "done", summary });return summary;}diff --git a/jarvis/ui/web/frontend/src/views/local-models/verifyLines.ts b/jarvis/ui/web/frontend/src/views/local-models/verifyLines.tsnew file mode 100644index 0000000000..19c73a48c7--- /dev/null+++ b/jarvis/ui/web/frontend/src/views/local-models/verifyLines.ts@@ -0,0 +1,51 @@+/**+ * The proof, one line per step — "Server — OK · 12 ms", "Chat — OK ·+ * gemma4:12b-it-qat · 1.8 s", "Embeddings — not tested · No embedding role+ * is configured." — shared by the overview's set-up summary and the Server+ * tab's "Run a check", so both read the same way.+ */+import type { VerifyResponse, VerifyStep } from "@/hooks/useLocalModels";+import { fill } from "@/i18n";++type T = (key: string) => string;++function stepLabel(step: VerifyStep, t: T): string {+ switch (step.id) {+ case "server":+ return t("local_models.verify.server");+ case "chat":+ return t("local_models.verify.chat");+ case "embedding":+ return t("local_models.verify.embedding");+ default:+ return step.id;+ }+}++function duration(ms: number, t: T): string {+ if (ms <= 0) return "";+ return ms >= 1000+ ? `${(ms / 1000).toFixed(1)} s`+ : fill(t("local_models.verify.ms"), { ms });+}++/** One line per step; `[]` when there is no proof yet. */+export function verifyLines(verify: VerifyResponse | undefined, t: T): string[] {+ if (!verify) return [];+ return verify.steps.map((step) => {+ const verdict =+ step.ok === null+ ? t("local_models.verify.skipped")+ : step.ok+ ? t("local_models.verify.ok")+ : t("local_models.verify.failed");+ const parts = [+ step.model,+ step.ok ? duration(step.ms, t) : "",+ step.ok === true ? "" : step.detail,+ ].filter(Boolean);+ return `${stepLabel(step, t)} — ${verdict}${+ parts.length > 0 ? ` · ${parts.join(" · ")}` : ""+ }`;+ });+}diff --git a/jarvis/ui/web/local_models_routes.py b/jarvis/ui/web/local_models_routes.pyindex dd07fd29ce..196e12e36b 100644--- a/jarvis/ui/web/local_models_routes.py+++ b/jarvis/ui/web/local_models_routes.py@@ -823,6 +823,84 @@ async def put_idle_release(return IdleReleaseResponse(minutes=int(body.minutes))+class AutostartResponse(BaseModel):+ #: ``[brain.providers.ollama].autostart`` — start the server with Jarvis.+ enabled: bool+ #: Whether anything in this install runs on the local server right now+ #: (the active brain, or a configured role); the boot task starts+ #: nothing while this is false, whatever ``enabled`` says.+ in_use: bool+ #: One sentence: what the boot task would do and why.+ reason: str+++class AutostartBody(BaseModel):+ enabled: bool++[email protected]("/runtime/autostart", response_model=AutostartResponse)+async def get_autostart(provider_id: str, request: Request) -> AutostartResponse:+ """Whether the local server starts with Jarvis, and whether that would fire."""+ _require_pull_capable(provider_id)+ from jarvis.core.config import ollama_autostart+ from jarvis.local_models import autostart++ cfg = _resolve_cfg(request)+ used, _why = autostart.in_use(cfg)+ _start, reason = autostart.should_autostart(cfg)+ return AutostartResponse(enabled=ollama_autostart(cfg), in_use=used, reason=reason)++[email protected]("/runtime/autostart", response_model=AutostartResponse)+async def put_autostart(+ provider_id: str, body: AutostartBody, request: Request+) -> AutostartResponse:+ """Switch "start the server with Jarvis" on or off (persisted)."""+ _require_pull_capable(provider_id)+ from jarvis.local_models import autostart++ cfg = _resolve_cfg(request)+ config_writer.set_ollama_autostart(body.enabled)+ provider = _ollama_provider_cfg(cfg)+ if provider is not None:+ try:+ provider.autostart = bool(body.enabled)+ except Exception: # noqa: BLE001 — a frozen config object still has the TOML write+ log.debug("local-models: in-memory autostart update skipped", exc_info=True)+ used, _why = autostart.in_use(cfg)+ _start, reason = autostart.should_autostart(cfg)+ return AutostartResponse(enabled=bool(body.enabled), in_use=used, reason=reason)+++class VerifyStep(BaseModel):+ #: ``server`` | ``chat`` | ``embedding``.+ id: str+ #: ``None`` = not run (the role is not configured, or the server is down).+ ok: bool | None+ model: str = ""+ detail: str = ""+ ms: int = 0+++class VerifyResponse(BaseModel):+ ok: bool+ #: The badge's vocabulary: ``ok`` | ``needs_setup`` | ``error``.+ status: str+ reason: str+ steps: list[VerifyStep]++[email protected]("/verify", response_model=VerifyResponse)+async def post_verify(provider_id: str, request: Request) -> VerifyResponse:+ """Prove the setup works — the server, one real chat answer, one real+ embedding — and refresh the sidebar's health badge with the result."""+ _require_pull_capable(provider_id)+ from jarvis.local_models import health_monitor++ result = await health_monitor.verify_setup(_resolve_cfg(request))+ return VerifyResponse(**result)++@router.post("/server/test", response_model=ServerProbeResponse)async def post_server_test(provider_id: str, body: ServerTestBody) -> ServerProbeResponse:"""Probe a host before saving it: version and latency, or the reason it failed."""diff --git a/jarvis/ui/web/server.py b/jarvis/ui/web/server.pyindex 3bcd9f07fd..4a83c7be18 100644--- a/jarvis/ui/web/server.py+++ b/jarvis/ui/web/server.py@@ -143,6 +143,9 @@ class WebServer:# Local models self-check (badge only): started next to the refresh# scheduler, i.e. after the serving path returned — never on boot.self._local_models_health_monitor: Any | None = None+ # Local server autostart: one task a few seconds after the serving+ # path returned; starts nothing unless local models are in use.+ self._local_models_autostart_task: asyncio.Task[None] | None = Noneself._refresh_registry_tasks: set[asyncio.Task[Any]] = set()self._refresh_scheduler_stopping = False# Realtime transport pre-warm — scheduled at the end of start() so the@@ -2154,6 +2157,35 @@ class WebServer:except Exception as exc: # noqa: BLE001 -- shutdown stays best-effortlogger.opt(exception=exc).debug("Local models health monitor stop failed.")+ def _schedule_local_models_autostart(self) -> None:+ """Start the local model server with Jarvis when it is wanted and in use.++ Best-effort, exactly once, off the boot path: the task sleeps a few+ seconds first, then decides from the config (autostart on AND a role+ or the active brain uses the server) and starts/warms accordingly.+ """+ if self._local_models_autostart_task is not None:+ return+ try:+ from jarvis.local_models.autostart import schedule++ self._local_models_autostart_task = schedule(lambda: self.cfg)+ except Exception as exc: # noqa: BLE001 -- a convenience must never block boot+ logger.opt(exception=exc).warning("Local models autostart did not schedule.")++ async def _stop_local_models_autostart(self) -> None:+ task = self._local_models_autostart_task+ self._local_models_autostart_task = None+ if task is None or task.done():+ return+ task.cancel()+ try:+ await task+ except asyncio.CancelledError:+ pass+ except Exception as exc: # noqa: BLE001 -- shutdown stays best-effort+ logger.opt(exception=exc).debug("Local models autostart stop failed.")+def _start_marketplace_refresh_scheduler(self) -> None:"""Create the periodic OAuth refresh task (best-effort, exactly once)."""self._refresh_scheduler_start_handle = None@@ -2655,6 +2687,7 @@ class WebServer:# hook covers normal desktop, headless, and direct WebServer starts.self._schedule_marketplace_refresh_scheduler()self._start_local_models_health_monitor()+ self._schedule_local_models_autostart()# Same reasoning, and the same three boot paths: a headless or# browser-only install has no desktop shell to warm the realtime# transport for it.@@ -3477,6 +3510,7 @@ class WebServer:# cannot enqueue a live-session rebuild while that registry is closing.await self._stop_marketplace_refresh_scheduler()await self._stop_local_models_health_monitor()+ await self._stop_local_models_autostart()# Stop the skill watcher, otherwise the watchdog thread stays behind# as a zombie and prevents the process from exiting.diff --git a/tests/unit/local_models/test_autostart.py b/tests/unit/local_models/test_autostart.pynew file mode 100644index 0000000000..6111d14b2e--- /dev/null+++ b/tests/unit/local_models/test_autostart.py@@ -0,0 +1,200 @@+"""Autostart: the local server comes up with Jarvis only when wanted AND used.++What would lie if it broke: a fresh install that never chose local models+spawning ``ollama serve`` at boot; a switched-off autostart starting anyway;+a remote server being "started"; an uninstalled one being installed; a boot+task that raises into the lifespan.+"""++from __future__ import annotations++import asyncio+from typing import Any++import pytest++from jarvis.core.config import BrainProviderConfig, JarvisConfig, OllamaModelOptions+from jarvis.local_models import autostart+++def _cfg(+ *,+ primary: str = "openrouter",+ chat: str = "",+ embedding: str = "",+ flag: bool | None = None,+) -> JarvisConfig:+ cfg = JarvisConfig()+ cfg.brain.primary = primary+ provider = BrainProviderConfig(model=chat)+ if flag is not None:+ provider.autostart = flag+ cfg.brain.providers["ollama"] = provider+ if embedding:+ cfg.ultrawiki.embedding_provider = "ollama"+ cfg.ultrawiki.embedding_model = embedding+ return cfg+++def test_nothing_is_in_use_on_a_fresh_install() -> None:+ used, why = autostart.in_use(_cfg())+ assert used is False+ assert "no role" in why+ start, reason = autostart.should_autostart(_cfg())+ assert start is False and reason == why+++def test_the_active_brain_or_a_configured_role_counts_as_in_use() -> None:+ assert autostart.in_use(_cfg(primary="ollama")) == (True, "the active brain")+ used, why = autostart.in_use(_cfg(chat="qwen3.5:4b"))+ assert used and why == "the chat role"+ used, why = autostart.in_use(_cfg(chat="qwen3.5:4b", embedding="embeddinggemma"))+ assert used and why == "the chat, embedding roles"+++def test_the_switch_off_wins_over_use() -> None:+ start, reason = autostart.should_autostart(_cfg(primary="ollama", flag=False))+ assert start is False and "switched off" in reason+ start, reason = autostart.should_autostart(_cfg(primary="ollama"))+ assert start is True and "the active brain" in reason+++def test_the_default_is_on_even_without_an_ollama_card() -> None:+ from jarvis.core.config import ollama_autostart++ cfg = JarvisConfig()+ cfg.brain.providers.pop("ollama", None)+ assert ollama_autostart(cfg) is True+ assert autostart.should_autostart(cfg)[0] is False # on, but nothing uses it+++async def test_run_once_starts_a_stopped_server_and_warms_the_chat_pick() -> None:+ cfg = _cfg(chat="qwen3.5:4b")+ cfg.brain.providers["ollama"].models["qwen3.5:4b"] = OllamaModelOptions(keep_alive="2h")+ started: list[str] = []+ warmed: list[tuple[str, str, Any]] = []++ async def _warm(root: str, model: str, keep_alive: Any) -> bool:+ warmed.append((root, model, keep_alive))+ return True++ record = await autostart.run_once(+ cfg,+ status=lambda: {"installed": True, "running": False},+ start=lambda: (started.append("go") or True, "Ollama started."),+ warm=_warm,+ )+ assert started == ["go"]+ assert record == {"started": True, "warmed": "qwen3.5:4b", "detail": "Ollama started."}+ # The pick's own keep-alive is what the warm ping asks for.+ assert warmed[0][1:] == ("qwen3.5:4b", "2h")+++async def test_run_once_only_warms_a_running_server() -> None:+ warmed: list[str] = []++ async def _warm(_root: str, model: str, keep_alive: Any) -> bool:+ warmed.append(f"{model}:{keep_alive}")+ return True++ record = await autostart.run_once(+ _cfg(chat="qwen3.5:4b"),+ status=lambda: {"installed": True, "running": True},+ start=lambda: (_ for _ in ()).throw(AssertionError("must not start")),+ warm=_warm,+ )+ assert record["started"] is False and record["warmed"] == "qwen3.5:4b"+ assert warmed == [f"qwen3.5:4b:{autostart.DEFAULT_KEEP_ALIVE}"]+++async def test_run_once_never_installs_and_never_starts_a_remote_server() -> None:+ absent = await autostart.run_once(+ _cfg(chat="qwen3.5:4b"),+ status=lambda: {"installed": False, "running": False},+ start=lambda: (_ for _ in ()).throw(AssertionError("must not start")),+ )+ assert absent["started"] is False and "not installed" in absent["detail"]++ cfg = _cfg(chat="qwen3.5:4b")+ cfg.brain.providers["ollama"].base_url = "http://box.lan:11434"+ remote = await autostart.run_once(+ cfg,+ status=lambda: {"installed": False, "running": False},+ start=lambda: (_ for _ in ()).throw(AssertionError("must not start")),+ )+ assert remote["started"] is False and "remote" in remote["detail"]+++async def test_run_once_reports_a_server_that_will_not_come_up() -> None:+ record = await autostart.run_once(+ _cfg(chat="qwen3.5:4b"),+ status=lambda: {"installed": True, "running": False},+ start=lambda: (False, "Ollama did not come up within 20 seconds."),+ warm=lambda *_a: (_ for _ in ()).throw(AssertionError("must not warm")),+ )+ assert record["started"] is False and "did not come up" in record["detail"]+++async def test_schedule_waits_then_decides_and_never_raises() -> None:+ slept: list[float] = []+ ran: list[str] = []++ async def _sleep(s: float) -> None:+ slept.append(s)++ async def _run(cfg: Any) -> dict[str, Any]:+ ran.append(cfg.brain.primary)+ return {"started": True, "warmed": "", "detail": ""}++ # Not in use: the run is skipped after the delay.+ await autostart.schedule(lambda: _cfg(), sleep=_sleep, run=_run)+ assert slept == [autostart.BOOT_DELAY_S] and ran == []++ # In use: the run happens.+ await autostart.schedule(lambda: _cfg(primary="ollama"), delay_s=0.0, sleep=_sleep, run=_run)+ assert ran == ["ollama"]++ # A failing run is logged, not raised into the lifespan.+ async def _boom(_cfg: Any) -> dict[str, Any]:+ raise RuntimeError("no binary")++ task = autostart.schedule(lambda: _cfg(primary="ollama"), delay_s=0.0, sleep=_sleep, run=_boom)+ await task+ assert task.exception() is None+++async def test_kick_runs_now_inside_a_loop() -> None:+ ran: list[str] = []++ async def _run(cfg: Any) -> dict[str, Any]:+ ran.append(cfg.brain.primary)+ return {"started": False, "warmed": "", "detail": ""}++ task = autostart.kick(_cfg(primary="ollama"), run=_run)+ assert task is not None+ await task+ assert ran == ["ollama"]+++def test_kick_is_a_no_op_outside_a_loop() -> None:+ assert autostart.kick(_cfg(primary="ollama")) is None+ # Nothing left behind for the next loop to trip over.+ assert not any(not t.done() for t in autostart._tasks)+++async def test_the_brain_switch_readies_the_local_server(monkeypatch: pytest.MonkeyPatch) -> None:+ from jarvis.brain import app_control++ kicked: list[str] = []+ monkeypatch.setattr(autostart, "kick", lambda cfg, **_kw: kicked.append(cfg.brain.primary))+ app_control._ready_local_server("ollama", _cfg(primary="ollama"))+ app_control._ready_local_server("openrouter", _cfg())+ assert kicked == ["ollama"]+ await asyncio.sleep(0)diff --git a/tests/unit/local_models/test_health_monitor.py b/tests/unit/local_models/test_health_monitor.pyindex e68e405502..5190ae2c1e 100644--- a/tests/unit/local_models/test_health_monitor.py+++ b/tests/unit/local_models/test_health_monitor.py@@ -47,6 +47,83 @@ def _record(tmp_path: Path) -> dict[str, Any]:return json.loads((tmp_path / "state" / "local_models_health.json").read_text("utf-8"))+def _embed(dims: int | Exception):+ async def _fn(_root: str, _model: str) -> int:+ if isinstance(dims, Exception):+ raise dims+ return dims++ return _fn+++def _cfg_with_embedding(chat: str, embedding: str) -> JarvisConfig:+ cfg = _cfg(chat)+ cfg.ultrawiki.embedding_provider = "ollama"+ cfg.ultrawiki.embedding_model = embedding+ return cfg+++async def test_verify_reports_every_step_and_writes_the_record(tmp_path: Path) -> None:+ async def _generate(_cfg: Any, _model: str) -> _Result:+ return _Result("ok")++ result = await hm.verify_setup(+ _cfg_with_embedding("qwen3.5:4b", "embeddinggemma"),+ probe=_probe(True),+ generate=_generate,+ embed=_embed(768),+ )+ assert result["ok"] is True and result["status"] == "ok" and result["reason"] == ""+ steps = {s["id"]: s for s in result["steps"]}+ assert list(steps) == ["server", "chat", "embedding"]+ assert steps["server"]["ok"] is True and "0.32.15" in steps["server"]["detail"]+ assert steps["chat"] == {+ "id": "chat",+ "ok": True,+ "model": "qwen3.5:4b",+ "detail": "Answered.",+ "ms": steps["chat"]["ms"],+ }+ assert steps["embedding"]["ok"] is True and "768" in steps["embedding"]["detail"]+ assert _record(tmp_path)["status"] == "ok"+++async def test_verify_names_the_failing_step(tmp_path: Path) -> None:+ async def _generate(_cfg: Any, _model: str) -> _Result:+ return _Result("ok")++ result = await hm.verify_setup(+ _cfg_with_embedding("qwen3.5:4b", "embeddinggemma"),+ probe=_probe(True),+ generate=_generate,+ embed=_embed(RuntimeError("/api/embed for 'embeddinggemma' failed: not found")),+ )+ assert result["ok"] is False and result["status"] == "error"+ assert result["reason"].startswith("embeddinggemma: ")+ assert "not found" in result["reason"]+ assert _record(tmp_path)["status"] == "error"+++async def test_verify_marks_unconfigured_roles_as_not_run_and_a_down_server_first(+ tmp_path: Path,+) -> None:+ async def _generate(_cfg: Any, _model: str) -> _Result:+ raise AssertionError("must not generate")++ nothing = await hm.verify_setup(_cfg(), probe=_probe(True), generate=_generate)+ assert nothing["status"] == "needs_setup"+ assert [s["ok"] for s in nothing["steps"]] == [True, None, None]++ down = await hm.verify_setup(_cfg("qwen3.5:4b"), probe=_probe(False), generate=_generate)+ assert down["status"] == "error" and "No Ollama answered" in down["reason"]+ assert [s["ok"] for s in down["steps"]] == [False, None, None]+ assert down["steps"][1]["model"] == "qwen3.5:4b"+ assert _record(tmp_path)["status"] == "error"++def test_interval_reads_the_one_config_field() -> None:assert hm.interval_hours(_cfg()) == 6.0assert hm.interval_hours(_cfg(hours=1.5)) == 1.5diff --git a/tests/unit/ui/web/test_local_models_routes.py b/tests/unit/ui/web/test_local_models_routes.pyindex b41e365798..fa687d0c97 100644--- a/tests/unit/ui/web/test_local_models_routes.py+++ b/tests/unit/ui/web/test_local_models_routes.py@@ -622,6 +622,56 @@ def test_server_stop_carries_the_danger_flag() -> None:# -- Idle release + the user's own choice --+def test_autostart_round_trip(server: WebServer, fake, monkeypatch) -> None:+ flags: list[tuple[str, str, bool]] = []+ monkeypatch.setattr(+ config_writer,+ "set_provider_flag",+ lambda provider, key, value, **_kw: flags.append((provider, key, value)),+ )+ with TestClient(server.app) as client:+ before = client.get(f"{BASE}/runtime/autostart").json()+ # The default is on, and the fixture's chat role puts the server in use.+ assert before == {"enabled": True, "in_use": True, "reason": before["reason"]}+ assert "chat" in before["reason"]+ off = client.put(f"{BASE}/runtime/autostart", json={"enabled": False}).json()+ assert off["enabled"] is False and "switched off" in off["reason"]+ assert client.get(f"{BASE}/runtime/autostart").json()["enabled"] is False+ assert flags == [("ollama", "autostart", False)]+ assert server.app.state.config.brain.providers["ollama"].autostart is False+++def test_verify_runs_the_three_steps_and_refreshes_the_badge(+ server: WebServer, fake, monkeypatch, tmp_path+) -> None:+ from jarvis.local_models import health_monitor++ async def _probe(_root: str) -> dict:+ return {"ok": True, "version": "0.32.15", "latency_ms": 7, "detail": ""}++ class _Result:+ status = "ok"+ detail = ""++ async def _generate(_cfg, _model: str) -> _Result:+ return _Result()++ async def _embed(_root: str, _model: str) -> int:+ return 1024++ monkeypatch.setattr(health_monitor, "_default_probe", _probe)+ monkeypatch.setattr(health_monitor, "_default_generate", _generate)+ monkeypatch.setattr(health_monitor, "_default_embed", _embed)+ with TestClient(server.app) as client:+ body = client.post(f"{BASE}/verify").json()+ assert body["ok"] is True and body["status"] == "ok"+ assert [s["id"] for s in body["steps"]] == ["server", "chat", "embedding"]+ assert body["steps"][0]["ms"] == 7+ assert body["steps"][1]["model"] == "qwen3.5:4b"+ assert body["steps"][2]["detail"] == "1024 dimensions."+ assert health_monitor.read_health_record()["status"] == "ok"++def test_idle_release_round_trip(server: WebServer, fake, monkeypatch) -> None:written: list[int] = []monkeypatch.setattr(