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(subagents): Local Mode reaches the worker tab, own-hardware gets its own group

rubenluetke10-beepb966cb742e39
diff --git a/jarvis/ui/web/frontend/src/components/JarvisAgentSection.local-mode.test.tsx b/jarvis/ui/web/frontend/src/components/JarvisAgentSection.local-mode.test.tsx
new file mode 100644
index 0000000000..41aaffc64d
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/components/JarvisAgentSection.local-mode.test.tsx
@@ -0,0 +1,159 @@
+/**
+ * Local Mode on the Subagents tab.
+ *
+ * This tab was the one place the switch did not reach, which made the whole
+ * feature look unreliable: a keyless install turned Local Mode on, saw the
+ * provider tiers filter correctly, then opened the tab that picks the WORKER —
+ * the one decision a local-only install cares most about — and got the full
+ * wall of hosted accounts back. These tests pin that it filters here too, and
+ * that it filters the subscription-login cards as well, not only the API column.
+ */
+import { cleanup, render, screen, waitFor } from "@testing-library/react";
+import { afterEach, describe, expect, it, vi } from "vitest";
+
+vi.mock("@/i18n", () => ({
+ useT: () => (key: string) => key,
+}));
+
+vi.mock("@/store/events", () => ({
+ useEventStore: (selector: (s: { pushToast: () => void }) => unknown) =>
+ selector({ pushToast: vi.fn() }),
+}));
+
+import { setLocalMode } from "@/lib/localMode";
+import { JarvisAgentSection } from "./JarvisAgentSection";
+
+function row(
+ jarvis: string,
+ billing: string,
+ {
+ active = false,
+ keyless = false,
+ label = `${jarvis} card`,
+ }: { active?: boolean; keyless?: boolean; label?: string } = {},
+) {
+ return {
+ jarvis,
+ worker_slug: jarvis,
+ env_var: `${jarvis.toUpperCase()}_API_KEY`,
+ env_fallback: null,
+ key_set: keyless,
+ api_key_set: false,
+ dedicated_key_set: false,
+ shared_key_set: false,
+ oauth_connected: false,
+ credential_source: "none",
+ secret_key: keyless ? null : `jarvis_agent_${jarvis}_api_key`,
+ dashboard_url: null,
+ credential_help: null,
+ is_active_brain: active,
+ keyless,
+ // A distinct label per row: the raw slug also appears in card body copy, so
+ // querying by it would match more than the card title.
+ label,
+ billing,
+ };
+}
+
+const STATUS = {
+ configured: true,
+ enabled: true,
+ binary_path: "openclaw",
+ binary_detected: null,
+ version_pin: null,
+ time_cap_min: null,
+ concurrency: null,
+ state_dir_root: null,
+ brain_primary: "ollama",
+ provider_slug: "ollama",
+ model_override: null,
+ sub_model_override: null,
+ model_resolved: null,
+ mapping: [
+ row("openai", "api"),
+ row("gemini", "api"),
+ row("claude-api", "subscription_or_api"),
+ row("openai-codex", "subscription_or_api"),
+ row("ollama", "local", { keyless: true }),
+ row("local-openai", "local", { keyless: true }),
+ ],
+};
+
+function mockFetch(status: unknown = STATUS) {
+ return vi.fn().mockImplementation(async (url: string) => {
+ const u = String(url);
+ if (u.includes("/api/jarvis-agent/status")) {
+ return { ok: true, json: async () => status };
+ }
+ return { ok: true, json: async () => ({}) };
+ });
+}
+
+afterEach(() => {
+ cleanup();
+ vi.restoreAllMocks();
+ setLocalMode(false);
+ window.localStorage.clear();
+});
+
+describe("JarvisAgentSection — Local Mode", () => {
+ it("shows every worker while Local Mode is off", async () => {
+ vi.stubGlobal("fetch", mockFetch());
+ render(<JarvisAgentSection />);
+
+ expect((await screen.findAllByText("openai card")).length).toBeGreaterThan(0);
+ expect(screen.getAllByText("ollama card").length).toBeGreaterThan(0);
+ expect(screen.queryByTestId("local-mode-notice")).toBeNull();
+ });
+
+ it("keeps only own-hardware workers when Local Mode is on", async () => {
+ setLocalMode(true);
+ vi.stubGlobal("fetch", mockFetch());
+ render(<JarvisAgentSection />);
+
+ expect((await screen.findAllByText("ollama card")).length).toBeGreaterThan(0);
+ expect(screen.getAllByText("local-openai card").length).toBeGreaterThan(0);
+ expect(screen.queryAllByText("openai card")).toHaveLength(0);
+ expect(screen.queryAllByText("gemini card")).toHaveLength(0);
+ });
+
+ it("filters the subscription-login cards too, not just the API column", async () => {
+ setLocalMode(true);
+ vi.stubGlobal("fetch", mockFetch());
+ render(<JarvisAgentSection />);
+
+ await screen.findAllByText("ollama card");
+ // The three dual-billed / subscription connection cards render their own
+ // headings; none of them survives a filter that means "own hardware only".
+ expect(screen.queryByText("Subscription logins")).toBeNull();
+ expect(screen.queryByText("API keys")).toBeNull();
+ });
+
+ it("explains the shorter list and counts what it hid", async () => {
+ setLocalMode(true);
+ vi.stubGlobal("fetch", mockFetch());
+ render(<JarvisAgentSection />);
+
+ const notice = await screen.findByTestId("local-mode-notice");
+ // openai, gemini, claude-api, openai-codex — four hosted workers.
+ expect(notice.getAttribute("data-hidden-count")).toBe("4");
+ });
+
+ it("never hides the worker that is actually active", async () => {
+ setLocalMode(true);
+ const status = {
+ ...STATUS,
+ mapping: [
+ row("openai", "api", { active: true }),
+ row("gemini", "api"),
+ row("ollama", "local", { keyless: true }),
+ ],
+ };
+ vi.stubGlobal("fetch", mockFetch(status));
+ render(<JarvisAgentSection />);
+
+ await waitFor(() => expect(screen.getByText("ollama card")).toBeTruthy());
+ expect(screen.getAllByText("openai card").length).toBeGreaterThan(0);
+ expect(screen.queryAllByText("gemini card")).toHaveLength(0);
+ });
+});
diff --git a/jarvis/ui/web/frontend/src/components/JarvisAgentSection.tsx b/jarvis/ui/web/frontend/src/components/JarvisAgentSection.tsx
index c338f06c67..2ab8e46484 100644
--- a/jarvis/ui/web/frontend/src/components/JarvisAgentSection.tsx
+++ b/jarvis/ui/web/frontend/src/components/JarvisAgentSection.tsx
@@ -24,6 +24,8 @@ import {
import { BrainModelSelector } from "@/components/BrainModelSelector";
import { ApiKeyForm } from "@/components/ApiKeyForm";
import { AgentAccountsPanel } from "@/components/AgentAccountsPanel";
+import { LocalModeNotice } from "@/components/providers/ProviderTierSection";
+import { filterForLocalMode, useLocalMode } from "@/lib/localMode";
/**
* Subagent tier for the API-Keys view.
@@ -153,6 +155,10 @@ export function JarvisAgentSection({
useState<AntigravityStatus | null>(null);
const [claudeStatus, setClaudeStatus] = useState<ClaudeStatus | null>(null);
const [error, setError] = useState<string | null>(null);
+ // The same per-machine view preference the provider tiers read. The subagent
+ // tier used to ignore it, which made Local Mode look broken exactly where a
+ // keyless install most needs it: this is the tab that picks the worker.
+ const { localMode, setLocalMode } = useLocalMode();
// Re-fetch on brain-switch / subagent-switch / secret-set so the active
// provider highlight + the per-provider "Key gesetzt" badges track live.
@@ -216,30 +222,69 @@ export function JarvisAgentSection({
// connection cards; their "Set active" control now lives ON those cards, so
// exclude them from the generic provider list to avoid a duplicate card per
// CLI (the confusing "no select button on the subscription" the user hit).
- const codexRow = bridge.mapping.find((r) => r.jarvis === "openai-codex");
- const antigravityRow = bridge.mapping.find((r) => r.jarvis === "antigravity");
+ // Local Mode applies to EVERY card on this tab, including the three
+ // subscription-login cards below — a keyless install has no ChatGPT plan
+ // either, and hiding only the API column would have been a half-answer.
+ // Same rule as the provider tiers: own-hardware cards stay, plus whichever
+ // card is the ACTIVE worker, so the tab can always show what is running.
+ const isActiveRow = (r: SubagentMappingRow) => r.is_active_brain;
+ const { visible: localVisibleRows, hiddenCount: hiddenByLocalMode } =
+ filterForLocalMode(bridge.mapping, localMode, isActiveRow);
+ const shown = new Set(localVisibleRows.map((r) => r.jarvis));
+ const inLocalMode = (r: SubagentMappingRow | undefined) =>
+ r && shown.has(r.jarvis) ? r : undefined;
+
+ const codexRow = inLocalMode(
+ bridge.mapping.find((r) => r.jarvis === "openai-codex"),
+ );
+ const antigravityRow = inLocalMode(
+ bridge.mapping.find((r) => r.jarvis === "antigravity"),
+ );
// Claude is dual-billed (Claude Max subscription OR Anthropic API key) — it
// gets its own connection card showing the signed-in account, like Codex /
// Antigravity, so exclude it from the generic per-key provider list too.
- const claudeRow = bridge.mapping.find((r) => r.jarvis === "claude-api");
- const providerRows = bridge.mapping.filter(
+ const claudeRow = inLocalMode(
+ bridge.mapping.find((r) => r.jarvis === "claude-api"),
+ );
+ const providerRows = localVisibleRows.filter(
(r) =>
r.jarvis !== "openai-codex" &&
r.jarvis !== "antigravity" &&
r.jarvis !== "claude-api",
);
// Split the generic providers by access type so each lands in the right
- // column. Practically these are all API-key providers (gemini/openai/…), but
- // splitting on the backend `billing` field keeps a future subscription
- // provider in the correct column instead of the wrong one (AP-21: gate on
- // capability, never a provider name).
- const subProviderRows = providerRows.filter((r) => r.billing !== "api");
+ // group. Splitting on the backend `billing` field keeps a future provider in
+ // the correct group instead of the wrong one (AP-21: gate on capability,
+ // never a provider name).
+ //
+ // Own-hardware workers get their OWN group rather than riding along in the
+ // subscription column. They were landing there because the split was
+ // "anything that is not billed per token", which put Ollama under a heading
+ // that reads "sign in with an account" — the opposite of what a keyless card
+ // is. Three access types, three headings.
+ const localProviderRows = providerRows.filter((r) => r.billing === "local");
+ const subProviderRows = providerRows.filter(
+ (r) => r.billing !== "api" && r.billing !== "local",
+ );
const apiProviderRows = providerRows.filter((r) => r.billing === "api");
+ const hasSubscriptionColumn =
+ Boolean(codexRow || antigravityRow || claudeRow) || subProviderRows.length > 0;
+ const hasApiColumn = Boolean(claudeRow) || apiProviderRows.length > 0;
return (
<section className="space-y-4">
{!hideHeader && <SectionHeader label={t("apikeys_view.tier_subagent")} />}
+ {localMode && hiddenByLocalMode > 0 && (
+ <LocalModeNotice
+ hiddenCount={hiddenByLocalMode}
+ keptActiveHosted={localVisibleRows.some(
+ (r) => isActiveRow(r) && r.billing !== "local",
+ )}
+ onDisable={() => setLocalMode(false)}
+ />
+ )}
+
<BridgeStatusStrip status={bridge} />
{/* The model pin sits right under the status strip — it is the setting
@@ -254,19 +299,45 @@ export function JarvisAgentSection({
{/* Scoped Agent keys are managed here. Older shared Brain keys remain a
compatibility fallback and are labelled honestly on the relevant card. */}
- <p className="flex items-start gap-2 px-1 text-[11px] leading-relaxed text-muted-foreground">
- <ArrowUp className="mt-0.5 h-3 w-3 shrink-0 text-primary" />
- <span>
- API-backed Agents can use a dedicated key set on this tab. Existing
- Brain keys remain available as a compatibility fallback; Realtime keys
- stay isolated to Realtime Voice.
- </span>
- </p>
+ {/* Suppressed once Local Mode has filtered the API column away: a note
+ about dedicated keys, above a screen with no key fields on it, is the
+ kind of leftover that makes a filtered view feel broken. */}
+ {hasApiColumn && (
+ <p className="flex items-start gap-2 px-1 text-[11px] leading-relaxed text-muted-foreground">
+ <ArrowUp className="mt-0.5 h-3 w-3 shrink-0 text-primary" />
+ <span>
+ API-backed Agents can use a dedicated key set on this tab. Existing
+ Brain keys remain available as a compatibility fallback; Realtime keys
+ stay isolated to Realtime Voice.
+ </span>
+ </p>
+ )}
{/* Two access-typed columns so the two ways to power an agent never mix:
subscription logins (violet) on the left, API-key providers (sky) on
the right. The colour matches each card's access badge + accent stripe. */}
+ {/* Own-hardware workers lead, full width. They are the group with no
+ account and no bill behind them, so they belong to neither column —
+ and putting them first is what makes the Subagents tab usable at all
+ on an install that entered no credentials. */}
+ {localProviderRows.length > 0 && (
+ <div className="space-y-3">
+ <ColumnHeader
+ icon={Laptop}
+ title="On your own hardware"
+ hint="no account, no key"
+ tone="emerald"
+ />
+ <div className="grid gap-3 md:grid-cols-2 md:items-start">
+ {localProviderRows.map((row) => (
+ <SubagentProviderCard key={row.jarvis} row={row} onSwitched={reload} />
+ ))}
+ </div>
+ </div>
+ )}
+
<div className="grid gap-4 md:grid-cols-2 md:items-start">
+ {hasSubscriptionColumn && (
<div className="space-y-3">
<ColumnHeader
icon={Sparkles}
@@ -299,7 +370,9 @@ export function JarvisAgentSection({
<SubagentProviderCard key={row.jarvis} row={row} onSwitched={reload} />
))}
</div>
+ )}
+ {hasApiColumn && (
<div className="space-y-3">
<ColumnHeader
icon={CreditCard}
@@ -318,6 +391,7 @@ export function JarvisAgentSection({
<SubagentProviderCard key={row.jarvis} row={row} onSwitched={reload} />
))}
</div>
+ )}
</div>
{/* Below the two columns rather than inside one: this is a second axis.
@@ -602,9 +676,16 @@ function ColumnHeader({
icon: LucideIcon;
title: string;
hint: string;
- tone: "violet" | "sky";
+ /** Matches the access accent each card in the group already carries:
+ * violet = subscription login, sky = API key, emerald = own hardware. */
+ tone: "violet" | "sky" | "emerald";
}) {
- const toneCls = tone === "violet" ? "text-violet-400" : "text-sky-400";
+ const toneCls =
+ tone === "violet"
+ ? "text-violet-400"
+ : tone === "emerald"
+ ? "text-emerald-400"
+ : "text-sky-400";
return (
<div className="flex items-center gap-2 px-1 pb-0.5">
<Icon className={cn("h-4 w-4", toneCls)} />
diff --git a/jarvis/ui/web/frontend/src/components/providers/ProviderTierSection.tsx b/jarvis/ui/web/frontend/src/components/providers/ProviderTierSection.tsx
index 855a8cece9..32db45f4c3 100644
--- a/jarvis/ui/web/frontend/src/components/providers/ProviderTierSection.tsx
+++ b/jarvis/ui/web/frontend/src/components/providers/ProviderTierSection.tsx
@@ -427,6 +427,10 @@ export function LocalModeNotice({
return (
<div
data-testid="local-mode-notice"
+ // The count as a plain attribute as well as in the sentence: the sentence
+ // is a translated template, so this is the one place a test (or a support
+ // screenshot) can read the number without depending on wording.
+ data-hidden-count={hiddenCount}
className="mb-3 flex items-start gap-2.5 rounded-xl border border-primary/25 bg-primary/[0.05] px-3 py-2"
>
<HardDrive aria-hidden="true" className="mt-0.5 h-4 w-4 shrink-0 text-primary" />
@@ -468,6 +472,7 @@ export function VoiceEngineContext({
activeSessionProvider,
activeSessionModel,
transitioning,
+ lastStartError = null,
liveMode,
onOpenRecommendedTab,
}: {
@@ -489,6 +494,8 @@ export function VoiceEngineContext({
activeSessionProvider: string;
activeSessionModel: string;
transitioning: boolean;
+ /** Why the LAST realtime start attempt failed; null while connecting/live. */
+ lastStartError?: { provider: string; message: string; at: number } | null;
liveMode: string;
onOpenRecommendedTab: (tab: RecommendationTab) => void;
}) {
@@ -599,6 +606,18 @@ export function VoiceEngineContext({
</p>
)}
+ {liveMode === "realtime" && lastStartError && (
+ <p
+ data-testid="voice-engine-last-start-error"
+ className="mt-1 text-[11px] leading-snug text-amber-600 dark:text-amber-400"
+ aria-live="polite"
+ >
+ {t("voice_state.connect_failed")
+ .replace("{0}", lastStartError.provider || "?")
+ .replace("{1}", lastStartError.message)}
+ </p>
+ )}
+
<p
data-testid="voice-engine-keys-hint"
className="mt-1 text-[11px] leading-snug text-muted-foreground/80"
diff --git a/jarvis/ui/web/frontend/src/lib/localMode.ts b/jarvis/ui/web/frontend/src/lib/localMode.ts
index 1caa7552d2..1fe5354924 100644
--- a/jarvis/ui/web/frontend/src/lib/localMode.ts
+++ b/jarvis/ui/web/frontend/src/lib/localMode.ts
@@ -31,7 +31,7 @@
* unit-testable without a renderer.
*/
import { create } from "zustand";
-import type { ProviderDescriptor } from "@/hooks/useProviders";
+import type { Billing } from "@/hooks/useProviders";
/** Where the preference is stored, per machine. */
export const LOCAL_MODE_KEY = "jarvis.providers.localMode";
@@ -71,14 +71,20 @@ export function writeLocalMode(value: boolean): void {
* `"local"`. Reading that field keeps the definition in ONE place — the moment
* a new keyless card ships, it shows up in Local Mode without a code change
* here, and a hosted card can never sneak in by being named "local-something".
+ *
+ * Deliberately typed on the field rather than on `ProviderDescriptor`: the
+ * subagent tier has its OWN row shape (`/api/jarvis-agent/status` returns a
+ * different payload) and carries the very same backend `billing` value. One
+ * definition serves both, so Local Mode cannot mean two different things on
+ * two tabs — which is exactly how the subagents tab came to ignore it.
*/
-export function runsOnOwnHardware(provider: ProviderDescriptor): boolean {
+export function runsOnOwnHardware(provider: { billing: Billing }): boolean {
return provider.billing === "local";
}
-export interface LocalModeFilter {
+export interface LocalModeFilter<T> {
/** The cards to render, in the order they came in. */
- visible: ProviderDescriptor[];
+ visible: T[];
/** How many hosted cards Local Mode took off the screen. */
hiddenCount: number;
/** True when a hosted card was kept because it is the ACTIVE one. */
@@ -86,23 +92,27 @@ export interface LocalModeFilter {
}
/**
- * Apply Local Mode to one tier's card list.
+ * Apply Local Mode to one list of provider cards.
*
* Disabled, this is the identity function — the exact same array comes back, so
* the off state cannot differ from the pre-feature behaviour in any way.
+ *
+ * `isActive` defaults to the `active` field the provider-tier payload uses; the
+ * subagent rows name theirs differently and pass their own reader.
*/
-export function filterForLocalMode(
- providers: ProviderDescriptor[],
+export function filterForLocalMode<T extends { billing: Billing; active?: boolean }>(
+ items: T[],
enabled: boolean,
-): LocalModeFilter {
+ isActive: (item: T) => boolean = (item) => item.active === true,
+): LocalModeFilter<T> {
if (!enabled) {
- return { visible: providers, hiddenCount: 0, keptActiveHosted: false };
+ return { visible: items, hiddenCount: 0, keptActiveHosted: false };
}
- const visible = providers.filter((p) => runsOnOwnHardware(p) || p.active);
+ const visible = items.filter((p) => runsOnOwnHardware(p) || isActive(p));
return {
visible,
- hiddenCount: providers.length - visible.length,
- keptActiveHosted: visible.some((p) => p.active && !runsOnOwnHardware(p)),
+ hiddenCount: items.length - visible.length,
+ keptActiveHosted: visible.some((p) => isActive(p) && !runsOnOwnHardware(p)),
};
}