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.

feat(frontend): Pipeline|Realtime segmented view switch in API-Keys

Ruben Lütkea059800edb06
diff --git a/jarvis/ui/web/frontend/src/views/ApiKeysView.antigravity.test.tsx b/jarvis/ui/web/frontend/src/views/ApiKeysView.antigravity.test.tsx
index c7b6d354d9..af7abac909 100644
--- a/jarvis/ui/web/frontend/src/views/ApiKeysView.antigravity.test.tsx
+++ b/jarvis/ui/web/frontend/src/views/ApiKeysView.antigravity.test.tsx
@@ -16,6 +16,21 @@ import {
import { ApiKeysView } from "@/views/ApiKeysView";
+// ApiKeysView now reads the live `[voice].mode` (for the Pipeline|Realtime
+// mode switch's "Active" badge only) via useVoiceMode, which needs a
+// QueryClientProvider. These tests render ApiKeysView standalone, so the
+// hook is mocked — the mode switch itself is exercised by
+// ApiKeysView.two-mode.test.tsx.
+vi.mock("@/hooks/useVoiceMode", () => ({
+ useVoiceMode: () => ({
+ mode: "pipeline",
+ realtimeAvailable: false,
+ setMode: vi.fn(),
+ isLoading: false,
+ isSaving: false,
+ }),
+}));
+
interface RouteResult {
status?: number;
body: unknown;
diff --git a/jarvis/ui/web/frontend/src/views/ApiKeysView.codex.test.tsx b/jarvis/ui/web/frontend/src/views/ApiKeysView.codex.test.tsx
index ed0960b6e5..d9726fb550 100644
--- a/jarvis/ui/web/frontend/src/views/ApiKeysView.codex.test.tsx
+++ b/jarvis/ui/web/frontend/src/views/ApiKeysView.codex.test.tsx
@@ -16,6 +16,21 @@ import {
import { ApiKeysView } from "@/views/ApiKeysView";
+// ApiKeysView now reads the live `[voice].mode` (for the Pipeline|Realtime
+// mode switch's "Active" badge only) via useVoiceMode, which needs a
+// QueryClientProvider. These tests render ApiKeysView standalone, so the
+// hook is mocked — the mode switch itself is exercised by
+// ApiKeysView.two-mode.test.tsx.
+vi.mock("@/hooks/useVoiceMode", () => ({
+ useVoiceMode: () => ({
+ mode: "pipeline",
+ realtimeAvailable: false,
+ setMode: vi.fn(),
+ isLoading: false,
+ isSaving: false,
+ }),
+}));
+
interface RouteResult {
status?: number;
body: unknown;
diff --git a/jarvis/ui/web/frontend/src/views/ApiKeysView.section-health.test.tsx b/jarvis/ui/web/frontend/src/views/ApiKeysView.section-health.test.tsx
index 707318a027..643d298c6f 100644
--- a/jarvis/ui/web/frontend/src/views/ApiKeysView.section-health.test.tsx
+++ b/jarvis/ui/web/frontend/src/views/ApiKeysView.section-health.test.tsx
@@ -12,6 +12,21 @@ import { cleanup, render, screen, waitFor } from "@testing-library/react";
import { ApiKeysView } from "@/views/ApiKeysView";
+// ApiKeysView now reads the live `[voice].mode` (for the Pipeline|Realtime
+// mode switch's "Active" badge only) via useVoiceMode, which needs a
+// QueryClientProvider. These tests render ApiKeysView standalone, so the
+// hook is mocked — the mode switch itself is exercised by
+// ApiKeysView.two-mode.test.tsx.
+vi.mock("@/hooks/useVoiceMode", () => ({
+ useVoiceMode: () => ({
+ mode: "pipeline",
+ realtimeAvailable: false,
+ setMode: vi.fn(),
+ isLoading: false,
+ isSaving: false,
+ }),
+}));
+
interface RouteResult {
status?: number;
body: unknown;
diff --git a/jarvis/ui/web/frontend/src/views/ApiKeysView.telephony.test.tsx b/jarvis/ui/web/frontend/src/views/ApiKeysView.telephony.test.tsx
index 17a6870daf..c6adb52908 100644
--- a/jarvis/ui/web/frontend/src/views/ApiKeysView.telephony.test.tsx
+++ b/jarvis/ui/web/frontend/src/views/ApiKeysView.telephony.test.tsx
@@ -13,6 +13,21 @@ import { cleanup, fireEvent, render, screen, waitFor } from "@testing-library/re
import { ApiKeysView } from "@/views/ApiKeysView";
import { useEventStore } from "@/store/events";
+// ApiKeysView now reads the live `[voice].mode` (for the Pipeline|Realtime
+// mode switch's "Active" badge only) via useVoiceMode, which needs a
+// QueryClientProvider. These tests render ApiKeysView standalone, so the
+// hook is mocked — the mode switch itself is exercised by
+// ApiKeysView.two-mode.test.tsx.
+vi.mock("@/hooks/useVoiceMode", () => ({
+ useVoiceMode: () => ({
+ mode: "pipeline",
+ realtimeAvailable: false,
+ setMode: vi.fn(),
+ isLoading: false,
+ isSaving: false,
+ }),
+}));
+
interface RouteResult {
status?: number;
body: unknown;
diff --git a/jarvis/ui/web/frontend/src/views/ApiKeysView.tsx b/jarvis/ui/web/frontend/src/views/ApiKeysView.tsx
index 5b69d938f8..e692fbdaf1 100644
--- a/jarvis/ui/web/frontend/src/views/ApiKeysView.tsx
+++ b/jarvis/ui/web/frontend/src/views/ApiKeysView.tsx
@@ -1,4 +1,4 @@
-import { useState } from "react";
+import { useEffect, useState } from "react";
import { AlertCircle, Bot, Brain, Check, Copy, KeyRound, Loader2, LogIn, LogOut, Mic, Phone, PlugZap, Radio, SlidersHorizontal, Terminal, Volume2, XCircle } from "lucide-react";
import { ViewHeader } from "@/views/ChatsView";
import { AltCredentialNote } from "@/components/AltCredentialNote";
@@ -32,6 +32,7 @@ import {
useSectionHealth,
} from "@/hooks/useProviders";
import { useEventStore } from "@/store/events";
+import { useVoiceMode } from "@/hooks/useVoiceMode";
import { cn } from "@/lib/utils";
import { useT } from "@/i18n";
@@ -42,6 +43,18 @@ import { useT } from "@/i18n";
// so it never competes with the five core categories.
type CategoryKey = ProviderTier | "subagents" | "advanced";
+// The top-level engine mode. This is a VIEW-ONLY switch (D1, binding): it only
+// decides which tab set is shown, and NEVER writes `[voice].mode` or flips the
+// live voice engine — that stays a deliberate, separately-gated action. The
+// "Active" badge (seeded from the existing `useVoiceMode` hook) is the only
+// place the live engine state is read here, purely for display.
+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"];
+
type LucideIcon = typeof Brain;
interface CategoryMeta {
@@ -95,6 +108,19 @@ export function ApiKeysView() {
const { health } = useSectionHealth();
const categories = makeProviderCategories(t);
const [active, setActive] = useState<CategoryKey>("brain");
+ const [engineMode, setEngineMode] = useState<VoiceEngineMode>("pipeline");
+ // Read the LIVE `[voice].mode` for the "Active" badge only — never written
+ // back to from here. See VoiceEngineMode / EngineModeSwitch above.
+ const { mode: liveMode } = useVoiceMode();
+
+ // Reset the selected tab to the mode's first tab whenever the mode changes,
+ // so switching Pipeline→Realtime never leaves `active` pointing at a tab
+ // that no longer exists in the new mode (e.g. "tts").
+ useEffect(() => {
+ setActive(engineMode === "realtime" ? "realtime" : "brain");
+ }, [engineMode]);
+
+ const modeTabs = engineMode === "realtime" ? REALTIME_TABS : PIPELINE_TABS;
return (
<div className="flex h-full flex-col">
@@ -104,7 +130,9 @@ export function ApiKeysView() {
subtitle={t("apikeys_view.subtitle")}
/>
- <CategoryTabs active={active} onSelect={setActive} health={health} />
+ <EngineModeSwitch mode={engineMode} liveMode={liveMode} onSelect={setEngineMode} />
+
+ <CategoryTabs active={active} onSelect={setActive} health={health} tabs={modeTabs} />
<div className="flex-1 overflow-y-auto scrollbar-jarvis p-6">
{(active === "brain" ||
@@ -129,6 +157,59 @@ export function ApiKeysView() {
);
}
+/**
+ * The Pipeline|Realtime segmented VIEW switch (D1, binding). Clicking a
+ * segment ONLY calls `onSelect` (local view-state) — it must NEVER write
+ * `[voice].mode` or call any voice-mode mutation. The segment whose value
+ * matches the LIVE `[voice].mode` (from `useVoiceMode`, read-only here) shows
+ * a small "Active" badge, so the user always sees which engine is actually
+ * running without the switch itself being able to change it.
+ */
+function EngineModeSwitch({
+ mode,
+ liveMode,
+ onSelect,
+}: {
+ mode: VoiceEngineMode;
+ /** The live `[voice].mode` value, for the "Active" badge only. */
+ liveMode: string;
+ onSelect: (mode: VoiceEngineMode) => void;
+}) {
+ const t = useT();
+ const segments: { key: VoiceEngineMode; label: string }[] = [
+ { key: "pipeline", label: t("apikeys_view.mode_pipeline") },
+ { key: "realtime", label: t("apikeys_view.mode_realtime") },
+ ];
+
+ return (
+ <div className="border-b border-border px-6 pt-4">
+ <div className="inline-flex items-center gap-1 rounded-xl border border-border bg-card/40 p-1">
+ {segments.map((seg) => (
+ <button
+ key={seg.key}
+ type="button"
+ onClick={() => onSelect(seg.key)}
+ aria-pressed={mode === seg.key}
+ className={cn(
+ "inline-flex items-center gap-2 rounded-lg px-3.5 py-1.5 text-sm font-medium transition-colors",
+ mode === seg.key
+ ? "bg-primary/10 text-primary ring-1 ring-primary/30"
+ : "text-muted-foreground hover:bg-secondary/60 hover:text-foreground",
+ )}
+ >
+ {seg.label}
+ {liveMode === seg.key && (
+ <span className="rounded-full bg-emerald-500/15 px-1.5 py-0.5 text-[10px] uppercase tracking-wider text-emerald-600">
+ {t("apikeys_view.mode_active_badge")}
+ </span>
+ )}
+ </button>
+ ))}
+ </div>
+ </div>
+ );
+}
+
/**
* The segmented category navigation. The four core categories are grouped in one
* pill container; the de-emphasized "Advanced" tab is set apart by a divider and
@@ -139,47 +220,59 @@ function CategoryTabs({
active,
onSelect,
health,
+ tabs,
}: {
active: CategoryKey;
onSelect: (key: CategoryKey) => void;
/** Per-tab health rollup keyed by category; absent keys render no dot. */
health: Record<string, SectionHealth>;
+ /** The mode-derived tab list (PIPELINE_TABS / REALTIME_TABS) — "advanced",
+ * if present, is rendered separately (de-emphasized, past a divider). */
+ tabs: CategoryKey[];
}) {
const t = useT();
- const coreTabs: { key: CategoryKey; label: string; icon: LucideIcon }[] = [
- { key: "brain", label: t("apikeys_view.tab_brain"), icon: Brain },
- { key: "tts", label: t("apikeys_view.tab_tts"), icon: Volume2 },
- { key: "stt", label: t("apikeys_view.tab_stt"), icon: Mic },
- { key: "realtime", label: t("apikeys_view.tab_realtime"), icon: Radio },
- { key: "subagents", label: t("apikeys_view.tab_subagents"), icon: Bot },
- ];
+ const tabMeta: Record<Exclude<CategoryKey, "advanced">, { label: string; icon: LucideIcon }> = {
+ brain: { label: t("apikeys_view.tab_brain"), icon: Brain },
+ 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 },
+ subagents: { label: t("apikeys_view.tab_subagents"), icon: Bot },
+ };
+ const coreTabs = tabs.filter(
+ (key): key is Exclude<CategoryKey, "advanced"> => key !== "advanced",
+ );
+ const showAdvanced = tabs.includes("advanced");
return (
<div className="border-b border-border px-6 py-3">
<div role="tablist" className="flex flex-wrap items-center gap-1.5">
<div className="flex flex-wrap items-center gap-1 rounded-xl border border-border bg-card/40 p-1">
- {coreTabs.map((tab) => (
+ {coreTabs.map((key) => (
<TabButton
- key={tab.key}
- icon={tab.icon}
- label={tab.label}
- selected={active === tab.key}
- onClick={() => onSelect(tab.key)}
- health={health[tab.key]}
+ key={key}
+ icon={tabMeta[key].icon}
+ label={tabMeta[key].label}
+ selected={active === key}
+ onClick={() => onSelect(key)}
+ health={health[key]}
/>
))}
</div>
- <span
- className="mx-1 hidden h-6 w-px bg-border/70 sm:block"
- aria-hidden="true"
- />
- <TabButton
- icon={SlidersHorizontal}
- label={t("apikeys_view.tab_advanced")}
- selected={active === "advanced"}
- onClick={() => onSelect("advanced")}
- health={health.advanced}
- muted
- />
+ {showAdvanced && (
+ <>
+ <span
+ className="mx-1 hidden h-6 w-px bg-border/70 sm:block"
+ aria-hidden="true"
+ />
+ <TabButton
+ icon={SlidersHorizontal}
+ label={t("apikeys_view.tab_advanced")}
+ selected={active === "advanced"}
+ onClick={() => onSelect("advanced")}
+ health={health.advanced}
+ muted
+ />
+ </>
+ )}
</div>
</div>
);
diff --git a/jarvis/ui/web/frontend/src/views/ApiKeysView.two-mode.test.tsx b/jarvis/ui/web/frontend/src/views/ApiKeysView.two-mode.test.tsx
new file mode 100644
index 0000000000..3e6885a422
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/views/ApiKeysView.two-mode.test.tsx
@@ -0,0 +1,95 @@
+/**
+ * Component tests for the Pipeline|Realtime segmented VIEW switch on the
+ * API-Keys screen.
+ *
+ * D1 (binding): the switch is VIEW-ONLY. It must never write `[voice].mode`
+ * or call any voice-mode mutation — only the existing, separately-gated
+ * activation path does that. These tests pin (1) the mode-derived tab sets
+ * and (2) that clicking a segment never fires the `useVoiceMode` mutation.
+ */
+import { afterEach, describe, expect, it, vi } from "vitest";
+import { cleanup, fireEvent, render, screen } from "@testing-library/react";
+
+// Mock the data hooks so the view renders deterministically, without a
+// network round-trip.
+vi.mock("@/hooks/useProviders", () => ({
+ useProviders: () => ({
+ providers: [],
+ loading: false,
+ error: null,
+ refetch: vi.fn(),
+ setActiveOptimistic: vi.fn(),
+ }),
+ useSectionHealth: () => ({ health: {} }),
+}));
+
+// The real `useVoiceMode` hook (jarvis/ui/web/frontend/src/hooks/useVoiceMode.ts)
+// returns { mode, realtimeAvailable, setMode, isLoading, isSaving } — mock that
+// exact shape so the "Active" badge + the D1 no-mutation assertion are real.
+const putVoiceMode = vi.fn();
+vi.mock("@/hooks/useVoiceMode", () => ({
+ useVoiceMode: () => ({
+ mode: "pipeline",
+ realtimeAvailable: true,
+ setMode: putVoiceMode,
+ isLoading: false,
+ isSaving: false,
+ }),
+}));
+
+import { ApiKeysView } from "@/views/ApiKeysView";
+
+afterEach(() => {
+ cleanup();
+ vi.clearAllMocks();
+});
+
+describe("ApiKeysView two-mode", () => {
+ it("defaults to Pipeline mode showing Brain/Voice/Subagents tabs, no Realtime tab", () => {
+ render(<ApiKeysView />);
+ 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();
+ });
+
+ it("shows the segmented Pipeline|Realtime switch with an Active badge on the live mode", () => {
+ render(<ApiKeysView />);
+ const pipelineSegment = screen.getByRole("button", { name: /pipeline/i });
+ const realtimeSegment = screen.getByRole("button", { name: /^realtime$/i });
+ expect(pipelineSegment).toBeTruthy();
+ expect(realtimeSegment).toBeTruthy();
+ // The live [voice].mode from the mocked useVoiceMode is "pipeline", so
+ // only the Pipeline segment carries the "Active" badge.
+ expect(pipelineSegment.textContent).toMatch(/active/i);
+ expect(realtimeSegment.textContent).not.toMatch(/active/i);
+ });
+
+ it("switching to Realtime mode shows only Realtime/Subagents/Advanced and NEVER writes voice-mode", () => {
+ render(<ApiKeysView />);
+ fireEvent.click(screen.getByRole("button", { name: /^realtime$/i })); // the segment
+
+ expect(screen.getByRole("tab", { name: /realtime/i })).toBeTruthy();
+ expect(screen.getByRole("tab", { name: /jarvis-agents/i })).toBeTruthy();
+ expect(screen.getByRole("tab", { name: /advanced/i })).toBeTruthy();
+ expect(screen.queryByRole("tab", { name: /^brain$/i })).toBeNull();
+ expect(screen.queryByRole("tab", { name: /voice output/i })).toBeNull();
+ expect(screen.queryByRole("tab", { name: /voice input/i })).toBeNull();
+
+ // D1 (binding): the segment switch is view-only — it must never mutate
+ // the live voice engine.
+ expect(putVoiceMode).not.toHaveBeenCalled();
+ });
+
+ it("switching back to Pipeline restores the five pipeline tabs, still without mutating voice-mode", () => {
+ render(<ApiKeysView />);
+ fireEvent.click(screen.getByRole("button", { name: /^realtime$/i }));
+ fireEvent.click(screen.getByRole("button", { name: /pipeline/i }));
+
+ expect(screen.getByRole("tab", { name: /brain/i })).toBeTruthy();
+ expect(screen.queryByRole("tab", { name: /realtime/i })).toBeNull();
+ expect(putVoiceMode).not.toHaveBeenCalled();
+ });
+});