Skip to content

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.

fix(ui): settle the frontend tests after the local-main merge

rubenluetke10-beep3f933b845da7
diff --git a/jarvis/ui/web/frontend/src/components/home/ChatStage.test.tsx b/jarvis/ui/web/frontend/src/components/home/ChatStage.test.tsx
index eb9fc27677..97515178cb 100644
--- a/jarvis/ui/web/frontend/src/components/home/ChatStage.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/home/ChatStage.test.tsx
@@ -501,19 +501,17 @@ describe("ChatStage (agent chat)", () => {
it("draws a different glyph per permission mode in the pill and the list", async () => {
render(<ChatStage />);
+ // The labelled pick row draws no glyph on the pill; the list carries them.
const pill = screen.getByTestId("composer-permission");
- // acceptEdits wears the pen, not the column's shield.
- expect(pill.querySelector("svg.lucide-file-pen")).not.toBeNull();
- expect(pill.querySelector("svg.lucide-shield-check")).toBeNull();
fireEvent.click(pill);
const panel = await screen.findByTestId("composer-permission-panel");
const glyphs = within(panel)
.getAllByRole("option")
.map((el) => el.querySelector("svg")?.getAttribute("class") ?? "");
- // default → question shield, acceptEdits → pen, bypass → shield off; plan lives on the switch.
- expect(glyphs.some((c) => c.includes("lucide-shield-question"))).toBe(true);
+ // default → hand, acceptEdits → pen, bypass → warning shield; plan lives on the switch.
+ expect(glyphs.some((c) => c.includes("lucide-hand"))).toBe(true);
expect(glyphs.some((c) => c.includes("lucide-file-pen"))).toBe(true);
- expect(glyphs.some((c) => c.includes("lucide-shield-off"))).toBe(true);
+ expect(glyphs.some((c) => c.includes("lucide-shield-alert"))).toBe(true);
expect(new Set(glyphs).size).toBe(glyphs.length);
});
@@ -564,17 +562,15 @@ describe("ChatStage (agent chat)", () => {
render(<ChatStage />);
const pill = screen.getByTestId("composer-permission");
expect(pill.getAttribute("data-value")).toBe("ask");
- expect(pill.querySelector("svg.lucide-shield-question")).not.toBeNull();
- expect(pill.querySelector("svg.lucide-shield-check")).toBeNull();
fireEvent.click(pill);
const panel = await screen.findByTestId("composer-permission-panel");
const rows = within(panel).getAllByRole("option");
// Plan is the switch next door, so the list holds the other three.
expect(rows.map((el) => el.getAttribute("data-value"))).toEqual(["ask", "accept-edits", "bypass"]);
const glyphs = rows.map((el) => el.querySelector("svg")?.getAttribute("class") ?? "");
- expect(glyphs[0]).toContain("lucide-shield-question");
+ expect(glyphs[0]).toContain("lucide-hand");
expect(glyphs[1]).toContain("lucide-file-pen");
- expect(glyphs[2]).toContain("lucide-shield-off");
+ expect(glyphs[2]).toContain("lucide-shield-alert");
expect(new Set(glyphs).size).toBe(glyphs.length);
});
diff --git a/jarvis/ui/web/frontend/src/components/society/chat/AgentChatPanel.switch.test.tsx b/jarvis/ui/web/frontend/src/components/society/chat/AgentChatPanel.switch.test.tsx
index 62bf025196..65b50f4131 100644
--- a/jarvis/ui/web/frontend/src/components/society/chat/AgentChatPanel.switch.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/society/chat/AgentChatPanel.switch.test.tsx
@@ -40,7 +40,9 @@ vi.mock("@/components/agentchat/useComposerDictation", () => ({
useComposerDictation: () => ({ dictating: false, stop() {}, toggle() {} }),
}));
vi.mock("@/components/agentchat/DictationButton", () => ({ DictationButton: () => null }));
-vi.mock("@/components/agentchat/useChatAttachments", () => ({
+vi.mock("@/components/agentchat/useChatAttachments", async (importOriginal) => ({
+ // The pure helpers (attachmentMedia, ...) stay real; only the hook is scripted.
+ ...(await importOriginal<typeof import("@/components/agentchat/useChatAttachments")>()),
useChatAttachments: () => ({
attachments: attachmentState.current,
analyzing: 0,
diff --git a/jarvis/ui/web/frontend/src/lib/pcm-worklet.mute.test.ts b/jarvis/ui/web/frontend/src/lib/pcm-worklet.mute.test.ts
index 25b8f1ac0f..d57bfcb63b 100644
--- a/jarvis/ui/web/frontend/src/lib/pcm-worklet.mute.test.ts
+++ b/jarvis/ui/web/frontend/src/lib/pcm-worklet.mute.test.ts
@@ -8,6 +8,8 @@ it("flushes queued PCM on mute and never replays samples received while muted",
process: (inputs: Float32Array[][], outputs: Float32Array[][]) => void;
}>();
vi.stubGlobal("sampleRate", 24000);
+ // The AudioWorklet global clock the timed playback queue reads.
+ vi.stubGlobal("currentTime", 0);
vi.stubGlobal("registerProcessor", (name: string, ctor: unknown) => processors.set(name, ctor as never));
vi.stubGlobal("AudioWorkletProcessor", class {
port = { onmessage: null, postMessage: vi.fn() };
diff --git a/jarvis/ui/web/frontend/src/views/AppshotsView.test.tsx b/jarvis/ui/web/frontend/src/views/AppshotsView.test.tsx
index 81313e6256..884e0a3a52 100644
--- a/jarvis/ui/web/frontend/src/views/AppshotsView.test.tsx
+++ b/jarvis/ui/web/frontend/src/views/AppshotsView.test.tsx
@@ -154,7 +154,7 @@ describe("AppshotsView", () => {
const button = await screen.findByTestId("appshots-try");
expect((button as HTMLButtonElement).disabled).toBe(true);
expect((screen.getByTestId("appshots-try-region") as HTMLButtonElement).disabled).toBe(true);
- expect(screen.getByText("Wayland capture is unavailable.")).toBeDefined();
+ expect(screen.getByText(/Wayland capture is unavailable\./)).toBeDefined();
expect(fetchMock.mock.calls.some(([url]) => url.startsWith("/api/permissions"))).toBe(false);
});
diff --git a/jarvis/ui/web/frontend/src/views/apikeys/RealtimeTab.subscription.test.tsx b/jarvis/ui/web/frontend/src/views/apikeys/RealtimeTab.subscription.test.tsx
deleted file mode 100644
index ffe2f15378..0000000000
--- a/jarvis/ui/web/frontend/src/views/apikeys/RealtimeTab.subscription.test.tsx
+++ /dev/null
@@ -1,290 +0,0 @@
-import { cleanup, fireEvent, render, screen, waitFor, within } from "@testing-library/react";
-import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
-import { afterEach, expect, it, vi } from "vitest";
-import { RealtimeTab } from "./RealtimeTab";
-import { liveProfileReady, type LiveAuthMode, type LiveProfileState } from "@/components/providers/LiveProfile";
-import type { ProviderDescriptor } from "@/hooks/useProviders";
-
-vi.mock("@/i18n", () => ({ useT: () => (key: string) => key }));
-const voiceRuntime = vi.hoisted(() => ({ statusKnown: true, mode: "realtime", activeModel: "",
- activeProvider: null as string | null, sessionActive: false, activeSessionProvider: "" }));
-vi.mock("@/hooks/useVoiceMode", () => ({ useVoiceMode: () => voiceRuntime }));
-vi.mock("@/components/RealtimeOptionsControl", () => ({ RealtimeOptionsControl: () => <div>Provider model options</div> }));
-vi.mock("@/components/providers/ProviderTierSection", async (importOriginal) => ({
- ...await importOriginal<typeof import("@/components/providers/ProviderTierSection")>(),
- AuthWidget: () => <p>API credential editor</p>,
- ProviderTestControl: () => <button>Paid API probe</button>,
- Tag: () => null,
-}));
-
-const scrollIntoViewDescriptor = Object.getOwnPropertyDescriptor(HTMLElement.prototype, "scrollIntoView");
-
-afterEach(() => {
- cleanup(); vi.unstubAllGlobals(); vi.restoreAllMocks();
- if (scrollIntoViewDescriptor) Object.defineProperty(HTMLElement.prototype, "scrollIntoView", scrollIntoViewDescriptor);
- else Reflect.deleteProperty(HTMLElement.prototype, "scrollIntoView");
- voiceRuntime.activeProvider = null;
- voiceRuntime.sessionActive = false;
- voiceRuntime.activeSessionProvider = "";
-});
-
-function state(mode: LiveAuthMode): LiveProfileState {
- return {
- key_ready: mode === "api_key", active: true, agent_configured: true,
- subscription: { account_id: "codex:default", account_connected: true, voice_status: "unverified" },
- profile: {
- auth_mode: mode, model: "gpt-live-1", voice: "gleam", backend_model: "api-model",
- subscription_account_id: "", subscription_voice: "cove", subscription_backend_model: "subscription-model",
- subscription_reasoning_effort: "medium", reasoning_effort: "high", web_search: true,
- configured: true, instructions: "", backend_instructions: "",
- },
- };
-}
-
-function setup(mode: LiveAuthMode, options: {
- keyReady?: boolean; subscriptionModel?: string; accountConnected?: boolean;
- legacy?: boolean; saveFails?: boolean; includeGemini?: boolean;
-} = {}) {
- let current = state(mode);
- current.key_ready = options.keyReady ?? current.key_ready;
- current.profile.subscription_backend_model = options.subscriptionModel ?? current.profile.subscription_backend_model;
- if (options.accountConnected === false) current.subscription!.account_connected = false;
- if (options.legacy) {
- delete current.profile.auth_mode;
- delete current.profile.subscription_backend_model;
- delete current.profile.subscription_account_id;
- delete current.profile.subscription_voice;
- delete current.profile.subscription_reasoning_effort;
- delete current.subscription;
- }
- const writes: LiveProfileState["profile"][] = [];
- const fetcher = vi.fn(async (url: string, init?: RequestInit) => {
- if (init?.method === "PUT") {
- const chosen = JSON.parse(String(init.body)) as LiveProfileState["profile"];
- writes.push(chosen);
- if (options.saveFails) return { ok: false, status: 409, json: async () => ({ detail: "Selection could not be saved" }) };
- current = { ...current, profile: chosen };
- }
- const data = url === "/api/agent-accounts"
- ? { platforms: [{ platform: "codex", active_account: "codex:default", accounts: [
- { id: "codex:default", label: "My ChatGPT", connected: options.accountConnected !== false, mode: "subscription" },
- ] }] }
- : url.startsWith("/api/live/options")
- ? { models: url.includes("chatgpt_subscription")
- ? [{ id: "subscription-model", label: "Subscription model" }]
- : [{ id: "api-model", label: "API model" }, { id: "cheap-api", label: "Cheaper API model" }],
- voices: [url.includes("chatgpt_subscription") ? "cove" : "gleam"], efforts: ["", "medium", "high"] }
- : url.includes("/realtime-options")
- ? { models: [], voices: [], current_model: "", current_voice: "", preview_available: false }
- : current;
- return { ok: true, json: async () => data };
- });
- vi.stubGlobal("fetch", fetcher);
- const provider: ProviderDescriptor = {
- id: "openai-live", label: "OpenAI GPT-Live", tier: "realtime", auth_mode: "api_key", billing: "api",
- active: true, configured: true, configuration_surface: "live", secret_keys: ["openai_api_key"],
- secrets_set: {}, dashboard_url: null, login_cli: null, install_hint: null, credential_path_hint: null,
- cli_installed: null, credential_help: null, signup_url: null, alt_credential: null,
- };
- const client = new QueryClient({ defaultOptions: { queries: { retry: false } } });
- let suppliedProviders = [provider, ...(options.includeGemini ? [{ ...provider,
- id: "gemini-live", label: "Gemini Live", configuration_surface: "provider" as const, active: false,
- }] : [])];
- let rendered: ReturnType<typeof render>;
- const onActivateOptimistic = vi.fn((_tier: string, id: string) => {
- suppliedProviders = suppliedProviders.map((entry) => ({ ...entry, active: entry.id === id }));
- rendered.rerender(tree());
- });
- const tree = () => <QueryClientProvider client={client}><RealtimeTab providers={suppliedProviders} loading={false} error={null}
- onChanged={vi.fn()} onActivateOptimistic={onActivateOptimistic} /></QueryClientProvider>;
- rendered = render(tree());
- return { client, writes, fetcher, onActivateOptimistic };
-}
-
-const subscriptionRow = () => screen.getByTestId("realtime-provider-openai-live-subscription");
-const apiRow = () => screen.getByTestId("realtime-provider-openai-live");
-
-it("places the exact GPT Subscription row above the independent API row", async () => {
- const { client } = setup("api_key");
- await screen.findByRole("combobox", { name: "live.thinking_model" });
- const rows = within(screen.getByTestId("realtime-provider-list")).getAllByRole("button");
- expect(rows.map((row) => row.dataset.testid)).toEqual([
- "realtime-provider-openai-live-subscription", "realtime-provider-openai-live",
- ]);
- expect(within(subscriptionRow()).getByText("GPT Subscription")).toBeTruthy();
- expect(within(subscriptionRow()).getByText("provider_billing.subscription")).toBeTruthy();
- expect(within(apiRow()).getByText("provider_billing.api")).toBeTruthy();
- expect(apiRow().dataset.active).toBe("true");
- expect(subscriptionRow().dataset.active).toBe("false");
- client.clear();
-});
-
-it("activates a complete subscription on its row click and switches back with the API row", async () => {
- const { client, writes, onActivateOptimistic } = setup("api_key", { keyReady: true });
- await screen.findByRole("combobox", { name: "live.thinking_model" });
- fireEvent.click(subscriptionRow());
- await waitFor(() => expect(subscriptionRow().dataset.active).toBe("true"));
- expect(writes).toHaveLength(1);
- expect(writes[0]).toMatchObject({ auth_mode: "chatgpt_subscription", subscription_backend_model: "subscription-model",
- voice: "gleam", backend_model: "api-model", reasoning_effort: "high" });
- expect(screen.queryByText("API credential editor")).toBeNull();
- expect(screen.queryByRole("button", { name: "Paid API probe" })).toBeNull();
- expect(screen.queryByRole("combobox", { name: "live.billing_method" })).toBeNull();
- expect(apiRow().dataset.active).toBe("false");
- expect(within(apiRow()).getByText("provider_billing.api")).toBeTruthy();
- expect(within(screen.getByTestId("voice-now")).getByText("GPT Subscription")).toBeTruthy();
- expect(onActivateOptimistic).not.toHaveBeenCalled();
- fireEvent.click(apiRow());
- await waitFor(() => expect(apiRow().dataset.active).toBe("true"));
- expect(writes).toHaveLength(2);
- expect(writes[1]).toMatchObject({ auth_mode: "api_key", backend_model: "api-model", voice: "gleam",
- subscription_backend_model: "subscription-model", subscription_voice: "cove" });
- await screen.findByRole("combobox", { name: "live.thinking_model" });
- client.clear();
-});
-
-it("opens missing subscription model setup on click without changing the active API provider", async () => {
- const scroll = vi.fn();
- Object.defineProperty(HTMLElement.prototype, "scrollIntoView", { configurable: true, value: scroll });
- const { client, writes } = setup("api_key", { subscriptionModel: "" });
- await screen.findByRole("combobox", { name: "live.thinking_model" });
- expect(within(subscriptionRow()).getByText("live.subscription_model_required")).toBeTruthy();
- expect(within(subscriptionRow()).queryByText("apikeys_view.state_missing")).toBeNull();
- fireEvent.click(subscriptionRow());
- await within(await screen.findByTestId("live-profile")).findByText("live.subscription_connected");
- expect(document.activeElement).toBe(screen.getByTestId("realtime-provider-setup"));
- expect(scroll).toHaveBeenCalledWith({ block: "start" });
- fireEvent.click(subscriptionRow());
- expect(scroll).toHaveBeenCalledTimes(2);
- expect(screen.queryByRole("button", { name: "live.subscription_sign_in" })).toBeNull();
- expect(writes).toHaveLength(0);
- expect(subscriptionRow().getAttribute("aria-pressed")).toBe("true");
- expect(subscriptionRow().dataset.active).toBe("false");
- expect(apiRow().dataset.active).toBe("true");
- expect((screen.getByRole("button", { name: "live.save" }) as HTMLButtonElement).disabled).toBe(true);
- expect(screen.getByText("live.billing_pending")).toBeTruthy();
- await waitFor(() => expect((screen.getByRole("combobox", { name: "live.thinking_model" }) as HTMLButtonElement).disabled).toBe(false));
- fireEvent.click(screen.getByRole("combobox", { name: "live.thinking_model" }));
- fireEvent.click(await screen.findByRole("option", { name: /Subscription model/ }));
- expect(writes).toHaveLength(0);
- fireEvent.click(screen.getByRole("button", { name: "live.save" }));
- await screen.findByText("live.saved");
- expect(writes[0]).toMatchObject({ auth_mode: "chatgpt_subscription", subscription_backend_model: "subscription-model" });
- expect(subscriptionRow().dataset.active).toBe("true");
- client.clear();
-});
-
-it("shows account sign-in for an incomplete subscription without falling back to the saved API key", async () => {
- const { client, writes } = setup("api_key", { accountConnected: false });
- await screen.findByRole("combobox", { name: "live.thinking_model" });
- expect(within(subscriptionRow()).getByText("live.subscription_sign_in")).toBeTruthy();
- expect(within(subscriptionRow()).queryByText("apikeys_view.state_missing")).toBeNull();
- fireEvent.click(subscriptionRow());
- await screen.findByRole("button", { name: "live.subscription_sign_in" });
- expect(writes).toHaveLength(0);
- expect(apiRow().dataset.active).toBe("true");
- expect(screen.queryByRole("button", { name: "Paid API probe" })).toBeNull();
- client.clear();
-});
-
-it("activates a saved subscription without any API key", async () => {
- const { client, writes } = setup("api_key", { keyReady: false });
- await screen.findByRole("combobox", { name: "live.thinking_model" });
- fireEvent.click(subscriptionRow());
- await waitFor(() => expect(subscriptionRow().dataset.active).toBe("true"));
- expect(writes[0].auth_mode).toBe("chatgpt_subscription");
- expect(screen.queryByText("live.key_required")).toBeNull();
- client.clear();
-});
-
-it("preserves the active API row when a subscription activation fails", async () => {
- const { client, writes, onActivateOptimistic } = setup("api_key", { saveFails: true });
- await screen.findByRole("combobox", { name: "live.thinking_model" });
- fireEvent.click(subscriptionRow());
- await waitFor(() => expect(writes).toHaveLength(1));
- await within(await screen.findByTestId("live-profile")).findByText("live.subscription_connected");
- expect(apiRow().dataset.active).toBe("true");
- expect(subscriptionRow().dataset.active).toBe("false");
- expect(onActivateOptimistic).not.toHaveBeenCalled();
- client.clear();
-});
-
-it("offers an explicit restart on an older backend and never submits an unsupported subscription profile", async () => {
- const { client, writes, fetcher } = setup("api_key", { legacy: true });
- await screen.findByRole("combobox", { name: "live.thinking_model" });
- fireEvent.click(subscriptionRow());
- await within(await screen.findByTestId("live-profile")).findByText("settings_view.wake_word.restart_required");
- expect((screen.getByRole("button", { name: "live.save" }) as HTMLButtonElement).disabled).toBe(true);
- expect(apiRow().dataset.active).toBe("true");
- expect(writes).toHaveLength(0);
- expect(fetcher.mock.calls.some(([url]) => url.includes("auth_mode=chatgpt_subscription"))).toBe(false);
- fireEvent.click(screen.getByRole("button", { name: "taskbar_view.restart_now" }));
- await waitFor(() => expect(fetcher.mock.calls.some(([url, init]) => url === "/api/settings/restart-app" && init?.method === "POST")).toBe(true));
- client.clear();
-});
-
-it("keeps the original API save contract on an older backend", async () => {
- const { client, writes } = setup("api_key", { legacy: true });
- await screen.findByRole("combobox", { name: "live.thinking_model" });
- fireEvent.click(screen.getByRole("combobox", { name: "live.thinking_model" }));
- fireEvent.click(await screen.findByRole("option", { name: /Cheaper API model/ }));
- await waitFor(() => expect(writes).toHaveLength(1));
- expect(writes[0]).toMatchObject({ backend_model: "cheap-api", voice: "gleam" });
- expect(writes[0]).not.toHaveProperty("auth_mode");
- await screen.findByText("live.saved");
- client.clear();
-});
-
-it("preserves grouped settings for the saved subscription while the API row remains an API choice", async () => {
- const { client } = setup("chatgpt_subscription");
- await within(await screen.findByTestId("live-profile")).findByText("live.subscription_connected");
- expect(screen.queryByText("API credential editor")).toBeNull();
- expect(screen.queryByRole("button", { name: "Paid API probe" })).toBeNull();
- expect(within(apiRow()).getByText("provider_billing.api")).toBeTruthy();
- expect(within(screen.getByTestId("voice-now")).getByText("GPT Subscription")).toBeTruthy();
- expect(within(screen.getByTestId("voice-now")).getByText("provider_billing.subscription")).toBeTruthy();
- expect(screen.getByRole("region", { name: "live.conversation_heading" })).toBeTruthy();
- expect(screen.getByRole("region", { name: "live.thinking_heading" })).toBeTruthy();
- expect(screen.getByText("live.prompts").closest("details")).toBeTruthy();
- expect(screen.getByTestId("live-profile-saved")).toBeTruthy();
- client.clear();
-});
-
-it("checks both saved credential paths independently", () => {
- const subscription = state("chatgpt_subscription");
- expect(liveProfileReady(subscription)).toBe(true);
- expect(liveProfileReady({ ...subscription, key_ready: true, subscription: undefined })).toBe(false);
- expect(liveProfileReady({ ...subscription, profile: { ...subscription.profile, subscription_backend_model: "" } })).toBe(false);
- const api = state("api_key");
- expect(liveProfileReady(api)).toBe(true);
- expect(liveProfileReady({ ...api, key_ready: false })).toBe(false);
- expect(liveProfileReady(api, "chatgpt_subscription")).toBe(true);
- expect(liveProfileReady({ ...subscription, key_ready: true }, "api_key")).toBe(true);
-});
-
-it.each([false, true])("keeps the actual API runtime in the header despite the saved subscription (running call=%s)", async (running) => {
- voiceRuntime.activeProvider = running ? "openai-live-subscription" : "openai-live";
- voiceRuntime.sessionActive = running;
- voiceRuntime.activeSessionProvider = running ? "openai-live" : "";
- const { client } = setup("chatgpt_subscription");
- await within(await screen.findByTestId("live-profile")).findByText("live.subscription_connected");
- expect(within(screen.getByTestId("voice-now")).getByText("OpenAI GPT-Live")).toBeTruthy();
- expect(within(screen.getByTestId("voice-now")).getByText("provider_billing.api")).toBeTruthy();
- expect(within(subscriptionRow()).getByText("provider_billing.subscription")).toBeTruthy();
- client.clear();
-});
-
-
-it.each(["api_key", "chatgpt_subscription"] as const)("clears the %s Live row when Gemini becomes active before cached Live queries update", async (mode) => {
- voiceRuntime.activeProvider = mode === "api_key" ? "openai-live" : "openai-live-subscription";
- const { client, onActivateOptimistic } = setup(mode, { includeGemini: true });
- await screen.findByRole("combobox", { name: "live.thinking_model" });
- fireEvent.click(screen.getByTestId("realtime-provider-gemini-live"));
- await waitFor(() => expect(onActivateOptimistic).toHaveBeenCalledWith("realtime", "gemini-live"));
- expect(screen.getByTestId("realtime-provider-gemini-live").dataset.active).toBe("true");
- expect(apiRow().dataset.active).toBe("false");
- expect(subscriptionRow().dataset.active).toBe("false");
- expect(screen.getByTestId("realtime-provider-list").querySelectorAll('[data-active="true"]')).toHaveLength(1);
- expect(within(screen.getByTestId("voice-now")).getByText("Gemini Live")).toBeTruthy();
- client.clear();
-});
diff --git a/jarvis/ui/web/frontend/src/views/apikeys/RealtimeTab.tsx b/jarvis/ui/web/frontend/src/views/apikeys/RealtimeTab.tsx
deleted file mode 100644
index 0fcbd4fcc1..0000000000
--- a/jarvis/ui/web/frontend/src/views/apikeys/RealtimeTab.tsx
+++ /dev/null
@@ -1,720 +0,0 @@
-import { useEffect, useRef, useState } from "react";
-import * as Dialog from "@radix-ui/react-dialog";
-import { useQuery, useQueryClient } from "@tanstack/react-query";
-import { AlertCircle, Check, Loader2, Radio, XCircle } from "lucide-react";
-import {
- LiveProfile,
- liveProfileQuery,
- liveProfileReady,
- saveLiveProfile,
- type LiveAuthMode,
-} from "@/components/providers/LiveProfile";
-import { ProviderLogo } from "@/components/providers/ProviderLogo";
-import {
- AuthWidget,
- ProviderTestControl,
- StatusBadge,
- Tag,
-} from "@/components/providers/ProviderTierSection";
-import { RealtimeOptionsControl } from "@/components/RealtimeOptionsControl";
-import { Button } from "@/components/ui/button";
-import {
- PROVIDER_BACKEND_UNREACHABLE,
- type ProviderDescriptor,
- type ProviderTier,
- type SectionHealth,
- sectionHealthForSubject,
- switchRealtimeProvider,
-} from "@/hooks/useProviders";
-import { useVoiceMode } from "@/hooks/useVoiceMode";
-import { useT } from "@/i18n";
-import {
- hasExperimentalConsent,
- rememberExperimentalConsent,
-} from "@/lib/experimentalConsent";
-import {
- realtimeTransportIssueKey,
- requestRealtimeTransportOffer,
-} from "@/lib/realtimeTransportIssue";
-import { cn } from "@/lib/utils";
-import { useEventStore } from "@/store/events";
-import { ProfileGroup, SettingRow } from "@/views/profile/ProfileGroup";
-
-type VoiceRuntime = ReturnType<typeof useVoiceMode>;
-
-function liveMode(provider: ProviderDescriptor): LiveAuthMode | undefined {
- if (provider.configuration_surface !== "live") return undefined;
- return provider.id === "openai-live-subscription" ? "chatgpt_subscription" : "api_key";
-}
-
-/**
- * The shared Realtime provider setup. Its parent owns the available voice
- * modes, including the separate classic pipeline settings.
- *
- * Top to bottom: what the voice runs on right now, the providers as one list
- * where a click on a provider with a saved key makes it the voice, then the
- * selected provider's own settings as plain groups (connection, model and
- * voice or the GPT-Live profile, and a connection test).
- *
- * The provider list and the settings are separate on purpose: the previous
- * layout named the provider twice (a chip, then a card header) and nested its
- * settings four frames deep inside a 600 px dialog.
- */
-export function RealtimeTab({
- providers,
- loading,
- error,
- onChanged,
- onActivateOptimistic,
- health,
-}: {
- providers: ProviderDescriptor[];
- loading: boolean;
- error: string | null;
- onChanged: () => void;
- onActivateOptimistic: (tier: ProviderTier, id: string) => void;
- /** Live health of the realtime tier's ACTIVE provider. */
- health?: SectionHealth;
-}) {
- const t = useT();
- const voice = useVoiceMode();
- const queryClient = useQueryClient();
- const pushToast = useEventStore((s) => s.pushToast);
- const rawChoices = providers.filter((provider) => provider.tier === "realtime");
- const hasLiveSurface = rawChoices.some(
- (provider) => provider.configuration_surface === "live",
- );
- const live = useQuery({ ...liveProfileQuery, enabled: hasLiveSurface });
- const apiLive = rawChoices.find((provider) => provider.id === "openai-live" && provider.configuration_surface === "live");
- const savedLiveId = live.data?.profile.auth_mode === "chatgpt_subscription" ? "openai-live-subscription" : "openai-live";
- const runtimeLiveId = voice.activeProvider === "openai-live" || voice.activeProvider === "openai-live-subscription"
- ? voice.activeProvider : undefined;
- // Provider selection updates before the profile/runtime queries catch up.
- // An active non-Live descriptor must clear both Live rows immediately.
- const activeOtherId = rawChoices.find((provider) => provider.active && provider.configuration_surface !== "live")?.id
- ?? rawChoices.find((provider) => provider.id === voice.activeProvider && provider.configuration_surface !== "live")?.id;
- const activeLiveId = activeOtherId ? undefined
- : live.data?.active ? savedLiveId : runtimeLiveId ?? (apiLive?.active ? "openai-live" : undefined);
- // Two visible choices share one profile, but retain independent credentials,
- // billing labels and saved model selections. The subscription comes first.
- const choices = apiLive ? rawChoices.flatMap((provider): ProviderDescriptor[] => {
- if (provider.id === "openai-live-subscription") return [];
- if (provider.id !== apiLive.id) return [{ ...provider, active: provider.id === activeOtherId }];
- return [{
- ...provider, id: "openai-live-subscription", label: "GPT Subscription", billing: "subscription",
- auth_mode: "codex", secret_keys: [], secrets_set: {}, secrets_effective: {},
- active: activeLiveId === "openai-live-subscription", configured: liveProfileReady(live.data, "chatgpt_subscription"),
- }, {
- ...provider, billing: "api", active: activeLiveId === "openai-live",
- configured: live.data ? liveProfileReady(live.data, "api_key") : provider.configured,
- }];
- }) : rawChoices;
- const [inspectedId, setInspectedId] = useState<string | null>(null);
- const [activatingId, setActivatingId] = useState<string | null>(null);
- const setupRef = useRef<HTMLDivElement>(null);
- const [setupFocusRequest, setSetupFocusRequest] = useState(0);
- useEffect(() => {
- if (!setupFocusRequest) return;
- setupRef.current?.scrollIntoView?.({ block: "start" });
- setupRef.current?.focus({ preventScroll: true });
- }, [setupFocusRequest]);
- // This transport uses an existing account, not the Codex CLI lifecycle.
- // Never infer a missing installation from an absent CLI status object.
- const subscriptionStatus = live.isError ? t("apikeys_view.load_error")
- : !live.data ? t("live.loading")
- : live.data.profile.auth_mode === undefined || !live.data.subscription
- ? t("settings_view.wake_word.restart_required")
- : !live.data.subscription.account_connected ? t("live.subscription_sign_in")
- : !live.data.profile.subscription_backend_model?.trim()
- ? t("live.subscription_model_required") : t("live.subscription_connected");
- // The provider waiting for the experimental acknowledgement, with the flag
- // its activation started with: a key saved a moment ago is still
- // "unconfigured" in this descriptor, and dropping the flag here would let
- // the confirmed dialog end in a silent no-op.
- const [consentFor, setConsentFor] = useState<{
- provider: ProviderDescriptor;
- assumeConfigured: boolean;
- } | null>(null);
-
- const active = choices.find((provider) => provider.active) ?? null;
- const currentProviderId = voice.sessionActive ? voice.activeSessionProvider : activeOtherId ?? voice.activeProvider;
- const currentProvider = choices.find((provider) => provider.id === currentProviderId) ?? active;
- const selected =
- choices.find((provider) => provider.id === inspectedId) ?? active ?? choices[0] ?? null;
- const activeHealth = active ? sectionHealthForSubject(health, active.id) : undefined;
-
- /** Whether a click can switch to this provider without asking for anything.
- * `assumeConfigured` covers the moment a key was just saved, before the
- * provider list has refetched and still calls the provider unconfigured. */
- function canSwitchTo(provider: ProviderDescriptor, assumeConfigured = false): boolean {
- if (provider.active || activatingId) return false;
- // GPT-Live saves its provider together with the thinking model, so it can
- // only take over once that profile is complete.
- if (provider.configuration_surface === "live") return liveProfileReady(live.data, liveMode(provider));
- if (!provider.configured && !assumeConfigured) return false;
- return true;
- }
-
- async function activate(
- provider: ProviderDescriptor,
- { consented = false, assumeConfigured = false } = {},
- ) {
- if (!canSwitchTo(provider, assumeConfigured)) return;
- // The experimental acknowledgement comes BEFORE the optimistic flip, so a
- // declined dialog leaves nothing to roll back.
- if (provider.experimental && !consented && !hasExperimentalConsent(provider.id)) {
- setConsentFor({ provider, assumeConfigured });
- return;
- }
- if (provider.configuration_surface !== "live") onActivateOptimistic("realtime", provider.id);
- setActivatingId(provider.id);
- try {
- if (provider.configuration_surface === "live" && live.data) {
- // Re-saving the stored profile is what selects GPT-Live; the backend
- // writes the provider and `[voice].mode = "realtime"` together.
- const mode = liveMode(provider)!;
- const chosen = mode === "api_key" && live.data.profile.auth_mode === undefined
- ? live.data.profile : { ...live.data.profile, auth_mode: mode };
- await saveLiveProfile(chosen);
- await queryClient.invalidateQueries({ queryKey: ["live-profile"] });
- } else {
- // The switch reconnects an OPEN call synchronously, and an
- // offer-requiring transport cannot start without a browser offer, so
- // ask for one before the POST (a transport that needs none ignores it).
- requestRealtimeTransportOffer();
- await switchRealtimeProvider(provider.id, provider.experimental === true);
- // The provider switch never touches `[voice].mode`. This page offers
- // no other engine, so picking a provider here also means "use it".
- if (voice.mode !== "realtime") voice.setMode("realtime");
- }
- pushToast(
- "success",
- t("apikeys_view.switch_done_realtime").replace("{0}", provider.label),
- );
- window.dispatchEvent(new CustomEvent("jarvis:realtime-switched"));
- onChanged();
- } catch (cause) {
- console.warn("realtime provider switch failed", provider.id, cause);
- pushToast("error", (cause as Error).message);
- // Roll the optimistic highlight back to the true active provider.
- onChanged();
- window.dispatchEvent(
- new CustomEvent("jarvis:provider-switch-failed", {
- detail: { section: "realtime", provider: provider.id },
- }),
- );
- } finally {
- setActivatingId(null);
- }
- }
-
- function select(provider: ProviderDescriptor) {
- if (activatingId) return;
- setInspectedId(provider.id);
- if (liveMode(provider) === "chatgpt_subscription") setSetupFocusRequest((count) => count + 1);
- // One click selects: the settings open below AND a provider whose key is
- // already saved becomes the voice. Without a key it only opens, so the
- // key field is on screen to paste into.
- if (provider.active) {
- // Already the provider; on an install still pinned to the pipeline
- // engine the click means "use it", which only the engine switch can do.
- if (voice.mode !== "realtime" && voice.realtimeAvailable) voice.setMode("realtime");
- return;
- }
- void activate(provider);
- }
-
- return (
- <section
- aria-label={t("apikeys_realtime.aria")}
- data-testid="realtime-tab"
- className="flex flex-col gap-group"
- >
- <VoiceNow active={currentProvider} activeHealth={currentProvider
- ? sectionHealthForSubject(health, currentProvider.id) : undefined} voice={voice} />
-
- {error && (
- <div
- role="alert"
- className="flex items-start gap-2 rounded-xl border border-border bg-card px-5 py-4 text-sm text-destructive"
- >
- <AlertCircle aria-hidden="true" className="mt-0.5 h-4 w-4 shrink-0" />
- <p className="min-w-0 flex-1">
- {error === PROVIDER_BACKEND_UNREACHABLE
- ? t("apikeys_view.backend_unavailable")
- : `${t("apikeys_view.load_error")} (${error}).`}
- </p>
- <Button variant="outline" size="sm" onClick={onChanged}>
- {t("common.retry")}
- </Button>
- </div>
- )}
-
- <ProfileGroup
- title={t("apikeys_realtime.providers_title")}
- description={t("apikeys_realtime.providers_desc")}
- testId="realtime-provider-list"
- >
- {loading && !choices.length ? (
- <div role="status" className="flex items-center gap-2 px-5 py-4 text-sm text-muted-foreground">
- <Loader2 aria-hidden="true" className="h-4 w-4 animate-spin" />
- {t("apikeys_realtime.loading")}
- </div>
- ) : (
- choices.map((provider) => (
- <ProviderRow
- key={provider.id}
- provider={provider}
- statusLabel={liveMode(provider) === "chatgpt_subscription" ? subscriptionStatus : undefined}
- selected={selected?.id === provider.id}
- activating={activatingId === provider.id}
- health={provider.active ? activeHealth : undefined}
- onSelect={() => select(provider)}
- />
- ))
- )}
- </ProfileGroup>
-
- {selected && (
- <div ref={setupRef} tabIndex={-1} data-testid="realtime-provider-setup" className="scroll-mt-4">
- <ProviderSettings
- key={selected.id}
- provider={selected}
- health={selected.active ? activeHealth : undefined}
- activating={activatingId === selected.id}
- canSwitch={canSwitchTo(selected)}
- onActivate={() => void activate(selected)}
- // The first provider set up becomes the voice by itself; once one
- // holds the voice, a new key never takes it over unasked.
- onKeySaved={
- active ? undefined : () => void activate(selected, { assumeConfigured: true })
- }
- onChanged={onChanged}
- />
- </div>
- )}
-
- <ExperimentalConsentDialog
- provider={consentFor?.provider ?? null}
- onCancel={() => setConsentFor(null)}
- onConfirm={() => {
- const pending = consentFor;
- setConsentFor(null);
- if (!pending) return;
- rememberExperimentalConsent(pending.provider.id);
- void activate(pending.provider, {
- consented: true,
- assumeConfigured: pending.assumeConfigured,
- });
- }}
- />
- </section>
- );
-}
-
-/**
- * What the voice runs on right now — one card, one sentence of state. It also
- * carries the one-click way back onto Realtime for an install that is still
- * currently configured for the separate pipeline engine.
- */
-function VoiceNow({
- active,
- activeHealth,
- voice,
- billingOverride,
-}: {
- active: ProviderDescriptor | null;
- activeHealth?: SectionHealth;
- voice: VoiceRuntime;
- billingOverride?: ProviderDescriptor["billing"];
-}) {
- const t = useT();
- if (!voice.statusKnown) {
- // A placeholder, never an invented "not set up": the status simply has
- // not answered yet.
- return (
- <div
- role="status"
- aria-busy="true"
- aria-label={t("apikeys_realtime.loading")}
- className="flex items-center gap-4 rounded-xl border border-border bg-card px-5 py-4"
- >
- <span className="h-9 w-9 shrink-0 rounded-md bg-foreground/10" />
- <span className="flex flex-1 flex-col gap-2">
- <span className="h-3.5 w-40 rounded bg-foreground/10" />
- <span className="h-3 w-24 rounded bg-foreground/10" />
- </span>
- </div>
- );
- }
-
- const realtimeOff = voice.mode !== "realtime";
- const onBackupPath =
- voice.sessionActive && voice.activeSessionMode === "pipeline" && !realtimeOff;
- const offerBlocked =
- !realtimeOff && voice.requiresWebRtcOffer && voice.transportOfferReady === false;
- const offerDetail = !offerBlocked
- ? ""
- : voice.transportIssue
- ? t(realtimeTransportIssueKey(voice.transportIssue))
- : voice.transportOfferDetail;
-
- const title = realtimeOff
- ? t("apikeys_realtime.state_off")
- : active
- ? active.label
- : t("apikeys_realtime.state_none");
- // A running call can still use the previous access, and a CLI can explicitly
- // select either Live runtime. Prefer that truth over the saved next-call mode.
- const runtimeProvider = voice.sessionActive ? voice.activeSessionProvider : voice.activeProvider;
- const billing = active?.configuration_surface === "live" && runtimeProvider === "openai-live-subscription"
- ? "subscription"
- : active?.configuration_surface === "live" && runtimeProvider === "openai-live"
- ? "api" : billingOverride ?? active?.billing;
- const subtitle = realtimeOff
- ? t(
- voice.realtimeAvailable
- ? "apikeys_realtime.off_hint"
- : "apikeys_realtime.off_hint_unavailable",
- )
- : active
- ? voice.activeModel || t(`provider_billing.${billing}`)
- : t("apikeys_realtime.none_hint");
-
- const state: { tone: "accent" | "pulse" | "warn" | "error" | "quiet"; label: string } | null =
- realtimeOff || !active
- ? null
- : voice.connecting
- ? { tone: "pulse", label: t("apikeys_realtime.state_connecting") }
- : voice.sessionActive && voice.activeSessionMode === "realtime"
- ? { tone: "accent", label: t("apikeys_realtime.state_call") }
- : onBackupPath
- ? { tone: "warn", label: t("apikeys_realtime.state_backup") }
- : activeHealth?.status === "error"
- ? { tone: "error", label: t("apikeys_view.health_error") }
- : { tone: "quiet", label: t("apikeys_realtime.state_ready") };
-
- const notes = [
- onBackupPath ? { key: "backup", alert: false, text: t("live.pipeline_fallback") } : null,
- !realtimeOff && voice.lastStartError
- ? {
- key: "start-error",
- alert: true,
- text: t("voice_state.connect_failed")
- .replace("{0}", voice.lastStartError.provider || "?")
- .replace("{1}", voice.lastStartError.message),
- }
- : null,
- offerDetail ? { key: "offer", alert: true, text: offerDetail } : null,
- ].filter((note): note is { key: string; alert: boolean; text: string } => note !== null);
-
- return (
- <div
- data-testid="voice-now"
- className="divide-y divide-border overflow-hidden rounded-xl border border-border bg-card"
- >
- <div className="flex items-center gap-4 px-5 py-4">
- {active && !realtimeOff ? (
- <ProviderLogo providerId={active.id} label={active.label} />
- ) : (
- <span
- aria-hidden="true"
- className="flex h-9 w-9 shrink-0 items-center justify-center rounded-md bg-secondary text-muted-foreground"
- >
- <Radio className="h-4 w-4" />
- </span>
- )}
- <div className="min-w-0 flex-1">
- <p className="truncate text-base font-semibold text-foreground-strong">{title}</p>
- <p className="mt-0.5 text-sm text-muted-foreground">{subtitle}</p>
- </div>
- {realtimeOff && voice.realtimeAvailable && (
- <Button
- size="sm"
- data-testid="voice-now-turn-on"
- disabled={voice.isSaving}
- onClick={() => voice.setMode("realtime")}
- >
- {voice.isSaving && <Loader2 className="animate-spin" />}
- {t("apikeys_realtime.turn_on")}
- </Button>
- )}
- {state && (
- <span
- data-testid="voice-now-state"
- aria-live="polite"
- className="inline-flex shrink-0 items-center gap-2 text-sm text-muted-foreground"
- >
- <span
- aria-hidden="true"
- className={cn(
- "h-2 w-2 rounded-full",
- state.tone === "accent" && "bg-accent",
- state.tone === "pulse" && "animate-pulse bg-accent motion-reduce:animate-none",
- state.tone === "warn" && "bg-warning",
- state.tone === "error" && "bg-destructive",
- state.tone === "quiet" && "bg-muted-foreground",
- )}
- />
- <span className={cn(state.tone !== "quiet" && "font-medium text-foreground")}>
- {state.label}
- </span>
- </span>
- )}
- </div>
- {notes.map((note) => (
- <p
- key={note.key}
- role={note.alert ? "alert" : "status"}
- data-testid={`voice-now-note-${note.key}`}
- className={cn(
- "px-5 py-3 text-sm",
- note.alert ? "text-destructive" : "text-warning",
- )}
- >
- {note.text}
- </p>
- ))}
- </div>
- );
-}
-
-/** One provider in the list: a radio mark for "this is the voice", its state on the right. */
-function ProviderRow({
- provider,
- billingOverride,
- statusLabel,
- selected,
- activating,
- health,
- onSelect,
-}: {
- provider: ProviderDescriptor;
- billingOverride?: ProviderDescriptor["billing"];
- statusLabel?: string;
- selected: boolean;
- activating: boolean;
- health?: SectionHealth;
- onSelect: () => void;
-}) {
- const t = useT();
- const broken = provider.active && health?.status === "error";
- return (
- <button
- type="button"
- aria-pressed={selected}
- data-testid={`realtime-provider-${provider.id}`}
- data-active={provider.active ? "true" : "false"}
- onClick={onSelect}
- className={cn(
- "flex w-full items-center gap-4 px-5 py-3.5 text-left transition-colors",
- "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",
- selected ? "bg-accent-soft" : "hover:bg-secondary",
- )}
- >
- <span
- aria-hidden="true"
- className={cn(
- "flex h-4 w-4 shrink-0 items-center justify-center rounded-full border-2 transition-colors",
- provider.active ? "border-accent" : "border-border-strong",
- )}
- >
- {provider.active && <span className="h-2 w-2 rounded-full bg-accent" />}
- </span>
- <ProviderLogo providerId={provider.id} label={provider.label} />
- <span className="min-w-0 flex-1">
- <span className="flex min-w-0 items-center gap-2">
- <span className="truncate text-base font-medium text-foreground">{provider.label}</span>
- {provider.recommended && <Tag tone="accent">{t("apikeys_view.recommended")}</Tag>}
- {provider.experimental && (
- <Tag tone="neutral" title={t("apikeys_view.experimental_note")}>
- {t("apikeys_view.experimental")}
- </Tag>
- )}
- </span>
- <span className="mt-0.5 block truncate text-sm text-muted-foreground">
- {t(`provider_billing.${billingOverride ?? provider.billing}`)}
- </span>
- </span>
- {activating ? (
- <span className="inline-flex shrink-0 items-center gap-1.5 text-sm text-muted-foreground">
- <Loader2 aria-hidden="true" className="h-3.5 w-3.5 animate-spin" />
- {t("apikeys_view.provider_activating")}
- </span>
- ) : broken ? (
- <span className="inline-flex shrink-0 items-center gap-1.5 text-sm font-medium text-destructive">
- <span aria-hidden="true" className="h-2 w-2 rounded-full bg-destructive" />
- {t("apikeys_view.health_error")}
- </span>
- ) : provider.active ? (
- <span className="inline-flex shrink-0 items-center gap-1.5 text-sm font-medium text-foreground">
- <Check aria-hidden="true" className="h-4 w-4 text-accent" />
- {t("apikeys_realtime.active")}
- </span>
- ) : statusLabel ? (
- <span title={statusLabel} className="inline-flex max-w-[45%] shrink-0 items-center gap-1.5 text-sm text-muted-foreground">
- <span aria-hidden="true" className="h-2 w-2 shrink-0 rounded-full bg-muted-foreground" />
- <span className="truncate">{statusLabel}</span>
- </span>
- ) : (
- <StatusBadge descriptor={provider} />
- )}
- </button>
- );
-}
-
-/**
- * Everything that edits the selected provider, as plain settings groups: its
- * connection (key, sign-in or local server) with a live test, then its model
- * and voice — or, for GPT-Live, its own conversation and thinking groups.
- */
-function ProviderSettings({
- provider,
- health,
- activating,
- canSwitch,
- onActivate,
- onKeySaved,
- onChanged,
-}: {
- provider: ProviderDescriptor;
- health?: SectionHealth;
- activating: boolean;
- canSwitch: boolean;
- onActivate: () => void;
- /** Called once a key was saved for a provider that had none. */
- onKeySaved?: () => void;
- onChanged: () => void;
-}) {
- const t = useT();
- const isLive = provider.configuration_surface === "live";
- const selectedAuthMode = liveMode(provider);
- const showCredentials = !isLive || selectedAuthMode === "api_key";
- const broken = provider.active && health?.status === "error";
- const brokenDetail = health?.detail?.trim() || "";
- const showOptions =
- !isLive &&
- (provider.configured ||
- // Keep the pickers mounted through a transient busy probe so the group
- // does not flicker while the provider is being checked.
- provider.codex_status?.reason_code === "busy");
-
- return (
- <div data-testid={`realtime-settings-${provider.id}`} className="flex flex-col gap-group">
- {(showCredentials || broken) && <ProfileGroup
- title={provider.label}
- description={
- isLive
- ? t("apikeys_realtime.settings_desc_live")
- : t(`provider_billing.${provider.billing}`)
- }
- aside={
- canSwitch && !isLive ? (
- <Button
- size="sm"
- variant="outline"
- disabled={activating}
- data-testid={`realtime-use-${provider.id}`}
- onClick={onActivate}
- >
- {activating && <Loader2 className="animate-spin" />}
- {t("apikeys_realtime.use_provider").replace("{0}", provider.label)}
- </Button>
- ) : undefined
- }
- >
- {broken && (
- <div
- role="status"
- data-testid={`realtime-health-error-${provider.id}`}
- className="flex items-start gap-2 px-5 py-3 text-sm text-destructive"
- >
- <XCircle aria-hidden="true" className="mt-0.5 h-4 w-4 shrink-0" />
- <span className="min-w-0 break-words">
- <span className="font-medium">{t("apikeys_view.health_error")}</span>
- {brokenDetail ? ` — ${brokenDetail}` : ""}
- </span>
- </div>
- )}
- {showCredentials && <div className="px-5 py-4">
- <AuthWidget descriptor={provider} onChanged={onChanged} onSavedActivate={onKeySaved} />
- </div>}
- {showOptions && (
- <SettingRow
- label={t("apikeys_realtime.model_voice")}
- hint={t("apikeys_realtime.model_voice_hint")}
- >
- <div className="mt-3">
- <RealtimeOptionsControl providerId={provider.id} healthActive={provider.active} />
- </div>
- </SettingRow>
- )}
- {showCredentials && <SettingRow
- label={t("apikeys_realtime.test_label")}
- hint={t("apikeys_realtime.test_hint")}
- control={
- <ProviderTestControl
- providerId={provider.id}
- providerLabel={provider.label}
- section={provider.tier}
- active={provider.active}
- />
- }
- />}
- </ProfileGroup>}
-
- {isLive && <LiveProfile onSaved={onChanged} selectedAuthMode={selectedAuthMode} />}
- </div>
- );
-}
-
-/**
- * The once-per-provider acknowledgement before an experimental route becomes
- * the voice. An in-app dialog, not `window.confirm`: the desktop WebView draws
- * that as a raw "127.0.0.1 says" box that blocks the whole window.
- */
-function ExperimentalConsentDialog({
- provider,
- onCancel,
- onConfirm,
-}: {
- provider: ProviderDescriptor | null;
- onCancel: () => void;
- onConfirm: () => void;
-}) {
- const t = useT();
- const subscriptionOnly =
- provider?.auth_mode === "codex" &&
- provider.billing === "subscription" &&
- provider.secret_keys.length === 0;
- return (
- <Dialog.Root open={provider !== null} onOpenChange={(open) => !open && onCancel()}>
- <Dialog.Portal>
- <Dialog.Overlay className="fixed inset-0 z-[80] bg-scrim/75 backdrop-blur-sm data-[state=open]:animate-in data-[state=open]:fade-in-0 motion-reduce:animate-none" />
- <Dialog.Content
- data-testid="realtime-consent-dialog"
- className="fixed inset-0 z-[80] m-auto h-fit w-[min(440px,calc(100vw-32px))] rounded-2xl border border-border bg-popover p-6 text-popover-foreground shadow-float outline-none data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 motion-reduce:animate-none"
- >
- <Dialog.Title className="text-base font-semibold text-foreground-strong">
- {provider?.label}
- </Dialog.Title>
- <Dialog.Description className="mt-1.5 text-sm text-muted-foreground">
- {t(
- subscriptionOnly
- ? "apikeys_view.experimental_subscription_consent"
- : "apikeys_view.experimental_consent",
- )}
- </Dialog.Description>
- <div className="mt-6 flex justify-end gap-2">
- <Button type="button" variant="ghost" onClick={onCancel}>
- {t("common.cancel")}
- </Button>
- <Button type="button" onClick={onConfirm}>
- {t("common.yes")}
- </Button>
- </div>
- </Dialog.Content>
- </Dialog.Portal>
- </Dialog.Root>
- );
-}
diff --git a/jarvis/ui/web/frontend/src/views/apikeys/settingsUi.tsx b/jarvis/ui/web/frontend/src/views/apikeys/settingsUi.tsx
index f197a46d17..ef009c7650 100644
--- a/jarvis/ui/web/frontend/src/views/apikeys/settingsUi.tsx
+++ b/jarvis/ui/web/frontend/src/views/apikeys/settingsUi.tsx
@@ -1,4 +1,4 @@
-import type { ComponentPropsWithoutRef, ReactNode } from "react";
+import { type ComponentPropsWithoutRef, type ReactNode, useId } from "react";
import { cn } from "@/lib/utils";
/**
@@ -25,10 +25,15 @@ export function SettingsSection({
plain?: boolean;
children: ReactNode;
}) {
+ // The title names the section, so assistive tech lists it as a region.
+ const headingId = useId();
return (
- <section {...props} className={cn("space-y-2.5", className)}>
+ <section aria-labelledby={headingId} {...props} className={cn("space-y-2.5", className)}>
<div className="flex min-h-7 items-center justify-between gap-4 px-1">
- <h2 className="flex min-h-7 min-w-0 items-center gap-2 text-sm font-normal text-foreground/70">
+ <h2
+ id={headingId}
+ className="flex min-h-7 min-w-0 items-center gap-2 text-sm font-normal text-foreground/70"
+ >
{icon}
<span className="truncate">{title}</span>
</h2>
diff --git a/jarvis/ui/web/frontend/src/views/voice/LanguageTab.test.tsx b/jarvis/ui/web/frontend/src/views/voice/LanguageTab.test.tsx
index 20344e715c..462adc24df 100644
--- a/jarvis/ui/web/frontend/src/views/voice/LanguageTab.test.tsx
+++ b/jarvis/ui/web/frontend/src/views/voice/LanguageTab.test.tsx
@@ -229,7 +229,7 @@ describe("LanguageTab", () => {
"es",
]);
// The row's first span is the name in the user's UI language …
- expect(options.map((o) => o.querySelector("span")?.textContent)).toEqual([
+ expect(options.map((o) => o.querySelector("span > span")?.textContent)).toEqual([
"Detect automatically",
"English",
"German",