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(realtime): add per-provider model + voice picker to Realtime cards
Ruben Lütkecddddb0bf475
diff --git a/jarvis/ui/web/frontend/src/components/RealtimeOptionsControl.test.tsx b/jarvis/ui/web/frontend/src/components/RealtimeOptionsControl.test.tsxnew file mode 100644index 0000000000..6e8b1b269d--- /dev/null+++ b/jarvis/ui/web/frontend/src/components/RealtimeOptionsControl.test.tsx@@ -0,0 +1,167 @@+import { cleanup, fireEvent, render, screen, waitFor } from "@testing-library/react";+import { afterEach, describe, expect, it, vi } from "vitest";++// Identity translator so rendered text equals the i18n key — matches the+// pattern used by CuModelSelector.test.tsx.+vi.mock("@/i18n", () => ({+ useT: () => (key: string) => key,+}));++vi.mock("@/store/events", () => ({+ useEventStore: (selector: (s: { pushToast: () => void }) => unknown) =>+ selector({ pushToast: vi.fn() }),+}));++const getRealtimeOptions = vi.fn();+const saveRealtimeOptions = vi.fn();++vi.mock("@/hooks/useProviders", () => ({+ getRealtimeOptions: (...args: unknown[]) => getRealtimeOptions(...args),+ saveRealtimeOptions: (...args: unknown[]) => saveRealtimeOptions(...args),+}));++import { RealtimeOptionsControl } from "./RealtimeOptionsControl";++const OPTIONS = {+ provider: "openai-realtime",+ models: [+ { id: "gpt-realtime", label: "GPT Realtime" },+ { id: "gpt-realtime-mini", label: "GPT Realtime Mini" },+ ],+ voices: [+ { id: "alloy", label: "Alloy" },+ { id: "echo", label: "Echo" },+ ],+ current_model: "",+ current_voice: "",+};++afterEach(() => {+ cleanup();+ vi.restoreAllMocks();+});++describe("RealtimeOptionsControl", () => {+ it("renders a MODEL and a VOICE dropdown, populated from getRealtimeOptions", async () => {+ getRealtimeOptions.mockResolvedValue(OPTIONS);+ render(<RealtimeOptionsControl providerId="openai-realtime" />);++ const modelSelect = (await screen.findByLabelText(+ "apikeys_view.realtime_model_label",+ )) as HTMLSelectElement;+ const voiceSelect = (await screen.findByLabelText(+ "apikeys_view.realtime_voice_label",+ )) as HTMLSelectElement;++ expect(getRealtimeOptions).toHaveBeenCalledWith("openai-realtime");+ expect(+ Array.from(modelSelect.options).map((o) => o.value),+ ).toEqual(["", "gpt-realtime", "gpt-realtime-mini"]);+ expect(+ Array.from(voiceSelect.options).map((o) => o.value),+ ).toEqual(["", "alloy", "echo"]);+ });++ it("maps the leading option to the 'Provider default' label and selects it when current_model/current_voice are empty", async () => {+ getRealtimeOptions.mockResolvedValue(OPTIONS);+ render(<RealtimeOptionsControl providerId="openai-realtime" />);++ const modelSelect = (await screen.findByLabelText(+ "apikeys_view.realtime_model_label",+ )) as HTMLSelectElement;+ const voiceSelect = (await screen.findByLabelText(+ "apikeys_view.realtime_voice_label",+ )) as HTMLSelectElement;++ expect(modelSelect.value).toBe("");+ expect(voiceSelect.value).toBe("");+ expect(screen.getAllByText("apikeys_view.realtime_provider_default").length).toBe(2);+ });++ it("pre-selects the persisted current_model/current_voice", async () => {+ getRealtimeOptions.mockResolvedValue({+ ...OPTIONS,+ current_model: "gpt-realtime-mini",+ current_voice: "echo",+ });+ render(<RealtimeOptionsControl providerId="openai-realtime" />);++ const modelSelect = (await screen.findByLabelText(+ "apikeys_view.realtime_model_label",+ )) as HTMLSelectElement;+ const voiceSelect = (await screen.findByLabelText(+ "apikeys_view.realtime_voice_label",+ )) as HTMLSelectElement;++ await waitFor(() => expect(modelSelect.value).toBe("gpt-realtime-mini"));+ expect(voiceSelect.value).toBe("echo");+ });++ it("selecting a model calls saveRealtimeOptions(id, {model})", async () => {+ getRealtimeOptions.mockResolvedValue(OPTIONS);+ saveRealtimeOptions.mockResolvedValue({+ ok: true,+ provider: "openai-realtime",+ model: "gpt-realtime",+ voice: "",+ restart_required: false,+ });+ render(<RealtimeOptionsControl providerId="openai-realtime" />);++ const modelSelect = await screen.findByLabelText("apikeys_view.realtime_model_label");+ fireEvent.change(modelSelect, { target: { value: "gpt-realtime" } });++ await waitFor(() =>+ expect(saveRealtimeOptions).toHaveBeenCalledWith("openai-realtime", {+ model: "gpt-realtime",+ }),+ );+ });++ it("selecting a voice calls saveRealtimeOptions(id, {voice})", async () => {+ getRealtimeOptions.mockResolvedValue(OPTIONS);+ saveRealtimeOptions.mockResolvedValue({+ ok: true,+ provider: "openai-realtime",+ model: "",+ voice: "echo",+ restart_required: false,+ });+ render(<RealtimeOptionsControl providerId="openai-realtime" />);++ const voiceSelect = await screen.findByLabelText("apikeys_view.realtime_voice_label");+ fireEvent.change(voiceSelect, { target: { value: "echo" } });++ await waitFor(() =>+ expect(saveRealtimeOptions).toHaveBeenCalledWith("openai-realtime", {+ voice: "echo",+ }),+ );+ });++ it("picking 'Provider default' again saves an explicit empty string", async () => {+ getRealtimeOptions.mockResolvedValue({+ ...OPTIONS,+ current_model: "gpt-realtime-mini",+ });+ saveRealtimeOptions.mockResolvedValue({+ ok: true,+ provider: "openai-realtime",+ model: "",+ voice: "",+ restart_required: false,+ });+ render(<RealtimeOptionsControl providerId="openai-realtime" />);++ const modelSelect = (await screen.findByLabelText(+ "apikeys_view.realtime_model_label",+ )) as HTMLSelectElement;+ await waitFor(() => expect(modelSelect.value).toBe("gpt-realtime-mini"));++ fireEvent.change(modelSelect, { target: { value: "" } });++ await waitFor(() =>+ expect(saveRealtimeOptions).toHaveBeenCalledWith("openai-realtime", { model: "" }),+ );+ });+});diff --git a/jarvis/ui/web/frontend/src/components/RealtimeOptionsControl.tsx b/jarvis/ui/web/frontend/src/components/RealtimeOptionsControl.tsxnew file mode 100644index 0000000000..2e7385a17b--- /dev/null+++ b/jarvis/ui/web/frontend/src/components/RealtimeOptionsControl.tsx@@ -0,0 +1,153 @@+import { useEffect, useState } from "react";+import { Loader2 } from "lucide-react";+import {+ getRealtimeOptions,+ saveRealtimeOptions,+ type RealtimeOptionInfo,+} from "@/hooks/useProviders";+import { useEventStore } from "@/store/events";+import { useT } from "@/i18n";++// "" always means "use the provider's own default" — mirrors the backend+// contract (RealtimeOptionsResponse.current_model/current_voice empty when+// nothing is pinned, RealtimeOptionsBody accepting "" to explicitly clear).+const PROVIDER_DEFAULT = "";++/**+ * Per-realtime-provider MODEL + VOICE picker (two compact dropdowns).+ *+ * Unlike every other tier, a realtime session needs BOTH a model and a voice+ * pinned per provider, so this is a small dedicated control against the+ * dedicated `GET/PUT /api/providers/{id}/realtime-options` endpoint rather+ * than the shared search-heavy `BrainModelSelector` — the curated lists are+ * short (a handful of models/voices), so a plain `<select>` is enough.+ *+ * Renders only inside a realtime provider card (`tier === "realtime"`), gated+ * on the card already having a stored credential — see `ApiKeysView.tsx`.+ */+export function RealtimeOptionsControl({ providerId }: { providerId: string }) {+ const t = useT();+ const pushToast = useEventStore((s) => s.pushToast);++ const [models, setModels] = useState<RealtimeOptionInfo[]>([]);+ const [voices, setVoices] = useState<RealtimeOptionInfo[]>([]);+ const [model, setModel] = useState<string>(PROVIDER_DEFAULT);+ const [voice, setVoice] = useState<string>(PROVIDER_DEFAULT);+ const [loading, setLoading] = useState(true);+ const [savingField, setSavingField] = useState<"model" | "voice" | null>(null);++ useEffect(() => {+ let alive = true;+ setLoading(true);+ void getRealtimeOptions(providerId)+ .then((r) => {+ if (!alive) return;+ // Defensive: an unexpected/malformed response (e.g. a catch-all test+ // fixture, or a future backend shape change) must degrade to empty+ // lists rather than crash the card's render.+ setModels(Array.isArray(r?.models) ? r.models : []);+ setVoices(Array.isArray(r?.voices) ? r.voices : []);+ setModel(r?.current_model || PROVIDER_DEFAULT);+ setVoice(r?.current_voice || PROVIDER_DEFAULT);+ })+ .catch(() => {+ // Best-effort — the row degrades to empty dropdowns rather than+ // breaking the card.+ })+ .finally(() => {+ if (alive) setLoading(false);+ });+ return () => {+ alive = false;+ };+ }, [providerId]);++ async function handleChange(field: "model" | "voice", next: string) {+ const prev = field === "model" ? model : voice;+ if (field === "model") setModel(next);+ else setVoice(next);+ setSavingField(field);+ try {+ await saveRealtimeOptions(+ providerId,+ field === "model" ? { model: next } : { voice: next },+ );+ } catch (e) {+ // Roll back the optimistic pick on failure.+ if (field === "model") setModel(prev);+ else setVoice(prev);+ pushToast("error", (e as Error).message);+ } finally {+ setSavingField(null);+ }+ }++ if (loading) return null;++ return (+ <div+ className="space-y-1.5"+ // A click into the selects must not bubble to the card's activate+ // handler (it only filters input/button/a/label, not select).+ onClick={(e) => e.stopPropagation()}+ onDoubleClick={(e) => e.stopPropagation()}+ >+ <RealtimeSelectRow+ label={t("apikeys_view.realtime_model_label")}+ value={model}+ options={models}+ saving={savingField === "model"}+ onChange={(next) => void handleChange("model", next)}+ />+ <RealtimeSelectRow+ label={t("apikeys_view.realtime_voice_label")}+ value={voice}+ options={voices}+ saving={savingField === "voice"}+ onChange={(next) => void handleChange("voice", next)}+ />+ </div>+ );+}++function RealtimeSelectRow({+ label,+ value,+ options,+ saving,+ onChange,+}: {+ label: string;+ value: string;+ options: RealtimeOptionInfo[];+ saving: boolean;+ onChange: (value: string) => void;+}) {+ const t = useT();+ return (+ <div className="flex items-center gap-2">+ <span className="w-14 shrink-0 text-[10px] uppercase tracking-wide text-muted-foreground">+ {label}+ </span>+ <select+ aria-label={label}+ value={value}+ disabled={saving}+ onChange={(e) => onChange(e.target.value)}+ className="min-w-0 flex-1 rounded-md border border-input bg-background px-2 py-1 text-xs disabled:opacity-60"+ >+ <option value={PROVIDER_DEFAULT}>+ {t("apikeys_view.realtime_provider_default")}+ </option>+ {options.map((o) => (+ <option key={o.id} value={o.id}>+ {o.label}+ </option>+ ))}+ </select>+ {saving && (+ <Loader2 className="h-3 w-3 shrink-0 animate-spin text-muted-foreground" />+ )}+ </div>+ );+}diff --git a/jarvis/ui/web/frontend/src/hooks/useProviders.ts b/jarvis/ui/web/frontend/src/hooks/useProviders.tsindex e4112cd188..4df39d0c7a 100644--- a/jarvis/ui/web/frontend/src/hooks/useProviders.ts+++ b/jarvis/ui/web/frontend/src/hooks/useProviders.ts@@ -802,3 +802,72 @@ export async function saveCuModel(};}+// ── Realtime model + voice picker (per realtime provider) ──────────────────+// Realtime needs BOTH a model AND a voice per provider (unlike every other+// picker above, which serves ONE selection) — mirrors+// jarvis/ui/web/provider_routes.py::RealtimeOptionsResponse /+// RealtimeOptionsSaveResponse. Curated lists only (no live catalog fetch);+// an empty current_model/current_voice means "use the provider default".++export interface RealtimeOptionInfo {+ id: string;+ label: string;+}++export interface RealtimeOptionsResult {+ provider: string;+ models: RealtimeOptionInfo[];+ voices: RealtimeOptionInfo[];+ current_model: string;+ current_voice: string;+}++/**+ * Lists a realtime provider's curated model + voice catalog, plus the+ * currently pinned selection. 400s for a non-realtime-tier id.+ */+export async function getRealtimeOptions(+ providerId: string,+): Promise<RealtimeOptionsResult> {+ const res = await fetch(+ `/api/providers/${encodeURIComponent(providerId)}/realtime-options`,+ );+ const body = await res.json().catch(() => ({}));+ if (!res.ok) {+ throw new Error(body.detail ?? `HTTP ${res.status}`);+ }+ return body as RealtimeOptionsResult;+}++export interface RealtimeOptionsSaveResult {+ ok: boolean;+ provider: string;+ model: string;+ voice: string;+ restart_required: boolean;+}++/**+ * Pins the model and/or voice for a realtime provider. An omitted field+ * leaves it unchanged server-side; `""` explicitly resets it to the provider+ * default. 409 without a stored credential.+ */+export async function saveRealtimeOptions(+ providerId: string,+ opts: { model?: string; voice?: string },+): Promise<RealtimeOptionsSaveResult> {+ const res = await fetch(+ `/api/providers/${encodeURIComponent(providerId)}/realtime-options`,+ {+ method: "PUT",+ headers: { "Content-Type": "application/json" },+ body: JSON.stringify(opts),+ },+ );+ const body = await res.json().catch(() => ({}));+ if (!res.ok) {+ throw new Error(body.detail ?? `HTTP ${res.status}`);+ }+ return body as RealtimeOptionsSaveResult;+}+diff --git a/jarvis/ui/web/frontend/src/i18n/locales/de.json b/jarvis/ui/web/frontend/src/i18n/locales/de.jsonindex e4870bf345..4aa79075da 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/de.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/de.json@@ -900,7 +900,10 @@"health_needs_setup": "Einrichtung nötig","health_error": "Funktioniert nicht","health_ok": "Funktioniert",- "security_notice": ""+ "security_notice": "",+ "realtime_model_label": "Realtime-Modell",+ "realtime_voice_label": "Stimme",+ "realtime_provider_default": "Anbieter-Standard"},"apikeys_test": {"button": "Testen",diff --git a/jarvis/ui/web/frontend/src/i18n/locales/en.json b/jarvis/ui/web/frontend/src/i18n/locales/en.jsonindex ad56dfb186..d3f601cf78 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/en.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/en.json@@ -901,7 +901,10 @@"health_error": "Not working","health_ok": "Working","security_notice": "",- "trademark_notice": "Provider and service names and logos are trademarks of their respective owners, shown only to identify the integrations you can connect. No affiliation or endorsement is implied."+ "trademark_notice": "Provider and service names and logos are trademarks of their respective owners, shown only to identify the integrations you can connect. No affiliation or endorsement is implied.",+ "realtime_model_label": "Realtime model",+ "realtime_voice_label": "Voice",+ "realtime_provider_default": "Provider default"},"apikeys_test": {"button": "Test",diff --git a/jarvis/ui/web/frontend/src/i18n/locales/es.json b/jarvis/ui/web/frontend/src/i18n/locales/es.jsonindex 0606f57bdf..2480de5598 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/es.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/es.json@@ -900,7 +900,10 @@"health_needs_setup": "Falta configurar","health_error": "No funciona","health_ok": "Funciona",- "security_notice": ""+ "security_notice": "",+ "realtime_model_label": "Modelo en tiempo real",+ "realtime_voice_label": "Voz",+ "realtime_provider_default": "Predeterminado del proveedor"},"apikeys_test": {"button": "Probar",diff --git a/jarvis/ui/web/frontend/src/views/ApiKeysView.tsx b/jarvis/ui/web/frontend/src/views/ApiKeysView.tsxindex 3523684378..8327ef6699 100644--- a/jarvis/ui/web/frontend/src/views/ApiKeysView.tsx+++ b/jarvis/ui/web/frontend/src/views/ApiKeysView.tsx@@ -6,6 +6,7 @@ import { ApiKeyForm } from "@/components/ApiKeyForm";import { BrainModelSelector } from "@/components/BrainModelSelector";import { OpenRouterTtsControls } from "@/components/OpenRouterTtsVoicePicker";import { CuModelSelector } from "@/components/CuModelSelector";+import { RealtimeOptionsControl } from "@/components/RealtimeOptionsControl";import { ProviderBillingBadge } from "@/components/ProviderBillingBadge";import { JarvisAgentSection } from "@/components/JarvisAgentSection";import { TelephonyPanel } from "@/views/TelephonyView";@@ -1025,6 +1026,14 @@ function ProviderCard({/>)}+ {/* Realtime needs BOTH a model AND a voice pinned per provider — a+ dedicated compact control (two dropdowns), gated on the card+ already having a stored credential like the other tiers' pickers+ above. */}+ {descriptor.tier === "realtime" && descriptor.configured && (+ <RealtimeOptionsControl providerId={descriptor.id} />+ )}+<ProviderTestControl providerId={descriptor.id} /></div>);