Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
feat(settings): list every connected subscription under its provider
rubenluetke10-beep437471d6762a
diff --git a/jarvis/ui/web/frontend/src/components/AgentAccountsPanel.tsx b/jarvis/ui/web/frontend/src/components/AgentAccountsPanel.tsxindex d4ca98867e..a4440c7242 100644--- a/jarvis/ui/web/frontend/src/components/AgentAccountsPanel.tsx+++ b/jarvis/ui/web/frontend/src/components/AgentAccountsPanel.tsx@@ -615,7 +615,7 @@ function AccountRow({* field replaces pasting into a TUI, which on Windows rendered late or not at* all and burned the single-use code.*/-function LoginFlowBox({+export function LoginFlowBox({flow,onFlow,onClose,diff --git a/jarvis/ui/web/frontend/src/i18n/locales/providers/de.json b/jarvis/ui/web/frontend/src/i18n/locales/providers/de.jsonindex 99bbf19d6c..cdf2878d51 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/providers/de.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/providers/de.json@@ -105,6 +105,9 @@"instructions_none": "Keine – GPT-Live nutzt seine Standards","instructions_edit": "Bearbeiten","instructions_hide": "Schließen",+ "accounts_section": "Konten",+ "account_active": "Aktiv",+ "account_use": "Für neue Terminals nutzen","tab_voice": "Live-Gespräche","tab_agents": "Agenten","subscriptions_title": "Abos",diff --git a/jarvis/ui/web/frontend/src/i18n/locales/providers/en.json b/jarvis/ui/web/frontend/src/i18n/locales/providers/en.jsonindex 5d5c6f6cd4..e5729ad906 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/providers/en.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/providers/en.json@@ -105,6 +105,9 @@"instructions_none": "None — GPT-Live uses its defaults","instructions_edit": "Edit","instructions_hide": "Close",+ "accounts_section": "Accounts",+ "account_active": "Active",+ "account_use": "Use for new terminals","tab_voice": "Live calls","tab_agents": "Agents","subscriptions_title": "Subscriptions",diff --git a/jarvis/ui/web/frontend/src/i18n/locales/providers/es.json b/jarvis/ui/web/frontend/src/i18n/locales/providers/es.jsonindex 5863e62434..0019d40356 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/providers/es.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/providers/es.json@@ -105,6 +105,9 @@"instructions_none": "Ninguna: GPT-Live usa sus valores por defecto","instructions_edit": "Editar","instructions_hide": "Cerrar",+ "accounts_section": "Cuentas",+ "account_active": "Activa",+ "account_use": "Usar en terminales nuevos","tab_voice": "Llamadas en directo","tab_agents": "Agentes","subscriptions_title": "Suscripciones",diff --git a/jarvis/ui/web/frontend/src/views/apikeys/AgentsTab.tsx b/jarvis/ui/web/frontend/src/views/apikeys/AgentsTab.tsxindex e0fe2842ec..de2d7f3814 100644--- a/jarvis/ui/web/frontend/src/views/apikeys/AgentsTab.tsx+++ b/jarvis/ui/web/frontend/src/views/apikeys/AgentsTab.tsx@@ -44,6 +44,7 @@ import {import { cn } from "@/lib/utils";import { useEventStore } from "@/store/events";import { KeyField } from "./KeyField";+import { SubscriptionAccounts } from "./SubscriptionAccounts";import { accessPatch, familyAccess, nextDefault, onPatch, withPatch, type Access, type FamilyAccess } from "./agentAccess";import { familyState, type FamilyState } from "./providers/familyState";import {@@ -393,6 +394,8 @@ function ProviderDetail({</SettingsSection>)}+ {subscription && family.subscription && <SubscriptionAccounts kind={family.subscription.kind} />}+{keyed && <SeparateKeys family={family} onChanged={onChanged} />}</div>);diff --git a/jarvis/ui/web/frontend/src/views/apikeys/SubscriptionAccounts.test.tsx b/jarvis/ui/web/frontend/src/views/apikeys/SubscriptionAccounts.test.tsxnew file mode 100644index 0000000000..f023f82b3f--- /dev/null+++ b/jarvis/ui/web/frontend/src/views/apikeys/SubscriptionAccounts.test.tsx@@ -0,0 +1,99 @@+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";+import { cleanup, fireEvent, render, screen, waitFor, within } from "@testing-library/react";++vi.mock("@/i18n", () => ({ useT: () => (key: string) => key }));++import { SubscriptionAccounts } from "./SubscriptionAccounts";++const account = (id: string, label: string, email: string, extra: Record<string, unknown> = {}) => ({+ id,+ platform: "claude",+ label,+ config_dir: "",+ builtin: id === "claude:default",+ connected: true,+ mode: "subscription",+ message: "",+ email,+ tier: "max",+ ...extra,+});++let accounts = [+ account("claude:default", "Default Claude Code login", "[email protected]"),+ account("claude:two", "Second", "[email protected]"),+];+let calls: { url: string; method: string; body: unknown }[] = [];++beforeEach(() => {+ calls = [];+ accounts = [+ account("claude:default", "Default Claude Code login", "[email protected]"),+ account("claude:two", "Second", "[email protected]"),+ ];+ vi.stubGlobal(+ "fetch",+ vi.fn(async (input: RequestInfo | URL, init?: RequestInit) => {+ const url = String(input);+ const method = (init?.method ?? "GET").toUpperCase();+ calls.push({ url, method, body: init?.body ? JSON.parse(String(init.body)) : null });+ const list = () => ({ platforms: [{ platform: "claude", display_name: "Claude Code", active_account: "claude:two", accounts }] });+ let body: unknown = {};+ if (url.startsWith("/api/agent-accounts/usage")) {+ body = {+ ttl_seconds: 60,+ generated_at: 0,+ accounts: [+ { account_id: "claude:default", platform: "claude", status: "ok", source: "live", as_of: 0, message: "", plan: "Max 20x",+ windows: [{ kind: "session", percent: 65.4, severity: "normal", resets_at: null, window_minutes: null, scope_label: null, raw_label: null }] },+ { account_id: "claude:two", platform: "claude", status: "ok", source: "live", as_of: 0, message: "", plan: "Max 20x",+ windows: [{ kind: "session", percent: 100, severity: "critical", resets_at: null, window_minutes: null, scope_label: null, raw_label: null }] },+ ],+ };+ } else if (url.includes("/login-flow")) {+ body = { flow: { flow_id: "f1", account_id: "claude:new", platform: "claude", label: "Work", status: "starting", url: null, code_expected: false, message: "", tail: "", finished: false } };+ } else if (url === "/api/agent-accounts" && method === "POST") {+ accounts = [...accounts, account("claude:new", "Work", "", { connected: false, mode: "unknown" })];+ body = list();+ } else if (url.startsWith("/api/agent-accounts")) {+ body = list();+ }+ return { ok: true, status: 200, json: async () => body } as Response;+ }),+ );+});++afterEach(() => {+ cleanup();+ vi.unstubAllGlobals();+});++describe("SubscriptionAccounts", () => {+ it("lists every connected seat with plan, usage and the active one", async () => {+ render(<SubscriptionAccounts kind="claude_cli" />);+ const first = await screen.findByTestId("subscription-account-row-claude:default");+ expect(first.textContent).toContain("[email protected]");+ await waitFor(() => expect(first.textContent).toContain("65%"));+ expect(first.textContent).toContain("Max 20x");+ const second = screen.getByTestId("subscription-account-row-claude:two");+ expect(within(second).getByText("providers_page.account_active")).toBeTruthy();+ await waitFor(() => expect(second.textContent).toContain("100%"));+ });++ it("adds a seat and starts its sign-in right away", async () => {+ render(<SubscriptionAccounts kind="claude_cli" />);+ await screen.findByTestId("subscription-account-row-claude:default");+ fireEvent.click(screen.getByTestId("subscription-account-add"));+ fireEvent.change(screen.getByLabelText("agent_accounts.name_placeholder"), { target: { value: "Work" } });+ fireEvent.click(screen.getByText("agent_accounts.add_confirm"));+ await waitFor(() =>+ expect(calls.find((c) => c.method === "POST" && c.url === "/api/agent-accounts")?.body).toEqual({ platform: "claude", label: "Work" }),+ );+ await waitFor(() => expect(calls.some((c) => c.url === "/api/agent-accounts/claude%3Anew/login-flow")).toBe(true));+ });++ it("stays away for a CLI with a single login", () => {+ const { container } = render(<SubscriptionAccounts kind="antigravity" />);+ expect(container.innerHTML).toBe("");+ });+});diff --git a/jarvis/ui/web/frontend/src/views/apikeys/SubscriptionAccounts.tsx b/jarvis/ui/web/frontend/src/views/apikeys/SubscriptionAccounts.tsxnew file mode 100644index 0000000000..fea8e05b81--- /dev/null+++ b/jarvis/ui/web/frontend/src/views/apikeys/SubscriptionAccounts.tsx@@ -0,0 +1,400 @@+import { useCallback, useEffect, useRef, useState } from "react";+import { AlertTriangle, ChevronRight, Loader2, LogIn, Pencil, Plus, Trash2 } from "lucide-react";+import { AccountUsageMeters } from "@/components/AccountUsageMeters";+import { LoginFlowBox } from "@/components/AgentAccountsPanel";+import { Button } from "@/components/ui/button";+import { Input } from "@/components/ui/input";+import { useT } from "@/i18n";+import {+ cancelLoginFlow,+ createAgentAccount,+ deleteAgentAccount,+ fetchAgentAccounts,+ fetchAgentUsage,+ getLoginFlow,+ groupFor,+ loginAgentAccount,+ renameAgentAccount,+ setActiveAgentAccount,+ startLoginFlow,+ type AccountUsage,+ type AgentAccount,+ type AgentAccountsResponse,+ type LoginFlowState,+} from "@/lib/agentAccountsApi";+import type { SubscriptionKind } from "@/lib/providerFamilies";+import { cn } from "@/lib/utils";+import { useEventStore } from "@/store/events";+import { SettingsGroup } from "./settingsUi";++/**+ * Which account registry holds a CLI's subscriptions. A CLI without an entry+ * (Antigravity) has one login only, and the section stays away.+ */+const ACCOUNT_PLATFORM: Partial<Record<SubscriptionKind, string>> = {+ claude_cli: "claude",+ codex: "codex",+ grok_build: "grok-build",+};++/** The highest share of any plan limit — the one that stops the seat first. */+function usedPercent(usage: AccountUsage | undefined): { percent: number; critical: boolean } | null {+ if (!usage || usage.status !== "ok" || usage.windows.length === 0) return null;+ const top = usage.windows.reduce((a, b) => (b.percent > a.percent ? b : a));+ return { percent: Math.round(top.percent), critical: top.severity === "critical" || top.percent >= 100 };+}++/**+ * Every subscription connected for one CLI, and the way to add another.+ *+ * One row per seat: who it is, what plan, how much of it is spent, and which+ * one new terminals use. A row opens for its usage limits and the rarer+ * actions (switch, sign in, rename, remove); adding a seat names it and goes+ * straight into the in-app sign-in.+ */+export function SubscriptionAccounts({ kind }: { kind: SubscriptionKind }) {+ const t = useT();+ const pushToast = useEventStore((s) => s.pushToast);+ const platform = ACCOUNT_PLATFORM[kind];+ const [data, setData] = useState<AgentAccountsResponse | null>(null);+ const [usage, setUsage] = useState<Record<string, AccountUsage>>({});+ const [openId, setOpenId] = useState<string | null>(null);+ const [busy, setBusy] = useState<string | null>(null);+ const [adding, setAdding] = useState(false);+ const [label, setLabel] = useState("");+ const [now, setNow] = useState(() => Date.now());+ // A seat added a moment ago starts its sign-in as soon as it is listed.+ const [signInFor, setSignInFor] = useState<string | null>(null);++ const reload = useCallback(async () => {+ try {+ setData(await fetchAgentAccounts());+ } catch (cause) {+ pushToast("error", (cause as Error).message);+ }+ }, [pushToast]);++ const loadUsage = useCallback(async () => {+ try {+ const body = await fetchAgentUsage();+ if (!body) return;+ setUsage(Object.fromEntries(body.accounts.map((entry) => [entry.account_id, entry])));+ } catch (cause) {+ // Usage is a hint next to each seat; without it the list still works.+ console.debug("account usage unavailable", cause);+ }+ }, []);++ useEffect(() => {+ if (!platform) return;+ void reload();+ void loadUsage();+ const usageTimer = window.setInterval(() => void loadUsage(), 60_000);+ const clock = window.setInterval(() => setNow(Date.now()), 30_000);+ return () => {+ window.clearInterval(usageTimer);+ window.clearInterval(clock);+ };+ }, [platform, reload, loadUsage]);++ if (!platform) return null;+ const group = groupFor(data, platform);+ const accounts = group?.accounts ?? [];++ async function run(key: string, action: () => Promise<AgentAccountsResponse | void>) {+ setBusy(key);+ try {+ const next = await action();+ if (next) setData(next);+ else await reload();+ } catch (cause) {+ pushToast("error", (cause as Error).message);+ } finally {+ setBusy(null);+ }+ }++ async function add() {+ const name = label.trim();+ if (!name || !platform) return;+ const before = new Set(accounts.map((account) => account.id));+ setBusy("add");+ try {+ const next = await createAgentAccount(platform, name);+ setData(next);+ const created = groupFor(next, platform)?.accounts.find((account) => !before.has(account.id));+ setLabel("");+ setAdding(false);+ if (created) {+ setOpenId(created.id);+ setSignInFor(created.id);+ }+ } catch (cause) {+ pushToast("error", (cause as Error).message);+ } finally {+ setBusy(null);+ }+ }++ return (+ <section className="space-y-2.5" data-testid={`subscription-accounts-${kind}`}>+ <div className="flex min-h-7 items-center justify-between gap-4 px-1">+ <h2 className="flex items-center gap-2 text-sm font-normal text-foreground/70">+ {t("providers_page.accounts_section")}+ {accounts.length > 0 ? <span className="text-xs text-muted-foreground">{accounts.length}</span> : null}+ </h2>+ {!adding ? (+ <Button size="sm" variant="ghost" className="h-7 text-xs" data-testid="subscription-account-add" onClick={() => setAdding(true)}>+ <Plus />+ {t("agent_accounts.add")}+ </Button>+ ) : null}+ </div>+ <SettingsGroup>+ {accounts.map((account) => (+ <AccountLine+ key={account.id}+ account={account}+ active={account.id === group?.active_account}+ usage={usage[account.id]}+ now={now}+ open={openId === account.id}+ onToggle={() => setOpenId((id) => (id === account.id ? null : account.id))}+ busy={busy}+ run={run}+ autoSignIn={signInFor === account.id}+ onAutoSignInStarted={() => setSignInFor(null)}+ />+ ))}+ {accounts.length === 0 ? (+ <div className="px-4 py-3 text-xs text-muted-foreground">{t("agent_accounts.loading")}</div>+ ) : null}+ {adding ? (+ <div className="flex items-center gap-2 px-4 py-3">+ <Input+ autoFocus+ value={label}+ onChange={(event) => setLabel(event.target.value)}+ onKeyDown={(event) => {+ if (event.key === "Enter") void add();+ if (event.key === "Escape") setAdding(false);+ }}+ placeholder={t("agent_accounts.name_placeholder")}+ aria-label={t("agent_accounts.name_placeholder")}+ className="h-8 min-w-0 flex-1 text-sm"+ />+ <Button size="sm" variant="ghost" onClick={() => setAdding(false)}>+ {t("agent_accounts.cancel")}+ </Button>+ <Button size="sm" disabled={!label.trim() || busy === "add"} onClick={() => void add()}>+ {busy === "add" && <Loader2 className="animate-spin" />}+ {t("agent_accounts.add_confirm")}+ </Button>+ </div>+ ) : null}+ </SettingsGroup>+ </section>+ );+}++function AccountLine({+ account,+ active,+ usage,+ now,+ open,+ onToggle,+ busy,+ run,+ autoSignIn,+ onAutoSignInStarted,+}: {+ account: AgentAccount;+ active: boolean;+ usage: AccountUsage | undefined;+ now: number;+ open: boolean;+ onToggle: () => void;+ busy: string | null;+ run: (key: string, action: () => Promise<AgentAccountsResponse | void>) => Promise<void>;+ autoSignIn: boolean;+ onAutoSignInStarted: () => void;+}) {+ const t = useT();+ const pushToast = useEventStore((s) => s.pushToast);+ const [flow, setFlow] = useState<LoginFlowState | null>(null);+ const [renaming, setRenaming] = useState(false);+ const [draft, setDraft] = useState(account.label);+ const pending = busy?.endsWith(account.id) ?? false;+ const used = usedPercent(usage);+ const plan = usage?.plan ?? account.tier;++ const signIn = useCallback(async () => {+ try {+ setFlow(await startLoginFlow(account.id));+ } catch (cause) {+ pushToast("error", (cause as Error).message);+ }+ }, [account.id, pushToast]);++ useEffect(() => {+ if (!autoSignIn) return;+ onAutoSignInStarted();+ void signIn();+ }, [autoSignIn, onAutoSignInStarted, signIn]);++ // Poll a running sign-in until it finishes; success re-reads the list.+ const runRef = useRef(run);+ runRef.current = run;+ useEffect(() => {+ if (!flow || flow.finished) return;+ const flowId = flow.flow_id;+ const timer = window.setInterval(() => {+ void (async () => {+ try {+ const next = await getLoginFlow(flowId);+ if (!next.finished) {+ setFlow(next);+ } else if (next.status === "success") {+ pushToast("success", `${account.label}: ${t("agent_accounts.flow.success")}`);+ setFlow(null);+ await runRef.current(`flow:${account.id}`, async () => {});+ } else {+ setFlow(next);+ }+ } catch {+ // The flow is gone (the server restarted); stop polling it.+ setFlow(null);+ }+ })();+ }, 1200);+ return () => window.clearInterval(timer);+ }, [flow, account.id, account.label, pushToast, t]);++ async function rename() {+ const name = draft.trim();+ setRenaming(false);+ if (!name || name === account.label) return;+ await run(`rename:${account.id}`, () => renameAgentAccount(account.id, name));+ }++ return (+ <div data-testid={`subscription-account-row-${account.id}`}>+ <button+ type="button"+ aria-expanded={open}+ onClick={onToggle}+ className="flex w-full items-center gap-3 px-4 py-3 text-left transition-colors hover:bg-secondary/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring"+ >+ <ChevronRight+ aria-hidden="true"+ className={cn("h-4 w-4 shrink-0 text-muted-foreground transition-transform motion-reduce:transition-none", open && "rotate-90")}+ />+ <span className="min-w-0 flex-1">+ <span className="flex min-w-0 items-center gap-2">+ <span className={cn("truncate text-sm font-medium", account.connected ? "text-foreground" : "text-muted-foreground")}>+ {account.email || account.label}+ </span>+ {active ? (+ <span className="shrink-0 rounded border border-border px-1.5 py-px text-[10px] font-medium uppercase tracking-wide text-muted-foreground">+ {t("providers_page.account_active")}+ </span>+ ) : null}+ {account.warning ? (+ <span title={account.warning} className="inline-flex shrink-0">+ <AlertTriangle aria-label={account.warning} className="h-3.5 w-3.5 text-warning" />+ </span>+ ) : null}+ </span>+ <span className="mt-0.5 block truncate text-xs text-muted-foreground">+ {[account.label, plan].filter(Boolean).join(" · ")}+ {!account.connected ? ` · ${t("agent_accounts.not_signed_in")}` : ""}+ </span>+ </span>+ {used ? (+ <span className={cn("shrink-0 text-sm tabular-nums", used.critical ? "text-destructive" : "text-muted-foreground")}>+ {used.percent}%+ </span>+ ) : null}+ </button>++ {open ? (+ <div className="space-y-3 px-4 pb-4 pl-11">+ {account.warning ? <p className="text-xs text-warning">{account.warning}</p> : null}+ <AccountUsageMeters usage={usage} now={now} />+ <div className="flex flex-wrap items-center gap-2">+ {!active && account.connected ? (+ <Button+ size="sm"+ variant="outline"+ disabled={pending}+ onClick={() => void run(`active:${account.id}`, () => setActiveAgentAccount(account.platform, account.id))}+ >+ {t("providers_page.account_use")}+ </Button>+ ) : null}+ {!account.connected && !flow ? (+ <Button size="sm" disabled={pending} onClick={() => void signIn()}>+ <LogIn />+ {t("agent_accounts.sign_in")}+ </Button>+ ) : null}+ {!account.builtin ? (+ renaming ? (+ <Input+ autoFocus+ value={draft}+ onChange={(event) => setDraft(event.target.value)}+ onBlur={() => void rename()}+ onKeyDown={(event) => {+ if (event.key === "Enter") void rename();+ if (event.key === "Escape") setRenaming(false);+ }}+ aria-label={t("agent_accounts.rename")}+ className="h-8 w-48 text-sm"+ />+ ) : (+ <>+ <Button size="sm" variant="ghost" className="text-muted-foreground" onClick={() => { setDraft(account.label); setRenaming(true); }}>+ <Pencil />+ {t("agent_accounts.rename")}+ </Button>+ <Button+ size="sm"+ variant="ghost"+ className="text-muted-foreground hover:text-destructive"+ disabled={pending}+ onClick={() => void run(`delete:${account.id}`, () => deleteAgentAccount(account.id))}+ >+ <Trash2 />+ {t("agent_accounts.remove")}+ </Button>+ </>+ )+ ) : null}+ </div>+ {flow ? (+ <LoginFlowBox+ flow={flow}+ onFlow={setFlow}+ onClose={() => {+ // Closing only abandons the sign-in; a cancel that fails leaves a+ // CLI process the server reaps on its own timeout.+ if (!flow.finished) void cancelLoginFlow(flow.flow_id).catch(() => undefined);+ setFlow(null);+ }}+ onRetry={() => void signIn()}+ onFallback={() => {+ setFlow(null);+ void run(`login:${account.id}`, async () => {+ const { message } = await loginAgentAccount(account.id);+ pushToast("info", message);+ });+ }}+ />+ ) : null}+ </div>+ ) : null}+ </div>+ );+}