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(local-models): the setup helper is a screen that names its own brain
rubenluetke10-beep4acd749f3b51
diff --git a/jarvis/ui/web/frontend/src/components/local-models/AssistantContext.tsx b/jarvis/ui/web/frontend/src/components/local-models/AssistantContext.tsxnew file mode 100644index 0000000000..f8f9720a95--- /dev/null+++ b/jarvis/ui/web/frontend/src/components/local-models/AssistantContext.tsx@@ -0,0 +1,283 @@+/**+ * The setup helper's context rail — who is answering, and what runs locally.+ *+ * The section is called "Local models", but the helper itself is NOT one: it+ * runs on the Agents-tier Tool Model, in the cloud, billed through that key+ * (`jarvis/local_models/assistant_session.py`). Every step it narrates+ * ("Downloaded ornith:9b") is about a model on this machine. Without naming+ * both, a reader cannot tell who is speaking from what is being installed —+ * so the rail names the brain at the top and the machine's roles underneath,+ * in that order.+ *+ * Nothing here is new data: the pair comes from the `/session` response the+ * panel already fetches, the roles and the server from the same two queries+ * the Overview tab runs (one React-Query cache, so switching tabs re-fetches+ * nothing).+ *+ * On a narrow window the rail is gone and `AssistantOriginChip` carries the+ * same answer in the header — one line instead of three blocks.+ */+import { useMemo } from "react";++import { ProviderLogo } from "@/components/providers/ProviderLogo";+import { StatusDot } from "@/components/extensions/primitives";+import { useRoles, useServer } from "@/hooks/useLocalModels";+import { fill, useT } from "@/i18n";+import { cn } from "@/lib/utils";++import type { AssistantHealth, AssistantSessionResponse } from "./assistantApi";+import { assistantTimestamp } from "./assistantApi";++/** The tone a health record draws with — shared by the rail and the timeline. */+export function healthTone(+ health: AssistantHealth | null,+): "ok" | "off" | "warn" | "error" {+ if (!health) return "off";+ if (health.status === "ok") return "ok";+ if (health.status === "unknown") return "off";+ return "warn";+}++/** "gemini" -> "Gemini" when nothing better is known; the resolver wins. */+export function providerDisplayName(+ providerId: string,+ resolve?: (id: string) => string,+): string {+ const resolved = resolve?.(providerId);+ if (resolved && resolved !== providerId) return resolved;+ return providerId ? providerId[0].toUpperCase() + providerId.slice(1) : "";+}++export interface AssistantContextProps {+ /** The local server's card id — the roles and server queries hang off it. */+ providerId: string;+ /** What the section calls that server ("Ollama"). */+ serverLabel: string;+ /** `/session`: the Agents-tier pair plus whether it can run right now. */+ session: AssistantSessionResponse | null;+ health: AssistantHealth | null;+ onOpenApiKeys: () => void;+ /** Starts a diagnose run — the Fix beside a failing health record. */+ onDiagnose: () => void;+ /** Provider id -> display label, from the section's provider list. */+ providerLabel?: (id: string) => string;+}++/** The one-line answer to "who is writing this?", for narrow windows. */+export function AssistantOriginChip({+ session,+ providerLabel,+ onOpenApiKeys,+}: {+ session: AssistantSessionResponse | null;+ providerLabel?: (id: string) => string;+ onOpenApiKeys: () => void;+}) {+ const t = useT();+ if (!session?.provider) return null;+ const label = providerDisplayName(session.provider, providerLabel);+ return (+ <button+ type="button"+ onClick={onOpenApiKeys}+ title={t("local_models.assistant.origin_cloud")}+ data-testid="assistant-origin-chip"+ className={cn(+ "inline-flex max-w-[18rem] items-center gap-1.5 rounded-full border border-border bg-card px-2.5 py-1",+ "text-[11.5px] text-muted-foreground transition-colors hover:text-foreground",+ "focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",+ )}+ >+ <ProviderLogo providerId={session.provider} label={label} size="sm" />+ <span className="truncate">+ {label}+ {session.model ? ` · ${session.model}` : ""}+ </span>+ {!session.ready && (+ <span className="h-1.5 w-1.5 shrink-0 rounded-full bg-amber-500" aria-hidden />+ )}+ </button>+ );+}++export function AssistantContext({+ providerId,+ serverLabel,+ session,+ health,+ onOpenApiKeys,+ onDiagnose,+ providerLabel,+}: AssistantContextProps) {+ const t = useT();+ const roles = useRoles(providerId);+ const server = useServer(providerId);++ // The primary slots only — the read-only advanced ones live in the Roles+ // panel behind "More roles" and would turn a rail into a ledger.+ const rows = useMemo(+ () => (roles.data?.roles ?? []).filter((r) => !r.advanced),+ [roles.data],+ );++ const checkedAt = assistantTimestamp(health?.checked_at);+ const needsFix = health?.status === "error" || health?.status === "needs_setup";+ const brandLabel = session?.provider+ ? providerDisplayName(session.provider, providerLabel)+ : "";++ return (+ <aside+ className="hidden w-[19rem] shrink-0 flex-col gap-7 overflow-y-auto border-l border-border/70 bg-card/30 px-5 py-6 xl:flex"+ data-testid="assistant-context"+ >+ {/* ── who is answering ─────────────────────────────────────────── */}+ <section data-testid="assistant-origin">+ <RailTitle>{t("local_models.assistant.origin_title")}</RailTitle>+ {brandLabel ? (+ <>+ <div className="mt-2.5 flex items-center gap-2">+ <ProviderLogo+ providerId={session?.provider ?? ""}+ label={brandLabel}+ size="sm"+ />+ <span className="truncate text-[13.5px] font-medium text-foreground">+ {brandLabel}+ </span>+ </div>+ <p+ className="mt-1 break-all font-mono text-[11.5px] leading-snug text-muted-foreground"+ data-testid="assistant-origin-model"+ >+ {session?.model || t("local_models.assistant.origin_default_model")}+ </p>+ </>+ ) : (+ <p className="mt-2.5 text-[12.5px] text-muted-foreground">+ {t("local_models.assistant.origin_unset")}+ </p>+ )}++ {session && !session.ready && session.reason ? (+ <p+ className="mt-3 rounded-lg border border-amber-500/40 bg-amber-500/10 px-2.5 py-2 text-[12px] leading-relaxed"+ data-testid="assistant-origin-blocked"+ >+ {session.reason}+ </p>+ ) : (+ <p className="mt-3 text-[12px] leading-relaxed text-muted-foreground">+ {t("local_models.assistant.origin_cloud")}+ </p>+ )}++ <button+ type="button"+ onClick={onOpenApiKeys}+ className="mt-2 text-[12px] font-medium text-primary underline-offset-4 hover:underline"+ data-testid="assistant-origin-change"+ >+ {t("local_models.assistant.origin_change")}+ </button>+ </section>++ {/* ── what runs here ───────────────────────────────────────────── */}+ <section data-testid="assistant-machine">+ <RailTitle>{t("local_models.assistant.machine_title")}</RailTitle>+ <div className="mt-2.5">+ <StatusDot+ tone={server.data?.running ? "ok" : "off"}+ label={+ <span className="text-[12.5px]">+ {fill(+ t(+ server.data?.running+ ? "local_models.assistant.machine_server_running"+ : "local_models.assistant.machine_server_stopped",+ ),+ { server: serverLabel },+ )}+ </span>+ }+ />+ </div>++ {rows.length > 0 ? (+ <dl className="mt-3 flex flex-col gap-2">+ {rows.map((row) => {+ // Configured but gone from the server: the run will fail on it,+ // so it reads as a warning here rather than as a plain name.+ const missing = row.current !== "" && !row.installed;+ return (+ <div key={row.id} className="flex flex-col gap-0.5">+ <dt className="text-[11.5px] text-muted-foreground">+ {t(row.label_key)}+ </dt>+ <dd+ className={cn(+ "break-all font-mono text-[11.5px] leading-snug",+ row.current ? "text-foreground" : "text-muted-foreground/70",+ missing && "text-amber-500",+ )}+ data-testid={`assistant-machine-${row.id}`}+ >+ {row.current || t("local_models.assistant.machine_unset")}+ {missing && (+ <span className="ml-1 font-sans text-[11px]">+ ({t("local_models.assistant.machine_missing")})+ </span>+ )}+ </dd>+ </div>+ );+ })}+ </dl>+ ) : (+ <p className="mt-3 text-[12px] text-muted-foreground">+ {roles.isLoading+ ? t("local_models.assistant.machine_loading")+ : (roles.data?.error ?? "")}+ </p>+ )}+ </section>++ {/* ── the monitor's verdict, parked instead of scrolling away ──── */}+ {health && checkedAt && (+ <section data-testid="assistant-health-rail">+ <StatusDot+ tone={healthTone(health)}+ label={+ <span className="text-[12px] leading-relaxed">+ {fill(t("local_models.assistant.last_check"), {+ when: checkedAt.toLocaleString(),+ what:+ health.reason ||+ t(`local_models.assistant.health_${health.status}`),+ })}+ </span>+ }+ />+ {needsFix && (+ <button+ type="button"+ onClick={onDiagnose}+ className="mt-1.5 text-[12px] font-medium text-primary underline-offset-4 hover:underline"+ data-testid="assistant-health-rail-fix"+ >+ {t("local_models.assistant.fix")}+ </button>+ )}+ </section>+ )}+ </aside>+ );+}++function RailTitle({ children }: { children: React.ReactNode }) {+ return (+ <h4 className="text-[10.5px] font-semibold uppercase tracking-[0.14em] text-muted-foreground/80">+ {children}+ </h4>+ );+}diff --git a/jarvis/ui/web/frontend/src/components/local-models/AssistantPanel.test.tsx b/jarvis/ui/web/frontend/src/components/local-models/AssistantPanel.test.tsxindex 85677b96ea..06e4d16f22 100644--- a/jarvis/ui/web/frontend/src/components/local-models/AssistantPanel.test.tsx+++ b/jarvis/ui/web/frontend/src/components/local-models/AssistantPanel.test.tsx@@ -1,3 +1,4 @@+import { QueryClient, QueryClientProvider } from "@tanstack/react-query";import { act, cleanup, fireEvent, render, screen, waitFor } from "@testing-library/react";import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";@@ -74,7 +75,7 @@ function finishedTurnWithProposal() {...EMPTY_TIMELINE,lastSeq: 3,items: [- { type: "user" as const, id: "u-1", text: "Help me set up", tsMs: 1 },+ { type: "user" as const, id: "u-1", text: "Help me set up", attachments: [], tsMs: 1 },{type: "turn" as const,id: "t1",@@ -95,6 +96,24 @@ function finishedTurnWithProposal() {};}+/** The rail reads the roles and the server through React Query. */+function renderPanel(props: Record<string, unknown> = {}) {+ const client = new QueryClient({+ defaultOptions: { queries: { retry: false, gcTime: 0 } },+ });+ return render(+ <QueryClientProvider client={client}>+ <AssistantPanel+ providerId="ollama"+ serverLabel="Ollama"+ request={null}+ onOpenApiKeys={() => {}}+ {...props}+ />+ </QueryClientProvider>,+ );+}+beforeEach(() => {vi.stubGlobal("WebSocket", FakeSocket);useLocalModelsAssistantStore.setState({@@ -122,14 +141,7 @@ describe("AssistantPanel", () => {[`POST ${BASE}/run`]: () => reply({ detail: sentence }, 409),});const onOpenApiKeys = vi.fn();- render(- <AssistantPanel- providerId="ollama"- serverLabel="Ollama"- request={{ mode: "setup", token: 1 }}- onOpenApiKeys={onOpenApiKeys}- />,- );+ renderPanel({ request: { mode: "setup", token: 1 }, onOpenApiKeys });await waitFor(() => expect(screen.getByTestId("assistant-blocked")).toBeDefined());expect(screen.getByTestId("assistant-blocked").textContent).toContain(sentence);@@ -146,7 +158,7 @@ describe("AssistantPanel", () => {reply({ status: "error", reason: "chat role: model not installed", since: 1_700_000_000, last_ok: null, checked_at: 1_700_000_000 }),[`POST ${BASE}/run`]: () => reply({ session_id: "s-1", turn_id: "t-1", surface: "local-models" }),});- render(<AssistantPanel providerId="ollama" serverLabel="Ollama" request={null} onOpenApiKeys={() => {}} />);+ renderPanel();await waitFor(() => expect(screen.getByTestId("assistant-health")).toBeDefined());expect(screen.getByTestId("assistant-health").textContent).toContain("chat role: model not installed");@@ -160,7 +172,7 @@ describe("AssistantPanel", () => {it("says so when the backend predates the assistant", async () => {stubFetch({});- render(<AssistantPanel providerId="ollama" serverLabel="Ollama" request={null} onOpenApiKeys={() => {}} />);+ renderPanel();await waitFor(() => expect(screen.getByTestId("assistant-backend-missing")).toBeDefined());});@@ -176,9 +188,11 @@ describe("AssistantPanel", () => {"GET /api/agent-chat/sessions?limit=500&surface=local-models": () => reply({ sessions: [] }),});useLocalModelsAssistantStore.setState({ activeSessionId: "s-1", timeline: finishedTurnWithProposal() });- render(<AssistantPanel providerId="ollama" serverLabel="Ollama" request={null} onOpenApiKeys={() => {}} />);+ renderPanel();await waitFor(() => expect(screen.getByTestId("setup-proposal")).toBeDefined());+ // The turn names who wrote it — read from the turn, not from config.+ expect(screen.getByTestId("assistant-turn-origin").textContent).toContain("\u00b7 m");fireEvent.click(screen.getByTestId("proposal-confirm"));await waitFor(() =>expect(calls.some((c) => c.url.endsWith("/messages") && String(c.body?.text).startsWith("Execute steps: s1, s2 ("))).toBe(true),@@ -212,4 +226,45 @@ describe("AssistantPanel", () => {await new Promise((r) => setTimeout(r, 20));expect(calls.some((c) => c.url.endsWith("/approvals/a-2"))).toBe(false);});+ it("names the brain that answers and marks it as the cloud one", async () => {+ stubFetch({+ [`GET ${BASE}/session`]: () =>+ reply({ session_id: null, provider: "gemini", model: "gemini-3-pro", ready: true, reason: "" }),+ [`GET ${BASE}/health`]: () => reply({}, 404),+ });+ renderPanel();++ await waitFor(() =>+ expect(screen.getByTestId("assistant-origin-model").textContent).toBe("gemini-3-pro"),+ );+ expect(screen.getByTestId("assistant-origin").textContent).toContain("Gemini");+ // Ready: the explaining sentence, not a warning.+ expect(screen.queryByTestId("assistant-origin-blocked")).toBeNull();+ expect(screen.getByTestId("assistant-origin").textContent).toContain(+ "local_models.assistant.origin_cloud",+ );+ // The same answer travels to a narrow window as one chip.+ expect(screen.getByTestId("assistant-origin-chip").textContent).toContain("gemini-3-pro");+ });++ it("says BEFORE the first click when no Tool Model can run the helper", async () => {+ const why = "Pick a Tool Model with an API key first — the helper runs on it.";+ stubFetch({+ [`GET ${BASE}/session`]: () =>+ reply({ session_id: null, provider: "gemini", model: "", ready: false, reason: why }),+ [`GET ${BASE}/health`]: () => reply({}, 404),+ });+ const onOpenApiKeys = vi.fn();+ renderPanel({ onOpenApiKeys });++ await waitFor(() =>+ expect(screen.getByTestId("assistant-origin-blocked").textContent).toBe(why),+ );+ // No model of its own: the pair falls back to the provider's default.+ expect(screen.getByTestId("assistant-origin-model").textContent).toBe(+ "local_models.assistant.origin_default_model",+ );+ fireEvent.click(screen.getByTestId("assistant-origin-change"));+ expect(onOpenApiKeys).toHaveBeenCalledTimes(1);+ });});diff --git a/jarvis/ui/web/frontend/src/components/local-models/AssistantPanel.tsx b/jarvis/ui/web/frontend/src/components/local-models/AssistantPanel.tsxindex 6cdaecf3d2..677b83506d 100644--- a/jarvis/ui/web/frontend/src/components/local-models/AssistantPanel.tsx+++ b/jarvis/ui/web/frontend/src/components/local-models/AssistantPanel.tsx@@ -10,15 +10,23 @@** Three deliberate departures from the coding-agent chat:*- * 1. **The conversation scrolls inside itself.** The panel is one screen with- * the composer at the bottom, so opening the helper never turns the section- * into a page thousands of pixels tall that buries the roles below it.+ * 1. **The conversation scrolls inside itself.** The panel fills the height it+ * is given (`h-full`, never a `100vh` sum guessed from the chrome above it)+ * with the composer pinned to its floor, so opening the helper never turns+ * the section into a page thousands of pixels tall — and never stacks a+ * page scrollbar on top of the conversation's own.* 2. **Only the current run is shown.** Every click on a mode button starts a* new run; the ones before collapse behind one "earlier messages" line* instead of stacking five identical setups on top of each other.* 3. **Steps read as sentences** (`AssistantSteps`), not as tool names — this* reader wants to follow what is being done to their machine.*+ * The conversation keeps a reading measure; the width left over on a wide+ * window goes to `AssistantContext`, which answers the question the prose+ * cannot: the helper runs on a CLOUD Tool Model while every model it installs+ * runs locally. Below `xl` the rail is gone and the header's origin chip says+ * the same thing in one line.+ ** When a turn ends with a ```jarvis-proposal block, the plan is shown as a* checklist (`SetupProposalCard`). ONE Confirm sends the "Execute steps: …"* message and remembers the steps; every `approval_required` the runner raises@@ -35,6 +43,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from "react";import type { TextBlock, TimelineItem, TurnItem } from "@/components/agentchat/reduce";import { SoftButton, StatusDot } from "@/components/extensions/primitives";+import { ProviderLogo } from "@/components/providers/ProviderLogo";import { fill, useT } from "@/i18n";import type { ApprovalDecision } from "@/lib/agentChatApi";import { cn } from "@/lib/utils";@@ -47,7 +56,14 @@ import {runAssistant,type AssistantHealth,type AssistantMode,+ type AssistantSessionResponse,} from "./assistantApi";+import {+ AssistantContext,+ AssistantOriginChip,+ healthTone,+ providerDisplayName,+} from "./AssistantContext";import { AssistantSteps } from "./AssistantSteps";import {matchesConfirmedStep,@@ -123,6 +139,8 @@ export function AssistantPanel({request,onOpenApiKeys,onOpenServerLog,+ providerLabel,+ className,}: {providerId: string;/** What the section calls the local server ("Ollama"). */@@ -132,6 +150,13 @@ export function AssistantPanel({onOpenApiKeys: () => void;/** The Server tab with the log open — one link for the reader who wants it raw. */onOpenServerLog?: () => void;+ /**+ * Brain provider id -> display label, from the section's provider list. The+ * panel does not fetch a catalog of its own for one word; without it the id+ * is title-cased, which is honest if less pretty.+ */+ providerLabel?: (id: string) => string;+ className?: string;}) {const t = useT();const items = useLocalModelsAssistantStore((s) => s.timeline.items);@@ -146,6 +171,8 @@ export function AssistantPanel({const disconnect = useLocalModelsAssistantStore((s) => s.disconnect);const [health, setHealth] = useState<AssistantHealth | null>(null);+ /** The whole `/session` answer: the pair the helper runs on, and readiness. */+ const [session, setSession] = useState<AssistantSessionResponse | null>(null);const [starting, setStarting] = useState<AssistantMode | null>(null);/** The 409 sentence: no usable Tool Model or Agents-tier fallback. */const [blocked, setBlocked] = useState<string | null>(null);@@ -159,6 +186,8 @@ export function AssistantPanel({const [showEarlier, setShowEarlier] = useState(false);const answered = useRef<Set<string>>(new Set());const scroller = useRef<HTMLDivElement | null>(null);+ /** Whether the reader is parked at the end — the only time we may scroll. */+ const atBottom = useRef(true);const running = isRunning(items);const start = runStartIndex(items, runTurnId);@@ -166,23 +195,35 @@ export function AssistantPanel({const earlier = items.slice(0, Math.min(start, items.length));const shown = showEarlier ? items : current;+ /**+ * The `/session` record: the pair the helper runs on and whether it can run.+ * Reading it is not optional bookkeeping — it is the only place the UI can+ * learn WHICH brain answers, and it says so before the first click instead+ * of leaving the reader to discover it as a 409.+ */+ const loadSession = useCallback(async (): Promise<AssistantSessionResponse | null> => {+ try {+ const s = await getAssistantSession(providerId);+ setSession(s);+ return s;+ } catch (err) {+ if (err instanceof AssistantApiError && err.status === 404) setBackendMissing(true);+ return null;+ }+ }, [providerId]);+// The one session per install: open it (and its socket) when the panel mounts.useEffect(() => {let cancelled = false;void (async () => {- try {- const s = await getAssistantSession(providerId);- if (cancelled) return;- if (s.session_id) openSession(s.session_id);- } catch (err) {- if (cancelled) return;- if (err instanceof AssistantApiError && err.status === 404) setBackendMissing(true);- }+ const s = await loadSession();+ if (cancelled || !s?.session_id) return;+ openSession(s.session_id);})();return () => {cancelled = true;};- }, [providerId, openSession]);+ }, [loadSession, openSession]);useEffect(() => () => disconnect(), [disconnect]);@@ -204,18 +245,30 @@ export function AssistantPanel({answered.current = new Set();}, [activeSessionId]);- // Follow the conversation while it writes, the way a chat does.+ // Follow the conversation while it writes, the way a chat does — but only+ // for a reader who is actually at the end. Scrolling unconditionally yanks+ // someone who scrolled up to re-read a step back down on the next token.useEffect(() => {const el = scroller.current;- if (el) el.scrollTop = el.scrollHeight;+ if (el && atBottom.current) el.scrollTop = el.scrollHeight;}, [items, shown.length]);+ const onScroll = useCallback(() => {+ const el = scroller.current;+ if (!el) return;+ // A small slack: a sub-pixel layout or a half-scrolled wheel tick must+ // still count as "at the end", or following stops for no visible reason.+ atBottom.current = el.scrollHeight - el.scrollTop - el.clientHeight < 80;+ }, []);+const run = useCallback(async (mode: AssistantMode) => {setStarting(mode);setBlocked(null);setRunError(null);setShowEarlier(false);+ // A run the reader asked for is a run they want to watch start.+ atBottom.current = true;try {const res = await runAssistant(providerId, mode);// Everything before this turn becomes "earlier": a second setup run is@@ -223,14 +276,20 @@ export function AssistantPanel({setRunTurnId(res.turn_id);if (res.session_id !== activeSessionId) openSession(res.session_id);} catch (err) {- if (err instanceof AssistantApiError && err.status === 409) setBlocked(err.message);- else if (err instanceof AssistantApiError && err.status === 404) setBackendMissing(true);- else setRunError(err instanceof Error ? err.message : String(err));+ if (err instanceof AssistantApiError && err.status === 409) {+ setBlocked(err.message);+ // The refusal and the rail must agree on why; re-read the record.+ void loadSession();+ } else if (err instanceof AssistantApiError && err.status === 404) {+ setBackendMissing(true);+ } else {+ setRunError(err instanceof Error ? err.message : String(err));+ }} finally {setStarting(null);}},- [providerId, activeSessionId, openSession],+ [providerId, activeSessionId, openSession, loadSession],);// The section's button click is the request; run it once per token.@@ -245,6 +304,15 @@ export function AssistantPanel({if (!running) void loadHealth();}, [running, loadHealth]);+ // A finished run can have changed the tier (a fallback took over, a key was+ // fixed mid-conversation). Re-read it then — and only then, so the mount's+ // own read is not doubled.+ const wasRunning = useRef(false);+ useEffect(() => {+ if (wasRunning.current && !running) void loadSession();+ wasRunning.current = running;+ }, [running, loadSession]);+// The plan in the last finished turn of the current run, if any.const proposal: { value: Proposal; turnId: string } | null = useMemo(() => {const last = lastAssistantText(current);@@ -291,9 +359,11 @@ export function AssistantPanel({}, [draft, activeSessionId, busy, running, send]);const checkedAt = assistantTimestamp(health?.checked_at);- const healthTone =- health?.status === "ok" ? "ok" : health?.status === "unknown" || !health ? "off" : "warn";const needsFix = health?.status === "error" || health?.status === "needs_setup";+ const brandName = useCallback(+ (id: string) => providerDisplayName(id, providerLabel),+ [providerLabel],+ );// One line that says what the helper is doing right now.const statusLine = running@@ -313,27 +383,47 @@ export function AssistantPanel({className={cn(// A chat is a room, not a form: its own ground, a header and a// composer pinned to the edges, and the conversation scrolling- // between them. The height is the screen's, minus what the section- // header and the rail already take.- "flex h-[calc(100vh-14.5rem)] min-h-[26rem] flex-col overflow-hidden rounded-xl border border-border",+ // between them. The height is whatever the section hands down+ // (`h-full`) — never a `100vh` minus a hand-measured chrome height,+ // which stops being true the moment that chrome wraps and leaves two+ // scrollbars stacked on each other.+ "flex h-full min-h-0 flex-col overflow-hidden rounded-xl border border-border",// Token colours only: `--card` and friends are HSL triplets, not// colours, so a color-mix() on them is invalid CSS and the room would// render with no ground at all. The conversation sits a shade off the// page, the two bars a shade above it."bg-card/40",+ className,)}data-testid="local-models-assistant">{/* ── header ─────────────────────────────────────────────────────── */}+ {/* Full width, unlike the conversation: a title band constrained to the+ reading measure leaves its buttons floating in mid-screen with empty+ bar on both sides, which reads as a broken layout rather than a calm+ one. Only prose wants a measure. */}<div className="shrink-0 border-b border-border/70 bg-card px-5 py-3">- <div className="mx-auto flex w-full max-w-[46rem] flex-wrap items-center justify-between gap-x-4 gap-y-2">- <div className="min-w-0">- <h3 className="text-[14px] font-semibold leading-tight tracking-[-0.01em]">- {t("local_models.assistant.title")}- </h3>- <p className="mt-0.5 text-[12.5px] text-muted-foreground" data-testid="assistant-status">- {statusLine}- </p>+ <div className="flex w-full flex-wrap items-center justify-between gap-x-4 gap-y-2">+ <div className="flex min-w-0 items-center gap-3">+ <div className="min-w-0">+ <h3 className="text-[14px] font-semibold leading-tight tracking-[-0.01em]">+ {t("local_models.assistant.title")}+ </h3>+ <p+ className="mt-0.5 text-[12.5px] text-muted-foreground"+ data-testid="assistant-status"+ >+ {statusLine}+ </p>+ </div>+ {/* Below xl there is no rail, so the answer moves here. */}+ <div className="xl:hidden">+ <AssistantOriginChip+ session={session}+ providerLabel={providerLabel}+ onOpenApiKeys={onOpenApiKeys}+ />+ </div></div><div className="flex flex-wrap items-center gap-1.5"><ChipButton primary onClick={() => void run("setup")} disabled={busyNow}>@@ -358,16 +448,34 @@ export function AssistantPanel({</div></div>- {/* ── conversation ───────────────────────────────────────────────── */}- <div ref={scroller} className="flex-1 overflow-y-auto" data-testid="assistant-timeline">- <div className="mx-auto flex w-full max-w-[46rem] flex-col gap-8 px-5 py-6">+ {/* ── conversation + context ─────────────────────────────────────── */}+ <div className="flex min-h-0 flex-1">+ <div+ ref={scroller}+ onScroll={onScroll}+ className="min-w-0 flex-1 overflow-y-auto"+ data-testid="assistant-timeline"+ >+ <div className="mx-auto flex min-h-full w-full max-w-[48rem] flex-col px-5 py-6">+ <div+ className={cn(+ // A short conversation rests on the composer instead of+ // hanging from the ceiling with a screen of void beneath it.+ // `mt-auto`, not `justify-end`: an auto margin collapses to+ // zero once the content outgrows the box, so a long run can+ // still be scrolled back to its own first line.+ "flex flex-col gap-8",+ items.length === 0 ? "my-auto" : "mt-auto",+ )}+ >+ {/* The rail carries this above xl; here it would be a second copy. */}{health && checkedAt && (<p- className="flex flex-wrap items-center gap-3 text-[12.5px]"+ className="flex flex-wrap items-center gap-3 text-[12.5px] xl:hidden"data-testid="assistant-health"><StatusDot- tone={healthTone}+ tone={healthTone(health)}label={fill(t("local_models.assistant.last_check"), {when: checkedAt.toLocaleString(),what: health.reason || t(`local_models.assistant.health_${health.status}`),@@ -499,6 +607,25 @@ export function AssistantPanel({<Sparkles className="h-3.5 w-3.5" /></span><div className="flex min-w-0 flex-1 flex-col gap-3">+ {/* Who wrote this turn — read from the turn itself, not from+ the configuration, so a fallback that took over is named+ instead of the pick that failed. */}+ {item.provider && (+ <span+ className="flex items-center gap-1.5 text-[11px] text-muted-foreground/70"+ data-testid="assistant-turn-origin"+ >+ <ProviderLogo+ providerId={item.provider}+ label={brandName(item.provider)}+ size="sm"+ />+ <span className="truncate">+ {brandName(item.provider)}+ {item.model ? ` · ${item.model}` : ""}+ </span>+ </span>+ )}<AssistantSteps blocks={item.blocks} live={live} onDecide={onDecide} />{answer && (<div@@ -536,12 +663,24 @@ export function AssistantPanel({</div>);})}+ </div>+ </div></div>++ <AssistantContext+ providerId={providerId}+ serverLabel={serverLabel}+ session={session}+ health={health}+ onOpenApiKeys={onOpenApiKeys}+ onDiagnose={() => void run("diagnose")}+ providerLabel={providerLabel}+ /></div>{/* ── composer ───────────────────────────────────────────────────── */}<div className="shrink-0 border-t border-border/70 bg-card px-5 py-3">- <div className="mx-auto w-full max-w-[46rem]">+ <div className="mx-auto w-full max-w-[48rem]"><formclassName={cn("flex items-end gap-2 rounded-2xl border border-border bg-background px-2.5 py-2 shadow-sm",diff --git a/jarvis/ui/web/frontend/src/i18n/locales/local_models/de.json b/jarvis/ui/web/frontend/src/i18n/locales/local_models/de.jsonindex 486cbcccef..473d838372 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/local_models/de.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/local_models/de.json@@ -458,7 +458,18 @@"ask_1": "Welches Modell soll meine Chats beantworten?","ask_2": "Schafft meine Grafikkarte ein 27B-Modell?","ask_3": "Speicherplatz freimachen",- "composer_hint": "Enter sendet · Umschalt+Enter für eine neue Zeile"+ "composer_hint": "Enter sendet · Umschalt+Enter für eine neue Zeile",+ "origin_title": "Antwortet gerade",+ "origin_cloud": "Die Hilfe selbst läuft auf deinem Tool Model in der Cloud und wird über dessen Schlüssel abgerechnet. Die Modelle darunter laufen auf deinem Rechner.",+ "origin_change": "In den API-Keys ändern",+ "origin_default_model": "Standardmodell des Anbieters",+ "origin_unset": "Es ist noch kein Tool Model gewählt.",+ "machine_title": "Auf diesem Rechner",+ "machine_unset": "nicht gesetzt",+ "machine_missing": "nicht installiert",+ "machine_server_running": "{server} läuft",+ "machine_server_stopped": "{server} läuft nicht",+ "machine_loading": "Rollen werden gelesen…"},"tab_assistant": "Einrichtungshilfe"}diff --git a/jarvis/ui/web/frontend/src/i18n/locales/local_models/en.json b/jarvis/ui/web/frontend/src/i18n/locales/local_models/en.jsonindex 80bd5b69c1..b2d25e6013 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/local_models/en.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/local_models/en.json@@ -458,7 +458,18 @@"ask_1": "Which model should answer my chats?","ask_2": "Can my graphics card run a 27B model?","ask_3": "Free up some disk space",- "composer_hint": "Enter sends · Shift+Enter for a new line"+ "composer_hint": "Enter sends · Shift+Enter for a new line",+ "origin_title": "Answering now",+ "origin_cloud": "The helper itself runs on your Tool Model in the cloud, billed through that key. The models below run on your machine.",+ "origin_change": "Change in API Keys",+ "origin_default_model": "the provider’s default model",+ "origin_unset": "No Tool Model is picked yet.",+ "machine_title": "On this machine",+ "machine_unset": "not set",+ "machine_missing": "not installed",+ "machine_server_running": "{server} is running",+ "machine_server_stopped": "{server} is not running",+ "machine_loading": "Reading the roles…"},"tab_assistant": "Setup helper"}diff --git a/jarvis/ui/web/frontend/src/i18n/locales/local_models/es.json b/jarvis/ui/web/frontend/src/i18n/locales/local_models/es.jsonindex db4d0f16a0..0bb9cda2d3 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/local_models/es.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/local_models/es.json@@ -458,7 +458,18 @@"ask_1": "¿Qué modelo debe responder mis chats?","ask_2": "¿Mi tarjeta gráfica puede con un modelo de 27B?","ask_3": "Liberar espacio en disco",- "composer_hint": "Enter envía · Mayús+Enter para una línea nueva"+ "composer_hint": "Enter envía · Mayús+Enter para una línea nueva",+ "origin_title": "Responde ahora",+ "origin_cloud": "El asistente funciona con tu Tool Model en la nube y se factura con esa clave. Los modelos de abajo se ejecutan en tu equipo.",+ "origin_change": "Cambiar en API Keys",+ "origin_default_model": "modelo predeterminado del proveedor",+ "origin_unset": "Todavía no hay un Tool Model elegido.",+ "machine_title": "En este equipo",+ "machine_unset": "sin definir",+ "machine_missing": "no instalado",+ "machine_server_running": "{server} está en marcha",+ "machine_server_stopped": "{server} no está en marcha",+ "machine_loading": "Leyendo los roles…"},"tab_assistant": "Asistente de configuración"}diff --git a/jarvis/ui/web/frontend/src/views/LocalModelsView.test.tsx b/jarvis/ui/web/frontend/src/views/LocalModelsView.test.tsxindex c9292fc6be..05ea3d84e3 100644--- a/jarvis/ui/web/frontend/src/views/LocalModelsView.test.tsx+++ b/jarvis/ui/web/frontend/src/views/LocalModelsView.test.tsx@@ -311,4 +311,38 @@ describe("LocalModelsView", () => {).toBe("yes");});+ it("hands the helper the leftover height and folds the page header away", () => {+ render(<LocalModelsView />);+ fireEvent.click(screen.getByRole("button", { name: "assistant" }));++ // Title, subtitle and the detail level describe the panels, not the+ // conversation — a chat that starts a fifth of the way down the window+ // reads as a widget rather than a screen.+ expect(screen.queryByText("local_models.title")).toBeNull();+ expect(+ screen.queryByRole("tab", { name: "local_models.mode_simple" }),+ ).toBeNull();+ // What still steers something stays: the way out, and the rail.+ expect(+ screen.getByRole("button", { name: "local_models.back" }),+ ).toBeDefined();+ expect(+ screen.getByRole("tab", { name: "local_models.tab_overview" }),+ ).toBeDefined();++ // The helper's area is a flex child that fills what is left, so the panel+ // never has to guess the chrome height above it.+ const area = screen.getByTestId("local-models-assistant-tab");+ expect(area.className).toContain("flex-1");+ expect(area.className).toContain("min-h-0");++ // Back on a panel tab the full header returns.+ fireEvent.click(+ screen.getByRole("tab", { name: "local_models.tab_overview" }),+ );+ expect(screen.getByText("local_models.title")).toBeDefined();+ expect(+ screen.getByRole("tab", { name: "local_models.mode_simple" }),+ ).toBeDefined();+ });});diff --git a/jarvis/ui/web/frontend/src/views/LocalModelsView.tsx b/jarvis/ui/web/frontend/src/views/LocalModelsView.tsxindex ee01423443..e5c3450bfe 100644--- a/jarvis/ui/web/frontend/src/views/LocalModelsView.tsx+++ b/jarvis/ui/web/frontend/src/views/LocalModelsView.tsx@@ -47,6 +47,7 @@ import { ServerPanel } from "@/views/local-models/ServerPanel";import { TuneSheet } from "@/views/local-models/TuneSheet";import { useEventStore } from "@/store/events";import { useLocaleChunk, useT } from "@/i18n";+import { cn } from "@/lib/utils";export type LocalModelsMode = "simple" | "advanced";export type LocalModelsTab =@@ -180,6 +181,20 @@ export function LocalModelsView() {storeMode(next);}, []);+ /**+ * Display name for a BRAIN provider id — the cloud model the helper runs+ * on, not the local server. The list is already here for the capability+ * lookup, so naming "gemini" as "Gemini" costs no request of its own.+ */+ const brainLabel = useCallback(+ (id: string) => providers.find((p) => p.id === id)?.label ?? id,+ [providers],+ );++ // The helper is a conversation, and a conversation is a screen: it gets the+ // window's leftover height instead of a slot inside the page scroller.+ const chatMode = tab === "assistant";+// Leaving Advanced while on an Advanced-only tab must not strand the user on// a tab the rail no longer shows.useEffect(() => {@@ -201,126 +216,171 @@ export function LocalModelsView() {}, [mode, t]);return (- <ScrollArea className="h-full">- <div className="flex w-full flex-col gap-4 px-8 py-6">- <BackLink- label={t("local_models.back")}- onClick={() => setActiveSection("apikeys")}- />- <PanelHeader- title={t("local_models.title")}- subtitle={t("local_models.subtitle")}- />+ <div className="flex h-full min-h-0 w-full flex-col">+ {/* The section header. On the helper's own area it collapses to the one+ row that still steers something — the rail. The title, the subtitle+ and the Simple/Advanced switch describe (and change) the panels, not+ the conversation, and a chat that starts a fifth of the way down the+ window reads as a widget rather than a screen. */}+ <div+ className={cn(+ "flex w-full shrink-0 flex-col gap-4 px-8",+ chatMode ? "pb-3 pt-4" : "py-6",+ )}+ >+ {!chatMode && (+ <>+ <BackLink+ label={t("local_models.back")}+ onClick={() => setActiveSection("apikeys")}+ />+ <PanelHeader+ title={t("local_models.title")}+ subtitle={t("local_models.subtitle")}+ />+ </>+ )}{/* The rail and the detail level belong together: the switch adds twoareas to this very row (and detail to the rows below), so it sitsbeside what it changes instead of alone in the header. */}<div className="flex flex-wrap items-center justify-between gap-3">- <SegmentedFilter<LocalModelsTab>- label={t("local_models.tabs_label")}- value={tab}- onChange={setTab}- options={tabs}- />- <div className="flex items-center gap-2">- <span className="text-[11px] uppercase tracking-[0.14em] text-muted-foreground">- {t("local_models.mode_label")}- </span>- <SegmentedFilter<LocalModelsMode>- label={t("local_models.mode_label")}- value={mode}- onChange={changeMode}- options={[- { id: "simple", label: t("local_models.mode_simple") },- { id: "advanced", label: t("local_models.mode_advanced") },- ]}- />- </div>- </div>-- {loading && !providerId && (- <p className="text-sm text-muted-foreground">- {t("local_models.loading")}- </p>- )}-- {!loading && !providerId && (- <Panel className="p-4">- <p className="text-sm text-muted-foreground">- {t("local_models.no_provider")}- </p>- </Panel>- )}-- {providerId && tab === "overview" && (- <div className="space-y-4" data-testid="local-models-overview">- <OverviewPanel- providerId={providerId}- onTune={setTuneModel}- onOpenApiKeys={openApiKeys}- onBrowse={openBrowse}- onOpenAssistant={openAssistant}- onReportProblem={reportProblem}- advanced={mode === "advanced"}- />- {tuneModel && (- <RoleTuneDrawer- providerId={providerId}- model={tuneModel}- onClose={closeTune}+ <div className="flex min-w-0 flex-wrap items-center gap-3">+ {chatMode && (+ <BackLink+ label={t("local_models.back")}+ onClick={() => setActiveSection("apikeys")}/>)}+ <SegmentedFilter<LocalModelsTab>+ label={t("local_models.tabs_label")}+ value={tab}+ onChange={setTab}+ options={tabs}+ /></div>- )}+ {!chatMode && (+ <div className="flex items-center gap-2">+ <span className="text-[11px] uppercase tracking-[0.14em] text-muted-foreground">+ {t("local_models.mode_label")}+ </span>+ <SegmentedFilter<LocalModelsMode>+ label={t("local_models.mode_label")}+ value={mode}+ onChange={changeMode}+ options={[+ { id: "simple", label: t("local_models.mode_simple") },+ { id: "advanced", label: t("local_models.mode_advanced") },+ ]}+ />+ </div>+ )}+ </div>+ </div>- {providerId && tab === "assistant" && (- <div data-testid="local-models-assistant-tab">+ {/* The helper is a screen of its own: it is handed the leftover height+ and measures nothing itself. Every other tab is a document and keeps+ the page scroller. */}+ {chatMode ? (+ <div+ className="min-h-0 flex-1 px-8 pb-6"+ data-testid="local-models-assistant-tab"+ >+ {providerId ? (<AssistantPanelproviderId={providerId}serverLabel={descriptor?.label ?? "Ollama"}request={assistantRequest}onOpenApiKeys={openApiKeys}onOpenServerLog={openServerLog}+ providerLabel={brainLabel}/>- </div>- )}+ ) : (+ <Panel className="p-4">+ <p className="text-sm text-muted-foreground">+ {loading+ ? t("local_models.loading")+ : t("local_models.no_provider")}+ </p>+ </Panel>+ )}+ </div>+ ) : (+ <ScrollArea className="min-h-0 flex-1">+ <div className="flex w-full flex-col gap-4 px-8 pb-6">+ {loading && !providerId && (+ <p className="text-sm text-muted-foreground">+ {t("local_models.loading")}+ </p>+ )}- {providerId && tab === "models" && (- <div data-testid="local-models-models">- <InventoryPanel providerId={providerId} />- </div>- )}+ {!loading && !providerId && (+ <Panel className="p-4">+ <p className="text-sm text-muted-foreground">+ {t("local_models.no_provider")}+ </p>+ </Panel>+ )}- {providerId && tab === "catalogue" && (- <Panel className="p-4">- <div className="space-y-3" data-testid="local-models-catalogue">- <PanelHeader- title={t("local_models.catalogue_title")}- subtitle={t("local_models.catalogue_subtitle")}- />- <CataloguePanel providerId={providerId} />- </div>- </Panel>- )}+ {providerId && tab === "overview" && (+ <div className="space-y-4" data-testid="local-models-overview">+ <OverviewPanel+ providerId={providerId}+ onTune={setTuneModel}+ onOpenApiKeys={openApiKeys}+ onBrowse={openBrowse}+ onOpenAssistant={openAssistant}+ onReportProblem={reportProblem}+ advanced={mode === "advanced"}+ />+ {tuneModel && (+ <RoleTuneDrawer+ providerId={providerId}+ model={tuneModel}+ onClose={closeTune}+ />+ )}+ </div>+ )}- {providerId && tab === "huggingface" && (- <Panel className="p-4">- <div className="space-y-3" data-testid="local-models-huggingface">- <PanelHeader title={t("local_models.huggingface_title")} />- <HuggingFacePanel providerId={providerId} />- </div>- </Panel>- )}+ {providerId && tab === "models" && (+ <div data-testid="local-models-models">+ <InventoryPanel providerId={providerId} />+ </div>+ )}- {providerId && tab === "server" && (- <div data-testid="local-models-server">- <ServerPanel- providerId={providerId}- initialLogOpen={serverLogOpen}- />+ {providerId && tab === "catalogue" && (+ <Panel className="p-4">+ <div className="space-y-3" data-testid="local-models-catalogue">+ <PanelHeader+ title={t("local_models.catalogue_title")}+ subtitle={t("local_models.catalogue_subtitle")}+ />+ <CataloguePanel providerId={providerId} />+ </div>+ </Panel>+ )}++ {providerId && tab === "huggingface" && (+ <Panel className="p-4">+ <div className="space-y-3" data-testid="local-models-huggingface">+ <PanelHeader title={t("local_models.huggingface_title")} />+ <HuggingFacePanel providerId={providerId} />+ </div>+ </Panel>+ )}++ {providerId && tab === "server" && (+ <div data-testid="local-models-server">+ <ServerPanel+ providerId={providerId}+ initialLogOpen={serverLogOpen}+ />+ </div>+ )}</div>- )}- </div>- </ScrollArea>+ </ScrollArea>+ )}+ </div>);}