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(ui): Local voice settings card
rubenluetke10-beep258fa1b3b4cc
diff --git a/jarvis/ui/web/frontend/src/components/providers/LocalVoicePanel.test.tsx b/jarvis/ui/web/frontend/src/components/providers/LocalVoicePanel.test.tsxnew file mode 100644index 0000000000..5f1b3ee23b--- /dev/null+++ b/jarvis/ui/web/frontend/src/components/providers/LocalVoicePanel.test.tsx@@ -0,0 +1,141 @@+/**+ * The Local voice card body. What it must never do is claim a readiness the+ * backend did not report: the phase line, the self-test verdict and the+ * "not verified on this system" note all come from `/local-voice/status`.+ */+import { afterEach, describe, expect, it, vi } from "vitest";+import { cleanup, fireEvent, render, screen, waitFor } from "@testing-library/react";++import { LocalVoicePanel } from "@/components/providers/LocalVoicePanel";+import type { LocalVoiceStatus } from "@/lib/localVoice";++vi.mock("@/i18n", () => ({+ useT: () => (key: string) => key,+ useUiLanguage: () => "en",+}));++const NOT_INSTALLED: LocalVoiceStatus = {+ phase: "not_installed",+ stage: "",+ progress: 0,+ reason: "Local voice is not set up on this machine yet.",+ installed: false,+ setup: {+ running: false,+ stage: "",+ progress: 0,+ detail: "",+ error: "",+ warnings: [],+ finished_at: null,+ },+ llm_model: "qwen3.5:4b",+ llm_source: "default",+ llm_installed: false,+ llm_error: "",+ llm_choices: ["llama3.2:3b"],+ voice: "pocket",+ voices: ["pocket", "piper"],+ machine_class: "apple",+ expected_latency: { low_s: 1.2, high_s: 1.8, basis: "estimate" },+ platform: "macos",+ os_verified: false,+ selftest: null,+ selftest_running: false,+};++function serve(handler: (url: string, init?: RequestInit) => LocalVoiceStatus) {+ const calls: Array<{ url: string; method: string }> = [];+ const fetchMock = vi.fn(async (input: RequestInfo | URL, init?: RequestInit) => {+ const url = String(input);+ calls.push({ url, method: init?.method ?? "GET" });+ const body = handler(url, init);+ return { ok: true, status: 200, json: async () => body } as Response;+ });+ (globalThis as unknown as { fetch: typeof fetch }).fetch = fetchMock as unknown as typeof fetch;+ return calls;+}++afterEach(() => {+ cleanup();+ vi.restoreAllMocks();+});++describe("LocalVoicePanel", () => {+ it("shows the phase, the machine, the estimate and the unverified note", async () => {+ serve(() => NOT_INSTALLED);+ render(<LocalVoicePanel onChanged={() => {}} />);++ expect(await screen.findByText("apikeys_view.local_voice_phase_not_installed")).toBeTruthy();+ expect(screen.getByTestId("local-voice-phase").dataset.phase).toBe("not_installed");+ expect(screen.getByTestId("local-voice-machine").textContent).toBe(+ "apikeys_view.local_voice_machine_apple",+ );+ expect(screen.getByTestId("local-voice-latency").textContent).toBe(+ "1.2–1.8 s · apikeys_view.local_voice_basis_estimate",+ );+ expect(screen.getByTestId("local-voice-unverified")).toBeTruthy();+ expect(screen.getByTestId("local-voice-llm-missing")).toBeTruthy();+ expect(screen.queryByTestId("local-voice-selftest")).toBeNull();+ });++ it("starts setup and then follows its progress", async () => {+ const installing: LocalVoiceStatus = {+ ...NOT_INSTALLED,+ phase: "installing",+ stage: "models",+ progress: 0.42,+ setup: { ...NOT_INSTALLED.setup, running: true, stage: "models", progress: 0.42 },+ };+ let started = false;+ const calls = serve((url) => {+ if (url.endsWith("/setup")) started = true;+ return started ? installing : NOT_INSTALLED;+ });+ render(<LocalVoicePanel onChanged={() => {}} />);++ fireEvent.click(await screen.findByTestId("local-voice-setup"));+ await waitFor(() => expect(screen.getByRole("progressbar").getAttribute("aria-valuenow")).toBe("42"));+ expect(calls.some((c) => c.url.endsWith("/local-voice/setup") && c.method === "POST")).toBe(true);+ expect(screen.getByText("apikeys_view.local_voice_stage_models")).toBeTruthy();+ expect(screen.queryByTestId("local-voice-setup")).toBeNull();+ });++ it("shows the backend's own reason when the engine failed", async () => {+ serve(() => ({+ ...NOT_INSTALLED,+ phase: "failed",+ installed: true,+ reason: "The local voice could not load: Ollama did not answer.",+ }));+ render(<LocalVoicePanel onChanged={() => {}} />);++ expect(await screen.findByText("The local voice could not load: Ollama did not answer.")).toBeTruthy();+ });++ it("offers the self-test once installed and shows a stale result honestly", async () => {+ serve(() => ({+ ...NOT_INSTALLED,+ phase: "stopped",+ reason: "",+ installed: true,+ os_verified: true,+ llm_installed: true,+ selftest: {+ ok: true,+ at: 1,+ stale: true,+ reason: "",+ languages: { de: { voice: "pocket-german", synth_ms: 210, stt_ms: 140, ok: true } },+ llm: { ok: true, ms: 390 },+ },+ }));+ render(<LocalVoicePanel onChanged={() => {}} />);++ expect(await screen.findByTestId("local-voice-selftest")).toBeTruthy();+ expect(screen.getByTestId("local-voice-selftest-result").dataset.ok).toBe("true");+ expect(screen.getByTestId("local-voice-selftest-stale")).toBeTruthy();+ expect(screen.queryByTestId("local-voice-unverified")).toBeNull();+ expect(screen.queryByTestId("local-voice-setup")).toBeNull();+ });+});diff --git a/jarvis/ui/web/frontend/src/components/providers/LocalVoicePanel.tsx b/jarvis/ui/web/frontend/src/components/providers/LocalVoicePanel.tsxnew file mode 100644index 0000000000..efdfd79f6a--- /dev/null+++ b/jarvis/ui/web/frontend/src/components/providers/LocalVoicePanel.tsx@@ -0,0 +1,316 @@+/**+ * Local voice card body: setup progress, self-test result, model and voice+ * choice, expected latency, and an honest "not verified on this system".+ *+ * Talks only to `/api/providers/local-voice/*` (see `@/lib/localVoice`). It+ * polls while setup, start-up or a self-test is running and otherwise reads+ * the status once on mount and then slowly. Every colour is a theme token, so+ * the panel follows light and dark mode.+ */+import { useCallback, useEffect, useMemo, useRef, useState } from "react";+import { AlertCircle, Check, Download, Loader2, Play, XCircle } from "lucide-react";+import { Button } from "@/components/ui/button";+import { BrandedSelect, type BrandedSelectOption } from "@/components/ui/select";+import { useT, useUiLanguage } from "@/i18n";+import {+ fetchLocalVoiceStatus,+ latencyFigure,+ localVoiceIsBusy,+ percentOf,+ runLocalVoiceSelftest,+ saveLocalVoiceSettings,+ stageKey,+ startLocalVoiceSetup,+ type LocalVoiceSelftest,+ type LocalVoiceStatus,+} from "@/lib/localVoice";+import { cn } from "@/lib/utils";++const BUSY_POLL_MS = 2500;+const IDLE_POLL_MS = 20_000;+/** The automatic model choice; never a real Ollama tag (tags contain ":"). */+const AUTO_MODEL = "__auto__";++export function LocalVoicePanel({ onChanged }: { onChanged: () => void }) {+ const t = useT();+ const locale = useUiLanguage();+ const [status, setStatus] = useState<LocalVoiceStatus | null>(null);+ const [error, setError] = useState<string | null>(null);+ const [saving, setSaving] = useState(false);+ const busy = localVoiceIsBusy(status);+ const wasBusy = useRef(false);++ const accept = useCallback(+ (next: LocalVoiceStatus) => {+ const nowBusy = localVoiceIsBusy(next);+ // A finished setup or self-test changes the card's readiness chip.+ const finished = wasBusy.current && !nowBusy;+ wasBusy.current = nowBusy;+ setStatus(next);+ if (finished) onChanged();+ },+ [onChanged],+ );++ const refresh = useCallback(async () => {+ try {+ accept(await fetchLocalVoiceStatus());+ setError(null);+ } catch (err) {+ setError(err instanceof Error ? err.message : String(err));+ }+ }, [accept]);++ useEffect(() => {+ let cancelled = false;+ const tick = async () => {+ if (!cancelled) await refresh();+ };+ void tick();+ const timer = window.setInterval(tick, busy ? BUSY_POLL_MS : IDLE_POLL_MS);+ return () => {+ cancelled = true;+ window.clearInterval(timer);+ };+ }, [busy, refresh]);++ const act = async (action: () => Promise<LocalVoiceStatus>) => {+ setError(null);+ try {+ accept(await action());+ } catch (err) {+ setError(err instanceof Error ? err.message : String(err));+ }+ };++ const save = async (change: { voice?: string; llm_model?: string }) => {+ setSaving(true);+ await act(() => saveLocalVoiceSettings(change));+ setSaving(false);+ onChanged();+ };++ const modelOptions = useMemo<BrandedSelectOption[]>(() => {+ if (!status) return [];+ const auto: BrandedSelectOption = {+ value: AUTO_MODEL,+ label: t("apikeys_view.local_voice_llm_auto"),+ hint: status.llm_source === "config" ? undefined : status.llm_model,+ };+ const names = new Set(status.llm_choices);+ if (status.llm_source === "config") names.add(status.llm_model);+ return [auto, ...[...names].sort().map((name) => ({ value: name, label: name }))];+ }, [status, t]);++ const voiceOptions = useMemo<BrandedSelectOption[]>(+ () =>+ (status?.voices ?? []).map((voice) => ({+ value: voice,+ label: t(`apikeys_view.local_voice_voice_${voice}`),+ })),+ [status?.voices, t],+ );++ if (!status) {+ return (+ <div className="border-t border-border pt-3 text-xs text-muted-foreground" data-testid="local-voice-panel">+ {error ?? <Loader2 className="h-3.5 w-3.5 animate-spin" aria-label={t("apikeys_view.local_voice_loading")} />}+ </div>+ );+ }++ const phaseLabel = t(`apikeys_view.local_voice_phase_${status.phase}`);+ const moving = status.phase === "installing" || status.phase === "starting";+ const stage = stageKey(status.stage);+ const stageLabel = stage ? t(`apikeys_view.local_voice_stage_${stage}`) : "";+ const showSetup = !status.setup.running && (!status.installed || Boolean(status.setup.error));+ const figure = latencyFigure(status.expected_latency, locale);++ return (+ <div className="space-y-3 border-t border-border pt-3 text-xs" data-testid="local-voice-panel">+ <div className="flex items-start gap-2" data-testid="local-voice-phase" data-phase={status.phase}>+ {status.phase === "ready" ? (+ <Check className="mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground" />+ ) : moving ? (+ <Loader2 className="mt-0.5 h-3.5 w-3.5 shrink-0 animate-spin text-muted-foreground" />+ ) : status.phase === "failed" ? (+ <XCircle className="mt-0.5 h-3.5 w-3.5 shrink-0 text-destructive" />+ ) : (+ <AlertCircle className="mt-0.5 h-3.5 w-3.5 shrink-0 text-foreground" />+ )}+ <div className="min-w-0 space-y-0.5">+ <p className="font-medium text-foreground">{phaseLabel}</p>+ {/* The backend's sentence explains a failure or a stop; "not set up"+ is already said by the translated phase label above. */}+ {status.reason && status.phase !== "installing" && status.phase !== "not_installed" && (+ <p className="text-muted-foreground">{status.reason}</p>+ )}+ </div>+ </div>++ {moving && (+ <div className="space-y-1" data-testid="local-voice-progress">+ <div className="flex justify-between gap-2 text-muted-foreground">+ <span className="truncate">{stageLabel || status.reason}</span>+ <span className="tabular-nums">{percentOf(status.progress)} %</span>+ </div>+ <div+ role="progressbar"+ aria-label={phaseLabel}+ aria-valuenow={percentOf(status.progress)}+ aria-valuemin={0}+ aria-valuemax={100}+ className="h-1.5 w-full overflow-hidden rounded-full bg-foreground/10"+ >+ <div+ className="h-full rounded-full bg-foreground/70 transition-all duration-500 motion-reduce:transition-none"+ style={{ width: `${Math.max(2, percentOf(status.progress))}%` }}+ />+ </div>+ {status.phase === "installing" && (+ <p className="text-muted-foreground">{t("apikeys_view.local_voice_setup_hint")}</p>+ )}+ </div>+ )}++ <dl className="grid grid-cols-[auto_1fr] items-center gap-x-3 gap-y-2">+ <dt className="text-muted-foreground">{t("apikeys_view.local_voice_machine_label")}</dt>+ <dd className="text-foreground" data-testid="local-voice-machine">+ {t(`apikeys_view.local_voice_machine_${status.machine_class}`)}+ </dd>+ <dt className="text-muted-foreground">{t("apikeys_view.local_voice_latency_label")}</dt>+ <dd className="text-foreground" data-testid="local-voice-latency">+ {figure === null+ ? t("apikeys_view.local_voice_latency_selftest")+ : `${figure} s · ${t(`apikeys_view.local_voice_basis_${status.expected_latency.basis}`)}`}+ </dd>+ <dt className="text-muted-foreground">{t("apikeys_view.local_voice_llm_label")}</dt>+ <dd className="min-w-0">+ <BrandedSelect+ value={status.llm_source === "config" ? status.llm_model : AUTO_MODEL}+ options={modelOptions}+ onValueChange={(value) => void save({ llm_model: value === AUTO_MODEL ? "" : value })}+ ariaLabel={t("apikeys_view.local_voice_llm_label")}+ disabled={saving || status.setup.running}+ testId="local-voice-llm"+ />+ </dd>+ <dt className="text-muted-foreground">{t("apikeys_view.local_voice_voice_label")}</dt>+ <dd className="min-w-0">+ <BrandedSelect+ value={status.voice}+ options={voiceOptions}+ onValueChange={(value) => void save({ voice: value })}+ ariaLabel={t("apikeys_view.local_voice_voice_label")}+ disabled={saving || status.setup.running}+ testId="local-voice-voice"+ />+ </dd>+ </dl>++ {status.llm_error ? (+ <p className="text-muted-foreground">{status.llm_error}</p>+ ) : (+ status.llm_installed === false && (+ <p className="text-muted-foreground" data-testid="local-voice-llm-missing">+ {t("apikeys_view.local_voice_llm_missing")}+ </p>+ )+ )}++ {!status.os_verified && (+ <div className="flex items-start gap-2 text-muted-foreground" data-testid="local-voice-unverified">+ <AlertCircle className="mt-0.5 h-3.5 w-3.5 shrink-0" />+ <span>{t("apikeys_view.local_voice_unverified")}</span>+ </div>+ )}++ <SelftestSummary selftest={status.selftest} running={status.selftest_running} />++ {status.setup.warnings.map((warning) => (+ <p key={warning} className="text-muted-foreground">{warning}</p>+ ))}+ {status.setup.error && status.phase !== "failed" && (+ <p className="text-destructive">{status.setup.error}</p>+ )}+ {error && <p className="text-destructive">{error}</p>}++ <div className="flex flex-wrap gap-2">+ {showSetup && (+ <Button size="sm" variant="secondary" className="gap-2" onClick={() => void act(startLocalVoiceSetup)} data-testid="local-voice-setup">+ <Download className="h-3.5 w-3.5" />+ {status.setup.error+ ? t("apikeys_view.local_voice_setup_retry")+ : t("apikeys_view.local_voice_setup_cta")}+ </Button>+ )}+ {status.installed && !status.setup.running && (+ <Button+ size="sm"+ variant="secondary"+ className="gap-2"+ onClick={() => void act(runLocalVoiceSelftest)}+ disabled={status.selftest_running}+ data-testid="local-voice-selftest"+ >+ {status.selftest_running ? (+ <Loader2 className="h-3.5 w-3.5 animate-spin" />+ ) : (+ <Play className="h-3.5 w-3.5" />+ )}+ {status.selftest_running+ ? t("apikeys_view.local_voice_selftest_running")+ : t("apikeys_view.local_voice_selftest_cta")}+ </Button>+ )}+ </div>+ </div>+ );+}++function SelftestSummary({+ selftest,+ running,+}: {+ selftest: LocalVoiceSelftest | null;+ running: boolean;+}) {+ const t = useT();+ if (running) return null;+ if (!selftest) {+ return <p className="text-muted-foreground">{t("apikeys_view.local_voice_selftest_none")}</p>;+ }+ const languages = Object.entries(selftest.languages);+ return (+ <div className="space-y-1" data-testid="local-voice-selftest-result" data-ok={selftest.ok}>+ <p className={cn("font-medium", selftest.ok ? "text-foreground" : "text-destructive")}>+ {selftest.ok+ ? t("apikeys_view.local_voice_selftest_passed")+ : t("apikeys_view.local_voice_selftest_failed")}+ </p>+ {selftest.reason && <p className="text-muted-foreground">{selftest.reason}</p>}+ {languages.length > 0 && (+ <ul className="space-y-0.5 text-muted-foreground">+ {languages.map(([language, result]) => (+ <li key={language} className="tabular-nums">+ {language.toUpperCase()} · {result.voice ?? "?"} ·{" "}+ {t("apikeys_view.local_voice_selftest_voice_ms").replace("{0}", String(result.synth_ms ?? "?"))}{" "}+ · {t("apikeys_view.local_voice_selftest_stt_ms").replace("{0}", String(result.stt_ms ?? "?"))}+ </li>+ ))}+ </ul>+ )}+ {selftest.llm && (+ <p className="tabular-nums text-muted-foreground">+ {t("apikeys_view.local_voice_selftest_llm_ms").replace("{0}", String(selftest.llm.ms ?? "?"))}+ {selftest.llm.error ? ` · ${selftest.llm.error}` : ""}+ </p>+ )}+ {selftest.stale && (+ <p className="text-muted-foreground" data-testid="local-voice-selftest-stale">+ {t("apikeys_view.local_voice_selftest_stale")}+ </p>+ )}+ </div>+ );+}diff --git a/jarvis/ui/web/frontend/src/components/providers/ProviderLogo.tsx b/jarvis/ui/web/frontend/src/components/providers/ProviderLogo.tsxindex f37cf4f8b5..b75f79a10f 100644--- a/jarvis/ui/web/frontend/src/components/providers/ProviderLogo.tsx+++ b/jarvis/ui/web/frontend/src/components/providers/ProviderLogo.tsx@@ -113,6 +113,8 @@ export function providerFamily(providerId: string): string | null {/** An on-device engine or a self-hosted server: a capability, not a brand. */function localGlyph(providerId: string): "device" | "server" | null {const id = providerId.toLowerCase();+ // The Jarvis-owned voice engine runs on this machine, not on a server.+ if (id === "local-voice") return "device";if (id.startsWith("local-") || id === "generic" || id === "home_server" || id === "strato") return "server";if (id === "multipass") return "device";if (id.includes("faster-whisper") || id.includes("piper")) return "device";diff --git a/jarvis/ui/web/frontend/src/components/providers/ProviderTierSection.tsx b/jarvis/ui/web/frontend/src/components/providers/ProviderTierSection.tsxindex 609bfb6998..3e416d3fd4 100644--- a/jarvis/ui/web/frontend/src/components/providers/ProviderTierSection.tsx+++ b/jarvis/ui/web/frontend/src/components/providers/ProviderTierSection.tsx@@ -5,6 +5,7 @@ import { ApiKeyForm } from "@/components/ApiKeyForm";import { BrainModelSelector } from "@/components/BrainModelSelector";import { OpenRouterTtsControls } from "@/components/OpenRouterTtsVoicePicker";import { RealtimeOptionsControl } from "@/components/RealtimeOptionsControl";+import { LocalVoicePanel } from "@/components/providers/LocalVoicePanel";import { ProviderLogo } from "@/components/providers/ProviderLogo";import { useRowGestures } from "@/components/providers/rowGestures";import { Button } from "@/components/ui/button";@@ -3682,6 +3683,7 @@ export function AuthWidget({)}<LocalRuntimePanel descriptor={descriptor} onChanged={onChanged} /><ManagedServerPanel descriptor={descriptor} onChanged={onChanged} />+ {descriptor.voice_engine && <LocalVoicePanel onChanged={onChanged} />}{descriptor.supports_base_url && descriptor.managed_server && (<details className="group text-xs"><summary className="inline-flex cursor-pointer list-none items-center gap-1.5 text-muted-foreground transition-colors hover:text-foreground [&::-webkit-details-marker]:hidden">@@ -4335,6 +4337,10 @@ export function providerStateChip(if (descriptor.managed_server) {return descriptor.managed_server.ready ? "ready" : "not_installed";}+ // Jarvis-owned local voice engine: set up on this machine, or not.+ if (descriptor.voice_engine) {+ return descriptor.voice_engine.installed ? "ready" : "not_installed";+ }// A keyless provider (Ollama, a local OpenAI-compatible server you point// at) has nothing to store and, without a probe in its payload, nothing// proven either: it needs no key, and a Test decides the rest.diff --git a/jarvis/ui/web/frontend/src/hooks/useProviders.ts b/jarvis/ui/web/frontend/src/hooks/useProviders.tsindex 1bce601e21..ddc2bf4178 100644--- a/jarvis/ui/web/frontend/src/hooks/useProviders.ts+++ b/jarvis/ui/web/frontend/src/hooks/useProviders.ts@@ -167,6 +167,12 @@ export interface ProviderDescriptor {* rendered verbatim — the client never guesses readiness. null elsewhere.*/managed_server?: ManagedServerStatus | null;+ /**+ * Local voice card only: whether the Jarvis-owned engine is set up on this+ * machine and running right now. The card body reads its full status from+ * `/api/providers/local-voice/status` (`@/lib/localVoice`). null elsewhere.+ */+ voice_engine?: { installed: boolean; ready: boolean } | null;/** Local/self-hosted cards: whether the card exposes an editable server URL* (persisted via PUT /api/providers/{id}/base-url). */supports_base_url?: boolean;diff --git a/jarvis/ui/web/frontend/src/i18n/locales/de.json b/jarvis/ui/web/frontend/src/i18n/locales/de.jsonindex 42cf4563d9..f32678662f 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/de.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/de.json@@ -1912,6 +1912,52 @@"managed_catalog_selected": "Modell ausgewählt. Installiere den Server, um den gesamten Stack zu testen und zu aktivieren.","managed_advanced_connection": "Erweiterte Verbindungseinstellungen","managed_brain_recheck_hint": "Prüft neu, welches Ollama-Modell auf diese Maschine passt, und stellt das Server-Gehirn darauf um — ohne Neuinstallation. Gilt ab dem nächsten Server-Start.",+ "local_voice_loading": "Status der lokalen Stimme wird geladen",+ "local_voice_phase_not_installed": "Auf diesem Gerät noch nicht eingerichtet",+ "local_voice_phase_installing": "Wird eingerichtet",+ "local_voice_phase_stopped": "Eingerichtet — startet mit dem ersten Anruf",+ "local_voice_phase_starting": "Startet",+ "local_voice_phase_ready": "Bereit",+ "local_voice_phase_failed": "Funktioniert nicht",+ "local_voice_stage_uv": "Python-Installer wird geholt",+ "local_voice_stage_python": "Python der Sprach-Engine wird angelegt",+ "local_voice_stage_packages": "Sprach-Laufzeiten werden installiert",+ "local_voice_stage_engine": "Sprach-Engine wird kopiert",+ "local_voice_stage_models": "Sprachmodelle werden geladen",+ "local_voice_stage_voice": "Stimme wird vorbereitet",+ "local_voice_stage_llm": "Sprachmodell wird vorbereitet",+ "local_voice_stage_selftest": "Stimme wird getestet",+ "local_voice_stage_process": "Engine wird gestartet",+ "local_voice_stage_speech": "Spracherkennung wird geladen",+ "local_voice_setup_cta": "Lokale Stimme einrichten",+ "local_voice_setup_retry": "Einrichtung erneut starten",+ "local_voice_setup_hint": "Lädt etwa 1,5 GB plus das Sprachmodell herunter. Du kannst Jarvis währenddessen weiter benutzen.",+ "local_voice_machine_label": "Dieses Gerät",+ "local_voice_machine_nvidia": "NVIDIA-Grafikkarte",+ "local_voice_machine_apple": "Apple Silicon",+ "local_voice_machine_gpu": "Grafikkarte (AMD oder Intel)",+ "local_voice_machine_cpu": "Keine nutzbare Grafikkarte (nur CPU)",+ "local_voice_latency_label": "Erwartete Antwortzeit",+ "local_voice_latency_selftest": "Steht nach dem Selbsttest fest",+ "local_voice_basis_measured": "gemessen auf dieser Geräteklasse",+ "local_voice_basis_estimate": "Schätzung",+ "local_voice_basis_selftest": "aus dem Selbsttest",+ "local_voice_llm_label": "Sprachmodell",+ "local_voice_llm_auto": "Automatisch",+ "local_voice_llm_missing": "Dieses Modell ist noch nicht heruntergeladen. Die Einrichtung lädt es.",+ "local_voice_voice_label": "Stimme",+ "local_voice_voice_pocket": "Natürlich (Pocket TTS)",+ "local_voice_voice_piper": "Einfach und am schnellsten (Piper)",+ "local_voice_unverified": "Auf diesem System noch nicht geprüft. Es kann funktionieren, wurde hier aber noch nicht getestet.",+ "local_voice_selftest_cta": "Selbsttest starten",+ "local_voice_selftest_running": "Wird getestet…",+ "local_voice_selftest_none": "Noch kein Selbsttest.",+ "local_voice_selftest_passed": "Selbsttest bestanden",+ "local_voice_selftest_failed": "Selbsttest fehlgeschlagen",+ "local_voice_selftest_voice_ms": "Stimme {0} ms",+ "local_voice_selftest_stt_ms": "Erkennung {0} ms",+ "local_voice_selftest_llm_ms": "Sprachmodell antwortete in {0} ms",+ "local_voice_selftest_stale": "Die Einrichtung hat sich seit diesem Test geändert. Bitte erneut testen.","shared_delete_prefix": "Dieser Schlüssel wird auch verwendet von:","shared_delete_suffix": "Beim Löschen werden auch diese Provider deaktiviert.","delete_anyway": "Trotzdem löschen",diff --git a/jarvis/ui/web/frontend/src/i18n/locales/en.json b/jarvis/ui/web/frontend/src/i18n/locales/en.jsonindex 4ab0ccb453..cce20821a0 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/en.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/en.json@@ -1945,6 +1945,52 @@"managed_catalog_selected": "Model selected. Install the server to test and activate the full stack.","managed_advanced_connection": "Advanced connection settings","managed_brain_recheck_hint": "Re-check which Ollama model fits this machine and switch the server's brain to it — no reinstall. Takes effect on the next server start.",+ "local_voice_loading": "Loading the local voice status",+ "local_voice_phase_not_installed": "Not set up on this machine yet",+ "local_voice_phase_installing": "Setting up",+ "local_voice_phase_stopped": "Set up — starts with the first call",+ "local_voice_phase_starting": "Starting",+ "local_voice_phase_ready": "Ready",+ "local_voice_phase_failed": "Not working",+ "local_voice_stage_uv": "Getting the Python installer",+ "local_voice_stage_python": "Creating the engine's Python",+ "local_voice_stage_packages": "Installing the speech runtimes",+ "local_voice_stage_engine": "Copying the voice engine",+ "local_voice_stage_models": "Downloading the speech models",+ "local_voice_stage_voice": "Preparing the voice",+ "local_voice_stage_llm": "Preparing the language model",+ "local_voice_stage_selftest": "Testing the voice",+ "local_voice_stage_process": "Starting the engine",+ "local_voice_stage_speech": "Loading speech recognition",+ "local_voice_setup_cta": "Set up local voice",+ "local_voice_setup_retry": "Run setup again",+ "local_voice_setup_hint": "Downloads about 1.5 GB plus the language model. You can keep using Jarvis meanwhile.",+ "local_voice_machine_label": "This machine",+ "local_voice_machine_nvidia": "NVIDIA graphics card",+ "local_voice_machine_apple": "Apple Silicon",+ "local_voice_machine_gpu": "Graphics card (AMD or Intel)",+ "local_voice_machine_cpu": "No usable graphics card (CPU only)",+ "local_voice_latency_label": "Expected response time",+ "local_voice_latency_selftest": "Known after the self-test",+ "local_voice_basis_measured": "measured on this kind of machine",+ "local_voice_basis_estimate": "estimate",+ "local_voice_basis_selftest": "from the self-test",+ "local_voice_llm_label": "Language model",+ "local_voice_llm_auto": "Automatic",+ "local_voice_llm_missing": "This model is not downloaded yet. Setup downloads it.",+ "local_voice_voice_label": "Voice",+ "local_voice_voice_pocket": "Natural (Pocket TTS)",+ "local_voice_voice_piper": "Basic and fastest (Piper)",+ "local_voice_unverified": "Not verified on this system yet. It may work, but it has not been tested here.",+ "local_voice_selftest_cta": "Run self-test",+ "local_voice_selftest_running": "Testing…",+ "local_voice_selftest_none": "No self-test yet.",+ "local_voice_selftest_passed": "Self-test passed",+ "local_voice_selftest_failed": "Self-test failed",+ "local_voice_selftest_voice_ms": "voice {0} ms",+ "local_voice_selftest_stt_ms": "recognition {0} ms",+ "local_voice_selftest_llm_ms": "Language model answered in {0} ms",+ "local_voice_selftest_stale": "The setup changed since this test. Run it again.","shared_delete_prefix": "This key is also used by:","shared_delete_suffix": "Deleting it disables those providers too.","delete_anyway": "Delete anyway",diff --git a/jarvis/ui/web/frontend/src/i18n/locales/es.json b/jarvis/ui/web/frontend/src/i18n/locales/es.jsonindex f4cbfb19c5..c034c9657a 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/es.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/es.json@@ -1912,6 +1912,52 @@"managed_catalog_selected": "Modelo seleccionado. Instala el servidor para probar y activar toda la configuración.","managed_advanced_connection": "Configuración avanzada de conexión","managed_brain_recheck_hint": "Vuelve a comprobar qué modelo de Ollama cabe en esta máquina y cambia el cerebro del servidor a él — sin reinstalar. Se aplica en el próximo arranque del servidor.",+ "local_voice_loading": "Cargando el estado de la voz local",+ "local_voice_phase_not_installed": "Aún no configurada en este equipo",+ "local_voice_phase_installing": "Configurando",+ "local_voice_phase_stopped": "Configurada — arranca con la primera llamada",+ "local_voice_phase_starting": "Arrancando",+ "local_voice_phase_ready": "Lista",+ "local_voice_phase_failed": "No funciona",+ "local_voice_stage_uv": "Obteniendo el instalador de Python",+ "local_voice_stage_python": "Creando el Python del motor",+ "local_voice_stage_packages": "Instalando los motores de voz",+ "local_voice_stage_engine": "Copiando el motor de voz",+ "local_voice_stage_models": "Descargando los modelos de voz",+ "local_voice_stage_voice": "Preparando la voz",+ "local_voice_stage_llm": "Preparando el modelo de lenguaje",+ "local_voice_stage_selftest": "Probando la voz",+ "local_voice_stage_process": "Arrancando el motor",+ "local_voice_stage_speech": "Cargando el reconocimiento de voz",+ "local_voice_setup_cta": "Configurar la voz local",+ "local_voice_setup_retry": "Volver a configurar",+ "local_voice_setup_hint": "Descarga unos 1,5 GB más el modelo de lenguaje. Puedes seguir usando Jarvis mientras tanto.",+ "local_voice_machine_label": "Este equipo",+ "local_voice_machine_nvidia": "Tarjeta gráfica NVIDIA",+ "local_voice_machine_apple": "Apple Silicon",+ "local_voice_machine_gpu": "Tarjeta gráfica (AMD o Intel)",+ "local_voice_machine_cpu": "Sin tarjeta gráfica utilizable (solo CPU)",+ "local_voice_latency_label": "Tiempo de respuesta esperado",+ "local_voice_latency_selftest": "Se sabrá tras la autoprueba",+ "local_voice_basis_measured": "medido en este tipo de equipo",+ "local_voice_basis_estimate": "estimación",+ "local_voice_basis_selftest": "de la autoprueba",+ "local_voice_llm_label": "Modelo de lenguaje",+ "local_voice_llm_auto": "Automático",+ "local_voice_llm_missing": "Este modelo aún no está descargado. La configuración lo descarga.",+ "local_voice_voice_label": "Voz",+ "local_voice_voice_pocket": "Natural (Pocket TTS)",+ "local_voice_voice_piper": "Básica y la más rápida (Piper)",+ "local_voice_unverified": "Aún no verificado en este sistema. Puede funcionar, pero no se ha probado aquí.",+ "local_voice_selftest_cta": "Ejecutar autoprueba",+ "local_voice_selftest_running": "Probando…",+ "local_voice_selftest_none": "Aún no hay autoprueba.",+ "local_voice_selftest_passed": "Autoprueba superada",+ "local_voice_selftest_failed": "Autoprueba fallida",+ "local_voice_selftest_voice_ms": "voz {0} ms",+ "local_voice_selftest_stt_ms": "reconocimiento {0} ms",+ "local_voice_selftest_llm_ms": "El modelo de lenguaje respondió en {0} ms",+ "local_voice_selftest_stale": "La configuración cambió desde esta prueba. Vuelve a ejecutarla.","shared_delete_prefix": "Esta clave también la usan:","shared_delete_suffix": "Al eliminarla, esos proveedores también se desactivan.","delete_anyway": "Eliminar de todos modos",diff --git a/jarvis/ui/web/frontend/src/lib/localVoice.test.ts b/jarvis/ui/web/frontend/src/lib/localVoice.test.tsnew file mode 100644index 0000000000..880b1be2f6--- /dev/null+++ b/jarvis/ui/web/frontend/src/lib/localVoice.test.ts@@ -0,0 +1,48 @@+import { describe, expect, it } from "vitest";++import {+ latencyFigure,+ localVoiceIsBusy,+ percentOf,+ stageKey,+ type LocalVoiceStatus,+} from "@/lib/localVoice";++describe("localVoice helpers", () => {+ it("formats a latency range with the UI language's decimal mark", () => {+ const measured = { low_s: 0.75, high_s: 0.9, basis: "measured" as const };+ expect(latencyFigure(measured, "en")).toBe("0.75–0.9");+ expect(latencyFigure(measured, "de")).toBe("0,75–0,9");+ expect(latencyFigure({ low_s: 2, high_s: 2, basis: "estimate" }, "en")).toBe("2");+ });++ it("has no figure when only the self-test can tell", () => {+ expect(latencyFigure({ low_s: null, high_s: null, basis: "selftest" }, "en")).toBeNull();+ });++ it("folds the worker's load stages into what a person recognises", () => {+ expect(stageKey("packages")).toBe("packages");+ expect(stageKey("tts:de")).toBe("voice");+ expect(stageKey("stt")).toBe("speech");+ expect(stageKey("process")).toBe("process");+ expect(stageKey("something-new")).toBe("");+ });++ it("clamps progress", () => {+ expect(percentOf(0.423)).toBe(42);+ expect(percentOf(2)).toBe(100);+ expect(percentOf(Number.NaN)).toBe(0);+ });++ it("polls only while something moves on its own", () => {+ const base = {+ phase: "stopped",+ setup: { running: false },+ selftest_running: false,+ } as unknown as LocalVoiceStatus;+ expect(localVoiceIsBusy(null)).toBe(false);+ expect(localVoiceIsBusy(base)).toBe(false);+ expect(localVoiceIsBusy({ ...base, phase: "starting" })).toBe(true);+ expect(localVoiceIsBusy({ ...base, selftest_running: true })).toBe(true);+ });+});diff --git a/jarvis/ui/web/frontend/src/lib/localVoice.ts b/jarvis/ui/web/frontend/src/lib/localVoice.tsnew file mode 100644index 0000000000..0ad37a8c32--- /dev/null+++ b/jarvis/ui/web/frontend/src/lib/localVoice.ts@@ -0,0 +1,184 @@+/**+ * Local voice card: the backend contract (`jarvis/ui/web/local_voice_routes.py`)+ * and the pure helpers the card renders with.+ *+ * The const tuples below mirror `jarvis/realtime/local_voice_setup.py`+ * (`PHASES`, `MACHINE_CLASSES`, `LATENCY_BASES`, `SETUP_STAGES`) and+ * `jarvis/core/config.py::VOICE_ENGINE_VOICES`;+ * `tests/unit/voice_engine/test_local_voice_parity.py` keeps them in lockstep+ * (AP-4).+ */++export const LOCAL_VOICE_PHASES = [+ "not_installed",+ "installing",+ "stopped",+ "starting",+ "ready",+ "failed",+] as const;+export type LocalVoicePhase = (typeof LOCAL_VOICE_PHASES)[number];++export const LOCAL_VOICE_MACHINE_CLASSES = ["nvidia", "apple", "gpu", "cpu"] as const;+export type LocalVoiceMachineClass = (typeof LOCAL_VOICE_MACHINE_CLASSES)[number];++export const LOCAL_VOICE_LATENCY_BASES = ["measured", "estimate", "selftest"] as const;+export type LocalVoiceLatencyBasis = (typeof LOCAL_VOICE_LATENCY_BASES)[number];++export const LOCAL_VOICE_SETUP_STAGES = [+ "uv",+ "python",+ "packages",+ "engine",+ "models",+ "voice",+ "llm",+ "selftest",+] as const;+export type LocalVoiceSetupStage = (typeof LOCAL_VOICE_SETUP_STAGES)[number];++export const LOCAL_VOICE_VOICES = ["pocket", "piper"] as const;+export type LocalVoiceVoice = (typeof LOCAL_VOICE_VOICES)[number];++export interface LocalVoiceSetupRun {+ running: boolean;+ stage: string;+ progress: number;+ detail: string;+ /** One English sentence from the backend, rendered verbatim. */+ error: string;+ warnings: string[];+ finished_at: number | null;+}++export interface LocalVoiceSelftestLanguage {+ voice?: string;+ heard?: string;+ cer?: number;+ synth_ms?: number;+ stt_ms?: number;+ ok?: boolean;+}++export interface LocalVoiceSelftest {+ ok: boolean;+ at: number | null;+ /** Engine, packages, model or voice changed since this result. */+ stale: boolean;+ reason: string;+ languages: Record<string, LocalVoiceSelftestLanguage>;+ llm: { ok?: boolean; ms?: number; error?: string | null } | null;+}++export interface LocalVoiceLatency {+ low_s: number | null;+ high_s: number | null;+ basis: LocalVoiceLatencyBasis;+}++export interface LocalVoiceStatus {+ phase: LocalVoicePhase;+ stage: string;+ progress: number;+ /** The backend's own sentence when not ready; rendered verbatim. */+ reason: string;+ installed: boolean;+ setup: LocalVoiceSetupRun;+ llm_model: string;+ llm_source: "config" | "setup" | "default";+ /** null when Ollama did not answer (see `llm_error`). */+ llm_installed: boolean | null;+ llm_error: string;+ llm_choices: string[];+ voice: string;+ voices: string[];+ machine_class: LocalVoiceMachineClass;+ expected_latency: LocalVoiceLatency;+ platform: "windows" | "macos" | "linux";+ os_verified: boolean;+ selftest: LocalVoiceSelftest | null;+ selftest_running: boolean;+ started?: boolean;+ message?: string;+}++const BASE = "/api/providers/local-voice";++async function readJson<T>(res: Response): Promise<T> {+ const body = await res.json().catch(() => ({}));+ if (!res.ok) throw new Error((body as { detail?: string }).detail ?? `HTTP ${res.status}`);+ return body as T;+}++export async function fetchLocalVoiceStatus(): Promise<LocalVoiceStatus> {+ return readJson<LocalVoiceStatus>(await fetch(`${BASE}/status`));+}++export async function startLocalVoiceSetup(): Promise<LocalVoiceStatus> {+ return readJson<LocalVoiceStatus>(await fetch(`${BASE}/setup`, { method: "POST" }));+}++export async function runLocalVoiceSelftest(): Promise<LocalVoiceStatus> {+ return readJson<LocalVoiceStatus>(await fetch(`${BASE}/selftest`, { method: "POST" }));+}++export async function saveLocalVoiceSettings(change: {+ voice?: string;+ llm_model?: string;+}): Promise<LocalVoiceStatus> {+ return readJson<LocalVoiceStatus>(+ await fetch(`${BASE}/settings`, {+ method: "PUT",+ headers: { "Content-Type": "application/json" },+ body: JSON.stringify(change),+ }),+ );+}++/** Whether the card should keep polling: something is moving on its own. */+export function localVoiceIsBusy(status: LocalVoiceStatus | null): boolean {+ if (!status) return false;+ return (+ status.setup.running ||+ status.selftest_running ||+ status.phase === "installing" ||+ status.phase === "starting"+ );+}++/** Seconds with the UI language's decimal mark ("0.75" / "0,75"). */+export function formatSeconds(value: number, locale: string): string {+ return value.toLocaleString(locale, { maximumFractionDigits: 2 });+}++/**+ * The latency figure without its basis: "0.75–0.9" or a single value, or null+ * when only the self-test can tell.+ */+export function latencyFigure(latency: LocalVoiceLatency, locale: string): string | null {+ const { low_s: low, high_s: high } = latency;+ if (low === null || high === null) return null;+ if (low === high) return formatSeconds(low, locale);+ return `${formatSeconds(low, locale)}–${formatSeconds(high, locale)}`;+}++/**+ * The i18n stage suffix for a setup stage or an engine load stage.+ *+ * Setup reports its own stages; a starting engine reports the worker's+ * (`process`, `vad`, `turn`, `stt`, `tts:<lang>`, `llm`), folded here into+ * what a person recognises. Unknown stages show no label rather than a raw id.+ */+export function stageKey(stage: string): string {+ if ((LOCAL_VOICE_SETUP_STAGES as readonly string[]).includes(stage)) return stage;+ if (stage === "process") return "process";+ if (stage.startsWith("tts")) return "voice";+ if (stage === "start" || stage === "vad" || stage === "turn" || stage === "stt") return "speech";+ return "";+}++/** 0..100 for a progress bar, clamped. */+export function percentOf(progress: number): number {+ if (!Number.isFinite(progress)) return 0;+ return Math.max(0, Math.min(100, Math.round(progress * 100)));+}diff --git a/jarvis/ui/web/frontend/src/lib/prettyProviderName.ts b/jarvis/ui/web/frontend/src/lib/prettyProviderName.tsindex 6f5c5ec7d6..bad11d72cd 100644--- a/jarvis/ui/web/frontend/src/lib/prettyProviderName.ts+++ b/jarvis/ui/web/frontend/src/lib/prettyProviderName.ts@@ -25,6 +25,7 @@ const PROVIDER_NAMES: Record<string, string> = {"gemini-live": "Gemini Live","vertex-live": "Vertex AI Live","local-realtime": "Self-hosted realtime",+ "local-voice": "Local voice",unknown: "—",};diff --git a/tests/unit/voice_engine/test_local_voice_parity.py b/tests/unit/voice_engine/test_local_voice_parity.pynew file mode 100644index 0000000000..7350bf67ce--- /dev/null+++ b/tests/unit/voice_engine/test_local_voice_parity.py@@ -0,0 +1,72 @@+"""The Local voice vocabulary agrees across Python, TypeScript and the locales (AP-4).++Layers under test:++1. ``jarvis/realtime/local_voice_setup.py`` — ``PHASES``, ``MACHINE_CLASSES``,+ ``LATENCY_BASES``, ``SETUP_STAGES`` (source of truth).+2. ``jarvis/core/config.py`` — ``VOICE_ENGINE_VOICES`` (the Pydantic config).+3. ``src/lib/localVoice.ts`` — the ``LOCAL_VOICE_*`` const tuples the card uses.+4. ``src/i18n/locales/{en,de,es}.json`` — one label per value the card renders.+"""++from __future__ import annotations++import json+import re+from pathlib import Path++import pytest++from jarvis.core.config import VOICE_ENGINE_VOICES+from jarvis.realtime import local_voice_setup as setup++REPO = Path(__file__).resolve().parents[3]+FRONTEND = REPO / "jarvis" / "ui" / "web" / "frontend" / "src"+TS = FRONTEND / "lib" / "localVoice.ts"+LOCALES = FRONTEND / "i18n" / "locales"+++def _ts_tuple(name: str) -> tuple[str, ...]:+ text = TS.read_text(encoding="utf-8")+ block = re.search(rf"export const {name} = \[([\s\S]+?)\] as const", text)+ assert block, f"{name} not found in localVoice.ts"+ return tuple(re.findall(r'"([^"]+)"', block.group(1)))+++ ("ts_name", "python_values"),+ [+ ("LOCAL_VOICE_PHASES", setup.PHASES),+ ("LOCAL_VOICE_MACHINE_CLASSES", setup.MACHINE_CLASSES),+ ("LOCAL_VOICE_LATENCY_BASES", setup.LATENCY_BASES),+ ("LOCAL_VOICE_SETUP_STAGES", setup.SETUP_STAGES),+ ("LOCAL_VOICE_VOICES", VOICE_ENGINE_VOICES),+ ],+)+def test_typescript_mirrors_python(ts_name: str, python_values: tuple[str, ...]) -> None:+ assert _ts_tuple(ts_name) == tuple(python_values)++[email protected]("locale", ["en", "de", "es"])+def test_every_rendered_value_has_a_label(locale: str) -> None:+ view = json.loads((LOCALES / f"{locale}.json").read_text(encoding="utf-8"))["apikeys_view"]+ needed = (+ [f"local_voice_phase_{v}" for v in setup.PHASES]+ + [f"local_voice_machine_{v}" for v in setup.MACHINE_CLASSES]+ + [f"local_voice_basis_{v}" for v in setup.LATENCY_BASES]+ + [f"local_voice_stage_{v}" for v in (*setup.SETUP_STAGES, "process", "speech")]+ + [f"local_voice_voice_{v}" for v in VOICE_ENGINE_VOICES]+ )+ missing = [key for key in needed if key not in view]+ assert missing == []+++def test_locales_carry_the_same_local_voice_keys() -> None:+ keys = {+ locale: {+ k for k in json.loads((LOCALES / f"{locale}.json").read_text(encoding="utf-8"))+ ["apikeys_view"] if k.startswith("local_voice_")+ }+ for locale in ("en", "de", "es")+ }+ assert keys["de"] == keys["en"] == keys["es"]