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
fix(onboarding): make the local-brain button land on the local brain
rubenluetke10-beep510a29b3b354
diff --git a/jarvis/ui/web/frontend/src/components/onboarding/steps/ApiKeysStep.test.tsx b/jarvis/ui/web/frontend/src/components/onboarding/steps/ApiKeysStep.test.tsxindex 5f21691ec2..3b79a2d19a 100644--- a/jarvis/ui/web/frontend/src/components/onboarding/steps/ApiKeysStep.test.tsx+++ b/jarvis/ui/web/frontend/src/components/onboarding/steps/ApiKeysStep.test.tsx@@ -12,8 +12,11 @@ afterEach(() => {type ProbeShape = { source: string; models: { id: string }[] } | null;-/** Stub fetch for the local-path probe (+ the brain switch). `null` = network error. */-function stubFetch(probe: ProbeShape) {+/**+ * Stub fetch for the local-path probe (+ the brain switch and the engine pin).+ * `null` = network error.+ */+function stubFetch(probe: ProbeShape, { voiceModeOk = true } = {}) {const calls: { url: string; init?: RequestInit }[] = [];vi.stubGlobal("fetch",@@ -26,6 +29,15 @@ function stubFetch(probe: ProbeShape) {if (url === "/api/brain/switch") {return { ok: true, json: async () => ({ ok: true }) } as Response;}+ if (url === "/api/settings/voice-mode") {+ if (!voiceModeOk) {+ return {+ ok: false,+ text: async () => "engine pin refused",+ } as Response;+ }+ return { ok: true, json: async () => ({ ok: true }) } as Response;+ }throw new Error(`unexpected fetch: ${url}`);}),);@@ -109,6 +121,40 @@ it("probes through the backend and offers one-click local activation", async ()expect(calls[0].url).toBe("/api/providers/ollama/models");});+it("pins the pipeline engine so the local brain is actually used", async () => {+ const calls = stubFetch({ source: "live", models: [{ id: "qwen3.5:9b" }] });+ renderStep();++ await screen.findByText("onboarding.api_keys.local_detected");+ fireEvent.click(+ screen.getByRole("button", { name: "onboarding.api_keys.local_use_button" }),+ );+ await screen.findByText("onboarding.api_keys.local_active");++ // Realtime replaces STT+Brain+TTS and never reads `[brain].primary`, so+ // activating the local brain without pinning Pipeline changes nothing the+ // user can hear — and `[voice].mode` defaults to realtime.+ const modeCall = calls.find((c) => c.url === "/api/settings/voice-mode");+ expect(modeCall?.init?.method).toBe("PUT");+ expect(JSON.parse(String(modeCall?.init?.body))).toMatchObject({+ mode: "pipeline",+ persist: true,+ });+});++it("reports a refused engine pin instead of claiming the local path is live", async () => {+ stubFetch({ source: "live", models: [{ id: "qwen3.5:9b" }] }, { voiceModeOk: false });+ renderStep();++ await screen.findByText("onboarding.api_keys.local_detected");+ fireEvent.click(+ screen.getByRole("button", { name: "onboarding.api_keys.local_use_button" }),+ );++ await screen.findByText("engine pin refused");+ expect(screen.queryByText("onboarding.api_keys.local_active")).toBeNull();+});+it("tells a running-but-empty Ollama to pull a model first", async () => {stubFetch({ source: "live", models: [] });renderStep();diff --git a/jarvis/ui/web/frontend/src/components/onboarding/steps/ApiKeysStep.tsx b/jarvis/ui/web/frontend/src/components/onboarding/steps/ApiKeysStep.tsxindex 92f370de9f..99a4703b3e 100644--- a/jarvis/ui/web/frontend/src/components/onboarding/steps/ApiKeysStep.tsx+++ b/jarvis/ui/web/frontend/src/components/onboarding/steps/ApiKeysStep.tsx@@ -2,6 +2,7 @@ import { useEffect, useState } from "react";import { CheckCircle2, HardDrive, KeyRound, Radio, Waypoints } from "lucide-react";import { Button } from "@/components/ui/button";import { switchBrainProvider } from "@/hooks/useProviders";+import { putVoiceMode } from "@/lib/voiceEngineMode";import { useT } from "@/i18n";import type { StepProps } from "../OnboardingFlow";@@ -48,6 +49,13 @@ function LocalPathCard() {setError(null);try {await switchBrainProvider("ollama");+ // Picking the local brain has to pin the PIPELINE engine as well.+ // Realtime replaces STT + Brain + TTS with one full-duplex cloud model+ // and never consults `[brain].primary`, and `[voice].mode` defaults to+ // realtime — so activating the local brain alone left the user on the+ // realtime cards with their choice having changed nothing audible.+ // Persisted, because onboarding ends in a restart.+ await putVoiceMode("pipeline");setActive(true);} catch (e) {setError(e instanceof Error ? e.message : String(e));diff --git a/jarvis/ui/web/frontend/src/components/providers/ProviderTierSection.order.test.tsx b/jarvis/ui/web/frontend/src/components/providers/ProviderTierSection.order.test.tsxnew file mode 100644index 0000000000..ff3480fe1d--- /dev/null+++ b/jarvis/ui/web/frontend/src/components/providers/ProviderTierSection.order.test.tsx@@ -0,0 +1,125 @@+/**+ * Card ORDER inside one provider tier.+ *+ * Two rules pull against each other and both matter:+ *+ * 1. The provider the tier actually runs on has to LEAD, or a fresh pick+ * (onboarding's local path is the sharpest case: the user chooses "run+ * local" and then has to find that card) sits buried in catalog order+ * below cards they never touched.+ * 2. Nothing may reorder while the list is on screen — a card that jumps to+ * the top the instant it is activated moves the next card under the+ * pointer mid-click.+ *+ * No jest-dom in this repo — assertions use plain values.+ */+import { afterEach, beforeEach, expect, it, vi } from "vitest";+import { cleanup, render, screen } from "@testing-library/react";++import { TierSection } from "@/components/providers/ProviderTierSection";+import type { ProviderDescriptor } from "@/hooks/useProviders";++function brainCard(over: Partial<ProviderDescriptor> = {}): ProviderDescriptor {+ return {+ id: "cloud-a",+ label: "Cloud A",+ tier: "brain",+ auth_mode: "api_key",+ secret_keys: ["cloud_a_api_key"],+ secrets_set: { cloud_a_api_key: true },+ dashboard_url: null,+ login_cli: null,+ install_hint: null,+ credential_path_hint: null,+ configured: true,+ active: false,+ cli_installed: null,+ credential_help: null,+ signup_url: null,+ billing: "api",+ alt_credential: null,+ ...over,+ };+}++/** Card labels in rendered order. */+function order(): string[] {+ return screen+ .getAllByRole("listitem")+ .map((li) => li.textContent ?? "")+ .map((text) => text.match(/Cloud A|Cloud B|Local X/)?.[0] ?? "");+}++beforeEach(() => {+ (globalThis as unknown as { fetch: typeof fetch }).fetch = vi.fn(+ async () =>+ ({+ ok: true,+ status: 200,+ json: async () => ({}),+ text: async () => "{}",+ }) as Response,+ ) as unknown as typeof fetch;+});++afterEach(() => {+ cleanup();+ vi.restoreAllMocks();+});++it("leads with the provider the tier runs on, then configured, then the rest", () => {+ render(+ <TierSection+ providers={[+ brainCard(),+ brainCard({ id: "cloud-b", label: "Cloud B", configured: false, secrets_set: {} }),+ // Keyless local provider — active without any credential, which is+ // exactly the shape the onboarding local path leaves behind.+ brainCard({+ id: "local-x",+ label: "Local X",+ auth_mode: "none",+ secret_keys: [],+ secrets_set: {},+ configured: false,+ active: true,+ billing: "local",+ }),+ ]}+ onChanged={() => {}}+ onActivateOptimistic={() => {}}+ />,+ );++ expect(order()).toEqual(["Local X", "Cloud A", "Cloud B"]);+});++it("does not re-sort under the pointer when the active provider changes", () => {+ const view = render(+ <TierSection+ providers={[+ brainCard(),+ brainCard({ id: "cloud-b", label: "Cloud B", configured: false, secrets_set: {} }),+ brainCard({ id: "local-x", label: "Local X", configured: true, active: true }),+ ]}+ onChanged={() => {}}+ onActivateOptimistic={() => {}}+ />,+ );+ expect(order()).toEqual(["Local X", "Cloud A", "Cloud B"]);++ // The user activates a different card: the lead is anchored to the mount, so+ // the list stays put. The new pick leads on the next visit to this tier.+ view.rerender(+ <TierSection+ providers={[+ brainCard({ active: true }),+ brainCard({ id: "cloud-b", label: "Cloud B", configured: false, secrets_set: {} }),+ brainCard({ id: "local-x", label: "Local X", configured: true, active: false }),+ ]}+ onChanged={() => {}}+ onActivateOptimistic={() => {}}+ />,+ );+ expect(order()).toEqual(["Local X", "Cloud A", "Cloud B"]);+});diff --git a/jarvis/ui/web/frontend/src/components/providers/ProviderTierSection.tsx b/jarvis/ui/web/frontend/src/components/providers/ProviderTierSection.tsxindex fe1016a80d..e29a3c3688 100644--- a/jarvis/ui/web/frontend/src/components/providers/ProviderTierSection.tsx+++ b/jarvis/ui/web/frontend/src/components/providers/ProviderTierSection.tsx@@ -727,16 +727,29 @@ export function TierSection({health?: SectionHealth;}) {const tierHasActive = providers.some((p) => p.active);- // Configured (or active) providers first — the wall of empty key forms used+ // The provider this tier actually RUNS on leads the list. Somebody who just+ // picked one — onboarding's local path being the sharpest case — has to find+ // it at the top, not somewhere inside the catalog order below cards they+ // never touched. Capability-driven: whatever is active leads, no provider id+ // is named here (AP-21).+ //+ // Anchored on the id that was active when this list FIRST rendered, never on+ // the live one: re-sorting on every change would yank a card to the top+ // under the pointer the moment it is activated. The anchor re-arms when the+ // tier is re-entered (the view remounts this list per tab/mode change), so+ // the next visit leads with the new choice.+ const [leadId] = useState<string | null>(+ () => providers.find((p) => p.active)?.id ?? null,+ );+ // Configured (or active) providers next — the wall of empty key forms used// to bury the one or two cards the user actually set up. `active` counts so// an active-but-keyless anomaly (e.g. a free-tier provider) can never hide// below untouched cards; among configured cards nothing reorders on a switch// (both stay rank 0), so a card never jumps under the pointer mid-click.// Stable within each group (Array.sort is stable).- const sorted = [...providers].sort(- (a, b) =>- Number(b.configured || b.active) - Number(a.configured || a.active),- );+ const rank = (p: ProviderDescriptor) =>+ p.id === leadId ? 2 : Number(p.configured || p.active);+ const sorted = [...providers].sort((a, b) => rank(b) - rank(a));return (<ul className="space-y-3">{sorted.map((p) => (diff --git a/jarvis/ui/web/frontend/src/hooks/useVoiceMode.ts b/jarvis/ui/web/frontend/src/hooks/useVoiceMode.tsindex 80ab7af378..a84eb27013 100644--- a/jarvis/ui/web/frontend/src/hooks/useVoiceMode.ts+++ b/jarvis/ui/web/frontend/src/hooks/useVoiceMode.ts@@ -7,6 +7,7 @@ import {type RealtimeTransportIssue,type RealtimeTransportIssueDetail,} from "@/lib/realtimeTransportIssue";+import { putVoiceMode, type VoiceEngineModeValue } from "@/lib/voiceEngineMode";import { useEventStore } from "@/store/events";type VoiceModeResp = {@@ -168,15 +169,8 @@ export function useVoiceMode() {}, [qc]);const m = useMutation({- mutationFn: async (mode: string) => {- const r = await fetch("/api/settings/voice-mode", {- method: "PUT",- headers: { "content-type": "application/json" },- body: JSON.stringify({ mode, persist: true }),- });- if (!r.ok) throw new Error(await r.text());- return r.json();- },+ mutationFn: async (mode: string) =>+ putVoiceMode(mode as VoiceEngineModeValue),// Optimistic: flip the cached mode BEFORE the PUT resolves, so the// Pipeline|Realtime segment's filled "live" state follows the click// instantly (the persist can take seconds on a busy backend, and the UIdiff --git a/jarvis/ui/web/frontend/src/i18n/locales/de.json b/jarvis/ui/web/frontend/src/i18n/locales/de.jsonindex ab9c7a63f7..a0b1247358 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/de.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/de.json@@ -2101,7 +2101,7 @@"local_detected": "Ollama auf diesem Rechner gefunden — Jarvis kann komplett lokal denken, ganz ohne Key.","local_detected_empty": "Ollama läuft, hat aber noch kein Modell — lade zuerst eins (z. B. ollama pull qwen3.5).","local_use_button": "Lokales Modell verwenden",- "local_active": "Lokales Gehirn aktiv — Ollama antwortet von diesem Rechner.",+ "local_active": "Lokales Gehirn aktiv — Ollama antwortet von diesem Rechner, und die Sprache steht auf Pipeline, damit es auch genutzt wird.","local_missing": "Kein API-Key zur Hand? Installiere Ollama und Jarvis läuft komplett lokal — ohne Cloud-Konto.","local_missing_link": "Ollama holen","continue": "Onboarding fortsetzen"diff --git a/jarvis/ui/web/frontend/src/i18n/locales/en.json b/jarvis/ui/web/frontend/src/i18n/locales/en.jsonindex fed88bb6ca..a0cd4fa4b1 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/en.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/en.json@@ -2101,7 +2101,7 @@"local_detected": "Ollama detected on this machine — Jarvis can think fully local, no key needed.","local_detected_empty": "Ollama is running but has no model yet — pull one first (e.g. ollama pull qwen3.5).","local_use_button": "Use local model",- "local_active": "Local brain active — Ollama answers from this machine.",+ "local_active": "Local brain active — Ollama answers from this machine, and voice is set to Pipeline so it is actually used.","local_missing": "No API key at hand? Install Ollama and Jarvis runs fully local — no cloud account needed.","local_missing_link": "Get Ollama","continue": "Continue onboarding"diff --git a/jarvis/ui/web/frontend/src/i18n/locales/es.json b/jarvis/ui/web/frontend/src/i18n/locales/es.jsonindex aaa82f86c1..ae6edb861b 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/es.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/es.json@@ -2101,7 +2101,7 @@"local_detected": "Ollama detectado en este equipo: Jarvis puede pensar totalmente en local, sin clave.","local_detected_empty": "Ollama está en marcha pero aún no tiene ningún modelo: descarga uno primero (p. ej. ollama pull qwen3.5).","local_use_button": "Usar modelo local",- "local_active": "Cerebro local activo: Ollama responde desde este equipo.",+ "local_active": "Cerebro local activo: Ollama responde desde este equipo y la voz queda en Pipeline para que se use de verdad.","local_missing": "¿Sin clave API a mano? Instala Ollama y Jarvis funciona totalmente en local, sin cuenta en la nube.","local_missing_link": "Obtener Ollama","continue": "Continuar la introducción"diff --git a/jarvis/ui/web/frontend/src/lib/voiceEngineMode.ts b/jarvis/ui/web/frontend/src/lib/voiceEngineMode.tsnew file mode 100644index 0000000000..3ea4dd1395--- /dev/null+++ b/jarvis/ui/web/frontend/src/lib/voiceEngineMode.ts@@ -0,0 +1,33 @@+/**+ * The one client-side writer for `[voice].mode`.+ *+ * It lives outside `useVoiceMode` so callers that are not React hooks can pin+ * the engine through the SAME route the segmented Pipeline|Realtime switch+ * uses. The onboarding local path needs exactly that from a plain click+ * handler, and a second hand-rolled fetch is precisely where the two would+ * drift apart (persist flag, error shape, endpoint).+ */++/** Engine modes the backend accepts (`settings_routes._VOICE_MODES`). */+export type VoiceEngineModeValue = "pipeline" | "realtime";++/**+ * PUT `[voice].mode`. Persisted by default — an engine choice is a standing+ * decision that has to survive the next restart, not a session-only nudge.+ *+ * Throws with the backend's own message on a refusal (e.g. pinning realtime+ * while no realtime provider is ready), so the caller can render the reason+ * verbatim instead of inventing one.+ */+export async function putVoiceMode(+ mode: VoiceEngineModeValue,+ { persist = true }: { persist?: boolean } = {},+): Promise<unknown> {+ const res = await fetch("/api/settings/voice-mode", {+ method: "PUT",+ headers: { "content-type": "application/json" },+ body: JSON.stringify({ mode, persist }),+ });+ if (!res.ok) throw new Error(await res.text());+ return res.json();+}