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(settings): bring back the list-and-detail Agents tab, slimmer

rubenluetke10-beep022c557976ab
diff --git a/jarvis/ui/web/frontend/src/components/PromptWriterCard.test.tsx b/jarvis/ui/web/frontend/src/components/PromptWriterCard.test.tsx
deleted file mode 100644
index 638cf29bc0..0000000000
--- a/jarvis/ui/web/frontend/src/components/PromptWriterCard.test.tsx
+++ /dev/null
@@ -1,109 +0,0 @@
-/**
- * Component tests for the brief-writer picker.
- *
- * The cases that matter are the ones where a wrong pixel means the wrong thing
- * gets billed, or a user cannot find out why their subscription sits idle:
- * that the CLI is named as the one THIS install connected rather than a vendor
- * this file guessed, that an option which cannot write is visible but
- * unselectable, and that a rejected save shows the server's reason instead of
- * a generic one — the server's reason is the one that names the fix.
- */
-import { afterEach, describe, expect, it, vi } from "vitest";
-import { cleanup, fireEvent, render, screen, waitFor } from "@testing-library/react";
-
-import { PromptWriterCard } from "@/components/PromptWriterCard";
-import { fetchPromptWriter, savePromptWriter } from "@/lib/agenticIdeApi";
-
-vi.mock("@/lib/agenticIdeApi", async () => {
- const actual =
- await vi.importActual<typeof import("@/lib/agenticIdeApi")>("@/lib/agenticIdeApi");
- return { ...actual, fetchPromptWriter: vi.fn(), savePromptWriter: vi.fn() };
-});
-
-const mockFetch = vi.mocked(fetchPromptWriter);
-const mockSave = vi.mocked(savePromptWriter);
-
-const STATE = {
- prompt_writer: "auto",
- options: [
- { id: "auto", label: "Automatic (your Tool Model, else the API model, else a connected subscription)", connected: true },
- { id: "tool_model", label: "Tool Model (Google Gemini - gemini-3.6-flash)", connected: true },
- { id: "subscription", label: "Any connected coding CLI (never an API key)", connected: true },
- { id: "api", label: "API model (billed per token)", connected: true },
- { id: "antigravity", label: "Antigravity (Google subscription)", connected: true },
- ],
-};
-
-afterEach(() => {
- cleanup();
- vi.clearAllMocks();
-});
-
-describe("PromptWriterCard", () => {
- it("names the Tool Model and the connected CLI as the server reports them", async () => {
- mockFetch.mockResolvedValue(STATE);
- render(<PromptWriterCard />);
-
- // The label carries the actual model, so the choice is informed rather
- // than a bare "Tool Model" the user has to go and look up.
- expect(
- await screen.findByText(/Tool Model \(Google Gemini - gemini-3\.6-flash\)/),
- ).toBeTruthy();
- // And the CLI is the one this install connected, under its own name.
- expect(screen.getByText("Antigravity (Google subscription)")).toBeTruthy();
- });
-
- it("persists the choice the user clicks", async () => {
- mockFetch.mockResolvedValue(STATE);
- mockSave.mockResolvedValue({ ...STATE, prompt_writer: "tool_model" });
- render(<PromptWriterCard />);
-
- fireEvent.click(await screen.findByText(/Tool Model \(Google Gemini/));
-
- await waitFor(() => expect(mockSave).toHaveBeenCalledWith("tool_model"));
- });
-
- it("shows an unusable option, but does not let it be chosen", async () => {
- // Hiding the row is what leaves "why is my subscription not an option?"
- // unanswerable from this screen.
- mockFetch.mockResolvedValue({
- prompt_writer: "auto",
- options: [
- { id: "auto", label: "Automatic", connected: true },
- { id: "tool_model", label: "Tool Model (none selected yet)", connected: false },
- ],
- });
- render(<PromptWriterCard />);
-
- const row = (await screen.findByText(/Tool Model \(none selected yet\)/)).closest(
- "button",
- );
- expect(row).toBeTruthy();
- expect((row as HTMLButtonElement).disabled).toBe(true);
-
- fireEvent.click(row as HTMLButtonElement);
- expect(mockSave).not.toHaveBeenCalled();
- });
-
- it("surfaces the server's own reason when a choice is refused", async () => {
- mockFetch.mockResolvedValue(STATE);
- mockSave.mockRejectedValue(
- new Error("No usable Tool Model is configured. Pick one in the Tool Model settings"),
- );
- render(<PromptWriterCard />);
-
- fireEvent.click(await screen.findByText(/Tool Model \(Google Gemini/));
-
- const alert = await screen.findByRole("alert");
- expect(alert.textContent).toContain("Pick one in the Tool Model settings");
- });
-
- it("says so when it cannot read the current setting", async () => {
- // An empty picker would read as "there are no options", which is a
- // different and wrong story.
- mockFetch.mockRejectedValue(new Error("offline"));
- render(<PromptWriterCard />);
-
- expect(await screen.findByRole("alert")).toBeTruthy();
- });
-});
diff --git a/jarvis/ui/web/frontend/src/components/PromptWriterCard.tsx b/jarvis/ui/web/frontend/src/components/PromptWriterCard.tsx
deleted file mode 100644
index ca1583d6fc..0000000000
--- a/jarvis/ui/web/frontend/src/components/PromptWriterCard.tsx
+++ /dev/null
@@ -1,208 +0,0 @@
-import { useCallback, useEffect, useState } from "react";
-import { Check, Loader2, Sparkles, Terminal, Wand2 } from "lucide-react";
-import {
- fetchPromptWriter,
- savePromptWriter,
- type PromptWriterOption,
- type PromptWriterState,
-} from "@/lib/agenticIdeApi";
-import { cn } from "@/lib/utils";
-import { useT } from "@/i18n";
-
-/**
- * Who writes Agentic-IDE task briefs: the Tool Model, or a connected coding CLI.
- *
- * The choice exists because the two are billed and sourced completely
- * differently — a coding CLI runs against a subscription the user already pays
- * for, the Tool Model against an API key billed per token — and until now the
- * decision was made for them by a resolver order they could not see. A user who
- * had deliberately pinned a strong Tool Model still found their briefs written
- * by whichever CLI happened to be signed in.
- *
- * Two properties this card has to keep:
- *
- * * **It names the real thing.** Every label comes from the server, which reads
- * it off the provider card — so the CLI shown is the one this install
- * actually connected, and the Tool Model row carries the model the user
- * picked. Nothing here hardcodes a vendor; an install with a CLI this file
- * has never heard of lists it correctly.
- * * **An option that cannot run is disabled, not hidden.** "Why is my
- * subscription not an option" is the question this screen exists to answer,
- * and a silently absent row answers nothing.
- */
-export function PromptWriterCard() {
- const t = useT();
- const [state, setState] = useState<PromptWriterState | null>(null);
- const [pending, setPending] = useState<string | null>(null);
- // Two separate failures, because they have different lifetimes. The load
- // error is a property of the current data; the save error is a message from
- // the server about the last thing the user tried, and it has to survive the
- // re-renders that follow. Holding both in one string let a re-render's
- // reload wipe the save error before it could be read.
- const [loadFailed, setLoadFailed] = useState(false);
- const [saveError, setSaveError] = useState("");
- const [loading, setLoading] = useState(true);
-
- // Deliberately no dependencies: this must run once per mount. Depending on
- // `t` re-ran it on every render, which reset the state mid-interaction.
- const load = useCallback(async () => {
- try {
- setState(await fetchPromptWriter());
- setLoadFailed(false);
- } catch {
- // A settings card that cannot read its own state says so rather than
- // rendering an empty picker that looks like "no options exist".
- setLoadFailed(true);
- } finally {
- setLoading(false);
- }
- }, []);
-
- useEffect(() => {
- void load();
- }, [load]);
-
- const choose = async (id: string) => {
- if (pending || state?.prompt_writer === id) return;
- setPending(id);
- setSaveError("");
- try {
- setState(await savePromptWriter(id));
- } catch (err) {
- // The server's own message names the blocker — an unsigned CLI, a Tool
- // Model with no key. Showing ours instead would send the user to fix the
- // wrong thing.
- setSaveError(
- err instanceof Error && err.message
- ? err.message
- : t("prompt_writer.save_failed"),
- );
- } finally {
- setPending(null);
- }
- };
-
- const error = saveError || (loadFailed ? t("prompt_writer.unavailable") : "");
-
- if (loading) {
- return (
- <div className="flex items-center gap-2 text-sm text-muted-foreground">
- <Loader2 className="h-3.5 w-3.5 animate-spin" />
- {t("prompt_writer.loading")}
- </div>
- );
- }
-
- const options = state?.options ?? [];
- const modes = options.filter((o) => MODE_IDS.has(o.id));
- const clis = options.filter((o) => !MODE_IDS.has(o.id));
-
- return (
- <div className="space-y-3" data-testid="prompt-writer-card">
- <div className="space-y-1">
- <h4 className="text-sm font-medium">{t("prompt_writer.title")}</h4>
- <p className="text-sm text-muted-foreground">
- {t("prompt_writer.description")}
- </p>
- </div>
-
- <div className="space-y-0.5">
- {modes.map((option) => (
- <WriterRow
- key={option.id}
- option={option}
- selected={state?.prompt_writer === option.id}
- pending={pending === option.id}
- disabled={pending !== null}
- onSelect={choose}
- />
- ))}
- </div>
-
- {clis.length > 0 && (
- <div className="space-y-0.5">
- <p className="px-2 pb-1 pt-2 text-xs text-muted-foreground">
- {t("prompt_writer.connected_clis")}
- </p>
- {clis.map((option) => (
- <WriterRow
- key={option.id}
- option={option}
- selected={state?.prompt_writer === option.id}
- pending={pending === option.id}
- disabled={pending !== null}
- onSelect={choose}
- />
- ))}
- </div>
- )}
-
- {error && (
- <p role="alert" className="text-xs leading-relaxed text-destructive">
- {error}
- </p>
- )}
- </div>
- );
-}
-
-/** The four selection MODES, as opposed to a concrete connected CLI. */
-const MODE_IDS = new Set(["auto", "tool_model", "subscription", "api"]);
-
-function iconFor(id: string) {
- if (id === "auto") return Wand2;
- if (id === "tool_model" || id === "api") return Sparkles;
- return Terminal;
-}
-
-function WriterRow({
- option,
- selected,
- pending,
- disabled,
- onSelect,
-}: {
- option: PromptWriterOption;
- selected: boolean;
- pending: boolean;
- disabled: boolean;
- onSelect: (id: string) => void;
-}) {
- const t = useT();
- const Icon = iconFor(option.id);
- // An unusable option stays visible but unselectable — except when it is
- // already the persisted choice, which the user needs to be able to see and
- // move away from.
- const blocked = !option.connected && !selected;
- return (
- <button
- type="button"
- role="radio"
- aria-checked={selected}
- disabled={blocked || disabled}
- onClick={() => onSelect(option.id)}
- className={cn(
- "flex w-full items-center gap-2.5 rounded-md px-2 py-1.5 text-left transition-colors",
- selected ? "bg-secondary text-foreground" : "text-muted-foreground hover:bg-secondary/50 hover:text-foreground",
- blocked && "cursor-not-allowed opacity-50 hover:bg-transparent",
- )}
- >
- <Icon className="h-3.5 w-3.5 shrink-0 text-muted-foreground" />
- <span className="min-w-0 flex-1 text-sm leading-snug">
- <span className="block truncate">{option.label}</span>
- {blocked && (
- <span className="block text-micro text-muted-foreground">
- {option.id === "tool_model"
- ? t("prompt_writer.tool_model_unset")
- : t("prompt_writer.not_connected")}
- </span>
- )}
- </span>
- {pending ? (
- <Loader2 className="h-3.5 w-3.5 shrink-0 animate-spin text-primary" />
- ) : (
- selected && <Check className="h-3.5 w-3.5 shrink-0 text-primary" />
- )}
- </button>
- );
-}
diff --git a/jarvis/ui/web/frontend/src/components/SubagentModelCard.test.tsx b/jarvis/ui/web/frontend/src/components/SubagentModelCard.test.tsx
deleted file mode 100644
index 3f50b40150..0000000000
--- a/jarvis/ui/web/frontend/src/components/SubagentModelCard.test.tsx
+++ /dev/null
@@ -1,97 +0,0 @@
-import { cleanup, fireEvent, render, screen, waitFor } from "@testing-library/react";
-import { afterEach, describe, expect, it, vi } from "vitest";
-
-// Identity translator so rendered text equals the i18n key (assert keys exactly).
-vi.mock("@/i18n", () => ({
- useT: () => (key: string) => key,
-}));
-
-vi.mock("@/store/events", () => ({
- useEventStore: (selector: (s: { pushToast: () => void }) => unknown) =>
- selector({ pushToast: vi.fn() }),
-}));
-
-import { SubagentModelCard, type SubagentStatus } from "./SubagentModelCard";
-
-const STATUS: SubagentStatus = {
- configured: true,
- enabled: true,
- binary_path: "openclaw",
- binary_detected: "/usr/bin/openclaw",
- version_pin: null,
- time_cap_min: null,
- concurrency: null,
- state_dir_root: null,
- brain_primary: "claude-api",
- provider_slug: "claude-cli",
- model_override: null,
- sub_model_override: "claude-sonnet-4-6",
- model_resolved: "claude-cli/claude-sonnet-4-6",
- mapping: [],
-};
-
-const MODELS = {
- provider: "claude-api",
- current_model: "claude-sonnet-4-6",
- models: [
- { id: "claude-opus-4-8", label: "Claude Opus 4.8" },
- { id: "claude-sonnet-4-6", label: "Claude Sonnet 4.6" },
- ],
- source: "static",
- fetched_at: 0,
- selects: "model",
-};
-
-function mockFetch() {
- return vi.fn().mockImplementation(async (url: string) => {
- const u = String(url);
- if (u.includes("/api/jarvis-agent/status")) return { ok: true, json: async () => STATUS };
- if (u.includes("/models")) return { ok: true, json: async () => MODELS };
- if (u.includes("/api/jarvis-agent/model")) {
- return {
- ok: true,
- json: async () => ({
- ok: true,
- model: "claude-opus-4-8",
- persisted: true,
- restart_required: true,
- }),
- };
- }
- return { ok: true, json: async () => ({}) };
- });
-}
-
-afterEach(() => {
- cleanup();
- vi.restoreAllMocks();
-});
-
-describe("SubagentModelCard — the agents' model dropdown", () => {
- it("opens a model dropdown for the active worker's provider", async () => {
- vi.stubGlobal("fetch", mockFetch());
- render(<SubagentModelCard status={STATUS} onSaved={() => undefined} />);
- const trigger = (await screen.findByLabelText("apikeys_model.model_label")) as HTMLElement;
- fireEvent.click(trigger);
- expect(await screen.findByText("claude-opus-4-8")).toBeTruthy();
- });
-
- it("saves a picked model via POST /api/jarvis-agent/model", async () => {
- const fetchMock = mockFetch();
- vi.stubGlobal("fetch", fetchMock);
- render(<SubagentModelCard status={STATUS} onSaved={() => undefined} />);
- const trigger = (await screen.findByLabelText("apikeys_model.model_label")) as HTMLElement;
- fireEvent.click(trigger);
- fireEvent.click(await screen.findByText("claude-opus-4-8"));
-
- await waitFor(() => {
- const post = fetchMock.mock.calls.find(
- (c) =>
- String(c[0]).includes("/api/jarvis-agent/model") &&
- (c[1] as RequestInit | undefined)?.method === "POST",
- );
- expect(post).toBeDefined();
- expect(JSON.parse((post![1] as RequestInit).body as string).model).toBe("claude-opus-4-8");
- });
- });
-});
diff --git a/jarvis/ui/web/frontend/src/components/SubagentModelCard.tsx b/jarvis/ui/web/frontend/src/components/SubagentModelCard.tsx
deleted file mode 100644
index c2a0da2ba4..0000000000
--- a/jarvis/ui/web/frontend/src/components/SubagentModelCard.tsx
+++ /dev/null
@@ -1,129 +0,0 @@
-import { BrainModelSelector } from "@/components/BrainModelSelector";
-import { LocalModelDownloadPanel } from "@/components/providers/ProviderTierSection";
-import { saveSubagentModel, useProviders, type Billing } from "@/hooks/useProviders";
-import { useT } from "@/i18n";
-
-/** Mirror of `GET /api/jarvis-agent/status` — the agents' worker bridge. */
-export interface SubagentMappingRow {
- jarvis: string;
- /** Server contract: the worker-harness provider slug (e.g. "google"). */
- worker_slug: string;
- env_var: string;
- env_fallback: string | null;
- key_set: boolean;
- api_key_set: boolean;
- dedicated_key_set: boolean;
- shared_key_set: boolean;
- oauth_connected: boolean;
- credential_source: string;
- secret_key: string | null;
- dashboard_url: string | null;
- credential_help: string | null;
- is_active_brain: boolean;
- /** Runs on the user's own hardware and has no credential at all. Such a card
- * is ready the moment it exists — asking it for a key locked a local-only
- * install out of picking any worker. */
- keyless?: boolean;
- /** The card's own display name from the provider spec, so the picker stops
- * showing raw ids ("local-openai") next to proper labels ("xAI Grok"). */
- label?: string | null;
- /** How this subagent is billed — "api" (per token) / "subscription" /
- * "subscription_or_api". Drives the billing badge so the API-vs-subscription
- * distinction is visible right on the subagent cards. */
- billing: Billing;
-}
-
-export interface SubagentStatus {
- configured: boolean;
- enabled: boolean;
- binary_path: string;
- binary_detected: string | null;
- version_pin: string | null;
- time_cap_min: number | null;
- concurrency: number | null;
- state_dir_root: string | null;
- brain_primary: string;
- provider_slug: string | null;
- model_override: string | null;
- /** The dedicated subagent LLM pin ([brain.sub_jarvis].model); empty/null
- * means "the active provider's deep model" (shown via model_resolved). */
- sub_model_override: string | null;
- model_resolved: string | null;
- mapping: SubagentMappingRow[];
-}
-
-/**
- * The dedicated subagent LLM model pin — the SAME dropdown as the brain cards,
- * showing the active subagent provider's catalog (``brain_primary``) and saving
- * through the subagent endpoint (POST /api/subagent/model) instead of the
- * per-provider model route. Empty selection = the provider's deep/frontier model
- * (shown in the hint via ``model_resolved``).
- */
-export function SubagentModelCard({
- status,
- onSaved,
-}: {
- status: SubagentStatus;
- onSaved: () => void;
-}) {
- const t = useT();
- // The subagent worker slug → the catalog provider id (Codex's worker slug
- // "openai-codex" maps to the catalog's "codex"; all others match 1:1).
- const catalogProvider =
- status.brain_primary === "openai-codex"
- ? "codex"
- : status.brain_primary === "grok-build"
- ? "grok-build"
- : status.brain_primary;
- // Whether the ACTIVE worker's server can be told to download a model. Read
- // off the provider catalog rather than a provider name, so a second local
- // server type that ships a puller lights this up on its own (AP-21).
- const { providers } = useProviders();
- const pullable = providers.find(
- (p) => p.id === catalogProvider && p.supports_model_pull,
- );
- return (
- <div className="space-y-3" data-testid="subagent-model-card">
- <h4 className="text-sm font-medium">{t("subagent_model.model_label")}</h4>
- <p className="text-sm text-muted-foreground">
- {t("subagent_model.description")}
- </p>
- {catalogProvider ? (
- <BrainModelSelector
- providerId={catalogProvider}
- currentModel={status.sub_model_override ?? ""}
- healthSection="subagents"
- healthActive
- onSave={async (model) => {
- const r = await saveSubagentModel(model);
- window.dispatchEvent(new Event("jarvis:agent-switched"));
- onSaved();
- return {
- ok: true,
- provider: status.brain_primary,
- model,
- persisted: r.persisted,
- applied_live: false,
- restart_required: r.restart_required,
- probe: null,
- };
- }}
- />
- ) : (
- <p className="text-xs text-muted-foreground">{t("subagent_model.model_hint")}</p>
- )}
- <p className="text-xs text-muted-foreground">
- {t("subagent_model.model_hint")}
- {status.model_resolved ? ` (${status.model_resolved})` : ""}
- </p>
-
- {/* The download panel, for a worker whose server can be told to fetch a
- model. Without it this tab dead-ended a local-only install: the picker
- above lists what the server HOLDS, so on a fresh Ollama it is empty,
- and the one screen that could fix that was three tabs away under
- Brain. Same panel, same endpoints — the capability flag decides. */}
- {pullable && <LocalModelDownloadPanel descriptor={pullable} onChanged={onSaved} />}
- </div>
- );
-}
-
diff --git a/jarvis/ui/web/frontend/src/components/providers/LiveProfile.test.tsx b/jarvis/ui/web/frontend/src/components/providers/LiveProfile.test.tsx
index 1f83f75e3e..f9a836b14a 100644
--- a/jarvis/ui/web/frontend/src/components/providers/LiveProfile.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/providers/LiveProfile.test.tsx
@@ -207,7 +207,7 @@ it("saves subscription voice without an API key and preserves the complete API s
const { client, writes, fetcher, onAuthModeChange } = subscriptionSetup();
await selectSubscription();
await screen.findByText("live.subscription_connected");
- expect(screen.getByText("live.subscription_voice_unverified")).toBeTruthy();
+ expect(screen.queryByText("live.subscription_voice_unverified")).toBeNull();
expect(screen.queryByText("live.key_required")).toBeNull();
expect(screen.queryByRole("button", { name: "live.use_for_agents" })).toBeNull();
await waitFor(() => expect((screen.getByRole("combobox", { name: "live.thinking_model" }) as HTMLButtonElement).disabled).toBe(false));
diff --git a/jarvis/ui/web/frontend/src/components/providers/LiveProfile.tsx b/jarvis/ui/web/frontend/src/components/providers/LiveProfile.tsx
index 81461a6b89..43dcc82d6a 100644
--- a/jarvis/ui/web/frontend/src/components/providers/LiveProfile.tsx
+++ b/jarvis/ui/web/frontend/src/components/providers/LiveProfile.tsx
@@ -7,7 +7,7 @@ import { BrandedSelect } from "@/components/ui/select";
import { Switch } from "@/components/ui/switch";
import { Textarea } from "@/components/ui/textarea";
import { Input } from "@/components/ui/input";
-import { Choice, Disclosure, Row, Rows, StatusLine } from "@/views/apikeys/ledger";
+import { Segmented, SettingsGroup, SettingsRow, SettingsSection } from "@/views/apikeys/settingsUi";
import { ProviderLogo } from "./ProviderLogo";
import { fetchAgentAccounts } from "@/lib/agentAccountsApi";
import { LiveSubscriptionAccount } from "./LiveSubscriptionAccount";
@@ -256,7 +256,6 @@ export function LiveProfile({ onSaved, onAuthModeChange, selectedAuthMode, keyFi
// "Saved & active" button read as a broken control; the saved state is a
// quiet line instead.
const showSave = !ready || dirty;
- const statusTone = billingPending ? "warn" : ready && !dirty ? "ok" : credentialReady ? "warn" : "off";
const statusText = billingPending
? t("live.billing_pending")
: ready && !dirty
@@ -265,191 +264,176 @@ export function LiveProfile({ onSaved, onAuthModeChange, selectedAuthMode, keyFi
? t("providers_page.voice_save_hint")
: t(subscription ? "live.subscription_sign_in" : "live.key_required");
return (
- <section
- aria-label="GPT-Live"
- data-testid="live-profile"
- className="grid gap-x-16 gap-y-10 lg:grid-cols-[minmax(0,22rem)_minmax(0,1fr)]"
- >
- {/* Left: what the voice is, whether it is ready, and how it is paid. */}
- <div className="min-w-0 lg:sticky lg:top-0 lg:self-start">
- <div className="flex items-center gap-3">
- <ProviderLogo providerId="openai-live" label="OpenAI" className="h-11 w-11" />
- <div className="min-w-0">
- <h2 className="text-lg font-semibold text-foreground-strong">GPT-Live</h2>
- <p className="text-sm text-muted-foreground">OpenAI</p>
- </div>
- </div>
- <p className="mt-4 text-sm text-muted-foreground">{t("live.conversation_help")}</p>
- <div className="mt-3" data-testid={ready && !dirty ? "live-profile-saved" : "live-profile-status"}>
- <StatusLine tone={statusTone}>{statusText}</StatusLine>
- </div>
-
- <div className="mt-8">
- <div className="flex items-center justify-between gap-4">
- <span className="text-sm font-medium text-foreground">{t("providers_page.access_title")}</span>
- {selectedAuthMode ? (
- <span className="text-sm text-muted-foreground">
- {subscription ? t("providers_page.access_subscription") : t("providers_page.access_api_key")}
- </span>
- ) : (
- <Choice<LiveAuthMode>
- value={authMode}
- disabled={saving}
- label={t("live.billing_method")}
- testId="live-access"
- onChange={(mode) => update({ auth_mode: mode })}
- options={[
- { value: "chatgpt_subscription", label: t("providers_page.access_subscription") },
- { value: "api_key", label: t("providers_page.access_api_key") },
- ]}
- />
- )}
- </div>
- <p className="mt-2 text-sm text-muted-foreground">
- {t(subscription ? "live.subscription_billing" : "live.billing")}
- </p>
- <div className="mt-4">
- {!subscription && keyField}
- {subscription && !supportsSubscription ? (
- <div className="flex items-center justify-between gap-4 py-2">
- <p className="text-sm text-muted-foreground">{t("settings_view.wake_word.restart_required")}</p>
- <Button size="sm" disabled={restart.restarting} onClick={() => void restart.restart()}>{restart.buttonLabel}</Button>
- </div>
- ) : null}
- {subscription && supportsSubscription ? (
- <>
- <LiveSubscriptionAccount group={group} accountId={value.subscription_account_id ?? ""}
- loading={accounts.isPending} disabled={saving}
- voiceStatus={profile.data?.subscription?.account_id === accountId
- ? profile.data.subscription.voice_status : "unverified"}
- onAccountChange={(subscription_account_id) => update({ subscription_account_id })}
- onConnected={() => {
- void queryClient.invalidateQueries({ queryKey: ["live-subscription-accounts"] });
- void queryClient.invalidateQueries({ queryKey: ["live-profile"] });
- void queryClient.invalidateQueries({ queryKey: ["live-options", "chatgpt_subscription"] });
- }} />
- {accounts.isError ? <p role="alert" className="mt-2 text-sm text-destructive">{t("live.subscription_accounts_failed")}</p> : null}
- </>
- ) : null}
- </div>
+ <section aria-label="GPT-Live" className="space-y-6" data-testid="live-profile">
+ <div className="space-y-2.5">
+ <div className="flex min-h-7 items-center justify-between gap-4 px-1">
+ <h2 className="flex min-w-0 items-center gap-2 text-sm font-normal text-foreground/70">
+ <ProviderLogo providerId="openai-live" label="OpenAI" size="sm" className="h-5 w-5" />
+ <span className="truncate">GPT-Live</span>
+ </h2>
+ <span
+ data-testid={ready && !dirty ? "live-profile-saved" : "live-profile-status"}
+ className="inline-flex items-center gap-1.5 text-xs text-muted-foreground"
+ >
+ <span
+ aria-hidden="true"
+ className={ready && !dirty ? "h-1.5 w-1.5 rounded-full bg-success" : "h-1.5 w-1.5 rounded-full bg-warning"}
+ />
+ {statusText}
+ </span>
</div>
+ <SettingsGroup>
+ <SettingsRow
+ title={t("providers_page.access_title")}
+ control={selectedAuthMode
+ ? <span className="text-sm text-muted-foreground">{subscription ? t("providers_page.access_subscription") : t("providers_page.access_api_key")}</span>
+ : <Segmented<LiveAuthMode>
+ size="xs"
+ value={authMode}
+ disabled={saving}
+ label={t("live.billing_method")}
+ testId="live-access"
+ onChange={(mode) => update({ auth_mode: mode })}
+ options={[
+ { value: "chatgpt_subscription", label: t("providers_page.access_subscription") },
+ { value: "api_key", label: t("providers_page.access_api_key") },
+ ]}
+ />}
+ />
+ {!subscription && keyField}
+ {subscription && !supportsSubscription ? (
+ <SettingsRow
+ title={t("live.subscription_mode")}
+ status={t("settings_view.wake_word.restart_required")}
+ control={<Button size="sm" disabled={restart.restarting} onClick={() => void restart.restart()}>{restart.buttonLabel}</Button>}
+ />
+ ) : null}
+ {subscription && supportsSubscription ? (
+ <div className="px-4 py-3">
+ <LiveSubscriptionAccount group={group} accountId={value.subscription_account_id ?? ""}
+ loading={accounts.isPending} disabled={saving}
+ voiceStatus={profile.data?.subscription?.account_id === accountId
+ ? profile.data.subscription.voice_status : "unverified"}
+ onAccountChange={(subscription_account_id) => update({ subscription_account_id })}
+ onConnected={() => {
+ void queryClient.invalidateQueries({ queryKey: ["live-subscription-accounts"] });
+ void queryClient.invalidateQueries({ queryKey: ["live-profile"] });
+ void queryClient.invalidateQueries({ queryKey: ["live-options", "chatgpt_subscription"] });
+ }} />
+ {accounts.isError ? <p role="alert" className="mt-2 text-xs text-destructive">{t("live.subscription_accounts_failed")}</p> : null}
+ </div>
+ ) : null}
+ </SettingsGroup>
</div>
- {/* Right: the few things a person tunes, one line each. */}
- <div className="min-w-0">
- <Rows>
- <Row
- title={t("live.voice")}
- description={subscription ? "GPT-Live · ChatGPT" : "GPT-Live 1"}
- control={
- <BrandedSelect
- className="w-60"
- value={voice}
- disabled={saving || (subscription && !options.data)}
- onValueChange={(selected) => choose(subscription ? { subscription_voice: selected } : { voice: selected })}
- ariaLabel={t("live.voice")}
- options={(options.data?.voices ?? (subscription ? [] : [voice])).map((voice) => ({
- value: voice,
- label: capitalize(voice),
- }))}
- />
- }
- />
- <Row
- title={t("live.thinking_model")}
- description={t(subscription ? "live.subscription_thinking_help" : "live.thinking_help")}
- control={
- <BrandedSelect
- className="w-60"
- value={backendModel}
- disabled={saving || (subscription && !options.data)}
- onValueChange={chooseModel}
- ariaLabel={t("live.thinking_model")}
- placeholder={t("live.choose_model")}
- searchPlaceholder={t("live.search_models")}
- options={modelOptions}
- />
- }
- />
- <Row
- title={t("live.reasoning")}
+ <SettingsSection title={t("live.conversation_heading")}>
+ <SettingsRow
+ title={t("live.voice")}
+ control={
+ <BrandedSelect
+ className="w-60"
+ value={voice}
+ disabled={saving || (subscription && !options.data)}
+ onValueChange={(selected) => choose(subscription ? { subscription_voice: selected } : { voice: selected })}
+ ariaLabel={t("live.voice")}
+ options={(options.data?.voices ?? (subscription ? [] : [voice])).map((voice) => ({
+ value: voice,
+ label: capitalize(voice),
+ }))}
+ />
+ }
+ />
+ </SettingsSection>
+
+ <SettingsSection title={t("live.thinking_heading")}>
+ <SettingsRow
+ title={t("live.thinking_model")}
+ control={
+ <BrandedSelect
+ className="w-60"
+ value={backendModel}
+ disabled={saving || (subscription && !options.data)}
+ onValueChange={chooseModel}
+ ariaLabel={t("live.thinking_model")}
+ placeholder={t("live.choose_model")}
+ searchPlaceholder={t("live.search_models")}
+ options={modelOptions}
+ />
+ }
+ />
+ <SettingsRow
+ title={t("live.reasoning")}
+ control={
+ <BrandedSelect
+ className="w-60"
+ value={reasoningEffort}
+ disabled={saving}
+ onValueChange={(selected) => choose(subscription ? { subscription_reasoning_effort: selected } : { reasoning_effort: selected })}
+ ariaLabel={t("live.reasoning")}
+ options={efforts.map((effort) => ({
+ value: effort,
+ label: effort ? capitalize(effort) : t("live.model_default"),
+ }))}
+ />
+ }
+ />
+ {!subscription && (
+ <SettingsRow
+ title={<label htmlFor="live-web-search">{t("live.web_search")}</label>}
control={
- <BrandedSelect
- className="w-60"
- value={reasoningEffort}
+ <Switch
+ id="live-web-search"
+ checked={value.web_search}
disabled={saving}
- onValueChange={(selected) => choose(subscription ? { subscription_reasoning_effort: selected } : { reasoning_effort: selected })}
- ariaLabel={t("live.reasoning")}
- options={efforts.map((effort) => ({
- value: effort,
- label: effort ? capitalize(effort) : t("live.model_default"),
- }))}
+ onCheckedChange={(web_search) => choose({ web_search })}
+ aria-label={t("live.web_search")}
/>
}
/>
- {!subscription && (
- <Row
- title={<label htmlFor="live-web-search">{t("live.web_search")}</label>}
- description={t("live.web_search_help")}
- control={
- <Switch
- id="live-web-search"
- checked={value.web_search}
- disabled={saving}
- onCheckedChange={(web_search) => choose({ web_search })}
- aria-label={t("live.web_search")}
- />
- }
- />
- )}
- </Rows>
+ )}
+ </SettingsSection>
- <div className="border-t border-border/60 pt-2">
- <Disclosure label={t("live.prompts")} testId="live-prompts">
- <div className="grid gap-4 pb-2 md:grid-cols-2">
- <label className="space-y-1.5">
- <span className="block text-sm text-muted-foreground">{t("live.conversation_prompt")}</span>
- <Textarea rows={3} value={value.instructions} onChange={(event) => update({ instructions: event.target.value })} />
- </label>
- <label className="space-y-1.5">
- <span className="block text-sm text-muted-foreground">{t("live.backend_prompt")}</span>
- <Textarea rows={3} value={value.backend_instructions} onChange={(event) => update({ backend_instructions: event.target.value })} />
- </label>
- {!subscription ? <label className="space-y-1.5 md:col-span-2">
- <span className="block text-sm text-muted-foreground">{t("live.custom_model")}</span>
- <Input value={value.backend_model} onChange={(event) => update({ backend_model: event.target.value })} />
- </label> : null}
- </div>
- </Disclosure>
+ <SettingsSection title={t("live.prompts")}>
+ <div className="grid gap-4 px-4 py-3 md:grid-cols-2">
+ <label className="space-y-1.5">
+ <span className="block text-xs text-muted-foreground">{t("live.conversation_prompt")}</span>
+ <Textarea rows={3} value={value.instructions} onChange={(event) => update({ instructions: event.target.value })} />
+ </label>
+ <label className="space-y-1.5">
+ <span className="block text-xs text-muted-foreground">{t("live.backend_prompt")}</span>
+ <Textarea rows={3} value={value.backend_instructions} onChange={(event) => update({ backend_instructions: event.target.value })} />
+ </label>
+ {!subscription ? <label className="space-y-1.5 md:col-span-2">
+ <span className="block text-xs text-muted-foreground">{t("live.custom_model")}</span>
+ <Input value={value.backend_model} onChange={(event) => update({ backend_model: event.target.value })} />
+ </label> : null}
</div>
+ </SettingsSection>
- <div className="mt-6 flex flex-col gap-3">
- {options.isError ? <p role="alert" className="text-sm text-destructive">{t("live.options_failed")}</p> : null}
- <div className="flex flex-wrap items-center justify-between gap-3">
- <p className="max-w-md text-sm text-muted-foreground">{t("live.agents_separate")}</p>
- <div className="flex items-center gap-2">
- {!subscription && sameCredentials && saved?.configured && !profile.data?.agent_configured && (
- <Button variant="outline" size="sm" disabled={saving} onClick={() => void useForAgents()}>
- {t("live.use_for_agents")}
- </Button>
- )}
- {showSave ? (
- <Button
- size="sm"
- disabled={saving || !backendModel.trim() || !credentialReady || !effortAvailable ||
- (subscription && (!options.data || options.isError || !models.some((model) => model.id === backendModel)))}
- onClick={() => void save()}
- >
- {saving && <Loader2 className="animate-spin" />}
- {ready ? t("live.save_changes") : t("live.save")}
- </Button>
- ) : null}
- </div>
- </div>
- {error && <p role="alert" className="text-sm text-destructive">{error}</p>}
- {message && <p role="status" className="text-sm text-muted-foreground">{message}</p>}
+ {(showSave || options.isError || error || message ||
+ (!subscription && sameCredentials && saved?.configured && !profile.data?.agent_configured)) && (
+ <div className="flex flex-wrap items-center justify-end gap-3 px-1">
+ {options.isError ? <p role="alert" className="mr-auto text-xs text-destructive">{t("live.options_failed")}</p> : null}
+ {error ? <p role="alert" className="mr-auto text-xs text-destructive">{error}</p> : null}
+ {message ? <p role="status" className="mr-auto text-xs text-muted-foreground">{message}</p> : null}
+ {!subscription && sameCredentials && saved?.configured && !profile.data?.agent_configured && (
+ <Button variant="outline" size="sm" disabled={saving} onClick={() => void useForAgents()}>
+ {t("live.use_for_agents")}
+ </Button>
+ )}
+ {showSave ? (
+ <Button
+ size="sm"
+ disabled={saving || !backendModel.trim() || !credentialReady || !effortAvailable ||
+ (subscription && (!options.data || options.isError || !models.some((model) => model.id === backendModel)))}
+ onClick={() => void save()}
+ >
+ {saving && <Loader2 className="animate-spin" />}
+ {ready ? t("live.save_changes") : t("live.save")}
+ </Button>
+ ) : null}
</div>
- </div>
+ )}
</section>
);
}
diff --git a/jarvis/ui/web/frontend/src/components/providers/LiveSubscriptionAccount.tsx b/jarvis/ui/web/frontend/src/components/providers/LiveSubscriptionAccount.tsx
index 49d78b6d31..9036ec10ae 100644
--- a/jarvis/ui/web/frontend/src/components/providers/LiveSubscriptionAccount.tsx
+++ b/jarvis/ui/web/frontend/src/components/providers/LiveSubscriptionAccount.tsx
@@ -226,9 +226,22 @@ export function LiveSubscriptionAccount({
return (
<div className="space-y-3">
- <label className="block space-y-2 text-sm">
- <span>{t("live.subscription_account")}</span>
+ {/* One settings row: the account and its state on the left, the
+ picker on the right. Only an unavailable voice says more. */}
+ <div className="flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between sm:gap-8">
+ <div className="min-w-0 space-y-1">
+ <div className="text-sm font-medium text-foreground">{t("live.subscription_account")}</div>
+ <p role="status" className="inline-flex items-center gap-1.5 text-xs text-muted-foreground">
+ <span aria-hidden="true" className={connected ? "h-1.5 w-1.5 rounded-full bg-success" : "h-1.5 w-1.5 rounded-full bg-border-strong"} />
+ {loading ? t("live.loading") : connected
+ ? t("live.subscription_connected") : t("live.subscription_sign_in_required")}
+ </p>
+ {connected && voiceStatus === "unavailable" ? (
+ <p className="text-xs text-warning">{t("live.subscription_voice_unavailable")}</p>
+ ) : null}
+ </div>
<BrandedSelect
+ className="w-60"
value={accountId}
disabled={disabled || loading || busy || installing}
ariaLabel={t("live.subscription_account")}
@@ -238,18 +251,7 @@ export function LiveSubscriptionAccount({
...(group?.accounts ?? []).map((entry) => ({ value: entry.id, label: entry.label })),
]}
/>
- </label>
- <p role="status" className="text-xs leading-relaxed text-muted-foreground">
- {loading ? t("live.loading") : connected
- ? t("live.subscription_connected") : t("live.subscription_sign_in_required")}
- </p>
- {connected ? (
- <p className="text-xs leading-relaxed text-muted-foreground">
- {t(voiceStatus === "ready" ? "live.subscription_voice_ready"
- : voiceStatus === "unavailable" ? "live.subscription_voice_unavailable"
- : "live.subscription_voice_unverified")}
- </p>
- ) : null}
+ </div>
{(!flow || flow.finished) && !connected ? (
cliMissing ? <div className="space-y-2">
<p role="status" className="text-xs leading-relaxed text-muted-foreground">
diff --git a/jarvis/ui/web/frontend/src/views/ApiKeysView.providers.test.tsx b/jarvis/ui/web/frontend/src/views/ApiKeysView.providers.test.tsx
index ce0339d884..be1ca3fb64 100644
--- a/jarvis/ui/web/frontend/src/views/ApiKeysView.providers.test.tsx
+++ b/jarvis/ui/web/frontend/src/views/ApiKeysView.providers.test.tsx
@@ -22,8 +22,6 @@ vi.mock("@/hooks/useVoiceMode", () => ({
// The sections below the providers own their data sources and have their own
// tests; here they only need to stay out of the way.
vi.mock("@/components/AgentAccountsPanel", () => ({ AgentAccountsPanel: () => null }));
-vi.mock("@/components/PromptWriterCard", () => ({ PromptWriterCard: () => null }));
-vi.mock("@/components/SubagentModelCard", () => ({ SubagentModelCard: () => null }));
// GPT-Live's own form has its own tests; here it only has to place the key row.
vi.mock("@/components/providers/LiveProfile", async (importOriginal) => ({
...(await importOriginal<typeof import("@/components/providers/LiveProfile")>()),
@@ -158,7 +156,7 @@ beforeEach(() => {
});
describe("ApiKeysView — Live calls", () => {
- it("opens on live calls with GPT-Live and one OpenAI key row", async () => {
+ it("opens on live calls with the GPT-Live pane and one OpenAI key row", async () => {
renderPage();
const voice = await screen.findByTestId("apikeys-voice");
expect(within(voice).getByTestId("live-profile")).toBeTruthy();
@@ -270,7 +268,6 @@ describe("ApiKeysView — Agents", () => {
const detail = await screen.findByTestId("agent-provider-detail-claude-api");
await waitFor(() => expect(detail.textContent).toContain("[email protected]"));
expect(within(detail).getByTestId("subscription-disconnect")).toBeTruthy();
- fireEvent.click(within(detail).getByRole("button", { name: "Runtime" }));
expect((within(detail).getByLabelText("Binary path") as HTMLInputElement).value).toBe("/usr/bin/claude");
});
});
diff --git a/jarvis/ui/web/frontend/src/views/ApiKeysView.tsx b/jarvis/ui/web/frontend/src/views/ApiKeysView.tsx
index 40e8f03e33..39d026f4cc 100644
--- a/jarvis/ui/web/frontend/src/views/ApiKeysView.tsx
+++ b/jarvis/ui/web/frontend/src/views/ApiKeysView.tsx
@@ -5,10 +5,11 @@ import { LiveProfile } from "@/components/providers/LiveProfile";
import { Button } from "@/components/ui/button";
import { AgentsTab } from "@/views/apikeys/AgentsTab";
import { KeyField } from "@/views/apikeys/KeyField";
-import { UnderlineTabs } from "@/views/apikeys/ledger";
+import { SettingsGroup } from "@/views/apikeys/settingsUi";
import { useProviders, useSectionHealth } from "@/hooks/useProviders";
import { useProviderFamilies } from "@/lib/providerFamilies";
import { useLocaleChunk, useT } from "@/i18n";
+import { cn } from "@/lib/utils";
import { useEventStore } from "@/store/events";
const TABS = ["voice", "agents"] as const;
@@ -26,15 +27,14 @@ function initialTab(): Tab {
}
/**
- * API Keys, in two parts:
+ * API Keys, in two parts behind one centred switch, both as a provider list
+ * beside the selected provider's settings:
*
* - Live calls: the live voice runs on OpenAI GPT-Live — paid with the
- * ChatGPT subscription or one OpenAI key — with its few settings;
+ * ChatGPT subscription or one OpenAI key — with its voice and the thinking
+ * model that answers with tools;
* - Agents: every company the assistant's agents can run on, any number of
* them on at once, each reached by its subscription or its API key.
- *
- * Both are set in type and hairlines on the page itself; nothing sits in a
- * box inside a box.
*/
export function ApiKeysView() {
const t = useT();
@@ -84,17 +84,14 @@ export function ApiKeysView() {
</Button>
}
/>
- <UnderlineTabs<Tab>
- value={tab}
- onChange={choose}
- label={t("apikeys_view.title")}
- options={TABS.map((value) => ({ value, label: t(`providers_page.tab_${value}`) }))}
- />
+ <div className="flex justify-center">
+ <TabSwitch value={tab} onChange={choose} />
+ </div>
</div>
<div
data-testid="api-keys-provider-scroll"
- className="min-h-0 flex-1 overflow-y-auto scrollbar-jarvis px-8 pb-12 pt-8"
+ className="min-h-0 flex-1 overflow-y-auto scrollbar-jarvis px-8 pb-10 pt-6"
>
<div key={tab} role="tabpanel" id="apikeys-panel" aria-labelledby={`apikeys-tab-${tab}`} className="profile-rise w-full">
{tab === "voice" && <VoiceTab data={families} onSaved={refetch} />}
@@ -110,28 +107,62 @@ export function ApiKeysView() {
);
}
+/** A segmented switch between the page's parts. */
+function TabSwitch({ value, onChange }: { value: Tab; onChange: (tab: Tab) => void }) {
+ const t = useT();
+ return (
+ <div
+ role="tablist"
+ aria-label={t("apikeys_view.title")}
+ data-testid="api-keys-category-tabs"
+ className="inline-flex rounded-lg border border-border/60 bg-card/40 p-0.5"
+ >
+ {TABS.map((tab) => (
+ <button
+ key={tab}
+ type="button"
+ role="tab"
+ id={`apikeys-tab-${tab}`}
+ aria-selected={value === tab}
+ aria-controls="apikeys-panel"
+ onClick={() => onChange(tab)}
+ className={cn(
+ "h-7 rounded-md px-3 text-sm font-medium transition-colors",
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
+ value === tab ? "bg-secondary text-foreground" : "text-muted-foreground hover:text-foreground",
+ )}
+ >
+ {t(`providers_page.tab_${tab}`)}
+ </button>
+ ))}
+ </div>
+ );
+}
+
/**
* Live calls run on OpenAI GPT-Live, the one live speech-to-speech model the
- * assistant runs: how it is paid for on the left, its few settings beside it.
+ * assistant runs — so the tab is that one provider's settings pane: how it is
+ * paid for, its voice and the thinking model that answers with tools.
*/
function VoiceTab({ data, onSaved }: { data: ReturnType<typeof useProviderFamilies>; onSaved: () => void }) {
const openai = data.families?.find((family) => family.id === "openai");
return (
- <div data-testid="apikeys-voice">
- <LiveProfile
- onSaved={onSaved}
- keyField={
- <KeyField
- stacked
- slot={openai?.key_slot ?? "openai_api_key"}
- present={openai?.key_present ?? false}
- providerLabel="OpenAI"
- dashboardUrl={openai?.dashboard_url}
- onChanged={() => void data.reload()}
- testId="voice-key"
- />
- }
- />
+ <div data-testid="apikeys-voice" className="mx-auto w-full max-w-3xl">
+ <SettingsGroup divided={false} className="p-4">
+ <LiveProfile
+ onSaved={onSaved}
+ keyField={
+ <KeyField
+ slot={openai?.key_slot ?? "openai_api_key"}
+ present={openai?.key_present ?? false}
+ providerLabel="OpenAI"
+ dashboardUrl={openai?.dashboard_url}
+ onChanged={() => void data.reload()}
+ testId="voice-key"
+ />
+ }
+ />
+ </SettingsGroup>
</div>
);
}
@@ -183,10 +214,15 @@ function RestartNeeded() {
}
return (
- <div role="status" data-testid="providers-restart-needed" className="flex items-center gap-6 border-y border-border/60 py-4">
+ <div
+ role="status"
+ data-testid="providers-restart-needed"
+ className="flex items-center gap-4 rounded-xl border border-border/60 bg-card/40 px-4 py-3"
+ >
+ <RefreshCw aria-hidden="true" className="h-4 w-4 shrink-0 text-muted-foreground" />
<div className="min-w-0 flex-1">
<p className="text-sm font-medium text-foreground">{t("providers_page.restart_title")}</p>
- <p className="mt-0.5 text-sm text-muted-foreground">{t("providers_page.restart_desc")}</p>
+ <p className="mt-0.5 text-xs text-muted-foreground">{t("providers_page.restart_desc")}</p>
</div>
<Button size="sm" disabled={restarting} onClick={() => void restart()}>
{restarting && <Loader2 className="animate-spin" />}
diff --git a/jarvis/ui/web/frontend/src/views/apikeys/AgentsTab.tsx b/jarvis/ui/web/frontend/src/views/apikeys/AgentsTab.tsx
index 43c7bedaa7..e0fe2842ec 100644
--- a/jarvis/ui/web/frontend/src/views/apikeys/AgentsTab.tsx
+++ b/jarvis/ui/web/frontend/src/views/apikeys/AgentsTab.tsx
@@ -1,11 +1,8 @@
-import { useEffect, useMemo, useState } from "react";
+import { useEffect, useMemo, useState, type ReactNode } from "react";
import { useQuery, useQueryClient } from "@tanstack/react-query";
-import { ChevronRight, FlaskConical, Loader2, LogIn, LogOut } from "lucide-react";
-import { AgentAccountsPanel } from "@/components/AgentAccountsPanel";
-import { PromptWriterCard } from "@/components/PromptWriterCard";
+import { Check, FlaskConical, Loader2, LogIn, LogOut } from "lucide-react";
import { ProviderLogo } from "@/components/providers/ProviderLogo";
import { ProviderTestControl } from "@/components/providers/ProviderTierSection";
-import { SubagentModelCard, type SubagentStatus } from "@/components/SubagentModelCard";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { Switch } from "@/components/ui/switch";
@@ -48,8 +45,17 @@ import { cn } from "@/lib/utils";
import { useEventStore } from "@/store/events";
import { KeyField } from "./KeyField";
import { accessPatch, familyAccess, nextDefault, onPatch, withPatch, type Access, type FamilyAccess } from "./agentAccess";
-import { Choice, Disclosure, Row, Rows, Section, StatusLine, ToggleChip } from "./ledger";
import { familyState, type FamilyState } from "./providers/familyState";
+import {
+ DetailHeader,
+ ListRow,
+ MasterDetail,
+ ModelList,
+ ModelListRow,
+ Segmented,
+ SettingsRow,
+ SettingsSection,
+} from "./settingsUi";
type FamiliesData = ReturnType<typeof useProviderFamilies>;
@@ -72,7 +78,6 @@ export function shortVersion(raw: string | null | undefined): string | null {
}
const SOCIETY_CATALOG_KEY = ["agent-chat", "catalog", "society"] as const;
-const TEST_TIER_ORDER: ProviderDescriptor["tier"][] = ["brain", "realtime", "tts", "stt", "dictation"];
/**
* The agents' provider choices and the one action that changes them: save a
@@ -139,10 +144,11 @@ function useAgentProviders(entriesFor: (prefs: AgentProviderPrefs) => FamilyAcce
type AgentProviders = ReturnType<typeof useAgentProviders>;
/**
- * The Agents tab: every company the assistant's agents can run on, one line
- * each. Any number are on at once; a line opens in place to set the company
- * up — how it is reached, whether it takes the tasks nobody assigned, and
- * which of its models the agents are offered.
+ * The Agents tab: every company the assistant's agents can run on, as one
+ * list beside the selected company's settings. Any number of companies are
+ * on at once — each one connected is one more seat an agent can sit on.
+ * Inside a company the person picks how it is reached (subscription or API
+ * key) and which of its models the agents are offered.
*/
export function AgentsTab({
data,
@@ -177,129 +183,116 @@ export function AgentsTab({
const entriesFor = (prefs: AgentProviderPrefs) => listed.map((f) => familyAccess(f, mapping, prefs, states[f.id]));
const control = useAgentProviders(entriesFor, agents?.brain_primary ?? "", refresh);
const entries = entriesFor(control.prefs);
- const [openId, setOpenId] = useState<string | null>(null);
- const onCount = entries.filter((entry) => entry.on).length;
+
+ const [selectedId, setSelectedId] = useState<string | null>(null);
+ useEffect(() => {
+ if (selectedId || !entries.length) return;
+ const primary = entries.find((fa) => fa.rows.some((row) => row.is_active_brain));
+ setSelectedId((primary ?? entries.find((fa) => fa.on) ?? entries[0]).family.id);
+ }, [entries, selectedId]);
+ const selected = entries.find((fa) => fa.family.id === selectedId) ?? null;
return (
- <div className="flex flex-col gap-14" data-testid="apikeys-agents">
- <Section
- title={t("providers_page.agent_providers_title")}
- description={t("providers_page.agent_providers_desc")}
- action={<span className="text-sm text-muted-foreground">{t("providers_page.agent_providers_count").replace("{0}", String(onCount))}</span>}
- data-testid="agents-providers"
- >
- <Rows>
- {entries.map((entry) => (
- <ProviderLine
- key={entry.family.id}
- entry={entry}
- state={states[entry.family.id]}
- open={openId === entry.family.id}
- onToggle={() => setOpenId((id) => (id === entry.family.id ? null : entry.family.id))}
+ <div className="flex flex-col gap-10" data-testid="apikeys-agents">
+ <SettingsSection title={t("providers_page.agent_providers_title")} plain data-testid="agents-providers">
+ <MasterDetail
+ testId="agent-provider-list"
+ list={entries.map((fa) => (
+ <ProviderListRow
+ key={fa.family.id}
+ entry={fa}
+ state={states[fa.family.id]}
+ selected={fa.family.id === selectedId}
+ onSelect={() => setSelectedId(fa.family.id)}
control={control}
- onChanged={refresh}
/>
))}
- </Rows>
- </Section>
-
- <AgentSettings />
-
- <div className="border-t border-border/60 pt-2">
- <Disclosure label={t("providers_page.accounts_title")} testId="agent-accounts">
- <AgentAccountsPanel />
- </Disclosure>
- </div>
+ detail={
+ selected && states[selected.family.id] ? (
+ <ProviderDetail
+ key={selected.family.id}
+ entry={selected}
+ state={states[selected.family.id]}
+ control={control}
+ onChanged={refresh}
+ />
+ ) : null
+ }
+ />
+ </SettingsSection>
</div>
);
}
+/** One entry per company, named and marked as the company, whichever access it uses. */
+function displayName(family: ProviderFamily): string {
+ return family.label;
+}
+
+function logoOf(family: ProviderFamily): string {
+ return family.logo_id;
+}
+
/** The line under a company's name: how it is reached, or what it still needs. */
-function entryStatus(entry: FamilyAccess, state: FamilyState | undefined, t: (key: string) => string): { tone: "ok" | "off" | "warn" | "error"; text: string } {
- if (state?.failing) return { tone: "error", text: state.failing };
- if (entry.access === "local") return { tone: "ok", text: t("providers_page.status_local") };
+function entryStatus(entry: FamilyAccess, state: FamilyState | undefined, t: (key: string) => string): string {
+ if (entry.access === "local") return t("providers_page.status_local");
if (entry.access === "subscription") {
- if (!state?.subscription) return { tone: "off", text: t("providers_page.subscription_unknown") };
+ if (!state?.subscription) return t("providers_page.subscription_unknown");
if (state.subscriptionOn) {
- return {
- tone: "ok",
- text: state.account ? t("providers_page.status_subscription_as").replace("{0}", state.account) : t("providers_page.status_subscription"),
- };
+ return state.account
+ ? t("providers_page.status_subscription_as").replace("{0}", state.account)
+ : t("providers_page.status_subscription");
}
- return { tone: "off", text: t(state.subscription.installed ? "providers_page.not_signed_in" : "providers_page.not_installed") };
+ if (!state.subscription.installed) return t("providers_page.not_installed");
+ return t("providers_page.not_signed_in");
}
- if (entry.family.key_present) return { tone: "ok", text: t("providers_page.status_key") };
- if (state?.viaProject) return { tone: "ok", text: t("providers_page.status_project") };
- return { tone: "off", text: t("providers_page.key_missing_short") };
+ if (entry.family.key_present) return t("providers_page.status_key");
+ if (state?.viaProject) return t("providers_page.status_project");
+ return t("providers_page.key_missing_short");
}
-function ProviderLine({
+function ProviderListRow({
entry,
state,
- open,
- onToggle,
+ selected,
+ onSelect,
control,
- onChanged,
}: {
entry: FamilyAccess;
state: FamilyState | undefined;
- open: boolean;
- onToggle: () => void;
+ selected: boolean;
+ onSelect: () => void;
control: AgentProviders;
- onChanged: () => Promise<void>;
}) {
const t = useT();
const family = entry.family;
- const status = entryStatus(entry, state, t);
- const version = entry.access === "subscription" ? shortVersion(state?.subscription?.version) : null;
- const isDefault = entry.on && entry.rows.some((row) => row.is_active_brain);
- const switchLabel = t("providers_page.agents_use_for").replace("{0}", family.label);
-
+ const name = displayName(family);
+ const label = t("providers_page.agents_use_for").replace("{0}", name);
return (
- <div data-testid={`agent-provider-${family.id}`}>
- <div className="flex items-center gap-4 py-3.5">
- <button
- type="button"
- aria-expanded={open}
- aria-label={family.label}
- onClick={onToggle}
- className="group flex min-w-0 flex-1 items-center gap-4 rounded-md text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
- >
- <ProviderLogo providerId={family.logo_id} label={family.label} className={cn(!entry.on && "opacity-60")} />
- <span className="min-w-0 flex-1">
- <span className="flex min-w-0 items-baseline gap-2">
- <span className={cn("truncate text-sm font-medium", entry.on ? "text-foreground" : "text-muted-foreground")}>{family.label}</span>
- {version ? <code className="shrink-0 text-xs text-muted-foreground">{version}</code> : null}
- {isDefault ? (
- <span className="shrink-0 rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-foreground">
- {t("providers_page.default_on")}
- </span>
- ) : null}
- </span>
- <span className="mt-0.5 flex min-w-0">
- <StatusLine tone={status.tone}>{status.text}</StatusLine>
- </span>
- </span>
- <ChevronRight
- aria-hidden="true"
- className={cn("h-4 w-4 shrink-0 text-muted-foreground transition-transform motion-reduce:transition-none", open && "rotate-90")}
- />
- </button>
+ <ListRow
+ testId={`agent-provider-${family.id}`}
+ icon={<ProviderLogo providerId={logoOf(family)} label={name} size="sm" className="h-5 w-5" />}
+ name={name}
+ version={entry.access === "subscription" ? shortVersion(state?.subscription?.version) : null}
+ status={entryStatus(entry, state, t)}
+ dot={state?.failing ? "error" : null}
+ selected={selected}
+ dimmed={!entry.on}
+ onSelect={onSelect}
+ trailing={
<Switch
checked={entry.on}
disabled={!entry.ready || !control.ready || control.busy !== null}
onCheckedChange={(on) => void control.save(family.id, onPatch(entry, on, control.prefs))}
- aria-label={switchLabel}
- title={entry.ready ? switchLabel : t("providers_page.agents_needs_access")}
+ aria-label={label}
+ title={entry.ready ? label : t("providers_page.agents_needs_access")}
/>
- </div>
- {open && state ? <ProviderSetup entry={entry} state={state} control={control} onChanged={onChanged} /> : null}
- </div>
+ }
+ />
);
}
-/** A company's setup, opened in place under its line. */
-function ProviderSetup({
+function ProviderDetail({
entry,
state,
control,
@@ -312,6 +305,7 @@ function ProviderSetup({
}) {
const t = useT();
const family = entry.family;
+ const name = displayName(family);
const subscription = entry.access === "subscription";
const keyed = entry.access === "api_key";
const testCard = keyed
@@ -319,81 +313,92 @@ function ProviderSetup({
: undefined;
return (
- <div data-testid={`agent-provider-detail-${family.id}`} className="pb-5 pl-[3.25rem]">
- <Rows>
- {entry.choices.length > 1 && (
- <Row
- title={t("providers_page.access_title")}
- description={t("providers_page.access_desc")}
- control={
- <Choice<Access>
- testId="agent-provider-access"
- label={t("providers_page.access_title")}
- value={entry.access}
- disabled={!control.ready || control.busy !== null}
- onChange={(access) => void control.save(family.id, accessPatch(entry, access, control.prefs))}
- options={entry.choices.map((choice) => ({ value: choice, label: t(`providers_page.access_${choice}`) }))}
- />
- }
- />
- )}
- {subscription && family.subscription && <AccountRow family={family} state={state} onChanged={onChanged} />}
- {keyed && family.key_slot && (
- <KeyField
- slot={family.key_slot}
- present={family.key_present}
- providerLabel={family.label}
- dashboardUrl={family.dashboard_url}
- description={state.viaProject && !family.key_present ? t("providers_page.key_project_hint") : t("providers_page.key_desc_short")}
+ <div data-testid={`agent-provider-detail-${family.id}`} className="space-y-6">
+ <div className="space-y-2.5">
+ <DetailHeader
+ icon={<ProviderLogo providerId={logoOf(family)} label={name} size="sm" className="h-5 w-5" />}
+ name={name}
+ version={subscription ? shortVersion(state.subscription?.version) : null}
+ />
+ <SettingsSectionCard>
+ {entry.choices.length > 1 && (
+ <SettingsRow
+ title={t("providers_page.access_title")}
+ control={
+ <Segmented<Access>
+ size="xs"
+ testId="agent-provider-access"
+ label={t("providers_page.access_title")}
+ value={entry.access}
+ disabled={!control.ready || control.busy !== null}
+ onChange={(access) => void control.save(family.id, accessPatch(entry, access, control.prefs))}
+ options={entry.choices.map((choice) => ({ value: choice, label: t(`providers_page.access_${choice}`) }))}
+ />
+ }
+ />
+ )}
+ {subscription && family.subscription && <SubscriptionAccountRow family={family} state={state} onChanged={onChanged} />}
+ {keyed && family.key_slot && (
+ <KeyField
+ slot={family.key_slot}
+ present={family.key_present}
+ providerLabel={family.label}
+ dashboardUrl={family.dashboard_url}
+ description={state.viaProject && !family.key_present ? t("providers_page.status_project") : undefined}
+ onChanged={onChanged}
+ />
+ )}
+ {entry.access === "local" && (
+ <SettingsRow title={t("providers_page.local_title")} />
+ )}
+ {entry.rows.map((row) => (
+ <DefaultRow
+ key={row.jarvis}
+ row={row}
+ label={family.local ? row.label ?? family.label : name}
+ entry={entry}
+ control={control}
+ />
+ ))}
+ {keyed && family.key_present && testCard && (
+ <SettingsRow
+ title={t("providers_page.key_test_label")}
+ control={<ProviderTestControl providerId={testCard.id} providerLabel={testCard.label} section={testCard.tier} active={testCard.active} />}
+ />
+ )}
+ </SettingsSectionCard>
+ </div>
+
+ {entry.rows.map((row) => (
+ <AgentModels
+ key={row.jarvis}
+ providerId={row.jarvis}
+ title={entry.rows.length > 1 ? `${t("providers_page.models_title")} · ${row.label ?? row.jarvis}` : t("providers_page.models_title")}
+ control={control}
+ familyId={family.id}
+ />
+ ))}
+
+ {subscription && family.subscription && state.subscription?.installed && (
+ <SettingsSection title={t("providers_page.runtime")}>
+ <BinaryPathRow
+ kind={family.subscription.kind}
+ path={"binary_path" in state.subscription ? state.subscription.binary_path ?? "" : ""}
onChanged={onChanged}
/>
- )}
- {entry.access === "local" && <Row title={t("providers_page.local_title")} description={t("providers_page.local_desc")} />}
- {entry.rows.map((row) => (
- <DefaultRow key={row.jarvis} row={row} label={family.local ? row.label ?? family.label : family.label} entry={entry} control={control} />
- ))}
- {entry.rows.map((row) => (
- <AgentModels
- key={`models-${row.jarvis}`}
- providerId={row.jarvis}
- title={entry.rows.length > 1 ? `${t("providers_page.models_title")} · ${row.label ?? row.jarvis}` : t("providers_page.models_title")}
- control={control}
- familyId={family.id}
+ <SettingsRow
+ title={t("providers_page.cli_check")}
+ control={<CliTest endpoint={CLI[family.subscription.kind].test} onChanged={onChanged} />}
/>
- ))}
- {keyed && family.key_present && testCard && (
- <Row
- title={t("providers_page.key_test_label")}
- description={t("providers_page.key_test_hint")}
- control={<ProviderTestControl providerId={testCard.id} providerLabel={testCard.label} section={testCard.tier} active={testCard.active} />}
- />
- )}
- {keyed && <SeparateKeys family={family} onChanged={onChanged} />}
- </Rows>
-
- {subscription && family.subscription && state.subscription?.installed && (
- <div className="border-t border-border/60 pt-1">
- <Disclosure label={t("providers_page.runtime")} testId={`agent-runtime-${family.id}`}>
- <Rows className="border-t-0">
- <BinaryPathRow
- kind={family.subscription.kind}
- path={"binary_path" in state.subscription ? state.subscription.binary_path ?? "" : ""}
- onChanged={onChanged}
- />
- <Row
- title={t("providers_page.cli_check")}
- description={t("providers_page.cli_check_hint")}
- control={<CliTest endpoint={CLI[family.subscription.kind].test} onChanged={onChanged} />}
- />
- </Rows>
- </Disclosure>
- </div>
+ </SettingsSection>
)}
+
+ {keyed && <SeparateKeys family={family} onChanged={onChanged} />}
</div>
);
}
-function AccountRow({ family, state, onChanged }: { family: ProviderFamily; state: FamilyState; onChanged: () => Promise<void> }) {
+function SubscriptionAccountRow({ family, state, onChanged }: { family: ProviderFamily; state: FamilyState; onChanged: () => Promise<void> }) {
const t = useT();
const pushToast = useEventStore((s) => s.pushToast);
const kind = family.subscription!.kind;
@@ -433,26 +438,28 @@ function AccountRow({ family, state, onChanged }: { family: ProviderFamily; stat
}
}
- const line = pending === "waiting"
- ? t(cli.where === "browser" ? "providers_page.login_waiting_browser" : "providers_page.login_waiting_terminal")
- : !status
- ? t("providers_page.subscription_unknown")
- : state.subscriptionOn
- ? state.account
- ? t("providers_page.authenticated_as").replace("{0}", state.account)
- : t("providers_page.authenticated")
- : !installed
- ? card?.install_hint || t("providers_page.subscription_install")
- : t("providers_page.not_signed_in");
+ const line = !state.subscription
+ ? t("providers_page.subscription_unknown")
+ : state.subscriptionOn
+ ? state.account
+ ? t("providers_page.authenticated_as").replace("{0}", state.account)
+ : t("providers_page.authenticated")
+ : !installed
+ ? card?.install_hint || t("providers_page.subscription_install")
+ : t("providers_page.not_signed_in");
return (
- <Row
+ <SettingsRow
data-testid={`subscription-account-${kind}`}
title={t("providers_page.account")}
- description={line}
+ status={
+ pending === "waiting"
+ ? t(cli.where === "browser" ? "providers_page.login_waiting_browser" : "providers_page.login_waiting_terminal")
+ : line
+ }
control={
state.subscriptionOn ? (
- <Button size="sm" variant="ghost" className="text-muted-foreground" data-testid="subscription-disconnect" disabled={pending !== null} onClick={() => void disconnect()}>
+ <Button size="sm" variant="outline" data-testid="subscription-disconnect" disabled={pending !== null} onClick={() => void disconnect()}>
{pending === "logout" ? <Loader2 className="animate-spin" /> : <LogOut />}
{t("providers_page.disconnect")}
</Button>
@@ -475,17 +482,20 @@ function DefaultRow({ row, label, entry, control }: { row: AgentRowStatus; label
const t = useT();
const isDefault = row.is_active_brain && entry.on;
return (
- <Row
+ <SettingsRow
data-testid={`agent-default-row-${row.jarvis}`}
title={t("providers_page.default_title")}
- description={!entry.ready ? t("providers_page.agents_needs_access") : t("providers_page.default_desc")}
+ status={!entry.ready ? t("providers_page.agents_needs_access") : undefined}
control={
isDefault ? (
- <span className="text-sm font-medium text-foreground">{t("providers_page.default_on")}</span>
+ <span className="inline-flex items-center gap-1.5 text-sm font-medium text-foreground">
+ <Check aria-hidden="true" className="h-4 w-4 text-accent" />
+ {t("providers_page.default_on")}
+ </span>
) : (
<Button
size="sm"
- variant="ghost"
+ variant="outline"
data-testid={`agent-make-default-${row.jarvis}`}
disabled={!entry.on || control.busy !== null}
onClick={() => void control.chooseDefault(row, label)}
@@ -500,8 +510,8 @@ function DefaultRow({ row, label, entry, control }: { row: AgentRowStatus; label
}
/**
- * The models a provider offers the agents, as chips: a chip switched off is
- * left out of every agent's model picker.
+ * The models a provider offers the agents, each with a switch: a model
+ * switched off is left out of every agent's model picker.
*/
function AgentModels({ providerId, title, control, familyId }: { providerId: string; title: string; control: AgentProviders; familyId: string }) {
const t = useT();
@@ -527,43 +537,55 @@ function AgentModels({ providerId, title, control, familyId }: { providerId: str
const busy = !control.ready || control.busy !== null;
return (
- <Row
- data-testid={`agent-models-${providerId}`}
- title={title}
- description={
- models.length === 0
- ? loading ? t("providers_page.models_loading") : t("providers_page.models_none")
- : t("providers_page.models_count").replace("{0}", String(shown)).replace("{1}", String(models.length))
- }
- control={
- models.length > 0 ? (
- <Button
- size="sm"
- variant="ghost"
- className="text-muted-foreground"
- disabled={busy}
- onClick={() => setHidden(shown === 0 ? [] : models.map((model) => model.id))}
- >
- {shown === 0 ? t("providers_page.models_show_all") : t("providers_page.models_hide_all")}
- </Button>
- ) : undefined
- }
- >
- {models.length > 0 ? (
- <div className="flex flex-wrap gap-1.5">
+ <SettingsSection title={title} plain data-testid={`agent-models-${providerId}`}>
+ {models.length === 0 ? (
+ <div className="rounded-xl border border-border/60 bg-card/40 px-4 py-3 text-xs text-muted-foreground">
+ {loading ? t("providers_page.models_loading") : t("providers_page.models_none")}
+ </div>
+ ) : (
+ <ModelList
+ header={t("providers_page.models_count").replace("{0}", String(shown)).replace("{1}", String(models.length))}
+ action={
+ <Button
+ size="sm"
+ variant="ghost"
+ className="h-7 text-xs"
+ disabled={busy}
+ onClick={() => setHidden(shown === 0 ? [] : models.map((model) => model.id))}
+ >
+ {shown === 0 ? t("providers_page.models_show_all") : t("providers_page.models_hide_all")}
+ </Button>
+ }
+ >
{models.map((model) => (
- <ToggleChip
+ <ModelListRow
key={model.id}
- on={!hidden.has(model.id)}
- label={model.label || model.id}
- hint={model.id}
- disabled={busy}
- onToggle={() => setHidden(toggled([...hidden], [model.id], hidden.has(model.id)))}
+ name={model.label || model.id}
+ id={model.id}
+ note={model.note ?? (model.efforts?.length ? t("providers_page.models_reasoning") : null)}
+ muted={hidden.has(model.id)}
+ control={
+ <Switch
+ checked={!hidden.has(model.id)}
+ disabled={busy}
+ onCheckedChange={(on) => setHidden(toggled([...hidden], [model.id], on))}
+ aria-label={model.label || model.id}
+ />
+ }
/>
))}
- </div>
- ) : null}
- </Row>
+ </ModelList>
+ )}
+ </SettingsSection>
+ );
+}
+
+/** A plain card (no section title) for the rows under a detail header. */
+function SettingsSectionCard({ children }: { children: ReactNode }) {
+ return (
+ <div className="overflow-hidden rounded-xl border border-border/60 bg-card/40 [&>*+*]:border-t [&>*+*]:border-border/50">
+ {children}
+ </div>
);
}
@@ -588,9 +610,8 @@ function BinaryPathRow({ kind, path, onChanged }: { kind: SubscriptionKind; path
}
return (
- <Row
+ <SettingsRow
title={t("providers_page.binary_path")}
- description={t("providers_page.binary_path_hint")}
control={
<Input
value={draft}
@@ -602,7 +623,7 @@ function BinaryPathRow({ kind, path, onChanged }: { kind: SubscriptionKind; path
onKeyDown={(event) => {
if (event.key === "Enter") void commit();
}}
- className={cn("h-8 font-mono text-sm sm:w-80", !editable && "text-muted-foreground")}
+ className={cn("h-8 font-mono text-sm sm:w-72", !editable && "text-muted-foreground")}
/>
}
/>
@@ -636,12 +657,12 @@ function CliTest({ endpoint, onChanged }: { endpoint: string; onChanged: () => P
<span
role="status"
title={error ?? result?.message}
- className={cn("max-w-[16rem] truncate text-sm", error || (result && !result.ok) ? "text-destructive" : "text-muted-foreground")}
+ className={cn("max-w-[16rem] truncate text-xs", error || (result && !result.ok) ? "text-destructive" : "text-muted-foreground")}
>
{error ?? result?.message}
</span>
)}
- <Button size="sm" variant="ghost" disabled={running} onClick={() => void run()}>
+ <Button size="sm" variant="outline" disabled={running} onClick={() => void run()}>
{running ? <Loader2 className="animate-spin" /> : <FlaskConical />}
{t("providers_page.test")}
</Button>
@@ -649,6 +670,8 @@ function CliTest({ endpoint, onChanged }: { endpoint: string; onChanged: () => P
);
}
+const TEST_TIER_ORDER: ProviderDescriptor["tier"][] = ["brain", "realtime", "tts", "stt", "dictation"];
+
/** Features that still hold a key of their own, each with a way back onto the main key. */
function SeparateKeys({ family, onChanged }: { family: ProviderFamily; onChanged: () => Promise<void> }) {
const t = useT();
@@ -671,17 +694,16 @@ function SeparateKeys({ family, onChanged }: { family: ProviderFamily; onChanged
}
return (
- <>
+ <SettingsSection title={t("providers_page.separate_title")}>
{family.separate_keys.map((entry) => (
- <Row
+ <SettingsRow
key={entry.slot}
data-testid={`provider-separate-key-${entry.slot}`}
title={t(`providers_page.separate_${entry.surface}`)}
- description={t("providers_page.separate_hint")}
control={
<Button
size="sm"
- variant="ghost"
+ variant="outline"
disabled={merging !== null || !family.key_present}
title={family.key_present ? undefined : t("providers_page.separate_needs_main")}
onClick={() => void merge(entry.slot)}
@@ -692,40 +714,6 @@ function SeparateKeys({ family, onChanged }: { family: ProviderFamily; onChanged
}
/>
))}
- </>
- );
-}
-
-/**
- * Settings that belong to the agents rather than to one provider: the model
- * a worker thinks with and who writes the task briefs.
- */
-function AgentSettings() {
- const t = useT();
- const [status, setStatus] = useState<SubagentStatus | null>(null);
- const reload = async () => {
- try {
- const res = await fetch("/api/jarvis-agent/status", { cache: "no-store" });
- if (res.ok) setStatus((await res.json()) as SubagentStatus);
- } catch (cause) {
- // The model picker stays hidden; the list above reports the same
- // endpoint's failure.
- console.debug("agent status unavailable", cause);
- }
- };
- useEffect(() => {
- void reload();
- const onChange = () => void reload();
- window.addEventListener("jarvis:agent-switched", onChange);
- return () => window.removeEventListener("jarvis:agent-switched", onChange);
- }, []);
-
- return (
- <Section title={t("providers_page.agent_settings_title")} description={t("providers_page.agent_settings_desc")} data-testid="provider-agent-settings">
- <div className="grid gap-x-12 gap-y-6 border-t border-border/60 pt-5 xl:grid-cols-2">
- {status && <SubagentModelCard status={status} onSaved={() => void reload()} />}
- <PromptWriterCard />
- </div>
- </Section>
+ </SettingsSection>
);
}
diff --git a/jarvis/ui/web/frontend/src/views/apikeys/KeyField.tsx b/jarvis/ui/web/frontend/src/views/apikeys/KeyField.tsx
index c33fe89cf0..8e171d4846 100644
--- a/jarvis/ui/web/frontend/src/views/apikeys/KeyField.tsx
+++ b/jarvis/ui/web/frontend/src/views/apikeys/KeyField.tsx
@@ -7,7 +7,7 @@ import { useT } from "@/i18n";
import { keyMatchesSecret } from "@/lib/keyFormat";
import { openExternalUrl } from "@/lib/openExternal";
import { useEventStore } from "@/store/events";
-import { Row } from "./ledger";
+import { SettingsRow } from "./settingsUi";
function announce(slot: string, action: "set" | "delete") {
// Every mounted list and the health dots re-read. Only the slot NAME
@@ -30,7 +30,6 @@ export function KeyField({
description,
onChanged,
testId = "provider-key",
- stacked = false,
}: {
slot: string;
present: boolean;
@@ -40,8 +39,6 @@ export function KeyField({
description?: string;
onChanged?: () => void | Promise<void>;
testId?: string;
- /** Field under the text, full width — for a narrow column. */
- stacked?: boolean;
}) {
const t = useT();
const pushToast = useEventStore((s) => s.pushToast);
@@ -99,8 +96,8 @@ export function KeyField({
) : null;
const control = showInput ? (
- <div className={stacked ? "flex w-full items-center gap-2" : "flex w-full items-center gap-2 sm:w-auto"}>
- <div className={stacked ? "relative min-w-0 flex-1" : "relative min-w-0 flex-1 sm:w-72 sm:flex-none"}>
+ <div className="flex w-full items-center gap-2 sm:w-auto">
+ <div className="relative min-w-0 flex-1 sm:w-72 sm:flex-none">
<Input
type={reveal ? "text" : "password"}
autoComplete="off"
@@ -167,38 +164,31 @@ export function KeyField({
</>
);
- const statusNode = (
- <span className="flex flex-wrap items-center gap-x-3 gap-y-1">
- <span className="inline-flex items-center gap-1.5">
- <span aria-hidden="true" className={present ? "h-1.5 w-1.5 rounded-full bg-success" : "h-1.5 w-1.5 rounded-full bg-border-strong"} />
- {confirmDelete
- ? t("providers_page.key_remove_confirm")
- : present
- ? t("providers_page.key_saved_hint")
- : t("providers_page.key_missing_hint")}
- </span>
- {getKey}
- {format && !format.match && format.detected && (
- <span role="status" className="inline-flex items-center gap-1 text-warning">
- <AlertTriangle aria-hidden="true" className="h-3.5 w-3.5" />
- {t("providers_page.key_format_warning")
- .replace("{0}", format.detected.label)
- .replace("{1}", providerLabel)}
- </span>
- )}
- </span>
- );
-
return (
- <Row
+ <SettingsRow
data-testid={testId}
- stacked={stacked}
title={title ?? t("providers_page.key_label")}
- description={
- <>
- {description ? <span className="block">{description}</span> : null}
- <span className={description ? "mt-1.5 block" : "block"}>{statusNode}</span>
- </>
+ description={description}
+ status={
+ <span className="flex flex-wrap items-center gap-x-2 gap-y-1">
+ <span className="inline-flex items-center gap-1.5">
+ <span aria-hidden="true" className={present ? "h-1.5 w-1.5 rounded-full bg-success" : "h-1.5 w-1.5 rounded-full bg-border-strong"} />
+ {confirmDelete
+ ? t("providers_page.key_remove_confirm")
+ : present
+ ? t("providers_page.key_saved_short")
+ : t("providers_page.key_missing_short")}
+ </span>
+ {getKey}
+ {format && !format.match && format.detected && (
+ <span role="status" className="inline-flex items-center gap-1 text-warning">
+ <AlertTriangle aria-hidden="true" className="h-3.5 w-3.5" />
+ {t("providers_page.key_format_warning")
+ .replace("{0}", format.detected.label)
+ .replace("{1}", providerLabel)}
+ </span>
+ )}
+ </span>
}
control={control}
/>
diff --git a/jarvis/ui/web/frontend/src/views/apikeys/ledger.tsx b/jarvis/ui/web/frontend/src/views/apikeys/ledger.tsx
deleted file mode 100644
index 9f1301e7d7..0000000000
--- a/jarvis/ui/web/frontend/src/views/apikeys/ledger.tsx
+++ /dev/null
@@ -1,250 +0,0 @@
-import { useState, type ComponentPropsWithoutRef, type ReactNode } from "react";
-import { ChevronRight } from "lucide-react";
-import { cn } from "@/lib/utils";
-
-/**
- * The provider page's visual grammar: type and hairlines, no boxes.
- *
- * A section is a heading with one quiet sentence. Its rows sit on the page
- * itself, separated by hairlines that run the width of the column — the
- * structure comes from alignment and rhythm, never from a card around a card.
- * Controls are small and sit on the right edge of their row.
- */
-export function Section({
- title,
- description,
- action,
- children,
- className,
- ...props
-}: Omit<ComponentPropsWithoutRef<"section">, "title"> & {
- title: ReactNode;
- description?: ReactNode;
- action?: ReactNode;
- children: ReactNode;
-}) {
- return (
- <section {...props} className={cn("min-w-0", className)}>
- <header className="flex items-end justify-between gap-6 pb-3">
- <div className="min-w-0">
- <h2 className="text-base font-semibold text-foreground-strong">{title}</h2>
- {description ? <p className="mt-1 max-w-2xl text-sm text-muted-foreground">{description}</p> : null}
- </div>
- {action ? <div className="flex shrink-0 items-center gap-2">{action}</div> : null}
- </header>
- {children}
- </section>
- );
-}
-
-/** Rows divided by hairlines, with a hairline above the first. */
-export function Rows({ className, ...props }: ComponentPropsWithoutRef<"div">) {
- return <div {...props} className={cn("divide-y divide-border/60 border-t border-border/60", className)} />;
-}
-
-/** One setting: what it is on the left, its control on the right. */
-export function Row({
- title,
- description,
- control,
- children,
- stacked = false,
- className,
- ...props
-}: Omit<ComponentPropsWithoutRef<"div">, "title"> & {
- title: ReactNode;
- description?: ReactNode;
- control?: ReactNode;
- /** Content under the row, full width (an account picker, a list of chips). */
- children?: ReactNode;
- /** Control under the text instead of beside it (narrow columns). */
- stacked?: boolean;
-}) {
- return (
- <div {...props} className={cn("py-4", className)}>
- <div
- className={cn(
- "flex flex-col gap-3",
- !stacked && "sm:flex-row sm:items-center sm:justify-between sm:gap-8",
- )}
- >
- <div className="min-w-0">
- <div className="text-sm font-medium text-foreground">{title}</div>
- {description ? <div className="mt-0.5 max-w-xl text-sm text-muted-foreground">{description}</div> : null}
- </div>
- {control ? <div className="flex min-w-0 shrink-0 flex-wrap items-center gap-2">{control}</div> : null}
- </div>
- {children ? <div className="pt-3">{children}</div> : null}
- </div>
- );
-}
-
-/** Text tabs on a hairline, the selected one underlined. */
-export function UnderlineTabs<T extends string>({
- value,
- options,
- onChange,
- label,
-}: {
- value: T;
- options: { value: T; label: string }[];
- onChange: (value: T) => void;
- label: string;
-}) {
- return (
- <div role="tablist" aria-label={label} data-testid="api-keys-category-tabs" className="flex gap-7 border-b border-border/60">
- {options.map((option) => {
- const selected = option.value === value;
- return (
- <button
- key={option.value}
- type="button"
- role="tab"
- id={`apikeys-tab-${option.value}`}
- aria-selected={selected}
- aria-controls="apikeys-panel"
- onClick={() => onChange(option.value)}
- className={cn(
- "-mb-px h-10 border-b-2 text-sm font-medium transition-colors",
- "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
- selected
- ? "border-foreground text-foreground-strong"
- : "border-transparent text-muted-foreground hover:text-foreground",
- )}
- >
- {option.label}
- </button>
- );
- })}
- </div>
- );
-}
-
-/** A small two- or three-way choice, as a pill track. */
-export function Choice<T extends string>({
- value,
- options,
- onChange,
- label,
- disabled,
- testId,
-}: {
- value: T;
- options: { value: T; label: string }[];
- onChange: (value: T) => void;
- label: string;
- disabled?: boolean;
- testId?: string;
-}) {
- return (
- <div role="radiogroup" aria-label={label} data-testid={testId} className="inline-flex rounded-full bg-secondary/70 p-0.5">
- {options.map((option) => {
- const selected = option.value === value;
- return (
- <button
- key={option.value}
- type="button"
- role="radio"
- aria-checked={selected}
- disabled={disabled}
- onClick={() => !selected && onChange(option.value)}
- className={cn(
- "h-7 rounded-full px-3 text-xs font-medium transition-colors disabled:opacity-50",
- "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
- selected ? "bg-background text-foreground shadow-sm" : "text-muted-foreground hover:text-foreground",
- )}
- >
- {option.label}
- </button>
- );
- })}
- </div>
- );
-}
-
-/** A model (or any item) that is on or off, as a chip that toggles on click. */
-export function ToggleChip({
- on,
- label,
- hint,
- disabled,
- onToggle,
-}: {
- on: boolean;
- label: string;
- hint?: string;
- disabled?: boolean;
- onToggle: () => void;
-}) {
- return (
- <button
- type="button"
- role="switch"
- aria-checked={on}
- title={hint}
- disabled={disabled}
- onClick={onToggle}
- className={cn(
- "inline-flex h-7 max-w-[16rem] items-center gap-1.5 rounded-full border px-3 text-xs transition-colors disabled:opacity-50",
- "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
- on
- ? "border-accent/50 bg-accent-soft text-foreground"
- : "border-border/70 text-muted-foreground hover:text-foreground",
- )}
- >
- <span
- aria-hidden="true"
- className={cn("h-1.5 w-1.5 shrink-0 rounded-full", on ? "bg-accent" : "bg-border-strong")}
- />
- <span className="truncate">{label}</span>
- </button>
- );
-}
-
-/** Rarely needed settings, folded behind one quiet line. */
-export function Disclosure({
- label,
- children,
- defaultOpen = false,
- testId,
-}: {
- label: ReactNode;
- children: ReactNode;
- defaultOpen?: boolean;
- testId?: string;
-}) {
- const [open, setOpen] = useState(defaultOpen);
- return (
- <div data-testid={testId}>
- <button
- type="button"
- aria-expanded={open}
- onClick={() => setOpen((value) => !value)}
- className="inline-flex items-center gap-1.5 py-2 text-sm text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
- >
- <ChevronRight aria-hidden="true" className={cn("h-4 w-4 transition-transform motion-reduce:transition-none", open && "rotate-90")} />
- {label}
- </button>
- {open ? <div className="pt-2">{children}</div> : null}
- </div>
- );
-}
-
-/** A status line: a small dot and a few words. */
-export function StatusLine({ tone, children }: { tone: "ok" | "off" | "warn" | "error"; children: ReactNode }) {
- return (
- <span className="inline-flex min-w-0 items-center gap-1.5 text-sm text-muted-foreground">
- <span
- aria-hidden="true"
- className={cn(
- "h-1.5 w-1.5 shrink-0 rounded-full",
- tone === "ok" && "bg-success",
- tone === "off" && "bg-border-strong",
- tone === "warn" && "bg-warning",
- tone === "error" && "bg-destructive",
- )}
- />
- <span className="truncate">{children}</span>
- </span>
- );
-}
diff --git a/jarvis/ui/web/frontend/src/views/apikeys/settingsUi.tsx b/jarvis/ui/web/frontend/src/views/apikeys/settingsUi.tsx
new file mode 100644
index 0000000000..f197a46d17
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/views/apikeys/settingsUi.tsx
@@ -0,0 +1,341 @@
+import type { ComponentPropsWithoutRef, ReactNode } from "react";
+import { cn } from "@/lib/utils";
+
+/**
+ * The compact settings grammar of the provider page.
+ *
+ * A section is a muted one-line title (with an optional action on the right)
+ * above one card. A row inside the card is a title and a short explanation on
+ * the left and its control on the right; on a narrow window the control drops
+ * under the text. Explanations belong to rows, never to section titles.
+ */
+export function SettingsSection({
+ title,
+ icon,
+ headerAction,
+ plain = false,
+ children,
+ className,
+ ...props
+}: Omit<ComponentPropsWithoutRef<"section">, "title"> & {
+ title: ReactNode;
+ icon?: ReactNode;
+ headerAction?: ReactNode;
+ /** No card around the children (they bring their own surfaces). */
+ plain?: boolean;
+ children: ReactNode;
+}) {
+ return (
+ <section {...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">
+ {icon}
+ <span className="truncate">{title}</span>
+ </h2>
+ {headerAction ? <div className="flex min-w-7 shrink-0 items-center justify-end gap-1">{headerAction}</div> : null}
+ </div>
+ {plain ? children : <SettingsGroup>{children}</SettingsGroup>}
+ </section>
+ );
+}
+
+/** The card surface: rounded, hairline border, rows divided by hairlines. */
+export function SettingsGroup({
+ divided = true,
+ className,
+ ...props
+}: ComponentPropsWithoutRef<"div"> & { divided?: boolean }) {
+ return (
+ <div
+ {...props}
+ className={cn(
+ "relative overflow-hidden rounded-xl border border-border/60 bg-card/40 text-foreground",
+ divided && "[&>*+*]:border-t [&>*+*]:border-border/50",
+ className,
+ )}
+ />
+ );
+}
+
+export function SettingsRow({
+ title,
+ description,
+ status,
+ control,
+ children,
+ className,
+ ...props
+}: Omit<ComponentPropsWithoutRef<"div">, "title"> & {
+ title: ReactNode;
+ description?: ReactNode;
+ /** A live state line under the description ("Authenticated as …"). */
+ status?: ReactNode;
+ control?: ReactNode;
+ /** Full-width content under the row (an input, a list). */
+ children?: ReactNode;
+}) {
+ return (
+ <div {...props} data-slot="settings-row" className={cn("px-4 py-3", className)}>
+ <div className="flex flex-col gap-3 sm:grid sm:grid-cols-[minmax(0,1fr)_minmax(10rem,auto)] sm:items-center sm:gap-8">
+ <div className="min-w-0 space-y-1">
+ <h3 className="flex min-h-5 items-center gap-1.5 text-sm font-medium text-foreground">{title}</h3>
+ {description ? (
+ <p className="max-w-xl text-xs leading-normal text-muted-foreground/80">{description}</p>
+ ) : null}
+ {status ? <div className="pt-0.5 text-xs text-muted-foreground">{status}</div> : null}
+ </div>
+ {control ? (
+ <div className="flex w-full min-w-0 shrink-0 items-center gap-2 sm:w-auto sm:justify-end">
+ {control}
+ </div>
+ ) : null}
+ </div>
+ {children ? <div className="pt-3">{children}</div> : null}
+ </div>
+ );
+}
+
+/**
+ * A list beside the selected item's settings, inside one card that fills the
+ * window below the page header, so the section is one view: the list sits on
+ * a slightly darker ground and both halves scroll on their own.
+ */
+export function MasterDetail({
+ list,
+ detail,
+ testId,
+}: {
+ list: ReactNode;
+ detail: ReactNode;
+ testId?: string;
+}) {
+ return (
+ <SettingsGroup
+ divided={false}
+ data-testid={testId}
+ className="md:grid md:h-[calc(100dvh-17.5rem)] md:min-h-[24rem] md:grid-cols-[17rem_minmax(0,1fr)]"
+ >
+ <div className="border-b border-border/60 bg-secondary/30 md:min-h-0 md:overflow-y-auto md:border-b-0 md:border-r scrollbar-jarvis">
+ <div className="divide-y divide-border/50">{list}</div>
+ </div>
+ <div className="min-w-0 md:min-h-0 md:overflow-y-auto scrollbar-jarvis">
+ <div className="space-y-6 p-4">{detail}</div>
+ </div>
+ </SettingsGroup>
+ );
+}
+
+/** One entry of a `MasterDetail` list: mark, name, version, status, and a switch. */
+export function ListRow({
+ icon,
+ name,
+ version,
+ status,
+ dot,
+ selected,
+ dimmed,
+ onSelect,
+ trailing,
+ testId,
+}: {
+ icon: ReactNode;
+ name: string;
+ version?: string | null;
+ status: ReactNode;
+ /** Only trouble gets a dot; a healthy row reads fine from its text. */
+ dot?: "warning" | "error" | null;
+ selected: boolean;
+ dimmed: boolean;
+ onSelect: () => void;
+ trailing?: ReactNode;
+ testId?: string;
+}) {
+ return (
+ <div
+ data-testid={testId}
+ className={cn(
+ "group flex min-h-[4.5rem] items-center gap-3 px-4 py-3 transition-colors",
+ selected ? "bg-secondary" : "hover:bg-secondary/50",
+ )}
+ >
+ <div
+ className={cn(
+ "relative flex min-w-0 flex-1 items-start gap-3 rounded-md text-left transition-opacity",
+ dimmed && !selected && "opacity-60 group-hover:opacity-100",
+ )}
+ >
+ <button
+ type="button"
+ className="absolute inset-0 cursor-pointer rounded-md outline-none focus-visible:ring-2 focus-visible:ring-ring"
+ onClick={onSelect}
+ aria-label={name}
+ aria-pressed={selected}
+ />
+ <span className="pointer-events-none mt-0.5 flex shrink-0">{icon}</span>
+ <span className="pointer-events-none min-w-0 flex-1">
+ <span className="flex min-w-0 items-center gap-2">
+ <span className="truncate text-sm font-medium text-foreground">{name}</span>
+ {version ? <code className="max-w-24 shrink-0 truncate text-xs text-muted-foreground">{version}</code> : null}
+ </span>
+ <span className="mt-0.5 flex items-start gap-1.5 text-xs leading-normal text-muted-foreground/80">
+ {dot ? (
+ <span className="flex h-[1.45em] shrink-0 items-center">
+ <span
+ aria-hidden="true"
+ className={cn("h-1.5 w-1.5 rounded-full", dot === "error" ? "bg-destructive" : "bg-warning")}
+ />
+ </span>
+ ) : null}
+ <span className="line-clamp-2 [overflow-wrap:anywhere]">{status}</span>
+ </span>
+ </span>
+ </div>
+ {trailing ? <span className="flex h-5 shrink-0 items-center">{trailing}</span> : null}
+ </div>
+ );
+}
+
+/**
+ * A small segmented choice ("Subscription | API key"). Each option is a radio:
+ * exactly one is picked, and arrow keys are not needed for two or three.
+ */
+export function Segmented<T extends string>({
+ value,
+ options,
+ onChange,
+ label,
+ disabled,
+ testId,
+ size = "sm",
+}: {
+ value: T;
+ options: { value: T; label: string; disabled?: boolean }[];
+ /** `xs` is the small switch that sits inside a row of a card. */
+ size?: "sm" | "xs";
+ onChange: (value: T) => void;
+ label: string;
+ disabled?: boolean;
+ testId?: string;
+}) {
+ return (
+ <div
+ role="radiogroup"
+ aria-label={label}
+ data-testid={testId}
+ className="inline-flex shrink-0 rounded-lg border border-border/60 bg-card/40 p-0.5"
+ >
+ {options.map((option) => (
+ <button
+ key={option.value}
+ type="button"
+ role="radio"
+ aria-checked={value === option.value}
+ disabled={disabled || option.disabled}
+ onClick={() => value !== option.value && onChange(option.value)}
+ className={cn(
+ size === "xs" ? "h-6 rounded-md px-2 text-xs font-medium transition-colors" : "h-7 rounded-md px-3 text-sm font-medium transition-colors",
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",
+ value === option.value ? "bg-secondary text-foreground" : "text-muted-foreground hover:text-foreground",
+ )}
+ >
+ {option.label}
+ </button>
+ ))}
+ </div>
+ );
+}
+
+/**
+ * A list of models inside a section card: name, id, a short note, and one
+ * control per row (a visibility switch, or the pick mark of a single choice).
+ * The header line carries a count and an optional bulk action.
+ */
+export function ModelList({
+ header,
+ action,
+ children,
+ testId,
+}: {
+ header: ReactNode;
+ action?: ReactNode;
+ children: ReactNode;
+ testId?: string;
+}) {
+ return (
+ <SettingsGroup divided={false} data-testid={testId}>
+ <div className="flex min-h-10 items-center justify-between gap-4 border-b border-border/50 px-4 py-2 text-xs text-muted-foreground">
+ <span>{header}</span>
+ {action}
+ </div>
+ <ul className="max-h-[22rem] overflow-y-auto py-1 scrollbar-jarvis">{children}</ul>
+ </SettingsGroup>
+ );
+}
+
+export function ModelListRow({
+ name,
+ id,
+ note,
+ control,
+ muted,
+ onClick,
+ selected,
+ disabled,
+}: {
+ name: string;
+ id?: string;
+ note?: string | null;
+ control: ReactNode;
+ muted?: boolean;
+ /** A single-choice list makes the whole row the hit target. */
+ onClick?: () => void;
+ selected?: boolean;
+ disabled?: boolean;
+}) {
+ const body = (
+ <>
+ <span className={cn("flex min-w-0 flex-1 items-baseline gap-2", muted && "opacity-60")}>
+ <span className="truncate text-sm text-foreground">{name}</span>
+ {id && id !== name ? <code className="truncate text-xs text-muted-foreground">{id}</code> : null}
+ </span>
+ {note ? <span className="hidden shrink-0 text-xs text-muted-foreground sm:inline">{note}</span> : null}
+ <span className="flex h-5 shrink-0 items-center">{control}</span>
+ </>
+ );
+ return (
+ <li>
+ {onClick ? (
+ <button
+ type="button"
+ role="radio"
+ aria-checked={Boolean(selected)}
+ aria-label={name}
+ disabled={disabled}
+ onClick={onClick}
+ className={cn(
+ "flex w-full items-center gap-3 px-4 py-2 text-left transition-colors",
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring disabled:cursor-not-allowed",
+ selected ? "bg-secondary/70" : "hover:bg-secondary/40",
+ )}
+ >
+ {body}
+ </button>
+ ) : (
+ <div className="flex items-center gap-3 px-4 py-2">{body}</div>
+ )}
+ </li>
+ );
+}
+
+/** The detail pane's title line: mark and name, and the version on the right. */
+export function DetailHeader({ icon, name, version }: { icon: ReactNode; name: string; version?: string | null }) {
+ return (
+ <div className="flex min-h-7 items-center justify-between gap-4 px-1">
+ <h2 className="flex min-w-0 items-center gap-2 text-sm font-normal text-foreground/70">
+ {icon}
+ <span className="truncate">{name}</span>
+ </h2>
+ {version ? <code className="truncate text-xs text-muted-foreground">{version}</code> : null}
+ </div>
+ );
+}