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.

chore: auto-save WIP via Claude stop-hook safety net (2026-07-08 18:56)

Ruben Lütkeaad1995a8705
diff --git a/jarvis/ui/web/frontend/src/components/RealtimeComputerUsePanel.test.tsx b/jarvis/ui/web/frontend/src/components/RealtimeComputerUsePanel.test.tsx
deleted file mode 100644
index 164b68d5fa..0000000000
--- a/jarvis/ui/web/frontend/src/components/RealtimeComputerUsePanel.test.tsx
+++ /dev/null
@@ -1,113 +0,0 @@
-/**
- * Component tests for `RealtimeComputerUsePanel` (Feature B — the Computer-Use
- * panel embedded in Realtime mode on the API-Keys screen).
- *
- * Realtime speech-to-speech models can't see the screen, so Computer-Use
- * during a realtime turn falls back to the ACTIVE Brain provider — exactly
- * what CU already runs on today. These tests pin: (1) the panel names the
- * active Brain provider and forwards its id (never a realtime id) to
- * `CuModelSelector`, (2) an active REALTIME provider is ignored when
- * resolving "the active Brain provider", and (3) with no active Brain
- * provider the panel shows a hint instead of the selector.
- */
-import { afterEach, describe, expect, it, vi } from "vitest";
-import { cleanup, render, screen } from "@testing-library/react";
-
-// Stub CuModelSelector so this test asserts exactly what the panel passes it
-// (providerId / recommendedModel), without pulling in its own network calls —
-// that component has its own tests.
-vi.mock("@/components/CuModelSelector", () => ({
- CuModelSelector: ({
- providerId,
- recommendedModel,
- }: {
- providerId: string;
- recommendedModel?: string | null;
- }) => (
- <div
- data-testid="cu-model-selector-stub"
- data-provider-id={providerId}
- data-recommended-model={recommendedModel ?? ""}
- />
- ),
-}));
-
-let mockProviders: Array<Record<string, unknown>> = [];
-vi.mock("@/hooks/useProviders", () => ({
- useProviders: () => ({
- providers: mockProviders,
- loading: false,
- error: null,
- refetch: vi.fn(),
- setActiveOptimistic: vi.fn(),
- }),
-}));
-
-import { RealtimeComputerUsePanel } from "@/components/RealtimeComputerUsePanel";
-
-afterEach(() => {
- cleanup();
- mockProviders = [];
-});
-
-function brainProvider(overrides: Record<string, unknown> = {}) {
- return {
- id: "openrouter",
- label: "OpenRouter",
- tier: "brain",
- active: true,
- recommended_model: "some-model",
- ...overrides,
- };
-}
-
-function realtimeProvider(overrides: Record<string, unknown> = {}) {
- return {
- id: "openai-realtime",
- label: "OpenAI Realtime",
- tier: "realtime",
- active: true,
- ...overrides,
- };
-}
-
-describe("RealtimeComputerUsePanel", () => {
- it("names the active Brain provider and passes the BRAIN id + recommended model to CuModelSelector", () => {
- mockProviders = [brainProvider(), realtimeProvider()];
- render(<RealtimeComputerUsePanel />);
-
- expect(screen.getByTestId("realtime-cu-panel").textContent).toMatch(/OpenRouter/);
- const stub = screen.getByTestId("cu-model-selector-stub");
- expect(stub.getAttribute("data-provider-id")).toBe("openrouter");
- expect(stub.getAttribute("data-recommended-model")).toBe("some-model");
- });
-
- it("ignores an active REALTIME provider — only the active BRAIN provider resolves", () => {
- mockProviders = [
- brainProvider({ id: "gemini", label: "Gemini", active: true }),
- realtimeProvider({ active: true }),
- ];
- render(<RealtimeComputerUsePanel />);
-
- const stub = screen.getByTestId("cu-model-selector-stub");
- expect(stub.getAttribute("data-provider-id")).toBe("gemini");
- expect(stub.getAttribute("data-provider-id")).not.toBe("openai-realtime");
- });
-
- it("shows a hint pointing back to Pipeline -> Brain instead of CuModelSelector when no Brain provider is active", () => {
- mockProviders = [brainProvider({ active: false }), realtimeProvider()];
- render(<RealtimeComputerUsePanel />);
-
- expect(screen.queryByTestId("cu-model-selector-stub")).toBeNull();
- const hint = screen.getByTestId("realtime-cu-no-brain-hint");
- expect(hint.textContent).toMatch(/Brain/i);
- });
-
- it("shows the hint when there are no providers at all", () => {
- mockProviders = [];
- render(<RealtimeComputerUsePanel />);
-
- expect(screen.queryByTestId("cu-model-selector-stub")).toBeNull();
- expect(screen.getByTestId("realtime-cu-no-brain-hint")).toBeTruthy();
- });
-});
diff --git a/jarvis/ui/web/frontend/src/components/RealtimeComputerUsePanel.tsx b/jarvis/ui/web/frontend/src/components/RealtimeComputerUsePanel.tsx
deleted file mode 100644
index 723a045c8b..0000000000
--- a/jarvis/ui/web/frontend/src/components/RealtimeComputerUsePanel.tsx
+++ /dev/null
@@ -1,62 +0,0 @@
-import { CuModelSelector } from "@/components/CuModelSelector";
-import { useProviders } from "@/hooks/useProviders";
-import { useT } from "@/i18n";
-
-/**
- * Realtime mode's Computer-Use delegation panel (Feature B).
- *
- * Realtime speech-to-speech models (`openai-realtime`, `gemini-live`) are pure
- * audio — they have no vision/screen and no tool-call event
- * (`jarvis/realtime/protocol.py`), so they can never run Computer-Use
- * themselves. Computer-Use already runs on the ACTIVE Brain provider today
- * (`jarvis/brain/brain_call.py` → `_build_fallback_chain("fast")` leads with
- * `brain.primary`), so this panel just makes that delegation visible inside
- * the Realtime tab and lets the user pin a Computer-Use model for it — no new
- * "CU provider" concept, no backend change. It reuses the existing
- * `CuModelSelector`, which already talks to `GET/PUT
- * /api/providers/{id}/cu-model` and is vision-filtered; that endpoint 400s for
- * non-brain ids, so this always passes the resolved BRAIN provider id, never a
- * realtime id.
- *
- * Reads providers via its own `useProviders()` call (read-through, like
- * `SubagentCategory`'s `JarvisAgentSection` owns `/api/openclaw/status`)
- * rather than a prop, so it never depends on ApiKeysView passing the right
- * slice down.
- */
-export function RealtimeComputerUsePanel() {
- const t = useT();
- const { providers } = useProviders();
- const activeBrain = providers.find((p) => p.tier === "brain" && p.active);
-
- return (
- <section
- data-testid="realtime-cu-panel"
- className="mt-6 border-t border-border pt-6"
- >
- <h3 className="font-display text-sm font-semibold tracking-tight">
- {t("apikeys_realtime_cu.title")}
- </h3>
- <p className="mt-0.5 text-xs text-muted-foreground">
- {activeBrain
- ? t("apikeys_realtime_cu.description").replace("{0}", activeBrain.label)
- : t("apikeys_realtime_cu.description_generic")}
- </p>
-
- <div className="mt-3">
- {activeBrain ? (
- <CuModelSelector
- providerId={activeBrain.id}
- recommendedModel={activeBrain.recommended_model}
- />
- ) : (
- <p
- data-testid="realtime-cu-no-brain-hint"
- className="rounded-md border border-amber-500/25 bg-amber-500/10 px-3 py-2 text-[11px] leading-relaxed text-amber-700"
- >
- {t("apikeys_realtime_cu.no_active_brain_hint")}
- </p>
- )}
- </div>
- </section>
- );
-}
diff --git a/jarvis/ui/web/frontend/src/components/onboarding/steps/ApiKeysStep.test.tsx b/jarvis/ui/web/frontend/src/components/onboarding/steps/ApiKeysStep.test.tsx
index 8fdb9a7e81..68485b2318 100644
--- a/jarvis/ui/web/frontend/src/components/onboarding/steps/ApiKeysStep.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/onboarding/steps/ApiKeysStep.test.tsx
@@ -6,6 +6,7 @@ const {
switchTtsProvider,
switchSttProvider,
switchRealtimeProvider,
+ switchComputerUseProvider,
refetch,
setActiveOptimistic,
PROVIDERS,
@@ -31,6 +32,7 @@ const {
switchTtsProvider: vi.fn().mockResolvedValue({}),
switchSttProvider: vi.fn().mockResolvedValue({}),
switchRealtimeProvider: vi.fn().mockResolvedValue({}),
+ switchComputerUseProvider: vi.fn().mockResolvedValue({}),
refetch: vi.fn(),
setActiveOptimistic: vi.fn(),
PROVIDERS: [
@@ -66,6 +68,7 @@ vi.mock("@/hooks/useProviders", () => ({
switchTtsProvider,
switchSttProvider,
switchRealtimeProvider,
+ switchComputerUseProvider,
}));
import { ApiKeysStep } from "./ApiKeysStep";
diff --git a/jarvis/ui/web/frontend/src/components/onboarding/steps/ApiKeysStep.tsx b/jarvis/ui/web/frontend/src/components/onboarding/steps/ApiKeysStep.tsx
index ff8fa00122..f12bc87754 100644
--- a/jarvis/ui/web/frontend/src/components/onboarding/steps/ApiKeysStep.tsx
+++ b/jarvis/ui/web/frontend/src/components/onboarding/steps/ApiKeysStep.tsx
@@ -9,6 +9,7 @@ import { JarvisAgentSection } from "@/components/JarvisAgentSection";
import {
useProviders,
switchBrainProvider,
+ switchComputerUseProvider,
switchRealtimeProvider,
switchTtsProvider,
switchSttProvider,
@@ -32,13 +33,15 @@ const TIERS: { tier: ProviderTier; label: string; hint: string; icon: JSX.Elemen
// Activate (select) a provider by its tier — mirrors the main Settings API-Keys
// section so onboarding lets the user pick which provider is active per class.
-// Realtime has no onboarding step of its own (see TIERS above — it stays a
-// Settings-only tier for now), but the map must stay total over ProviderTier.
+// Realtime and Computer-Use have no onboarding step of their own (see TIERS
+// above — they stay Settings-only tiers for now), but the map must stay total
+// over ProviderTier.
const SWITCH: Record<ProviderTier, (id: string) => Promise<unknown>> = {
brain: switchBrainProvider,
tts: switchTtsProvider,
stt: switchSttProvider,
realtime: switchRealtimeProvider,
+ "computer-use": switchComputerUseProvider,
};
export function ApiKeysStep({ goNext, skip }: StepProps) {
diff --git a/jarvis/ui/web/frontend/src/hooks/useProviders.ts b/jarvis/ui/web/frontend/src/hooks/useProviders.ts
index 92bfcc3cc1..e4112cd188 100644
--- a/jarvis/ui/web/frontend/src/hooks/useProviders.ts
+++ b/jarvis/ui/web/frontend/src/hooks/useProviders.ts
@@ -1,7 +1,7 @@
import { useCallback, useEffect, useState } from "react";
export type AuthMode = "api_key" | "codex" | "antigravity" | "none";
-export type ProviderTier = "brain" | "tts" | "stt" | "realtime";
+export type ProviderTier = "brain" | "tts" | "stt" | "realtime" | "computer-use";
/** How using a provider is billed — mirror of provider_spec.Billing. */
export type Billing = "api" | "subscription" | "subscription_or_api" | "local";
@@ -31,6 +31,12 @@ export interface ProviderDescriptor {
credential_path_hint: string | null;
configured: boolean;
active: boolean;
+ /**
+ * Whether this brain provider is the dedicated Computer-Use planner
+ * (`[brain.computer_use].provider`) — an OVERLAY selection, independent of
+ * `active`/`brain.primary` above. Only ever true for `tier === "brain"`.
+ */
+ computer_use_active?: boolean;
brain_switchable?: boolean;
cli_installed: boolean | null;
/** Plain-English "which key / subscription, and what for". */
@@ -167,17 +173,20 @@ export function useProviders() {
const onTts = () => void refetch();
const onStt = () => void refetch();
const onRealtime = () => void refetch();
+ const onComputerUse = () => void refetch();
window.addEventListener("jarvis:secret-configured", onSecret);
window.addEventListener("jarvis:brain-switched", onBrain);
window.addEventListener("jarvis:tts-switched", onTts);
window.addEventListener("jarvis:stt-switched", onStt);
window.addEventListener("jarvis:realtime-switched", onRealtime);
+ window.addEventListener("jarvis:computer-use-switched", onComputerUse);
return () => {
window.removeEventListener("jarvis:secret-configured", onSecret);
window.removeEventListener("jarvis:brain-switched", onBrain);
window.removeEventListener("jarvis:tts-switched", onTts);
window.removeEventListener("jarvis:stt-switched", onStt);
window.removeEventListener("jarvis:realtime-switched", onRealtime);
+ window.removeEventListener("jarvis:computer-use-switched", onComputerUse);
};
}, [refetch]);
@@ -250,6 +259,7 @@ export function useSectionHealth() {
"jarvis:tts-switched",
"jarvis:stt-switched",
"jarvis:realtime-switched",
+ "jarvis:computer-use-switched",
"jarvis:subagent-switched",
"jarvis:provider-tested",
];
@@ -459,6 +469,29 @@ export async function switchRealtimeProvider(
return body as PipelineSwitchResult;
}
+/**
+ * Switches the dedicated GLOBAL Computer-Use planner provider
+ * (`[brain.computer_use].provider`). An OVERLAY over the brain-tier provider
+ * ids — decoupled from `brain.primary` — so the same CU provider applies in
+ * both Pipeline and Realtime mode. Persists to jarvis.toml (3-layer,
+ * drift-guarded) and takes effect immediately on the server, so
+ * `restart_required` is always false here (unlike TTS/STT/Realtime/worker).
+ */
+export async function switchComputerUseProvider(
+ providerId: string,
+): Promise<PipelineSwitchResult> {
+ const res = await fetch("/api/computer-use/switch", {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({ provider: providerId, persist: true }),
+ });
+ const body = await res.json().catch(() => ({}));
+ if (!res.ok) {
+ throw new Error(body.detail ?? `HTTP ${res.status}`);
+ }
+ return body as PipelineSwitchResult;
+}
+
/**
* Switches the active heavy-task WORKER provider
* (`[brain.sub_jarvis].provider`). Persists across 3 layers
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/de.json b/jarvis/ui/web/frontend/src/i18n/locales/de.json
index ce59c49293..e4870bf345 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/de.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/de.json
@@ -866,12 +866,14 @@
"tier_tts": "Voice-Output (TTS)",
"tier_stt": "Voice-Input (STT)",
"tier_realtime": "Realtime-Sprache",
+ "tier_computer_use": "Computer-Use-Provider",
"tier_subagent": "Jarvis-Agent (Heavy-Tasks)",
"tier_telephony": "Telefonie",
"tab_brain": "Brain",
"tab_tts": "Sprachausgabe",
"tab_stt": "Spracheingabe",
"tab_realtime": "Realtime",
+ "tab_computer_use": "Computer-Use",
"tab_subagents": "Jarvis-Agents",
"tab_advanced": "Erweitert",
"mode_pipeline": "Pipeline",
@@ -881,6 +883,7 @@
"cat_tts_desc": "Die Stimme, mit der Jarvis spricht.",
"cat_stt_desc": "Wie Jarvis deine Sprache in Text umwandelt.",
"cat_realtime_desc": "Die Vollduplex-Sprache-zu-Sprache-Engine (OpenAI Realtime). Nutzt deinen vorhandenen OpenAI-Key mit. Standardmäßig AUS, bis der Browser-Client angebunden ist (Phase 2).",
+ "cat_computer_use_desc": "Computer-Use liest deinen Bildschirm; wähle, welcher Provider das plant — unabhängig von deinem Chat-Brain. Realtime-Modelle können den Bildschirm nicht sehen, deshalb läuft es auch dort darüber.",
"cat_subagents_title": "Jarvis-Agents",
"cat_subagents_desc": "Wähle, welcher Provider schwere Hintergrund-Aufgaben übernimmt.",
"advanced_title": "Zugang & Integrationen",
@@ -969,12 +972,6 @@
"cleared": "Computer-Use-Modell auf dein Hauptmodell zurückgesetzt",
"vision_note": "Es werden nur Modelle angezeigt, die Bilder verstehen - Computer-Use liest den Bildschirm über Screenshots, ein reines Text-Modell kann es nicht steuern."
},
- "apikeys_realtime_cu": {
- "title": "Computer-Use",
- "description": "Realtime-Modelle können deinen Bildschirm nicht sehen. Wenn ein Realtime-Gespräch Computer-Use braucht, nutzt Jarvis deinen aktiven Brain-Provider: {0}.",
- "description_generic": "Realtime-Modelle können deinen Bildschirm nicht sehen. Computer-Use braucht einen aktiven Brain-Provider als Rückfalloption.",
- "no_active_brain_hint": "Es ist noch kein aktiver Brain-Provider eingerichtet. Wechsle zu Pipeline → Brain und aktiviere einen, um Computer-Use in Realtime-Gesprächen zu ermöglichen."
- },
"settings_view": {
"silence_window": {
"title": "Denkpause",
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/en.json b/jarvis/ui/web/frontend/src/i18n/locales/en.json
index 3409da6eb8..ad56dfb186 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/en.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/en.json
@@ -866,12 +866,14 @@
"tier_tts": "Voice Output (TTS)",
"tier_stt": "Voice Input (STT)",
"tier_realtime": "Realtime voice",
+ "tier_computer_use": "Computer-Use provider",
"tier_subagent": "Jarvis-Agent (heavy tasks)",
"tier_telephony": "Telephony",
"tab_brain": "Brain",
"tab_tts": "Voice Output",
"tab_stt": "Voice Input",
"tab_realtime": "Realtime",
+ "tab_computer_use": "Computer-Use",
"tab_subagents": "Jarvis-Agents",
"tab_advanced": "Advanced",
"mode_pipeline": "Pipeline",
@@ -881,6 +883,7 @@
"cat_tts_desc": "The voice Jarvis speaks with.",
"cat_stt_desc": "How Jarvis turns your speech into text.",
"cat_realtime_desc": "The full-duplex speech-to-speech engine (OpenAI Realtime). Reuses your OpenAI key. Default-OFF until the browser client is wired in (Phase 2).",
+ "cat_computer_use_desc": "Computer-Use reads your screen; pick which provider plans it — independent of your chat Brain. Realtime models can't see the screen, so this runs it there too.",
"cat_subagents_title": "Jarvis-Agents",
"cat_subagents_desc": "Choose which provider runs heavy background tasks.",
"advanced_title": "Access & Integrations",
@@ -970,12 +973,6 @@
"cleared": "Computer-Use model reset to your main model",
"vision_note": "Only models that can see images are listed - Computer-Use reads the screen from screenshots, so a text-only model cannot run it."
},
- "apikeys_realtime_cu": {
- "title": "Computer-Use",
- "description": "Realtime models can't see your screen. When a realtime conversation needs Computer-Use, Jarvis uses your active Brain provider: {0}.",
- "description_generic": "Realtime models can't see your screen. Computer-Use needs an active Brain provider to fall back to.",
- "no_active_brain_hint": "No active Brain provider is configured yet. Switch to Pipeline → Brain and activate one to enable Computer-Use during Realtime conversations."
- },
"settings_view": {
"silence_window": {
"title": "Thinking pause",
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/es.json b/jarvis/ui/web/frontend/src/i18n/locales/es.json
index 540eb4e3f7..0606f57bdf 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/es.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/es.json
@@ -866,12 +866,14 @@
"tier_tts": "Salida de voz (TTS)",
"tier_stt": "Entrada de voz (STT)",
"tier_realtime": "Voz en tiempo real",
+ "tier_computer_use": "Proveedor de Computer-Use",
"tier_subagent": "Jarvis-Agent (tareas pesadas)",
"tier_telephony": "Telefonía",
"tab_brain": "IA",
"tab_tts": "Salida de voz",
"tab_stt": "Entrada de voz",
"tab_realtime": "Tiempo real",
+ "tab_computer_use": "Computer-Use",
"tab_subagents": "Jarvis-Agents",
"tab_advanced": "Avanzado",
"mode_pipeline": "Pipeline",
@@ -881,6 +883,7 @@
"cat_tts_desc": "La voz con la que habla Jarvis.",
"cat_stt_desc": "Cómo convierte Jarvis tu voz en texto.",
"cat_realtime_desc": "El motor de voz a voz en tiempo real (dúplex completo, OpenAI Realtime). Reutiliza tu clave de OpenAI. Desactivado por defecto hasta que el cliente de navegador esté conectado (Fase 2).",
+ "cat_computer_use_desc": "Computer-Use lee tu pantalla; elige qué proveedor lo planifica, independientemente de tu Brain de chat. Los modelos Realtime no pueden ver la pantalla, así que esto también se ejecuta ahí.",
"cat_subagents_title": "Jarvis-Agents",
"cat_subagents_desc": "Elige qué proveedor ejecuta las tareas pesadas en segundo plano.",
"advanced_title": "Acceso e integraciones",
@@ -969,12 +972,6 @@
"cleared": "Modelo de Computer-Use restablecido a tu modelo principal",
"vision_note": "Solo se muestran modelos que entienden imágenes: Computer-Use lee la pantalla mediante capturas, un modelo de solo texto no puede controlarlo."
},
- "apikeys_realtime_cu": {
- "title": "Computer-Use",
- "description": "Los modelos Realtime no pueden ver tu pantalla. Cuando una conversación Realtime necesita Computer-Use, Jarvis usa tu proveedor Brain activo: {0}.",
- "description_generic": "Los modelos Realtime no pueden ver tu pantalla. Computer-Use necesita un proveedor Brain activo como alternativa.",
- "no_active_brain_hint": "Todavía no hay un proveedor Brain activo configurado. Cambia a Pipeline → Brain y activa uno para habilitar Computer-Use en las conversaciones Realtime."
- },
"settings_view": {
"silence_window": {
"title": "Pausa para pensar",
diff --git a/jarvis/ui/web/frontend/src/views/ApiKeysView.computer-use.test.tsx b/jarvis/ui/web/frontend/src/views/ApiKeysView.computer-use.test.tsx
new file mode 100644
index 0000000000..b06c55f362
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/views/ApiKeysView.computer-use.test.tsx
@@ -0,0 +1,245 @@
+/**
+ * Component tests for the dedicated "Computer-Use" tab on the API-Keys
+ * screen.
+ *
+ * Computer-Use (CU — the loop that reads the screen and clicks) used to be
+ * hard-locked to the active Brain provider. This tab is an OVERLAY over the
+ * SAME brain-provider cards (Claude/OpenAI/OpenRouter/Gemini) shown on the
+ * Brain tab, but "Set active" here flips `computer_use_active` via
+ * `POST /api/computer-use/switch` — a SEPARATE selection from `brain.primary`,
+ * independent of the Brain tab's `active`. The CU provider is GLOBAL, so the
+ * tab renders identically in Pipeline and Realtime mode.
+ *
+ * These tests pin: (1) the tab exists in both modes, (2) it renders the
+ * brain-provider cards, (3) activating a card calls
+ * `switchComputerUseProvider` with the BRAIN id (never a realtime id) and
+ * flips `computer_use_active` without touching the Brain tab's `active` or
+ * calling `/api/brain/switch`, (4) the CU-model picker renders under the tab,
+ * keyed by the brain id.
+ */
+import { afterEach, describe, expect, it, vi } from "vitest";
+import { cleanup, fireEvent, render, screen, waitFor, within } from "@testing-library/react";
+
+// ApiKeysView reads the live `[voice].mode` (for the Pipeline|Realtime mode
+// switch) via useVoiceMode, which needs a QueryClientProvider — mocked here
+// exactly like the other ApiKeysView.*.test.tsx files. realtimeAvailable=true
+// so clicking the Realtime segment actually switches the tab set.
+vi.mock("@/hooks/useVoiceMode", () => ({
+ useVoiceMode: () => ({
+ mode: "pipeline",
+ realtimeAvailable: true,
+ setMode: vi.fn(),
+ isLoading: false,
+ isSaving: false,
+ }),
+}));
+
+// Stub CuModelSelector so this test asserts exactly which provider id the CU
+// tab forwards to it, without pulling in its own model-catalog network calls
+// (covered by CuModelSelector's own tests).
+vi.mock("@/components/CuModelSelector", () => ({
+ CuModelSelector: ({ providerId }: { providerId: string }) => (
+ <div
+ data-testid={`cu-model-selector-stub-${providerId}`}
+ data-provider-id={providerId}
+ />
+ ),
+}));
+
+function brainProvider(overrides: Record<string, unknown> = {}) {
+ return {
+ id: "openai",
+ label: "OpenAI",
+ tier: "brain",
+ auth_mode: "api_key",
+ secret_keys: ["OPENAI_API_KEY"],
+ secrets_set: { OPENAI_API_KEY: true },
+ dashboard_url: null,
+ login_cli: null,
+ install_hint: null,
+ credential_path_hint: null,
+ configured: true,
+ active: false,
+ brain_switchable: true,
+ cli_installed: null,
+ credential_help: null,
+ signup_url: null,
+ billing: "api",
+ recommended_model: null,
+ alt_credential: null,
+ computer_use_active: false,
+ ...overrides,
+ };
+}
+
+function realtimeProvider(overrides: Record<string, unknown> = {}) {
+ return {
+ id: "openai-realtime",
+ label: "OpenAI Realtime",
+ tier: "realtime",
+ auth_mode: "api_key",
+ secret_keys: ["OPENAI_API_KEY"],
+ secrets_set: { OPENAI_API_KEY: true },
+ dashboard_url: null,
+ login_cli: null,
+ install_hint: null,
+ credential_path_hint: null,
+ configured: true,
+ active: true,
+ brain_switchable: true,
+ cli_installed: null,
+ credential_help: null,
+ signup_url: null,
+ billing: "api",
+ alt_credential: null,
+ ...overrides,
+ };
+}
+
+let providersState: Array<Record<string, unknown>> = [];
+
+function jsonResponse(body: unknown, status = 200): Response {
+ return {
+ ok: status >= 200 && status < 300,
+ status,
+ statusText: status >= 200 && status < 300 ? "OK" : "ERR",
+ json: async () => body,
+ text: async () => JSON.stringify(body),
+ } as Response;
+}
+
+function installFetchMock() {
+ const calls: { url: string; method: string; body: unknown }[] = [];
+ const fetchMock = vi.fn(async (input: RequestInfo | URL, init?: RequestInit) => {
+ const url = String(input);
+ const method = (init?.method ?? "GET").toUpperCase();
+ let body: unknown = null;
+ if (typeof init?.body === "string") {
+ try {
+ body = JSON.parse(init.body);
+ } catch {
+ body = init.body;
+ }
+ }
+ calls.push({ url, method, body });
+
+ if (url.startsWith("/api/providers/section-health")) {
+ return jsonResponse({ sections: {}, checked_at: 0, cached: false });
+ }
+ if (url === "/api/computer-use/switch" && method === "POST") {
+ const providerId = (body as { provider?: string })?.provider ?? "";
+ const spec = providersState.find((p) => p.id === providerId);
+ if (!spec || !spec.configured) {
+ return jsonResponse({ detail: "no key" }, 409);
+ }
+ providersState = providersState.map((p) => ({
+ ...p,
+ computer_use_active: p.tier === "brain" && p.id === providerId,
+ }));
+ return jsonResponse({
+ ok: true,
+ active: providerId,
+ persisted: true,
+ restart_required: false,
+ });
+ }
+ if (url.startsWith("/api/providers")) {
+ return jsonResponse({ providers: providersState });
+ }
+ throw new Error(`unexpected fetch ${url} (${method})`);
+ });
+ (globalThis as unknown as { fetch: typeof fetch }).fetch =
+ fetchMock as unknown as typeof fetch;
+ return { calls };
+}
+
+import { ApiKeysView } from "@/views/ApiKeysView";
+
+afterEach(() => {
+ cleanup();
+ vi.restoreAllMocks();
+});
+
+describe("ApiKeysView — Computer-Use tab", () => {
+ it("appears in both Pipeline and Realtime mode", async () => {
+ providersState = [brainProvider(), realtimeProvider()];
+ installFetchMock();
+ render(<ApiKeysView />);
+
+ expect(await screen.findByRole("tab", { name: /computer-use/i })).toBeTruthy();
+
+ fireEvent.click(screen.getByRole("button", { name: /^realtime$/i }));
+
+ expect(await screen.findByRole("tab", { name: /computer-use/i })).toBeTruthy();
+ expect(screen.getByRole("tab", { name: /^realtime$/i })).toBeTruthy();
+ });
+
+ it("renders the 4 brain-provider cards, same style as the Brain tab", async () => {
+ providersState = [
+ brainProvider({ id: "claude-api", label: "Claude" }),
+ brainProvider({ id: "openai", label: "OpenAI", active: true }),
+ brainProvider({ id: "openrouter", label: "OpenRouter" }),
+ brainProvider({ id: "gemini", label: "Gemini", configured: false }),
+ ];
+ installFetchMock();
+ render(<ApiKeysView />);
+
+ fireEvent.click(await screen.findByRole("tab", { name: /computer-use/i }));
+
+ expect(await screen.findByText("Claude")).toBeTruthy();
+ expect(screen.getByText("OpenAI")).toBeTruthy();
+ expect(screen.getByText("OpenRouter")).toBeTruthy();
+ expect(screen.getByText("Gemini")).toBeTruthy();
+ });
+
+ it("'Set active' calls switchComputerUseProvider with the brain id and flips computer_use_active independently of the Brain tab's active", async () => {
+ providersState = [
+ brainProvider({ id: "claude-api", label: "Claude", configured: true, active: false }),
+ brainProvider({ id: "openai", label: "OpenAI", active: true, computer_use_active: true }),
+ ];
+ const { calls } = installFetchMock();
+ render(<ApiKeysView />);
+
+ fireEvent.click(await screen.findByRole("tab", { name: /computer-use/i }));
+ const claudeCard = (await screen.findByText("Claude")).closest("li") as HTMLElement | null;
+ if (!claudeCard) throw new Error("Claude card not found");
+ fireEvent.click(within(claudeCard).getByRole("radio"));
+
+ // The backend call carries the BRAIN id, never a realtime id.
+ await waitFor(() =>
+ expect(
+ calls.some(
+ (c) =>
+ c.url === "/api/computer-use/switch" &&
+ c.method === "POST" &&
+ (c.body as { provider?: string })?.provider === "claude-api",
+ ),
+ ).toBe(true),
+ );
+
+ // The CU tab's own radio flips to Claude after the refetch.
+ await waitFor(() => {
+ const card = screen.getByText("Claude").closest("li") as HTMLElement;
+ expect(within(card).getByRole("radio")).toHaveProperty("checked", true);
+ });
+
+ // The Brain tab's real `active` (brain.primary) is untouched — still
+ // OpenAI — and no `/api/brain/switch` call was ever made.
+ fireEvent.click(screen.getByRole("tab", { name: /^brain$/i }));
+ const brainOpenAiCard = screen.getByText("OpenAI").closest("li") as HTMLElement;
+ expect(within(brainOpenAiCard).getByRole("radio")).toHaveProperty("checked", true);
+ expect(calls.some((c) => c.url.startsWith("/api/brain/switch"))).toBe(false);
+ });
+
+ it("renders the CU-model picker under the Computer-Use tab, keyed by the brain id", async () => {
+ providersState = [
+ brainProvider({ id: "openai", label: "OpenAI", active: true, computer_use_active: true }),
+ ];
+ installFetchMock();
+ render(<ApiKeysView />);
+
+ fireEvent.click(await screen.findByRole("tab", { name: /computer-use/i }));
+
+ expect(await screen.findByTestId("cu-model-selector-stub-openai")).toBeTruthy();
+ });
+});
diff --git a/jarvis/ui/web/frontend/src/views/ApiKeysView.realtime-cu.test.tsx b/jarvis/ui/web/frontend/src/views/ApiKeysView.realtime-cu.test.tsx
deleted file mode 100644
index 2760622d3e..0000000000
--- a/jarvis/ui/web/frontend/src/views/ApiKeysView.realtime-cu.test.tsx
+++ /dev/null
@@ -1,165 +0,0 @@
-/**
- * Integration test for Feature B: the Computer-Use panel embedded in Realtime
- * mode on the API-Keys screen.
- *
- * Confirms the wiring end-to-end inside `ApiKeysView` — the `active ===
- * "realtime"` branch renders `RealtimeCategory`, which renders the existing
- * `ProviderCategory` (the realtime cards, unchanged) followed by
- * `RealtimeComputerUsePanel` — and that Pipeline tabs (brain/tts/stt) are
- * completely unaffected by the Realtime-only change (the plan's binding
- * constraint: Pipeline stays byte-for-byte unaffected).
- */
-import { afterEach, describe, expect, it, vi } from "vitest";
-import { cleanup, fireEvent, render, screen } from "@testing-library/react";
-
-// ApiKeysView reads the live `[voice].mode` (for the Pipeline|Realtime mode
-// switch) via useVoiceMode, which needs a QueryClientProvider — mocked here
-// exactly like the other ApiKeysView.*.test.tsx files. realtimeAvailable=true
-// so clicking the Realtime segment actually switches (mirrors
-// ApiKeysView.two-mode.test.tsx).
-vi.mock("@/hooks/useVoiceMode", () => ({
- useVoiceMode: () => ({
- mode: "pipeline",
- realtimeAvailable: true,
- setMode: vi.fn(),
- isLoading: false,
- isSaving: false,
- }),
-}));
-
-// Stub CuModelSelector so this test asserts exactly what
-// RealtimeComputerUsePanel forwards to it, without pulling in its own model
-// catalog network calls (covered by CuModelSelector's own tests).
-vi.mock("@/components/CuModelSelector", () => ({
- CuModelSelector: ({ providerId }: { providerId: string }) => (
- <div data-testid="cu-model-selector-stub" data-provider-id={providerId} />
- ),
-}));
-
-const PROVIDERS = [
- {
- id: "openrouter",
- label: "OpenRouter",
- tier: "brain",
- auth_mode: "api_key",
- secret_keys: ["OPENROUTER_API_KEY"],
- secrets_set: { OPENROUTER_API_KEY: true },
- dashboard_url: null,
- login_cli: null,
- install_hint: null,
- credential_path_hint: null,
- configured: true,
- active: true,
- brain_switchable: true,
- cli_installed: null,
- credential_help: null,
- signup_url: null,
- billing: "api",
- recommended_model: "some-model",
- alt_credential: null,
- },
- {
- id: "openai-realtime",
- label: "OpenAI Realtime",
- tier: "realtime",
- auth_mode: "api_key",
- secret_keys: ["OPENAI_API_KEY"],
- secrets_set: { OPENAI_API_KEY: true },
- dashboard_url: null,
- login_cli: null,
- install_hint: null,
- credential_path_hint: null,
- configured: true,
- active: true,
- brain_switchable: true,
- cli_installed: null,
- credential_help: null,
- signup_url: null,
- billing: "api",
- alt_credential: null,
- },
-];
-
-function jsonResponse(body: unknown): Response {
- return {
- ok: true,
- status: 200,
- statusText: "OK",
- json: async () => body,
- text: async () => JSON.stringify(body),
- } as Response;
-}
-
-function installFetchMock() {
- const fetchMock = vi.fn(async (input: RequestInfo | URL) => {
- const url = String(input);
- if (url.startsWith("/api/providers/section-health")) {
- return jsonResponse({
- sections: {
- brain: { status: "ok", reason: "ok", detail: "" },
- tts: { status: "ok", reason: "ok", detail: "" },
- stt: { status: "ok", reason: "ok", detail: "" },
- realtime: { status: "ok", reason: "ok", detail: "" },
- subagents: { status: "unknown", reason: "unknown", detail: "" },
- advanced: { status: "unknown", reason: "unknown", detail: "" },
- },
- checked_at: 0,
- cached: false,
- });
- }
- if (url.startsWith("/api/providers")) {
- return jsonResponse({ providers: PROVIDERS });
- }
- if (url.startsWith("/api/openclaw/status")) {
- return jsonResponse({ mapping: [], brain_primary: "" });
- }
- throw new Error(`unexpected fetch ${url}`);
- });
- (globalThis as unknown as { fetch: typeof fetch }).fetch =
- fetchMock as unknown as typeof fetch;
-}
-
-import { ApiKeysView } from "@/views/ApiKeysView";
-
-afterEach(() => {
- cleanup();
- vi.restoreAllMocks();
-});
-
-describe("ApiKeysView — Realtime Computer-Use panel (Feature B)", () => {
- it("shows the Computer-Use panel naming the active Brain provider once Realtime is selected", async () => {
- installFetchMock();
- render(<ApiKeysView />);
-
- // Pipeline tabs are the default view — no realtime panel yet.
- expect(screen.getByRole("tab", { name: /^Brain$/i })).toBeTruthy();
- expect(screen.queryByTestId("realtime-cu-panel")).toBeNull();
-
- fireEvent.click(screen.getByRole("button", { name: /^realtime$/i }));
-
- const panel = await screen.findByTestId("realtime-cu-panel");
- expect(panel.textContent).toMatch(/OpenRouter/);
-
- // The BRAIN id ("openrouter"), never the realtime id ("openai-realtime").
- const stub = await screen.findByTestId("cu-model-selector-stub");
- expect(stub.getAttribute("data-provider-id")).toBe("openrouter");
- });
-
- it("switching back to Pipeline removes the Realtime Computer-Use panel, and Pipeline tabs are untouched", async () => {
- installFetchMock();
- render(<ApiKeysView />);
- fireEvent.click(screen.getByRole("button", { name: /^realtime$/i }));
- await screen.findByTestId("realtime-cu-panel");
-
- fireEvent.click(screen.getByRole("button", { name: /pipeline/i }));
-
- expect(screen.queryByTestId("realtime-cu-panel")).toBeNull();
- // The five Pipeline tabs render exactly as before Feature B.
- expect(screen.getByRole("tab", { name: /^Brain$/i })).toBeTruthy();
- expect(screen.getByRole("tab", { name: /voice output/i })).toBeTruthy();
- expect(screen.getByRole("tab", { name: /voice input/i })).toBeTruthy();
- expect(screen.getByRole("tab", { name: /jarvis-agents/i })).toBeTruthy();
- expect(screen.getByRole("tab", { name: /advanced/i })).toBeTruthy();
- expect(screen.queryByRole("tab", { name: /realtime/i })).toBeNull();
- });
-});
diff --git a/jarvis/ui/web/frontend/src/views/ApiKeysView.tsx b/jarvis/ui/web/frontend/src/views/ApiKeysView.tsx
index fbbfbacd63..3523684378 100644
--- a/jarvis/ui/web/frontend/src/views/ApiKeysView.tsx
+++ b/jarvis/ui/web/frontend/src/views/ApiKeysView.tsx
@@ -8,7 +8,6 @@ import { OpenRouterTtsControls } from "@/components/OpenRouterTtsVoicePicker";
import { CuModelSelector } from "@/components/CuModelSelector";
import { ProviderBillingBadge } from "@/components/ProviderBillingBadge";
import { JarvisAgentSection } from "@/components/JarvisAgentSection";
-import { RealtimeComputerUsePanel } from "@/components/RealtimeComputerUsePanel";
import { TelephonyPanel } from "@/views/TelephonyView";
import { WikiProviderCard } from "@/views/settings/WikiProviderCard";
import { JarvisApiGroup } from "@/views/settings/JarvisApiGroup";
@@ -25,6 +24,7 @@ import {
type SectionHealth,
startCodexLogin,
switchBrainProvider,
+ switchComputerUseProvider,
switchRealtimeProvider,
switchSttProvider,
switchTtsProvider,
@@ -54,8 +54,18 @@ type VoiceEngineMode = "pipeline" | "realtime";
// Realtime replaces STT+Brain+TTS with one full-duplex model, so those three
// tiers don't apply in Realtime mode — that's the whole reason for the split.
-const PIPELINE_TABS: CategoryKey[] = ["brain", "tts", "stt", "subagents", "advanced"];
-const REALTIME_TABS: CategoryKey[] = ["realtime", "subagents", "advanced"];
+// "computer-use" is GLOBAL (not mode-specific — Computer-Use is one engine for
+// the whole app), so it appears right after the main chat-model tab in BOTH
+// tab sets.
+const PIPELINE_TABS: CategoryKey[] = [
+ "brain",
+ "computer-use",
+ "tts",
+ "stt",
+ "subagents",
+ "advanced",
+];
+const REALTIME_TABS: CategoryKey[] = ["realtime", "computer-use", "subagents", "advanced"];
type LucideIcon = typeof Brain;
@@ -99,6 +109,12 @@ function makeProviderCategories(
description: t("apikeys_view.cat_realtime_desc"),
icon: Radio,
},
+ "computer-use": {
+ tab: t("apikeys_view.tab_computer_use"),
+ title: t("apikeys_view.tier_computer_use"),
+ description: t("apikeys_view.cat_computer_use_desc"),
+ icon: Terminal,
+ },
};
}
@@ -167,6 +183,17 @@ export function ApiKeysView() {
health={health.realtime}
/>
)}
+ {active === "computer-use" && (
+ <ComputerUseCategory
+ meta={categories["computer-use"]}
+ providers={providers}
+ loading={loading}
+ error={error}
+ onChanged={refetch}
+ onActivateOptimistic={setActiveOptimistic}
+ health={health["computer-use"]}
+ />
+ )}
{active === "subagents" && <SubagentCategory />}
{active === "advanced" && <AdvancedCategory />}
</div>
@@ -268,6 +295,7 @@ function CategoryTabs({
tts: { label: t("apikeys_view.tab_tts"), icon: Volume2 },
stt: { label: t("apikeys_view.tab_stt"), icon: Mic },
realtime: { label: t("apikeys_view.tab_realtime"), icon: Radio },
+ "computer-use": { label: t("apikeys_view.tab_computer_use"), icon: Terminal },
subagents: { label: t("apikeys_view.tab_subagents"), icon: Bot },
};
const coreTabs = tabs.filter(
@@ -490,12 +518,13 @@ function ProviderCategory({
/**
* The Realtime category (Feature B): the two realtime provider cards, via the
- * SAME `ProviderCategory` used for brain/tts/stt (unchanged), followed by the
- * Computer-Use delegation panel. Realtime speech-to-speech models can't see
- * the screen, so Computer-Use during a realtime turn falls back to the ACTIVE
- * Brain provider — exactly what CU already runs on today. This wrapper mirrors
- * `SubagentCategory` below: it owns nothing itself, it just composes the
- * existing tier section with the new read-through panel.
+ * SAME `ProviderCategory` used for brain/tts/stt (unchanged). Realtime
+ * speech-to-speech models can't see the screen, so Computer-Use during a
+ * realtime turn runs on the dedicated Computer-Use provider (or the active
+ * Brain provider, until one is picked) — now its own "Computer-Use" tab
+ * (see `ComputerUseCategory` below) rather than a panel embedded here. This
+ * wrapper mirrors `SubagentCategory` below: it owns nothing itself, it just
+ * composes the existing tier section.
*/
function RealtimeCategory({
meta,
@@ -515,19 +544,66 @@ function RealtimeCategory({
health?: SectionHealth;
}) {
return (
- <>
- <ProviderCategory
- meta={meta}
- tier="realtime"
- providers={providers}
- loading={loading}
- error={error}
- onChanged={onChanged}
- onActivateOptimistic={onActivateOptimistic}
- health={health}
- />
- <RealtimeComputerUsePanel />
- </>
+ <ProviderCategory
+ meta={meta}
+ tier="realtime"
+ providers={providers}
+ loading={loading}
+ error={error}
+ onChanged={onChanged}
+ onActivateOptimistic={onActivateOptimistic}
+ health={health}
+ />
+ );
+}
+
+/**
+ * The Computer-Use tab: an OVERLAY over the brain-tier provider cards
+ * (Claude/OpenAI/OpenRouter/Gemini), NOT a new provider tier. Reuses the SAME
+ * `ProviderCategory`/`TierSection`/`ProviderCard` machinery as Brain/TTS/STT
+ * by mapping every brain-switchable provider to a synthetic `"computer-use"`
+ * tier descriptor whose `active` mirrors `computer_use_active` — a SEPARATE
+ * selection from the Brain tab's `active`/`brain.primary`. The synthetic
+ * `tier` value forks the shared machinery cleanly: the radio group's
+ * `name="active-computer-use"` never collides with `name="active-brain"`,
+ * and `ProviderCard.activate()` routes to `switchComputerUseProvider` instead
+ * of `switchBrainProvider`. The CU provider is GLOBAL (one engine for the
+ * whole app), so this tab renders identically in Pipeline and Realtime mode —
+ * it replaces the old `RealtimeComputerUsePanel`, which only displayed the
+ * delegation without letting the user pick a provider.
+ */
+function ComputerUseCategory({
+ meta,
+ providers,
+ loading,
+ error,
+ onChanged,
+ onActivateOptimistic,
+ health,
+}: {
+ meta: CategoryMeta;
+ providers: ProviderDescriptor[];
+ loading: boolean;
+ error: string | null;
+ onChanged: () => void;
+ onActivateOptimistic: (tier: ProviderTier, id: string) => void;
+ health?: SectionHealth;
+}) {
+ const cuProviders: ProviderDescriptor[] = providers
+ .filter((p) => p.tier === "brain" && p.brain_switchable !== false)
+ .map((p) => ({ ...p, tier: "computer-use", active: !!p.computer_use_active }));
+
+ return (
+ <ProviderCategory
+ meta={meta}
+ tier="computer-use"
+ providers={cuProviders}
+ loading={loading}
+ error={error}
+ onChanged={onChanged}
+ onActivateOptimistic={onActivateOptimistic}
+ health={health}
+ />
);
}
@@ -729,6 +805,10 @@ function ProviderCard({
: "";
pushToast("success", `Voice input → ${descriptor.label}${note}`);
window.dispatchEvent(new CustomEvent("jarvis:stt-switched"));
+ } else if (descriptor.tier === "computer-use") {
+ await switchComputerUseProvider(descriptor.id);
+ pushToast("success", `Computer-Use → ${descriptor.label}`);
+ window.dispatchEvent(new CustomEvent("jarvis:computer-use-switched"));
} else {
const result = await switchRealtimeProvider(descriptor.id);
const note = result.restart_required
@@ -932,13 +1012,18 @@ function ProviderCard({
)}
{/* Phase 3: a dedicated Computer-Use model, selectable per brain provider
- (defaults to the provider's main model — no automatic escalation). */}
- {descriptor.tier === "brain" && descriptor.configured && isBrainSwitchable && (
- <CuModelSelector
- providerId={descriptor.id}
- recommendedModel={descriptor.recommended_model}
- />
- )}
+ (defaults to the provider's main model — no automatic escalation).
+ Also shown under the Computer-Use tab (synthetic "computer-use"
+ tier, same underlying brain id) — but never the plain
+ BrainModelSelector above, which stays Brain-tab-only. */}
+ {(descriptor.tier === "brain" || descriptor.tier === "computer-use") &&
+ descriptor.configured &&
+ isBrainSwitchable && (
+ <CuModelSelector
+ providerId={descriptor.id}
+ recommendedModel={descriptor.recommended_model}
+ />
+ )}
<ProviderTestControl providerId={descriptor.id} />
</div>