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(wake): apply onboarding changes without restart
Ruben Lütked3c8b7e386e9
diff --git a/docs/local-wakeword/USER-GUIDE-WAKE-WORD.md b/docs/local-wakeword/USER-GUIDE-WAKE-WORD.mdindex 81ae4cb6db..fc48253a3e 100644--- a/docs/local-wakeword/USER-GUIDE-WAKE-WORD.md+++ b/docs/local-wakeword/USER-GUIDE-WAKE-WORD.md@@ -55,9 +55,11 @@ ships no pre-trained brand models and never downloads one.## Applying a change-Saving a wake-word change from Settings applies it to a running voice-pipeline immediately when possible; otherwise the app tells you a restart is-needed and offers it.+Saving a wake-word change or switching always-on wake listening on/off applies+to a running desktop voice pipeline immediately. Hotkeys remain available and+unchanged throughout the switch. In a headless or voice-disabled process there+is no live microphone pipeline to update, so the setting is stored for the next+voice start instead.---diff --git a/jarvis/plugins/stt/fwhisper.py b/jarvis/plugins/stt/fwhisper.pyindex c69246a105..546b855b4a 100644--- a/jarvis/plugins/stt/fwhisper.py+++ b/jarvis/plugins/stt/fwhisper.py@@ -379,6 +379,17 @@ class FasterWhisperProvider:forensic) and therefore needs the unbiased second-pass confirm."""return self._initial_prompt+ def set_initial_prompt(self, prompt: str | None) -> None:+ """Replace the per-call decoder bias without rebuilding the model.++ Faster-Whisper reads ``_initial_prompt`` for every transcription, so an+ atomic reference swap is enough for a live wake-phrase change. An+ inference already in flight may finish with the prior prompt; the wake+ reload event discards that detector session before the new one re-arms.+ """+ normalized = prompt.strip() if prompt and prompt.strip() else None+ self._initial_prompt = normalized+def _ensure_model(self) -> None:if self._model is not None:returndiff --git a/jarvis/speech/pipeline.py b/jarvis/speech/pipeline.pyindex 3a88b791d9..232b351370 100644--- a/jarvis/speech/pipeline.py+++ b/jarvis/speech/pipeline.py@@ -1303,6 +1303,19 @@ class SpeechPipeline:except Exception as exc: # noqa: BLE001 — corrections must never break voice bootlog.warning("STT dictionary wrapper unavailable: %s", exc)self._tts = tts or _default_tts_for_pipeline(config)+ # Keep the user's activation preference separate from the detector+ # selected by the current wake plan. A phrase/model can change while+ # always-on listening is disabled; that must update the prepared plan+ # without silently opening the microphone. Older/duck-typed callers+ # without a TriggerConfig keep the legacy behaviour where a later+ # set_wake_plan() arms the resolved detector.+ trigger_cfg = getattr(config, "trigger", None)+ configured_wake_enabled = getattr(trigger_cfg, "wake_word_enabled", None)+ self._wake_word_enabled: bool | None = (+ bool(configured_wake_enabled)+ if configured_wake_enabled is not None+ else None+ )self._openwakeword_enabled = enable_openwakeword# Custom-wake-word plan (jarvis.speech.wake_phrase.WakeWordPlan) or None.# When None, the wake path is byte-identical to the legacy "Hey Jarvis"@@ -1995,16 +2008,32 @@ class SpeechPipeline:live-switch contract. Safe to call from the FastAPI handler thread — itshares the pipeline's event loop."""+ wake_preference = getattr(self, "_wake_word_enabled", None)+ wake_enabled = True if wake_preference is None else bool(wake_preference)prev = getattr(self._wake_plan, "oww_keyword", None)self._wake_plan = planself._wake_matcher = getattr(plan, "matcher", None)self._wake_phrase_label = getattr(plan, "phrase", None) or "the wake word"engine = getattr(plan, "engine", "openwakeword")+ # A Faster-Whisper wake provider reads its phrase bias on every call.+ # Update it through a capability method so switching between arbitrary+ # stt_match phrases cannot keep transcribing with the old wake word.+ # Clear the bias on non-stt plans because the same provider can also+ # serve the live transcript preview.+ set_initial_prompt = getattr(self._stt, "set_initial_prompt", None)+ if callable(set_initial_prompt):+ prompt = getattr(plan, "phrase", None) if engine == "stt_match" else None+ set_initial_prompt(prompt)+# Build a local Whisper engine on demand for the stt_match path. The# provider __init__ is light (the model loads lazily on first# transcription), so this does not block the caller.- if getattr(plan, "needs_local_whisper", False) and self._stt is None:+ if (+ wake_enabled+ and getattr(plan, "needs_local_whisper", False)+ and self._stt is None+ ):try:from jarvis.plugins.stt import build_wake_whisper@@ -2074,7 +2103,7 @@ class SpeechPipeline:keyword=plan.oww_keyword,early_candidate_listener=self._vosk_early_candidate_listener,)- self._openwakeword_enabled = True+ self._openwakeword_enabled = wake_enabledif self._whisper_wake is not None and self._wake_matcher is not None:self._whisper_wake._pattern = self._wake_matcher # noqa: SLF001self._whisper_wake_enabled = False@@ -2087,7 +2116,7 @@ class SpeechPipeline:# quiet breath to full scale and false-fires (see the ctor site).gain_normalization=engine != "custom_onnx",)- self._openwakeword_enabled = True+ self._openwakeword_enabled = wake_enabled# OWW stands alone for a live switch (lightweight default). The heavy# RollingWhisperWake backstop is a boot-time opt-in (heavy_local_whisper),# not part of a live wake-word change — turn it off here so switching@@ -2097,7 +2126,10 @@ class SpeechPipeline:self._whisper_wake._pattern = self._wake_matcher # noqa: SLF001self._whisper_wake_enabled = Falseelse: # stt_match — arbitrary phrase via local-Whisper transcript match- if self._stt is not None:+ if not wake_enabled:+ self._openwakeword_enabled = False+ self._whisper_wake_enabled = False+ elif self._stt is not None:self._openwakeword_enabled = Falseself._whisper_wake = RollingWhisperWake(self._stt,@@ -2135,6 +2167,24 @@ class SpeechPipeline:# Re-arm the running wake loop with the new detectors.self._wake_reload_event.set()+ def set_wake_activation(self, enabled: bool) -> None:+ """Enable or park always-on wake listening without restarting.++ The configured plan stays resident while disabled so hotkeys and the+ rest of the audio pipeline remain untouched. Enabling re-applies that+ plan, lazily preparing any detector it needs, and both transitions wake+ the parked/running wake loop through the existing reload event.+ """+ self._wake_word_enabled = bool(enabled)+ plan = getattr(self, "_wake_plan", None)+ if self._wake_word_enabled and plan is not None:+ self.set_wake_plan(plan)+ return++ self._openwakeword_enabled = False+ self._whisper_wake_enabled = False+ self._wake_reload_event.set()+def set_keybinds(self,*,diff --git a/jarvis/ui/desktop_app.py b/jarvis/ui/desktop_app.pyindex d1a6bdacb8..9fc973e9de 100644--- a/jarvis/ui/desktop_app.py+++ b/jarvis/ui/desktop_app.py@@ -2589,6 +2589,37 @@ class DesktopApp:# phrase matcher for the verifier + rolling-whisper.wake_plan=wake_plan,)+ # Onboarding is usable while the voice stack warms in the+ # background. A user can therefore save a new phrase after the+ # initial plan was resolved above but before this constructor+ # finishes. Re-resolve once at the handoff boundary and apply only+ # when the effective plan changed, closing that startup race without+ # adding work to the normal boot path.+ latest_wake_plan = resolve_wake_plan(+ self.cfg.trigger.wake_word,+ local_whisper_available=(+ _ilu.find_spec("faster_whisper") is not None+ ),+ language=resolve_wake_language(self.cfg),+ )+ plan_signature = (+ wake_plan.phrase,+ wake_plan.engine,+ wake_plan.oww_model_path,+ wake_plan.vosk_model_path,+ )+ latest_plan_signature = (+ latest_wake_plan.phrase,+ latest_wake_plan.engine,+ latest_wake_plan.oww_model_path,+ latest_wake_plan.vosk_model_path,+ )+ if latest_plan_signature != plan_signature:+ pipeline.set_wake_plan(latest_wake_plan)+ wake_plan = latest_wake_plan+ latest_wake_enabled = bool(self.cfg.trigger.wake_word_enabled)+ if pipeline._wake_word_enabled != latest_wake_enabled: # noqa: SLF001+ pipeline.set_wake_activation(latest_wake_enabled)_t_ctor = time.perf_counter()# Targeted boot-timing breakdown so the log shows exactly which voice# build step costs what (the wake-Whisper CUDA probe was the hiddendiff --git a/jarvis/ui/web/frontend/src/components/onboarding/steps/WakeWordStep.test.tsx b/jarvis/ui/web/frontend/src/components/onboarding/steps/WakeWordStep.test.tsxindex e5053c2335..029214b71a 100644--- a/jarvis/ui/web/frontend/src/components/onboarding/steps/WakeWordStep.test.tsx+++ b/jarvis/ui/web/frontend/src/components/onboarding/steps/WakeWordStep.test.tsx@@ -2,7 +2,12 @@ import { cleanup, fireEvent, render, screen, waitFor } from "@testing-library/reimport { afterEach, expect, it, vi } from "vitest";vi.mock("@/i18n", () => ({ useT: () => (k: string) => k }));const saveWakeWord = vi.fn().mockResolvedValue({ ok: true, degraded: false });-const setWakeActivation = vi.fn().mockResolvedValue({ ok: true, enabled: true, restart_required: true });+const setWakeActivation = vi.fn().mockResolvedValue({+ ok: true,+ enabled: true,+ applied_live: true,+ restart_required: false,+});vi.mock("@/hooks/useWakeWord", () => ({useWakeWord: () => ({ saveWakeWord, setWakeActivation }),useLocalSpeechInstall: () => ({diff --git a/jarvis/ui/web/frontend/src/hooks/useWakeWord.ts b/jarvis/ui/web/frontend/src/hooks/useWakeWord.tsindex 0368a54ced..e6ae28536c 100644--- a/jarvis/ui/web/frontend/src/hooks/useWakeWord.ts+++ b/jarvis/ui/web/frontend/src/hooks/useWakeWord.ts@@ -48,6 +48,13 @@ export interface WakeWordSaveResult {restart_required: boolean;}+export interface WakeActivationResult {+ ok: boolean;+ enabled: boolean;+ applied_live: boolean;+ restart_required: boolean;+}+/*** Returns true when the wake-word config is fully set up (phrase is non-empty).* Used by WakeWordOnboardingGate to decide whether to show the blocking overlay.@@ -112,11 +119,11 @@ export function useWakeWord() {[],);- // Turn the always-on wake word ON/OFF (the activation master switch). Persists- // to jarvis.toml; the change takes effect after a voice restart. Returns- // whether a restart is required (always true today).+ // Turn the always-on wake word ON/OFF (the activation master switch). The+ // backend applies it to a running voice pipeline and only requests a restart+ // when no live desktop voice pipeline exists.const setWakeActivation = useCallback(- async (enabled: boolean): Promise<{ ok: boolean; enabled: boolean; restart_required: boolean }> => {+ async (enabled: boolean): Promise<WakeActivationResult> => {const res = await fetch("/api/settings/wake-word/activation", {method: "POST",headers: { "Content-Type": "application/json" },@@ -127,7 +134,7 @@ export function useWakeWord() {throw new Error(body.detail ?? `HTTP ${res.status}`);}window.dispatchEvent(new CustomEvent("jarvis:wake-word-changed"));- return body as { ok: boolean; enabled: boolean; restart_required: boolean };+ return body as WakeActivationResult;},[],);diff --git a/jarvis/ui/web/frontend/src/i18n/locales/de.json b/jarvis/ui/web/frontend/src/i18n/locales/de.jsonindex 9a4b8a21e9..81c8afb0a8 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/de.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/de.json@@ -1087,7 +1087,7 @@"description": "Aktivierungsphrase für den Sprachmodus. Tippe deine eigene ein.","activation_title": "Aktivierungswort einschalten","activation_hint": "An: Jarvis hört ständig auf dein Wort (braucht ein lokales Modell). Aus: aktiviere per Tastenkombination (Push-to-Talk).",- "activation_saved": "Aktivierung gespeichert — Neustart nötig, damit sie greift.",+ "activation_saved": "Wake-Word-Aktivierung ist sofort aktualisiert.","phrase_label": "Aktivierungsphrase","phrase_placeholder": "z. B. Jonas","language_label": "Welche Sprache sprichst du?",@@ -1113,7 +1113,7 @@},"enable_local_button": "Beliebiges Wake-Word aktivieren","enable_local_installing": "Sprachpaket wird installiert… das kann einen Moment dauern.",- "enable_local_done": "Sprachpaket installiert. Starte neu, um dein Wake-Word zu nutzen.",+ "enable_local_done": "Sprachpaket installiert. Dein Wake-Word ist ohne Neustart bereit.","enable_local_error": "Installation fehlgeschlagen. Prüfe deine Internetverbindung und versuche es erneut.","enable_local_retry": "Erneut versuchen","enable_local_restart": "Jetzt neu starten",diff --git a/jarvis/ui/web/frontend/src/i18n/locales/en.json b/jarvis/ui/web/frontend/src/i18n/locales/en.jsonindex 82e5c35922..8ab23ef4c8 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/en.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/en.json@@ -1088,7 +1088,7 @@"description": "Activation phrase for voice mode. Type your own.","activation_title": "Activate wake word","activation_hint": "On: Jarvis is always listening for your word (needs a local model). Off: activate with a keyboard shortcut (push-to-talk).",- "activation_saved": "Activation saved — restart to apply.",+ "activation_saved": "Wake-word activation updated immediately.","phrase_label": "Wake phrase","phrase_placeholder": "e.g. Jonas","language_label": "Which language do you speak?",@@ -1114,7 +1114,7 @@},"enable_local_button": "Enable any wake word","enable_local_installing": "Installing the local speech pack… this can take a minute.",- "enable_local_done": "Local speech pack installed. Restart to use your wake word.",+ "enable_local_done": "Local speech pack installed. Your wake word is ready without a restart.","enable_local_error": "Install failed. Check your internet connection and try again.","enable_local_retry": "Try again","enable_local_restart": "Restart now",diff --git a/jarvis/ui/web/frontend/src/i18n/locales/es.json b/jarvis/ui/web/frontend/src/i18n/locales/es.jsonindex 65f36ac229..230b2fe35f 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/es.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/es.json@@ -1087,7 +1087,7 @@"description": "Frase de activación para el modo de voz. Escribe la tuya.","activation_title": "Activar palabra de activación","activation_hint": "Activado: Jarvis escucha siempre tu palabra (necesita un modelo local). Desactivado: actívalo con un atajo de teclado (pulsar para hablar).",- "activation_saved": "Activación guardada — reinicia para aplicar.",+ "activation_saved": "La activación se actualizó inmediatamente.","phrase_label": "Frase de activación","phrase_placeholder": "p. ej. Jonas","language_label": "¿Qué idioma hablas?",@@ -1113,7 +1113,7 @@},"enable_local_button": "Activar cualquier palabra de activación","enable_local_installing": "Instalando el paquete de voz local… puede tardar un momento.",- "enable_local_done": "Paquete de voz local instalado. Reinicia para usar tu palabra de activación.",+ "enable_local_done": "Paquete de voz local instalado. Tu palabra de activación está lista sin reiniciar.","enable_local_error": "Error en la instalación. Comprueba tu conexión a Internet e inténtalo de nuevo.","enable_local_retry": "Intentar de nuevo","enable_local_restart": "Reiniciar ahora",diff --git a/jarvis/ui/web/frontend/src/views/SettingsView.tsx b/jarvis/ui/web/frontend/src/views/SettingsView.tsxindex e5e092c2d1..85951fca5b 100644--- a/jarvis/ui/web/frontend/src/views/SettingsView.tsx+++ b/jarvis/ui/web/frontend/src/views/SettingsView.tsx@@ -299,8 +299,15 @@ function WakeWordPanel() {setTogglingActivation(true);setEnabled(next); // optimistictry {- await setWakeActivation(next);- pushToast("info", t("settings_view.wake_word.activation_saved"));+ const activation = await setWakeActivation(next);+ pushToast(+ activation.restart_required ? "info" : "success",+ t(+ activation.restart_required+ ? "settings_view.wake_word.restart_required"+ : "settings_view.wake_word.activation_saved",+ ),+ );} catch (e) {setEnabled(!next); // revert on failurepushToast("error", (e as Error).message);@@ -344,15 +351,6 @@ function WakeWordPanel() {}}- async function onRestart() {- try {- await fetch("/api/settings/restart-app", { method: "POST" });- pushToast("info", t("settings_view.wake_word.restarting"));- } catch (e) {- pushToast("error", (e as Error).message);- }- }-// Recovers the "stt_match only, unreliable" degrade in-app: provisions the// per-language Vosk model via POST /api/settings/wake-word/download-model// (jarvis/ui/web/settings_routes.py), then re-runs Save so the plan@@ -578,9 +576,6 @@ function WakeWordPanel() {{installStatus.state === "done" && (<div className="mt-2 text-foreground"><p>{t("settings_view.wake_word.enable_local_done")}</p>- <Button size="sm" className="mt-2" onClick={() => void onRestart()}>- {t("settings_view.wake_word.enable_local_restart")}- </Button></div>)}</div>diff --git a/jarvis/ui/web/settings_routes.py b/jarvis/ui/web/settings_routes.pyindex d9a14a08a5..a5e233e0cf 100644--- a/jarvis/ui/web/settings_routes.py+++ b/jarvis/ui/web/settings_routes.py@@ -476,8 +476,8 @@ async def put_stt_language(body: SttLanguageBody, request: Request) -> dict[str,# ---------------------------------------------------------------------------# Wake word (custom-wake-word feature). GET current + options; PUT to switch.-# Persisted to jarvis.toml [trigger.wake_word]; applies on the next voice-# bootstrap (a Jarvis restart). See docs/local-wakeword/CUSTOM-WAKE-WORD-DESIGN.md.+# Persisted to jarvis.toml [trigger.wake_word] and live-applied when the desktop+# voice pipeline is running. See docs/local-wakeword/CUSTOM-WAKE-WORD-DESIGN.md.# ---------------------------------------------------------------------------@@ -582,7 +582,7 @@ async def enable_local_speech(request: Request) -> dict[str, object]:@router.get("/wake-word/enable-local-speech/status")-async def enable_local_speech_status() -> dict[str, object]:+async def enable_local_speech_status(request: Request) -> dict[str, object]:"""Report the local-speech install progress + whether the pack is present."""available = _local_whisper_available()with _local_speech_install_lock:@@ -592,7 +592,36 @@ async def enable_local_speech_status() -> dict[str, object]:# or a prior run before a restart) → report done so the UI is truthful.if available and state in ("idle", "running"):state = "done"- return {"state": state, "message": message, "available": available}+ applied_live = False+ if available:+ try:+ from jarvis.speech.wake_model_fetch import resolve_wake_language+ from jarvis.speech.wake_phrase import resolve_wake_plan++ cfg = _config(request)+ pipeline = getattr(request.app.state, "speech_pipeline", None)+ if (+ cfg is not None+ and getattr(getattr(cfg, "trigger", None), "wake_word", None) is not None+ and pipeline is not None+ and hasattr(pipeline, "set_wake_plan")+ ):+ plan = resolve_wake_plan(+ cfg.trigger.wake_word,+ local_whisper_available=True,+ language=resolve_wake_language(cfg),+ )+ pipeline.set_wake_plan(plan)+ applied_live = True+ except Exception as exc: # noqa: BLE001 — install status must never 500+ log.warning("local-speech wake live-apply skipped: %s", exc)+ return {+ "state": state,+ "message": message,+ "available": available,+ "applied_live": applied_live,+ "restart_required": available and not applied_live,+ }@router.get("/wake-word")@@ -744,9 +773,9 @@ async def set_wake_activation(body: WakeActivationBody, request: Request) -> diconly. This was previously settable only by hand-editing jarvis.toml (defaultFalse), so a fresh downloader could never enable their wake word in-app.- Persisted to ``[trigger] wake_word_enabled``; takes effect on the next voice- restart (the detector enable-flags are wired at pipeline construction), so- ``restart_required`` is always True.+ Persisted to ``[trigger] wake_word_enabled`` and applied to the running voice+ pipeline when available. Headless/voice-disabled processes keep the setting+ for their next voice start."""try:from jarvis.core import config_writer@@ -763,7 +792,20 @@ async def set_wake_activation(body: WakeActivationBody, request: Request) -> diccfg.trigger.wake_word_enabled = bool(body.enabled)except Exception as exc: # noqa: BLE001 — frozen model is not an errorlog.debug("in-memory wake_word_enabled update skipped: %s", exc)- return {"ok": True, "enabled": bool(body.enabled), "restart_required": True}+ applied_live = False+ pipeline = getattr(request.app.state, "speech_pipeline", None)+ if pipeline is not None and hasattr(pipeline, "set_wake_activation"):+ try:+ pipeline.set_wake_activation(bool(body.enabled))+ applied_live = True+ except Exception as exc: # noqa: BLE001 — persistence already succeeded+ log.warning("wake activation live-apply failed: %s", exc)+ return {+ "ok": True,+ "enabled": bool(body.enabled),+ "applied_live": applied_live,+ "restart_required": not applied_live,+ }@router.post("/wake-word/download-model")diff --git a/tests/unit/speech/test_wake_live_apply.py b/tests/unit/speech/test_wake_live_apply.pyindex 01824f6b90..7434179520 100644--- a/tests/unit/speech/test_wake_live_apply.py+++ b/tests/unit/speech/test_wake_live_apply.py@@ -61,10 +61,10 @@ def _cfg(**kw: object) -> SimpleNamespace:return SimpleNamespace(**base)-def _pipe() -> SpeechPipeline:+def _pipe(*, wake_enabled: bool = True) -> SpeechPipeline:return SpeechPipeline(tts=_FakeTTS(), bus=None,- enable_openwakeword=False, enable_whisper_wake=False,+ enable_openwakeword=wake_enabled, enable_whisper_wake=False,enable_local_whisper=False, config=None,)@@ -184,4 +184,37 @@ def test_set_wake_plan_switch_between_phrases_stays_on_stt_match(tmp_path) -> Noassert pipe._openwakeword_enabled is Falseassert pipe._whisper_wake_enabled is Trueassert pipe._wake_phrase_label == "Hey Jarvis"+ assert pipe._stt.bias_prompt == "Hey Jarvis"+ assert pipe._wake_reload_event.is_set()+++def test_disabled_wake_stays_parked_across_plan_changes_and_toggles_live(tmp_path) -> None:+ pipe = _pipe(wake_enabled=False)+ pipe.set_wake_activation(False)+ pipe._wake_reload_event.clear()+ onnx = tmp_path / "hey_fable.onnx"+ onnx.write_bytes(b"stub")+ plan = resolve_wake_plan(+ _cfg(phrase="Hey Fable", engine="custom_onnx", custom_model_path=str(onnx)),+ local_whisper_available=False,+ )++ pipe.set_wake_plan(plan)++ assert pipe._wake_plan is plan+ assert pipe._openwakeword_enabled is False+ assert pipe._whisper_wake_enabled is False++ pipe._wake_reload_event.clear()+ pipe.set_wake_activation(True)++ assert pipe._openwakeword_enabled is True+ assert pipe._whisper_wake_enabled is False+ assert pipe._wake_reload_event.is_set()++ pipe._wake_reload_event.clear()+ pipe.set_wake_activation(False)++ assert pipe._openwakeword_enabled is False+ assert pipe._whisper_wake_enabled is Falseassert pipe._wake_reload_event.is_set()diff --git a/tests/unit/ui/test_wake_local_speech_install.py b/tests/unit/ui/test_wake_local_speech_install.pyindex ccb9496bbc..2a4bd40e9c 100644--- a/tests/unit/ui/test_wake_local_speech_install.py+++ b/tests/unit/ui/test_wake_local_speech_install.py@@ -8,6 +8,8 @@ The install itself (pip) is mocked; these lock the endpoint's state machine:"""from __future__ import annotations+from types import SimpleNamespace+from fastapi import FastAPIfrom fastapi.testclient import TestClient@@ -105,3 +107,39 @@ def test_status_reports_available_when_present(monkeypatch) -> None:assert status["available"] is Trueassert status["state"] == "done"+++def test_available_pack_reapplies_current_wake_plan_live(monkeypatch) -> None:+ from jarvis.core.config import WakeWordConfig++ _reset_state()+ monkeypatch.setattr(sr, "_local_whisper_available", lambda: True)++ class _Pipeline:+ plan = None++ def set_wake_plan(self, plan) -> None: # noqa: ANN001+ self.plan = plan++ app = FastAPI()+ app.include_router(sr.router)+ pipeline = _Pipeline()+ app.state.speech_pipeline = pipeline+ app.state.config = SimpleNamespace(+ trigger=SimpleNamespace(+ wake_word=WakeWordConfig(phrase="Hey Fable", engine="auto")+ ),+ stt=SimpleNamespace(language="en"),+ ui=SimpleNamespace(language="en"),+ )++ body = TestClient(app).get(+ "/api/settings/wake-word/enable-local-speech/status"+ ).json()++ assert body["available"] is True+ assert body["applied_live"] is True+ assert body["restart_required"] is False+ assert pipeline.plan is not None+ assert pipeline.plan.phrase == "Hey Fable"+ assert pipeline.plan.wake_available is Truediff --git a/tests/unit/ui/test_wake_word_route.py b/tests/unit/ui/test_wake_word_route.pyindex b54cf80e94..468b46e5b2 100644--- a/tests/unit/ui/test_wake_word_route.py+++ b/tests/unit/ui/test_wake_word_route.py@@ -15,10 +15,14 @@ class _FakePipeline:def __init__(self) -> None:self.applied = None+ self.activation: bool | None = Nonedef set_wake_plan(self, plan: object) -> None:self.applied = plan+ def set_wake_activation(self, enabled: bool) -> None:+ self.activation = enabled+def _client(wake_word: WakeWordConfig | None = None,@@ -86,6 +90,36 @@ def test_put_without_pipeline_reports_restart_required() -> None:assert body["restart_required"] is True+def test_activation_live_applies_without_restart(monkeypatch) -> None:+ from jarvis.core import config_writer++ monkeypatch.setattr(config_writer, "set_wake_word_enabled", lambda _enabled: None)+ pipe = _FakePipeline()+ response = _client(pipeline=pipe).post(+ "/api/settings/wake-word/activation", json={"enabled": True}+ )++ assert response.status_code == 200+ assert response.json()["applied_live"] is True+ assert response.json()["restart_required"] is False+ assert pipe.activation is True+++def test_activation_without_voice_pipeline_is_persisted_for_next_start(monkeypatch) -> None:+ from jarvis.core import config_writer++ persisted: list[bool] = []+ monkeypatch.setattr(config_writer, "set_wake_word_enabled", persisted.append)+ response = _client().post(+ "/api/settings/wake-word/activation", json={"enabled": False}+ )++ assert response.status_code == 200+ assert response.json()["applied_live"] is False+ assert response.json()["restart_required"] is True+ assert persisted == [False]++def test_put_rejects_unknown_engine() -> None:resp = _client().put("/api/settings/wake-word",