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
fix(ui): section-health reports the resolved provider, not the dead default
Ruben Lütke76d8613eaf23
diff --git a/jarvis/ui/web/provider_routes.py b/jarvis/ui/web/provider_routes.pyindex b7b0eb5635..f9ae973080 100644--- a/jarvis/ui/web/provider_routes.py+++ b/jarvis/ui/web/provider_routes.py@@ -355,13 +355,58 @@ def _active_brain(request: Request) -> str | None:def _active_tts(request: Request) -> str | None:+ """The TTS provider actually powering voice output — the resolved cross-family+ provider, not the raw configured default.++ Mirrors ``_active_brain`` reporting the LIVE provider. Without this, a user+ whose only key is (say) ElevenLabs sees an amber "Gemini Flash TTS: no key set"+ dot even though the runtime crossed to ElevenLabs and voice works — pointing+ them at the wrong fix and masking that the fallback is healthy. Only reports a+ DIFFERENT provider when the runtime genuinely crossed away from the configured+ one; otherwise returns the raw configured value so the health lookup behaves+ exactly as before. Health must never 500, so any resolver error falls back to+ the configured value.+ """cfg = _resolve_cfg(request)- return getattr(getattr(cfg, "tts", None), "provider", None) if cfg else None+ tts_cfg = getattr(cfg, "tts", None) if cfg else None+ if tts_cfg is None:+ return None+ configured = getattr(tts_cfg, "provider", None)+ try:+ from jarvis.plugins.tts import (+ _canonical_tts_name,+ _resolve_keyed_tts_provider,+ )++ resolved, _ = _resolve_keyed_tts_provider((configured or "").lower(), tts_cfg)+ if _canonical_tts_name((configured or "").lower()) != resolved:+ return resolved+ except Exception as exc: # noqa: BLE001 — the health panel must never 500+ log.debug("resolved-provider health probe failed (%s); using configured.", exc)+ return configureddef _active_stt(request: Request) -> str | None:+ """The STT provider actually powering voice input — the resolved cross-family+ provider, not the raw configured default (which may be a dead, keyless default+ the runtime already crossed away from). See ``_active_tts`` for the rationale.+ """cfg = _resolve_cfg(request)- return getattr(getattr(cfg, "stt", None), "provider", None) if cfg else None+ stt_cfg = getattr(cfg, "stt", None) if cfg else None+ if stt_cfg is None:+ return None+ configured = (getattr(stt_cfg, "provider", None) or "").strip() or None+ if not configured:+ return configured+ try:+ from jarvis.plugins.stt import _resolve_keyed_stt_provider++ resolved = _resolve_keyed_stt_provider(configured)+ if resolved and resolved != configured:+ return resolved+ except Exception as exc: # noqa: BLE001 — the health panel must never 500+ log.debug("resolved-provider health probe failed (%s); using configured.", exc)+ return configureddef _resolve_cfg(request: Request):diff --git a/tests/unit/ui/test_provider_health_resolved.py b/tests/unit/ui/test_provider_health_resolved.pynew file mode 100644index 0000000000..af7584eede--- /dev/null+++ b/tests/unit/ui/test_provider_health_resolved.py@@ -0,0 +1,76 @@+"""The section-health tab reports the RESOLVED provider, not the dead default.++Regression guard for audit item A6: ``_active_stt`` / ``_active_tts`` used to return+the raw configured provider (a keyless shipped default), so a single-key user whose+voice actually works via a crossed-to family saw a false "no key set" dot pointing+at the wrong fix. They must now report the provider the runtime actually crossed to+— while leaving the configured value untouched when it has a key (maintainer path).+"""+from __future__ import annotations++from types import SimpleNamespace++import jarvis.core.config as cfg+import jarvis.plugins.stt as stt_pkg+from jarvis.core.config import ResolvedEndpoint+from jarvis.ui.web.provider_routes import _active_stt, _active_tts+++def _request(stt_provider: str, tts_provider: str):+ state = SimpleNamespace(+ config=SimpleNamespace(+ stt=SimpleNamespace(provider=stt_provider),+ tts=SimpleNamespace(+ provider=tts_provider, use_vertex=False, voice_de="", voice_en=""+ ),+ )+ )+ return SimpleNamespace(app=SimpleNamespace(state=state))+++def _only(family_key: str):+ """A get_secret_any double where ONLY ``family_key`` resolves to a key."""++ def _fake(candidates) -> str | None:+ keys = {c[0] for c in candidates}+ return "real-key" if family_key in keys else None++ return _fake+++def _no_proxy(monkeypatch) -> None:+ monkeypatch.setattr(+ cfg,+ "resolve_provider_endpoint",+ lambda pid, **kw: ResolvedEndpoint(base_url=None, credential=None, via_proxy=False),+ )+++def test_active_stt_reports_the_crossed_to_provider(monkeypatch):+ _no_proxy(monkeypatch)+ monkeypatch.setattr(stt_pkg, "_load_provider_class", lambda name: object)+ # groq default has no key; the user's only key is an OpenRouter key.+ monkeypatch.setattr(cfg, "get_secret_any", _only("openrouter_api_key"))++ assert _active_stt(_request("groq-api", "gemini-flash-tts")) == "openrouter-stt"+++def test_active_stt_keeps_configured_when_it_has_a_key(monkeypatch):+ _no_proxy(monkeypatch)+ monkeypatch.setattr(stt_pkg, "_load_provider_class", lambda name: object)+ monkeypatch.setattr(cfg, "get_secret_any", _only("groq_api_key"))++ assert _active_stt(_request("groq-api", "gemini-flash-tts")) == "groq-api"+++def test_active_tts_reports_the_crossed_to_provider(monkeypatch):+ # gemini default has no key; the user's only key is ElevenLabs.+ monkeypatch.setattr(cfg, "get_secret_any", _only("elevenlabs_api_key"))++ assert _active_tts(_request("groq-api", "gemini-flash-tts")) == "elevenlabs"+++def test_active_tts_keeps_configured_when_it_has_a_key(monkeypatch):+ monkeypatch.setattr(cfg, "get_secret_any", _only("gemini_api_key"))++ assert _active_tts(_request("groq-api", "gemini-flash-tts")) == "gemini-flash-tts"