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
chore: auto-save WIP via Claude stop-hook safety net (2026-07-03 16:25)
Ruben Lütke785d026a68ba
diff --git a/jarvis/ui/web/frontend/src/hooks/useWakeWord.ts b/jarvis/ui/web/frontend/src/hooks/useWakeWord.tsindex 2e9210171e..6a612b65ef 100644--- a/jarvis/ui/web/frontend/src/hooks/useWakeWord.ts+++ b/jarvis/ui/web/frontend/src/hooks/useWakeWord.ts@@ -1,4 +1,4 @@-import { useCallback, useEffect, useState } from "react";+import { useCallback, useEffect, useRef, useState } from "react";/*** Current wake-word configuration as returned by GET /api/settings/wake-word.@@ -110,3 +110,78 @@ export function useWakeWord() {return { config, loading, error, refetch, saveWakeWord };}++/**+ * Progress of the in-app "local speech pack" (faster-whisper) install that+ * unlocks ANY wake phrase. Mirrors the backend state machine in+ * jarvis/ui/web/settings_routes.py (enable-local-speech).+ */+export interface LocalSpeechStatus {+ state: "idle" | "running" | "done" | "error";+ message: string;+ available: boolean;+}++/**+ * Drives POST /api/settings/wake-word/enable-local-speech and polls its status+ * endpoint until the install finishes. Calls `onInstalled` once the pack is+ * present so the caller can refetch the wake config. The install runs in the+ * backend; this only starts it and reflects progress.+ */+export function useLocalSpeechInstall(onInstalled?: () => void) {+ const [status, setStatus] = useState<LocalSpeechStatus>({+ state: "idle",+ message: "",+ available: true,+ });+ const pollRef = useRef<number | null>(null);+ const onInstalledRef = useRef(onInstalled);+ onInstalledRef.current = onInstalled;++ const stopPoll = useCallback(() => {+ if (pollRef.current !== null) {+ window.clearInterval(pollRef.current);+ pollRef.current = null;+ }+ }, []);++ const poll = useCallback(async () => {+ try {+ const res = await fetch(+ "/api/settings/wake-word/enable-local-speech/status",+ );+ const data = (await res.json()) as LocalSpeechStatus;+ setStatus(data);+ if (data.state === "done" || data.state === "error") {+ stopPoll();+ if (data.state === "done") onInstalledRef.current?.();+ }+ } catch {+ // Transient network blip during a long install — keep polling.+ }+ }, [stopPoll]);++ const install = useCallback(async () => {+ setStatus({ state: "running", message: "", available: false });+ try {+ const res = await fetch("/api/settings/wake-word/enable-local-speech", {+ method: "POST",+ });+ const data = (await res.json()) as LocalSpeechStatus & { already?: boolean };+ if (data.state === "done" && data.available) {+ setStatus({ state: "done", message: data.message ?? "", available: true });+ onInstalledRef.current?.();+ return;+ }+ stopPoll();+ pollRef.current = window.setInterval(() => void poll(), 2000);+ } catch (e) {+ setStatus({ state: "error", message: (e as Error).message, available: false });+ }+ }, [poll, stopPoll]);++ // Clean up the interval if the panel unmounts mid-install.+ useEffect(() => () => stopPoll(), [stopPoll]);++ return { status, install };+}diff --git a/jarvis/ui/web/frontend/src/views/SettingsView.tsx b/jarvis/ui/web/frontend/src/views/SettingsView.tsxindex 85718e15f6..c55b35c871 100644--- a/jarvis/ui/web/frontend/src/views/SettingsView.tsx+++ b/jarvis/ui/web/frontend/src/views/SettingsView.tsx@@ -3,6 +3,7 @@ import {Settings,Mic,Keyboard,+ Loader2,X,} from "lucide-react";import { ViewHeader } from "@/views/ChatsView";@@ -14,7 +15,11 @@ import { AppSettingsGroup } from "@/views/settings/AppSettingsGroup";import { SilenceWindowGroup } from "@/views/settings/SilenceWindowGroup";import { VolumeGroup } from "@/views/settings/VolumeGroup";import { SystemPromptGroup } from "@/views/settings/SystemPromptGroup";-import { useWakeWord, type WakeWordSaveResult } from "@/hooks/useWakeWord";+import {+ useWakeWord,+ useLocalSpeechInstall,+ type WakeWordSaveResult,+} from "@/hooks/useWakeWord";import {useKeybinds,chordToCombo,@@ -110,8 +115,11 @@ function SettingRow({ row }: { row: SettingRow }) {*/function WakeWordPanel() {const t = useT();- const { config, loading, error, saveWakeWord } = useWakeWord();+ const { config, loading, error, saveWakeWord, refetch } = useWakeWord();const pushToast = useEventStore((s) => s.pushToast);+ // In-app installer for the local speech pack (faster-whisper) that unlocks any+ // wake phrase. Refetch the wake config on success so the hint clears.+ const { status: installStatus, install } = useLocalSpeechInstall(refetch);const [phrase, setPhrase] = useState("");const [engine, setEngine] = useState<string>("auto");@@ -162,6 +170,15 @@ 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);+ }+ }+return (<div className="rounded-lg border border-border bg-card/60 p-4"><div className="flex items-start gap-3">@@ -248,11 +265,56 @@ function WakeWordPanel() {className="mt-1.5 w-full accent-primary disabled:opacity-50"/>- {/* Inline degrade hint */}+ {/* Any-phrase enablement: install the local speech pack in-app so+ an arbitrary wake word works, instead of silently degrading. */}{showNeedsWhisperHint && (- <p className="mt-3 text-xs text-amber-500">- {t("settings_view.wake_word.needs_whisper_hint")}- </p>+ <div className="mt-3 rounded-md border border-amber-500/40 bg-amber-500/10 p-3 text-xs text-amber-500">+ <p>{t("settings_view.wake_word.needs_whisper_hint")}</p>++ {installStatus.state === "idle" && (+ <Button+ size="sm"+ className="mt-2"+ onClick={() => void install()}+ >+ {t("settings_view.wake_word.enable_local_button")}+ </Button>+ )}++ {installStatus.state === "running" && (+ <p className="mt-2 flex items-center gap-2 text-foreground">+ <Loader2 className="h-3.5 w-3.5 animate-spin" />+ {t("settings_view.wake_word.enable_local_installing")}+ </p>+ )}++ {installStatus.state === "error" && (+ <div className="mt-2 text-destructive">+ <p>{t("settings_view.wake_word.enable_local_error")}</p>+ {installStatus.message && (+ <p className="mt-1 font-mono text-[11px] text-muted-foreground">+ {installStatus.message}+ </p>+ )}+ <Button+ size="sm"+ className="mt-2"+ onClick={() => void install()}+ >+ {t("settings_view.wake_word.enable_local_retry")}+ </Button>+ </div>+ )}++ {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>)}{/* Save button */}diff --git a/tests/unit/ui/test_wake_local_speech_install.py b/tests/unit/ui/test_wake_local_speech_install.pynew file mode 100644index 0000000000..ccb9496bbc--- /dev/null+++ b/tests/unit/ui/test_wake_local_speech_install.py@@ -0,0 +1,107 @@+"""POST/GET /api/settings/wake-word/enable-local-speech — the in-app installer+that pulls faster-whisper so ANY wake phrase works on a fresh install.++The install itself (pip) is mocked; these lock the endpoint's state machine:+- already installed → done/already, no pip call+- fresh install → pip runs, status flips to done+- pip failure → status reports error with the reason+"""+from __future__ import annotations++from fastapi import FastAPI+from fastapi.testclient import TestClient++import jarvis.ui.web.settings_routes as sr+++def _client() -> TestClient:+ app = FastAPI()+ app.include_router(sr.router)+ return TestClient(app)+++def _reset_state() -> None:+ sr._local_speech_install["state"] = "idle"+ sr._local_speech_install["message"] = ""+++class _SyncThread:+ """Runs the install target synchronously so the test is deterministic."""++ def __init__(self, target=None, **_kw) -> None:+ self._target = target++ def start(self) -> None:+ if self._target is not None:+ self._target()+++def test_already_installed_returns_done_without_pip(monkeypatch) -> None:+ _reset_state()+ monkeypatch.setattr(sr, "_local_whisper_available", lambda: True)+ called = []+ monkeypatch.setattr(+ "jarvis.setup.dependencies.install_pip_package",+ lambda *a, **k: called.append(a) or (True, "x"),+ )++ body = _client().post("/api/settings/wake-word/enable-local-speech").json()++ assert body["state"] == "done"+ assert body["already"] is True+ assert body["available"] is True+ assert called == [] # short-circuits — never shells out to pip+++def test_fresh_install_runs_pip_and_status_flips_to_done(monkeypatch) -> None:+ _reset_state()+ monkeypatch.setattr(sr, "_local_whisper_available", lambda: False)+ packages: list[str] = []++ def fake_install(pkg, **_kw):+ packages.append(pkg)+ return True, "install reported success"++ monkeypatch.setattr("jarvis.setup.dependencies.install_pip_package", fake_install)+ monkeypatch.setattr(sr.threading, "Thread", _SyncThread)++ client = _client()+ post = client.post("/api/settings/wake-word/enable-local-speech").json()+ assert post["state"] == "running"+ assert packages == [sr._LOCAL_SPEECH_PACKAGE]++ status = client.get("/api/settings/wake-word/enable-local-speech/status").json()+ assert status["state"] == "done"+ assert "success" in status["message"]+++def test_pip_failure_is_reported_as_error(monkeypatch) -> None:+ _reset_state()+ monkeypatch.setattr(sr, "_local_whisper_available", lambda: False)++ def fake_install(pkg, **_kw):+ return False, "pip exited 1: no matching wheel for this platform"++ monkeypatch.setattr("jarvis.setup.dependencies.install_pip_package", fake_install)+ monkeypatch.setattr(sr.threading, "Thread", _SyncThread)++ client = _client()+ client.post("/api/settings/wake-word/enable-local-speech")++ status = client.get("/api/settings/wake-word/enable-local-speech/status").json()+ assert status["state"] == "error"+ assert "no matching wheel" in status["message"]+++def test_status_reports_available_when_present(monkeypatch) -> None:+ # Present but this process never ran the installer (installed manually or in a+ # prior run) → status is truthful without a restart.+ _reset_state()+ monkeypatch.setattr(sr, "_local_whisper_available", lambda: True)++ status = _client().get(+ "/api/settings/wake-word/enable-local-speech/status"+ ).json()++ assert status["available"] is True+ assert status["state"] == "done"