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(settings): wire in-app Download-wake-model button for the stt_match degrade
Ruben Lütkee7bb850b23ff
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/de.json b/jarvis/ui/web/frontend/src/i18n/locales/de.jsonindex f33d9eae8c..3a8d4f497d 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/de.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/de.json@@ -1082,7 +1082,12 @@"enable_local_error": "Installation fehlgeschlagen. Prüfe deine Internetverbindung und versuche es erneut.","enable_local_retry": "Erneut versuchen","enable_local_restart": "Jetzt neu starten",- "restarting": "Neustart…"+ "restarting": "Neustart…",+ "download_model_button": "Wake-Modell herunterladen",+ "download_model_downloading": "Wake-Modell wird heruntergeladen…",+ "download_model_done": "Wake-Modell heruntergeladen — Wake-Word wird neu gespeichert…",+ "download_model_error": "Wake-Modell konnte nicht heruntergeladen werden. Prüfe deine Internetverbindung und versuche es erneut.",+ "download_model_retry": "Erneut versuchen"},"onboarding": {"wake_word": {diff --git a/jarvis/ui/web/frontend/src/i18n/locales/en.json b/jarvis/ui/web/frontend/src/i18n/locales/en.jsonindex 738fdf6492..0c6e0328d8 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/en.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/en.json@@ -1083,7 +1083,12 @@"enable_local_error": "Install failed. Check your internet connection and try again.","enable_local_retry": "Try again","enable_local_restart": "Restart now",- "restarting": "Restarting…"+ "restarting": "Restarting…",+ "download_model_button": "Download wake model",+ "download_model_downloading": "Downloading the wake model…",+ "download_model_done": "Wake model downloaded — re-saving your wake word…",+ "download_model_error": "Could not download the wake model. Check your connection and try again.",+ "download_model_retry": "Try again"},"onboarding": {"wake_word": {diff --git a/jarvis/ui/web/frontend/src/i18n/locales/es.json b/jarvis/ui/web/frontend/src/i18n/locales/es.jsonindex 98cdca6e03..3ac846f1a8 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/es.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/es.json@@ -1082,7 +1082,12 @@"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",- "restarting": "Reiniciando…"+ "restarting": "Reiniciando…",+ "download_model_button": "Descargar modelo de activación",+ "download_model_downloading": "Descargando el modelo de activación…",+ "download_model_done": "Modelo de activación descargado — guardando de nuevo tu palabra de activación…",+ "download_model_error": "No se pudo descargar el modelo de activación. Comprueba tu conexión e inténtalo de nuevo.",+ "download_model_retry": "Intentar de nuevo"},"onboarding": {"wake_word": {diff --git a/jarvis/ui/web/frontend/src/views/SettingsView.tsx b/jarvis/ui/web/frontend/src/views/SettingsView.tsxindex 2598d17e76..4d4b65f341 100644--- a/jarvis/ui/web/frontend/src/views/SettingsView.tsx+++ b/jarvis/ui/web/frontend/src/views/SettingsView.tsx@@ -135,6 +135,14 @@ function WakeWordPanel() {// word (needs a local model for the user's word), off = hotkey / push-to-talk.const [enabled, setEnabled] = useState(false);const [togglingActivation, setTogglingActivation] = useState(false);+ // In-app recovery for the degraded-wake-word scenario: downloads the Vosk+ // model that wake_phrase.py's degrade message points at (Settings -> Wake+ // word -> "Download wake model"). Mirrors the local-speech-install status+ // shape above but drives a different, one-shot backend route.+ const [wakeModelDownload, setWakeModelDownload] = useState<{+ state: "idle" | "running" | "done" | "error";+ message: string;+ }>({ state: "idle", message: "" });// Hydrate the form once the GET resolves (and whenever the config changes).useEffect(() => {@@ -174,6 +182,9 @@ function WakeWordPanel() {if (!trimmedPhrase) return;setSaving(true);setResult(null);+ // A fresh save gets a fresh download control — stale done/error state from+ // a previous degrade shouldn't bleed into the next result.+ setWakeModelDownload({ state: "idle", message: "" });try {const res = await saveWakeWord({phrase: trimmedPhrase,@@ -205,6 +216,44 @@ function WakeWordPanel() {}}+ // 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+ // re-resolves to vosk_kws now that the model is present. Never throws — a+ // failed fetch or a still-absent model surfaces an honest retry message.+ async function onDownloadWakeModel() {+ setWakeModelDownload({ state: "running", message: "" });+ try {+ const res = await fetch("/api/settings/wake-word/download-model", {+ method: "POST",+ });+ const data: { ok?: boolean; present?: boolean; message?: string } = await res+ .json()+ .catch(() => ({}));+ const backendMessage = typeof data.message === "string" ? data.message : "";+ if (!res.ok) {+ setWakeModelDownload({+ state: "error",+ message: backendMessage || `HTTP ${res.status}`,+ });+ return;+ }+ if (data.present) {+ setWakeModelDownload({ state: "done", message: backendMessage });+ // Model is present now — re-save with the same phrase/engine so the+ // panel re-resolves to vosk_kws and drops out of the degraded state.+ await onSave();+ } else {+ setWakeModelDownload({+ state: "error",+ message: backendMessage || t("settings_view.wake_word.download_model_error"),+ });+ }+ } catch (e) {+ setWakeModelDownload({ state: "error", message: (e as Error).message });+ }+ }+return (<div className="rounded-lg border border-border bg-card/60 p-4"><div className="flex items-start gap-3">@@ -400,6 +449,53 @@ function WakeWordPanel() {{t("settings_view.wake_word.restart_required")}</p>)}++ {/* In-app recovery for the degraded ("stt_match only") scenario:+ wires the backend's own suggestion (Settings -> Wake word ->+ "Download wake model") to a real button instead of a+ CLI/API-only route. */}+ {result.degraded && (+ <div className="mt-2">+ {wakeModelDownload.state === "idle" && (+ <Button+ size="sm"+ onClick={() => void onDownloadWakeModel()}+ >+ {t("settings_view.wake_word.download_model_button")}+ </Button>+ )}++ {wakeModelDownload.state === "running" && (+ <p className="flex items-center gap-2 text-foreground">+ <Loader2 className="h-3.5 w-3.5 animate-spin" />+ {t("settings_view.wake_word.download_model_downloading")}+ </p>+ )}++ {wakeModelDownload.state === "done" && (+ <p className="text-foreground">+ {wakeModelDownload.message ||+ t("settings_view.wake_word.download_model_done")}+ </p>+ )}++ {wakeModelDownload.state === "error" && (+ <div className="text-destructive">+ <p>+ {wakeModelDownload.message ||+ t("settings_view.wake_word.download_model_error")}+ </p>+ <Button+ size="sm"+ className="mt-2"+ onClick={() => void onDownloadWakeModel()}+ >+ {t("settings_view.wake_word.download_model_retry")}+ </Button>+ </div>+ )}+ </div>+ )}</div>)}</div>diff --git a/jarvis/ui/web/frontend/src/views/settings/WakeWordPanel.test.tsx b/jarvis/ui/web/frontend/src/views/settings/WakeWordPanel.test.tsxindex f703cd961f..32103ed58f 100644--- a/jarvis/ui/web/frontend/src/views/settings/WakeWordPanel.test.tsx+++ b/jarvis/ui/web/frontend/src/views/settings/WakeWordPanel.test.tsx@@ -5,7 +5,7 @@* - Placeholder text is "e.g. Jonas" (from i18n key settings_view.wake_word.phrase_placeholder).* - The phrase input starts empty when the backend returns phrase == "".*/-import { cleanup, render, screen, waitFor } from "@testing-library/react";+import { cleanup, fireEvent, render, screen, waitFor } from "@testing-library/react";import { afterEach, describe, expect, it, vi } from "vitest";// ---------------------------------------------------------------------------@@ -56,6 +56,12 @@ vi.mock("@/views/settings/AppSettingsGroup", () => ({vi.mock("@/views/settings/JarvisApiGroup", () => ({JarvisApiGroup: () => null,}));+// RealtimeVoiceGroup uses react-query (useVoiceMode) and needs a+// QueryClientProvider this test doesn't set up — silence it like the other+// sibling groups above, unrelated to wake-word.+vi.mock("@/views/settings/RealtimeVoiceGroup", () => ({+ RealtimeVoiceGroup: () => null,+}));// Silence the onboarding gate so it doesn't interfere with SettingsView tests.vi.mock("@/components/onboarding/OnboardingGate", () => ({@@ -143,4 +149,92 @@ describe("WakeWordPanel (via SettingsView)", () => {expect(input).not.toBeNull();expect(input!.value).toBe("");});++ it("shows the 'Download wake model' button on a degraded save result and POSTs the download-model route on click", async () => {+ // A minimal request router: GET hydrates the form, PUT simulates the+ // backend resolving the phrase to the unreliable stt_match-only path+ // (jarvis/speech/wake_phrase.py's degrade branch), and the download route+ // simulates the Vosk model becoming available in-app.+ const calls: { url: string; method: string }[] = [];+ const fetchMock = vi.fn((url: string, init?: RequestInit) => {+ const method = init?.method ?? "GET";+ calls.push({ url, method });++ if (url === "/api/settings/wake-word" && method === "GET") {+ return Promise.resolve({+ ok: true,+ json: () => Promise.resolve(makeWakeWordGET("")),+ });+ }+ if (url === "/api/settings/wake-word" && method === "PUT") {+ return Promise.resolve({+ ok: true,+ json: () =>+ Promise.resolve({+ ok: true,+ phrase: "Jonas",+ engine: "auto",+ resolved_engine: "stt_match",+ degraded: true,+ wake_available: true,+ message:+ "Custom phrase 'Jonas' is on the local-Whisper transcript " ++ "match — this is UNRELIABLE for a hard name. Download the " ++ "Vosk model for the configured language to make it reliable " ++ "(Settings -> Wake word -> 'Download wake model').",+ persisted: true,+ restart_required: true,+ }),+ });+ }+ if (+ url === "/api/settings/wake-word/download-model" &&+ method === "POST"+ ) {+ return Promise.resolve({+ ok: true,+ json: () =>+ Promise.resolve({+ ok: true,+ present: true,+ message: "Wake model ready.",+ }),+ });+ }+ // Anything else (assistant-name refresh, restart probes, …).+ return Promise.resolve({ ok: true, json: () => Promise.resolve({}) });+ });+ vi.stubGlobal("fetch", fetchMock);++ render(<SettingsView />);++ await waitFor(() => screen.getByText("Wake Word"));++ const input = screen.getByPlaceholderText(+ "e.g. Jonas",+ ) as HTMLInputElement;+ fireEvent.change(input, { target: { value: "Jonas" } });++ const saveButton = screen.getByRole("button", { name: "Save wake word" });+ fireEvent.click(saveButton);++ // Degraded result renders the download control (there is no such button+ // for a non-degraded save).+ const downloadButton = await screen.findByRole("button", {+ name: "Download wake model",+ });+ expect(downloadButton).toBeDefined();++ fireEvent.click(downloadButton);++ await waitFor(() => {+ expect(+ calls.some(+ (c) =>+ c.url === "/api/settings/wake-word/download-model" &&+ c.method === "POST",+ ),+ ).toBe(true);+ });+ });});