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(agentic-ide): a missing CLI is installable from the menu that offers it
rubenluetke10-beep74611371417d
diff --git a/jarvis/ui/web/frontend/src/components/agentic/AgentInstallDialog.test.tsx b/jarvis/ui/web/frontend/src/components/agentic/AgentInstallDialog.test.tsxnew file mode 100644index 0000000000..dfd259f49c--- /dev/null+++ b/jarvis/ui/web/frontend/src/components/agentic/AgentInstallDialog.test.tsx@@ -0,0 +1,168 @@+/**+ * The install dialog's one hard claim: "installed" is something the app went+ * and checked, not something it inferred.+ *+ * That distinction is the whole reason this component polls at all. A package+ * manager exiting 0 does not mean a binary is on this app's PATH — the+ * recurring macOS/Linux symptom is exactly that gap — so a dialog that turned+ * green on an exit code would be confidently wrong on the machines where it+ * matters most.+ */+import {+ act,+ cleanup,+ fireEvent,+ render,+ screen,+} from "@testing-library/react";+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";++import { AgentInstallDialog } from "./AgentInstallDialog";++// xterm wants a canvas and a device-pixel ratio jsdom has not got. What the+// installer prints is WorkspaceTerminal's own test; this file is about what+// the dialog concludes from the probe.+vi.mock("../workspace/WorkspaceTerminal", () => ({+ WorkspaceTerminal: ({ installName }: { installName?: string }) => (+ <div data-testid={`stub-install-pty-${installName}`} />+ ),+}));++const recheckAgent = vi.fn();+vi.mock("@/lib/agenticIdeApi", () => ({+ recheckAgent: (name: string) => recheckAgent(name),+}));++function open(onClose = vi.fn()) {+ render(+ <AgentInstallDialog+ agent="deepseek-harness"+ displayName="DeepSeek Harness"+ command="npm install -g @deepseek-ai/dsh"+ onClose={onClose}+ />,+ );+ return onClose;+}++/** Run the poll interval forward and let its promise settle. */+async function tick(ms: number) {+ await act(async () => {+ vi.advanceTimersByTime(ms);+ await Promise.resolve();+ await Promise.resolve();+ });+}++beforeEach(() => {+ vi.useFakeTimers();+ recheckAgent.mockReset();+});++afterEach(() => {+ vi.useRealTimers();+ cleanup();+});++describe("AgentInstallDialog", () => {+ it("runs the installer in a terminal and shows the command it runs", () => {+ open();+ expect(+ screen.getByTestId("stub-install-pty-deepseek-harness"),+ ).toBeTruthy();+ // Readable BEFORE it matters: a user who would rather run it in their own+ // shell can take it from here and close this.+ expect(screen.getByText("npm install -g @deepseek-ai/dsh")).toBeTruthy();+ });++ it("stays honest while the probe keeps saying no", async () => {+ recheckAgent.mockResolvedValue({+ name: "deepseek-harness",+ display_name: "DeepSeek Harness",+ installed: false,+ version: null,+ });+ open();+ await tick(9000);+ expect(recheckAgent).toHaveBeenCalled();+ expect(+ screen.queryByTestId("agent-install-done-deepseek-harness"),+ ).toBeNull();+ });++ it("reports the install the moment a probe finds the binary", async () => {+ recheckAgent+ .mockResolvedValueOnce({+ name: "deepseek-harness",+ display_name: "DeepSeek Harness",+ installed: false,+ version: null,+ })+ .mockResolvedValue({+ name: "deepseek-harness",+ display_name: "DeepSeek Harness",+ installed: true,+ version: "0.1.1",+ });+ const onClose = open();++ await tick(4100);+ expect(+ screen.queryByTestId("agent-install-done-deepseek-harness"),+ ).toBeNull();++ await tick(4100);+ const done = screen.getByTestId("agent-install-done-deepseek-harness");+ // The version is part of the claim: it is what proves the app can start+ // the thing, not merely that a file appeared.+ expect(done.textContent).toContain("0.1.1");++ fireEvent.click(+ screen.getByTestId("agent-install-dismiss-deepseek-harness"),+ );+ expect(onClose).toHaveBeenCalledWith(true);+ });++ it("stops asking once the answer is yes", async () => {+ recheckAgent.mockResolvedValue({+ name: "deepseek-harness",+ display_name: "DeepSeek Harness",+ installed: true,+ version: "0.1.1",+ });+ open();+ await tick(4100);+ const afterFirst = recheckAgent.mock.calls.length;+ await tick(20000);+ // A dialog left open on a finished install must not keep spawning probes+ // for as long as the user looks at it.+ expect(recheckAgent.mock.calls.length).toBe(afterFirst);+ });++ it("keeps watching when a probe itself fails", async () => {+ recheckAgent+ .mockRejectedValueOnce(new Error("backend restarting"))+ .mockResolvedValue({+ name: "deepseek-harness",+ display_name: "DeepSeek Harness",+ installed: true,+ version: "0.1.1",+ });+ open();+ await tick(4100);+ // A failed probe is not an answer — treating it as "not installed" and+ // giving up would strand the user in front of a finished install.+ await tick(4100);+ expect(+ screen.getByTestId("agent-install-done-deepseek-harness"),+ ).toBeTruthy();+ });++ it("never claims an install it did not observe", () => {+ const onClose = open();+ fireEvent.click(+ screen.getByTestId("agent-install-dismiss-deepseek-harness"),+ );+ expect(onClose).toHaveBeenCalledWith(false);+ });+});diff --git a/jarvis/ui/web/frontend/src/components/agentic/AgentInstallDialog.tsx b/jarvis/ui/web/frontend/src/components/agentic/AgentInstallDialog.tsxnew file mode 100644index 0000000000..6865880b9e--- /dev/null+++ b/jarvis/ui/web/frontend/src/components/agentic/AgentInstallDialog.tsx@@ -0,0 +1,219 @@+/**+ * "Install this CLI" — the whole flow, from the picker, without leaving it.+ *+ * The absence of a coding CLI used to be a dead end wearing a label: the entry+ * sat in the "open a terminal — what?" menu greyed out under the words NOT+ * INSTALLED, and the only way forward was to know that a CLIs page exists,+ * find it, and come back. Every registered entry that CAN be installed now+ * offers it where the user meets it (maintainer, 2026-08-23).+ *+ * Three things make this honest rather than a progress bar over a hope:+ *+ * 1. **The install runs in a real terminal the user can read.** `npm install+ * -g` fails for reasons only its own output explains — a permissions error,+ * a proxy, a Node that is too old. A spinner would hide every one of them.+ * It is also the same PTY the CLI itself would run in, so a machine where+ * the pane cannot start says so here rather than after the install.+ * 2. **"Installed" is a fresh probe, never an exit code.** A package manager+ * that exits 0 has not proved that a binary is on this app's PATH — the+ * recurring macOS/Linux symptom is exactly that gap. The dialog polls the+ * single-entry recheck route, which re-augments PATH and looks, so the+ * green line means the app can actually find and start the thing.+ * 3. **It reports failure as failure.** The dialog never closes itself on a+ * guess; the user closes it, and the row behind it tells the truth either+ * way at the next read.+ */+import { useCallback, useEffect, useRef, useState } from "react";+import { createPortal } from "react-dom";+import { Check, Loader2, X } from "lucide-react";++import { WorkspaceTerminal } from "../workspace/WorkspaceTerminal";+import { recheckAgent } from "@/lib/agenticIdeApi";+import { AgentMark } from "./AgentMark";++/**+ * How often the dialog asks whether the binary has appeared.+ *+ * One subprocess per ask, against ONE entry — cheap next to the full sweep,+ * but not free, and nobody watching an npm install needs sub-second news. Four+ * seconds is under the time it takes to notice a finished install and reach+ * for the mouse, which is the only latency that matters here.+ */+const POLL_MS = 4000;++/** Long enough for a slow registry over a slow line; short enough to end. */+const MAX_POLL_MS = 15 * 60 * 1000;++interface AgentInstallDialogProps {+ /** Registry id — "codex", "deepseek-harness". */+ agent: string;+ /** What the user reads — "DeepSeek Harness". */+ displayName: string;+ /** The command that will run, shown before it does. */+ command?: string;+ /** The mark for a CLI the user added; shipped entries need none. */+ logoUrl?: string;+ /**+ * Closing hands back whether the entry ended up installed, so the surface+ * that opened this can re-read its list once instead of polling too.+ */+ onClose: (installed: boolean) => void;+}++export function AgentInstallDialog({+ agent,+ displayName,+ command,+ logoUrl,+ onClose,+}: AgentInstallDialogProps) {+ const [installed, setInstalled] = useState(false);+ const [version, setVersion] = useState<string | null>(null);+ /*+ * Read by the poll, never a dependency of it. The poll must keep its own+ * identity for the whole dialog — restarting the interval on every state+ * change would reset the elapsed budget below and poll forever.+ */+ const installedRef = useRef(false);+ installedRef.current = installed;++ const close = useCallback(() => onClose(installedRef.current), [onClose]);++ useEffect(() => {+ let cancelled = false;+ const startedAt = Date.now();+ const ask = () => {+ if (cancelled || installedRef.current) return;+ void recheckAgent(agent).then(+ (row) => {+ if (cancelled || !row.installed) return;+ setInstalled(true);+ setVersion(row.version);+ },+ () => {+ /* A failed probe is not an answer. The next tick asks again, and the+ dialog keeps showing the terminal — which is where the reason for+ a genuinely broken install is written anyway. */+ },+ );+ };+ const timer = window.setInterval(() => {+ if (Date.now() - startedAt > MAX_POLL_MS) {+ window.clearInterval(timer);+ return;+ }+ ask();+ }, POLL_MS);+ return () => {+ cancelled = true;+ window.clearInterval(timer);+ };+ }, [agent]);++ // Escape closes, like every other overlay in the app. Bound on the document+ // because focus starts inside the xterm canvas, which swallows keystrokes.+ useEffect(() => {+ const onKey = (e: KeyboardEvent) => {+ if (e.key === "Escape") close();+ };+ document.addEventListener("keydown", onKey);+ return () => document.removeEventListener("keydown", onKey);+ }, [close]);++ if (typeof document === "undefined") return null;++ return createPortal(+ <div+ className="fixed inset-0 z-[60] flex items-center justify-center bg-scrim/70 p-4 backdrop-blur-sm"+ onMouseDown={close}+ >+ <div+ role="dialog"+ aria-modal="true"+ aria-label={`Install ${displayName}`}+ data-testid={`agent-install-dialog-${agent}`}+ className="flex h-[32rem] max-h-full w-full max-w-3xl flex-col overflow-hidden rounded-xl border border-border bg-card shadow-2xl"+ onMouseDown={(e) => e.stopPropagation()}+ >+ <header className="flex items-center gap-3 border-b border-border px-4 py-3">+ <AgentMark+ agent={agent}+ label={displayName}+ size="sm"+ logoUrl={logoUrl}+ />+ <div className="min-w-0 flex-1">+ <p className="truncate text-sm font-semibold text-foreground">+ Install {displayName}+ </p>+ {/* The command, before and while it runs. A user who would rather+ run it in their own shell can read it here and close this. */}+ {command && (+ <p className="truncate font-mono text-[11px] text-muted-foreground">+ {command}+ </p>+ )}+ </div>+ <button+ type="button"+ aria-label="Close"+ data-testid={`agent-install-close-${agent}`}+ onClick={close}+ className="rounded-md p-1.5 text-muted-foreground transition-colors hover:bg-primary/10 hover:text-foreground"+ >+ <X className="h-4 w-4" />+ </button>+ </header>++ {/* The installer's own output. Keyed by nothing: this component mounts+ once per install, so the PTY is opened once and never restarted+ under a running package manager. */}+ <div className="min-h-0 flex-1">+ <WorkspaceTerminal+ paneKey={`install-${agent}`}+ installName={agent}+ title={`Installing ${displayName}`}+ />+ </div>++ <footer className="flex items-center justify-between gap-3 border-t border-border px-4 py-3">+ {installed ? (+ <p+ data-testid={`agent-install-done-${agent}`}+ /* Both appearances explicitly: emerald-400 is legible on the+ dark app and washes out to nearly nothing on paper. */+ className="flex items-center gap-2 text-sm font-medium text-emerald-600 dark:text-emerald-400"+ >+ <Check className="h-4 w-4" />+ <span>+ {displayName} is installed+ {version ? ` — ${version}` : ""}+ </span>+ </p>+ ) : (+ <p className="flex items-center gap-2 text-sm text-muted-foreground">+ <Loader2 className="h-4 w-4 animate-spin" />+ {/* Not "installing…": what is true is that this app is watching.+ The installer's own progress is the terminal above, and+ claiming to know its state would be inventing one. */}+ <span>Watching for {displayName} to appear…</span>+ </p>+ )}+ <button+ type="button"+ onClick={close}+ data-testid={`agent-install-dismiss-${agent}`}+ className={+ installed+ ? "shrink-0 rounded-md bg-primary px-3 py-1.5 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90"+ : "shrink-0 rounded-md border border-border px-3 py-1.5 text-sm text-foreground transition-colors hover:bg-primary/10"+ }+ >+ {installed ? "Done" : "Close"}+ </button>+ </footer>+ </div>+ </div>,+ document.body,+ );+}diff --git a/jarvis/ui/web/frontend/src/components/agentic/AgentPicker.test.tsx b/jarvis/ui/web/frontend/src/components/agentic/AgentPicker.test.tsxindex 9cfca6483f..432a8d4dbd 100644--- a/jarvis/ui/web/frontend/src/components/agentic/AgentPicker.test.tsx+++ b/jarvis/ui/web/frontend/src/components/agentic/AgentPicker.test.tsx@@ -4,6 +4,18 @@ import { afterEach, describe, expect, it, vi } from "vitest";import { AgentPickerMenu, offersAgentChoice } from "./AgentPicker";+/*+ * The install dialog embeds a real xterm pane, and xterm needs a canvas and a+ * device-pixel ratio jsdom does not have. Stubbed here because these tests are+ * about the MENU — whether the offer appears, for which entries, and what it+ * reports back. What the terminal itself does is WorkspaceTerminal's own test.+ */+vi.mock("../workspace/WorkspaceTerminal", () => ({+ WorkspaceTerminal: ({ installName }: { installName?: string }) => (+ <div data-testid={`stub-install-pty-${installName}`} />+ ),+}));+afterEach(cleanup);function PickerHarness({ onPick = vi.fn() }: { onPick?: (agent: string) => void }) {@@ -182,3 +194,93 @@ describe("offersAgentChoice", () => {).toBe(true);});});++describe("AgentPickerMenu install offer", () => {+ function InstallHarness({+ onInstalled = vi.fn(),+ }: {+ onInstalled?: (agent: string, installed: boolean) => void;+ }) {+ return (+ <AgentPickerMenu+ title="Open what?"+ ariaLabel="Choose a terminal"+ agents={[+ { name: "codex", displayName: "Codex", installed: true },+ {+ name: "deepseek-harness",+ displayName: "DeepSeek Harness",+ installed: false,+ installCommand: "npm install -g @deepseek-ai/dsh",+ },+ // A CLI the user added: not installed, and nothing this app knows how+ // to install — its command is theirs to run.+ { name: "mycli", displayName: "My CLI", installed: false },+ // A host with no shell at all. Nothing to install here either, and+ // the reason is a different one, so the wording must not be shared.+ {+ name: "shell",+ displayName: "Plain Terminal",+ installed: false,+ kind: "shell",+ },+ ]}+ onPick={vi.fn()}+ onDismiss={vi.fn()}+ onInstalled={onInstalled}+ testId="picker"+ itemTestId={(agent) => `pick-${agent}`}+ />+ );+ }++ it("offers to install exactly the entries an install command exists for", () => {+ render(<InstallHarness />);++ // The whole point: a missing CLI is now a button, not a dead label.+ expect(screen.getByTestId("pick-deepseek-harness-install")).toBeTruthy();+ // ...and the row it belongs to still says, by being disabled, that it+ // cannot be opened yet.+ expect(+ screen.getByTestId("pick-deepseek-harness").hasAttribute("disabled"),+ ).toBe(true);++ // No install command, no button — offering one would run nothing.+ expect(screen.queryByTestId("pick-mycli-install")).toBeNull();+ expect(screen.queryByTestId("pick-shell-install")).toBeNull();+ // Those two keep the label, and each keeps its OWN reason.+ expect(screen.getByText("not installed")).toBeTruthy();+ expect(screen.getByText("no shell here")).toBeTruthy();+ });++ it("does not repeat the label beside the button it made redundant", () => {+ render(<InstallHarness />);+ // One label, and it belongs to the custom CLI — not two, which in a 272px+ // menu would cost an entry's description its line to say nothing new.+ expect(screen.getAllByText("not installed")).toHaveLength(1);+ });++ it("opens the installer for the entry whose button was pressed", () => {+ render(<InstallHarness />);+ fireEvent.click(screen.getByTestId("pick-deepseek-harness-install"));+ expect(+ screen.getByTestId("agent-install-dialog-deepseek-harness"),+ ).toBeTruthy();+ });++ it("tells the host what happened, so the row can stop saying 'not installed'", () => {+ const onInstalled = vi.fn();+ render(<InstallHarness onInstalled={onInstalled} />);+ fireEvent.click(screen.getByTestId("pick-deepseek-harness-install"));+ fireEvent.click(+ screen.getByTestId("agent-install-dismiss-deepseek-harness"),+ );+ // False here is not a failure report — nothing probed positive while the+ // dialog was open. The host re-reads either way; what it must never do is+ // believe an install happened because a dialog was closed.+ expect(onInstalled).toHaveBeenCalledWith("deepseek-harness", false);+ expect(+ screen.queryByTestId("agent-install-dialog-deepseek-harness"),+ ).toBeNull();+ });+});diff --git a/jarvis/ui/web/frontend/src/components/agentic/AgentPicker.tsx b/jarvis/ui/web/frontend/src/components/agentic/AgentPicker.tsxindex eea44542b1..159d084edd 100644--- a/jarvis/ui/web/frontend/src/components/agentic/AgentPicker.tsx+++ b/jarvis/ui/web/frontend/src/components/agentic/AgentPicker.tsx@@ -19,11 +19,17 @@* CLIs: a plain terminal (this machine's own shell, no agent around it) sits in* the same menu, and a CLI registered later appears here without a change on* this side. An entry that is not installed stays listed but disabled, so the- * absence is visible and explains itself rather than silently not being there.+ * absence is visible and explains itself rather than silently not being there —+ * and where an install command exists it carries an Install button, so the+ * absence is fixable from the menu instead of only from the CLIs page+ * (maintainer, 2026-08-23). The install runs in a real terminal the user can+ * read, and "installed" is a fresh probe rather than an exit code; see+ * `AgentInstallDialog` for why both of those matter.*/import { useEffect, useState } from "react";import { createPortal } from "react-dom";import { cn } from "@/lib/utils";+import { AgentInstallDialog } from "./AgentInstallDialog";import { AgentMark } from "./AgentMark";/** A coding CLI an "open a terminal" action may start. */@@ -46,6 +52,15 @@ export interface SplitAgentChoice {* Absent for everything else, where `AgentMark`'s own table answers.*/logoUrl?: string;+ /**+ * The command that would install this entry, when one exists.+ *+ * Present is what turns the row's dead "NOT INSTALLED" label into an Install+ * button, so the menu offers the fix where the user meets the problem. Absent+ * for the plain terminal (a host without a shell is not something an install+ * fixes) and for a user-added CLI, whose command is theirs to run.+ */+ installCommand?: string;}/**@@ -109,6 +124,7 @@ export function AgentPickerMenu({itemTestId,className,anchorTo,+ onInstalled,}: {/** The line above the entries — "Open beside — what?". */title: string;@@ -133,9 +149,23 @@ export function AgentPickerMenu({* the thing it was opened from. Absent, the menu stays where it always was.*/anchorTo?: HTMLElement | null;+ /**+ * Called once an install started from this menu ended, with whether the CLI+ * is now there. The host re-reads its agent list; without it the install+ * still works and the row catches up at the next natural read.+ */+ onInstalled?: (agent: string, installed: boolean) => void;}) {const first = agents.find((a) => a.installed);const [placement, setPlacement] = useState<FixedPlacement | null>(null);+ /*+ * The entry whose installer is running, owned HERE rather than handed up to+ * every caller. Three surfaces open this menu (a pane's split buttons, the+ * chat rail, an empty workspace) and none of them has anything to add to an+ * install — threading dialog state through all three would be three copies+ * of the same wiring and three chances for one of them to drift.+ */+ const [installing, setInstalling] = useState<SplitAgentChoice | null>(null);/** Re-measure while the menu is open, not once when it opened.@@ -218,9 +248,25 @@ export function AgentPickerMenu({<p className="mb-1 border-b border-border/60 px-2 pb-1.5 pt-1 text-[11px] font-semibold uppercase tracking-wider text-foreground/70">{title}</p>- {agents.map((agent) => (+ {agents.map((agent) => {+ /*+ * A missing entry is only a dead end when nothing can be done+ * about it. A CLI that ships an install command gets a button+ * instead of the old label; the plain terminal on a host with no+ * shell keeps the label, because there is nothing to install.+ */+ const installable =+ !agent.installed && agent.kind !== "shell" && Boolean(agent.installCommand);+ return (+ <div+ key={agent.name}+ /* `none` and not `presentation`: this wrapper exists only so+ the row can hold two menu items side by side, and it must+ not take a place of its own in the menu's structure. */+ role="none"+ className="flex items-stretch gap-1"+ ><button- key={agent.name}type="button"role="menuitem"autoFocus={agent === first}@@ -237,7 +283,7 @@ export function AgentPickerMenu({listed. State now reads from the ink COLOUR (muted rather thanforeground) with only a slight dim on top, so it is plainlyunavailable and still says why. */- className="flex w-full items-start justify-between gap-2 rounded-md px-2 py-1.5 text-left text-sm transition-colors hover:bg-primary/10 disabled:cursor-not-allowed disabled:text-muted-foreground disabled:opacity-80 disabled:hover:bg-transparent"+ className="flex min-w-0 flex-1 items-start justify-between gap-2 rounded-md px-2 py-1.5 text-left text-sm transition-colors hover:bg-primary/10 disabled:cursor-not-allowed disabled:text-muted-foreground disabled:opacity-80 disabled:hover:bg-transparent">{/* The mark, at list weight rather than as a framed tile: this is amenu of choices, and forty boxes down a column read as a grid@@ -263,14 +309,55 @@ export function AgentPickerMenu({</span>)}</span>- {!agent.installed && (+ {/* The label survives only where it is the whole answer. Where an+ Install button sits beside the row, repeating "not installed"+ in a 272px menu costs the entry's description its line and says+ nothing the button does not. */}+ {!agent.installed && !installable && (<span className="shrink-0 text-[10px] font-medium uppercase tracking-wide text-muted-foreground">{agent.kind === "shell" ? "no shell here" : "not installed"}</span>)}</button>- ))}+ {installable && (+ <button+ type="button"+ role="menuitem"+ data-testid={`${itemTestId(agent.name)}-install`}+ title={agent.installCommand}+ onClick={(e) => {+ e.stopPropagation();+ setInstalling(agent);+ }}+ /* Outlined rather than filled: it is the row's secondary+ action, and a column of solid buttons would read as the+ menu itself being about installing. Its colours are theme+ tokens, so it follows light and dark. */+ className="my-0.5 shrink-0 self-center rounded-md border border-border px-2 py-1 text-[11px] font-medium text-foreground transition-colors hover:border-primary/60 hover:bg-primary/10"+ >+ Install+ </button>+ )}+ </div>+ );+ })}</div>+ {/* The installer, over the menu rather than instead of it: closing the+ dialog puts the user back in front of the list they were picking+ from, with the entry they just installed now pickable. */}+ {installing && (+ <AgentInstallDialog+ agent={installing.name}+ displayName={installing.displayName}+ command={installing.installCommand}+ logoUrl={installing.logoUrl}+ onClose={(installed) => {+ const name = installing.name;+ setInstalling(null);+ onInstalled?.(name, installed);+ }}+ />+ )}</>);diff --git a/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.tsx b/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.tsxindex 735189f38f..3a735bc04d 100644--- a/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.tsx+++ b/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.tsx@@ -137,6 +137,14 @@ interface AgenticGridProps {maxTerminals?: number;/** Coding CLIs a split may start — the pane split menus offer these. */agents?: SplitAgentChoice[];+ /**+ * A split menu installed a CLI — the owner re-reads its agent list.+ *+ * The list is answered from a cached detection sweep, so without this the+ * entry the user just installed keeps reading as missing for up to half a+ * minute, which looks exactly like an installer that did nothing.+ */+ onAgentsChanged?: () => void;/** Adding or closing a pane changes the workspace — the owner re-reads it. */onSessionChanged?: (session: SessionState) => void;/**@@ -663,6 +671,7 @@ export function AgenticGrid({busy = false,maxTerminals = 12,agents,+ onAgentsChanged,onSessionChanged,accounts = [],onStateChanged,@@ -2707,6 +2716,7 @@ export function AgenticGrid({itemTestId={(agent) => `chat-rail-new-${agent}`}className="left-2 top-full"onDismiss={() => setPicking(null)}+ onInstalled={() => onAgentsChanged?.()}onPick={(agent) => {setPicking(null);void split(null, "right", agent);@@ -3048,6 +3058,7 @@ export function AgenticGrid({layoutBusy={layoutBusy}splitDisabled={atLimit || busy || working}agents={agents}+ onAgentsChanged={onAgentsChanged}onFocus={() => {if (takesPrompts(term)) setTarget(term.name);}}@@ -3213,6 +3224,7 @@ export function AgenticGrid({itemTestId={(agent) => `empty-workspace-new-${agent}`}className="left-1/2 top-full mt-1 -translate-x-1/2"onDismiss={() => setPicking(null)}+ onInstalled={() => onAgentsChanged?.()}onPick={(agent) => {setPicking(null);void split(null, "right", agent);diff --git a/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx b/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsxindex 2667632125..3ca9c1fcd5 100644--- a/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx+++ b/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx@@ -451,6 +451,8 @@ interface AgenticTerminalProps {* choose, so the split buttons act immediately instead of opening a menu.*/agents?: SplitAgentChoice[];+ /** The split menu installed one of them — the grid re-reads its list. */+ onAgentsChanged?: () => void;/*** Give this pane another call-sign.*@@ -527,6 +529,7 @@ export function AgenticTerminal({onToggleMaximize,onSplit,agents,+ onAgentsChanged,onRename,onClose,splitDisabled = false,@@ -2139,6 +2142,7 @@ export function AgenticTerminal({onToggleMaximize={onToggleMaximize}onSplit={onSplit}agents={agents}+ onAgentsChanged={onAgentsChanged}onRename={onRename}onClose={onClose}splitDisabled={splitDisabled}@@ -2282,6 +2286,7 @@ function PaneHeader({onToggleMaximize,onSplit,agents,+ onAgentsChanged,onRename,onClose,splitDisabled,@@ -2306,6 +2311,7 @@ function PaneHeader({onToggleMaximize?: () => void;onSplit?: (direction: SplitDirection, agent?: string) => void;agents?: SplitAgentChoice[];+ onAgentsChanged?: () => void;onRename?: (name: string) => Promise<boolean>;onClose?: () => void;splitDisabled: boolean;@@ -2868,6 +2874,7 @@ function PaneHeader({// the header when the pane sits at the bottom of the screen.anchorTo={headerRef.current}onDismiss={() => setPicking(null)}+ onInstalled={() => onAgentsChanged?.()}onPick={(agent) => {setPicking(null);onSplit?.(picking, agent);diff --git a/jarvis/ui/web/frontend/src/lib/agenticIdeApi.ts b/jarvis/ui/web/frontend/src/lib/agenticIdeApi.tsindex a20504ddba..6f9450dea9 100644--- a/jarvis/ui/web/frontend/src/lib/agenticIdeApi.ts+++ b/jarvis/ui/web/frontend/src/lib/agenticIdeApi.ts@@ -545,6 +545,33 @@ export function fetchIdeAgents(): Promise<AgentsResponse> {return getJson<AgentsResponse>("/api/agentic-ide/agents");}+/** One entry, probed just now — what an install dialog watches for. */+export interface AgentRecheck {+ name: string;+ display_name: string;+ installed: boolean;+ version: string | null;+}++/**+ * Ask about ONE CLI right now, bypassing the sweep's cache.+ *+ * Lives beside the IDE reads because the IDE's install dialog is what polls it,+ * but it is a workspace route: detection belongs to the registry both surfaces+ * share. `fetchIdeAgents` cannot answer this question — it probes every+ * registered CLI at once and serves a 30-second cache, so polling it while an+ * installer runs would spend a burst of subprocesses to be told what the app+ * believed half a minute ago.+ */+export async function recheckAgent(name: string): Promise<AgentRecheck> {+ const res = await fetch(+ `/api/workspace/agents/${encodeURIComponent(name)}/recheck`,+ { method: "POST", cache: "no-store" },+ );+ if (!res.ok) throw new Error(await detail(res));+ return (await res.json()) as AgentRecheck;+}+/*** What each pane of a workspace is doing right now.*diff --git a/jarvis/ui/web/frontend/src/views/AgenticIdeView.tsx b/jarvis/ui/web/frontend/src/views/AgenticIdeView.tsxindex cb3f4557b9..4d316137e6 100644--- a/jarvis/ui/web/frontend/src/views/AgenticIdeView.tsx+++ b/jarvis/ui/web/frontend/src/views/AgenticIdeView.tsx@@ -459,7 +459,8 @@ export function AgenticIdeView({ onScreen = true }: AgenticIdeViewProps) {// What the grid's split menus offer — every entry the backend registered, so// the coding CLIs and the plain terminal, and anything registered later// without a change here. Uninstalled entries stay in the list but disabled,- // so their absence is visible rather than silently missing.+ // so their absence is visible rather than silently missing — and carry their+ // install command, which is what lets the menu offer to fix it on the spot.const splitChoices = useMemo(() =>agents.map((a) => ({@@ -468,6 +469,7 @@ export function AgenticIdeView({ onScreen = true }: AgenticIdeViewProps) {installed: a.installed,kind: a.kind ?? "cli",logoUrl: a.logo_url || undefined,+ installCommand: a.install_command || undefined,// For a plain terminal the useful second line is WHICH shell opens; a// CLI's name already says what it is, so it gets no line of its own.description:@@ -888,6 +890,10 @@ export function AgenticIdeView({ onScreen = true }: AgenticIdeViewProps) {busy={busy}maxTerminals={maxTerminals}agents={splitChoices}+ /* An install started from a split menu changes the one thing this+ list answers, and the sweep behind it is cached — so the re-read+ is explicit rather than waited for. */+ onAgentsChanged={() => void reloadAgents()}onSessionChanged={setSession}accounts={ideAccounts}onStateChanged={applyStateFromSettings}diff --git a/jarvis/ui/web/workspace_routes.py b/jarvis/ui/web/workspace_routes.pyindex 7389591980..9d908ff86c 100644--- a/jarvis/ui/web/workspace_routes.py+++ b/jarvis/ui/web/workspace_routes.py@@ -8,8 +8,10 @@ PTY inside the Jarvis project folder.Endpoints (prefix ``/api/workspace``):- ``GET /agents`` → detect Claude Code + Codex (installed? version?)- ``POST /launch`` → validate + pre-trust + return the grid plan (slots)+- ``POST /agents/{name}/recheck`` → probe ONE entry now (after an install)- ``WS /pty/{key}`` → interactive PTY running one agent (or its installer)"""+from __future__ import annotationsimport asyncio@@ -25,7 +27,9 @@ from jarvis.workspace.agents import (build_install_argv,coding_agent_names,detect_agents,+ invalidate_agent_detection,pty_available,+ recheck_agent,)from jarvis.workspace.launcher import LAYOUT_CHOICES, plan_workspace, validate_splitfrom jarvis.workspace.trust import ensure_trusted@@ -56,6 +60,15 @@ class AgentsResponse(BaseModel):agents: list[AgentStatusModel]+class AgentRecheckResponse(BaseModel):+ """One entry, probed just now rather than read from the sweep's cache."""++ name: str+ display_name: str+ installed: bool+ version: str | None++class LaunchRequest(BaseModel):layout: intsplit: dict[str, int] = Field(default_factory=dict)@@ -87,6 +100,28 @@ async def get_agents() -> AgentsResponse:)[email protected]("/agents/{name}/recheck", response_model=AgentRecheckResponse)+async def recheck(name: str) -> AgentRecheckResponse:+ """Probe ONE entry now — "the install finished, did it work?".++ Cheap enough to poll while a user watches an installer run, which is the+ whole point: the full sweep behind ``GET /agents`` starts a subprocess per+ registered CLI and answers from a 30-second cache, so it can neither be+ polled nor tell the truth immediately after something appeared on disk.+ This one probes the single entry, re-augments PATH first, and drops that+ cache on the way through.+ """+ info = await recheck_agent(name)+ if info is None:+ raise HTTPException(status_code=404, detail=f"No agent named {name!r} is registered.")+ return AgentRecheckResponse(+ name=info.name,+ display_name=info.display_name,+ installed=info.installed,+ version=info.version,+ )++@router.post("/launch")async def launch(req: LaunchRequest) -> dict:try:@@ -159,14 +194,14 @@ async def workspace_pty(ws: WebSocket, key: str) -> None:async with send_lock:try:await ws.send_json({"t": "o", "d": text})- except Exception: # noqa: BLE001 - client gone; reader will stop+ except Exception: # noqa: BLE001, S110 - client gone; the reader stopspassasync def on_closed(_tid: str, code: int) -> None:async with send_lock:try:await ws.send_json({"t": "exit", "code": code})- except Exception: # noqa: BLE001+ except Exception: # noqa: BLE001, S110 - client gone; nowhere to reportpasstry:@@ -196,7 +231,7 @@ async def workspace_pty(ws: WebSocket, key: str) -> None:# AP-20: an unclean teardown raises RuntimeError, not# WebSocketDisconnect — treat any read error as terminal.break- except Exception: # noqa: BLE001 - malformed frame; keep the PTY alive+ except Exception: # noqa: BLE001, S112 - malformed frame; keep the PTY alivecontinuekind = msg.get("t")if kind == "i":@@ -210,6 +245,13 @@ async def workspace_pty(ws: WebSocket, key: str) -> None:# other frames are ignoredfinally:mgr.close(session.terminal_id)+ # An installer just ran to whatever end it reached, so the cached sweep+ # is describing a machine that no longer exists. Dropped here rather+ # than only in the recheck route, because the user may simply close the+ # dialog — and then the NEXT full read is the one that has to be honest+ # about what is installed.+ if install:+ invalidate_agent_detection()def _safe_int(value: object, default: int) -> int:diff --git a/jarvis/workspace/agents.py b/jarvis/workspace/agents.pyindex 4f852472a1..0a3a492c0e 100644--- a/jarvis/workspace/agents.py+++ b/jarvis/workspace/agents.py@@ -1233,25 +1233,38 @@ async def detect_agents(return list(infos)+def _augment_path() -> None:+ """Put the places CLIs install themselves onto this process's PATH.++ A GUI-launched process starts with a minimal PATH, so a correctly installed+ CLI reads as missing on macOS and Linux — and a CLI installed WHILE the app+ runs is invisible on every OS until something re-reads the environment. Both+ are the same call, and it is idempotent, so every detection path makes it+ rather than hoping an earlier one did.++ Best-effort by design: PATH augmentation failing must degrade to "detection+ sees whatever the process already had", never to no detection at all.+ """+ try:+ from jarvis.core.path_augment import ensure_cli_paths++ ensure_cli_paths()+ except Exception: # noqa: BLE001, S110 - PATH augmentation is best-effort+ pass++def _on_path(binary: str) -> bool:"""Is ``binary`` resolvable the way a pane would resolve it?The whole detection story for a user-added entry. No subprocess: see:func:`_custom_agent` for why a stranger's ``--version`` is not something- this sweep may run. ``ensure_cli_paths`` first, because a GUI-launched- process starts with a minimal PATH and would otherwise report a correctly- installed CLI as missing on macOS and Linux.+ this sweep may run."""import shutilif not binary:return False- try:- from jarvis.core.path_augment import ensure_cli_paths-- ensure_cli_paths()- except Exception: # noqa: BLE001, S110 - PATH augmentation is best-effort- pass+ _augment_path()return shutil.which(binary) is not None@@ -1268,6 +1281,7 @@ async def _sweep_agents(prober: CliStatusProber) -> list[AgentInfo]:question a ``--version`` probe can ask."""registry = _registry()+ _augment_path()specs = [a.spec for a in registry.values() if a.spec is not None]statuses = await prober.probe_all(specs) if specs else {}shell = default_shell()@@ -1276,55 +1290,100 @@ async def _sweep_agents(prober: CliStatusProber) -> list[AgentInfo]:if unspecced:found = await asyncio.to_thread(lambda: {a.name: _on_path(a.executable) for a in unspecced})- out: list[AgentInfo] = []- for agent in registry.values():- if agent.spec is None and agent.is_coding_agent:- out.append(- AgentInfo(- name=agent.name,- display_name=agent.display_name,- installed=found.get(agent.name, False),- # Deliberately none. Asking would be the subprocess this- # path exists to avoid, and a made-up number beside- # someone's own command is worse than a blank one.- version=None,- install_command=None,- launch_command=agent.launch_command or "",- kind=agent.kind,- description=agent.description,- custom=agent.custom,- logo_url=agent.logo_url,- )- )- continue- if agent.spec is None:- out.append(- AgentInfo(- name=agent.name,- display_name=agent.display_name,- installed=shell is not None,- version=shell.label if shell else None,- install_command=None,- launch_command="",- kind=agent.kind,- description=agent.description,- )- )- continue- st = statuses.get(agent.name)- out.append(- AgentInfo(- name=agent.name,- display_name=agent.display_name,- installed=bool(st and st.installed),- version=st.version if st else None,- install_command=install_command(agent.name),- launch_command=agent.launch_command or "",- kind=agent.kind,- description=agent.description,- )+ return [+ _agent_info(+ agent,+ status=statuses.get(agent.name),+ shell=shell,+ on_path=found.get(agent.name, False),)- return out+ for agent in registry.values()+ ]+++def _agent_info(+ agent: WorkspaceAgent,+ *,+ status: Any | None,+ shell: Any | None,+ on_path: bool,+) -> AgentInfo:+ """One entry's status row, from whichever of the three answers applies.++ Shared by the full sweep and the single-entry recheck, so the row a user+ sees right after installing something cannot disagree with the row the next+ sweep produces — the two used to be the same three branches written twice,+ which is exactly the shape that drifts.+ """+ if agent.spec is None and agent.is_coding_agent:+ return AgentInfo(+ name=agent.name,+ display_name=agent.display_name,+ installed=on_path,+ # Deliberately none. Asking would be the subprocess this path+ # exists to avoid, and a made-up number beside someone's own+ # command is worse than a blank one.+ version=None,+ install_command=None,+ launch_command=agent.launch_command or "",+ kind=agent.kind,+ description=agent.description,+ custom=agent.custom,+ logo_url=agent.logo_url,+ )+ if agent.spec is None:+ return AgentInfo(+ name=agent.name,+ display_name=agent.display_name,+ installed=shell is not None,+ version=shell.label if shell else None,+ install_command=None,+ launch_command="",+ kind=agent.kind,+ description=agent.description,+ )+ return AgentInfo(+ name=agent.name,+ display_name=agent.display_name,+ installed=bool(status and status.installed),+ version=status.version if status else None,+ install_command=install_command(agent.name),+ launch_command=agent.launch_command or "",+ kind=agent.kind,+ description=agent.description,+ )+++async def recheck_agent(name: str) -> AgentInfo | None:+ """Probe ONE entry right now, and forget the cached sweep.++ What "the install finished, did it work?" needs. The alternative —+ ``detect_agents(force=True)`` — answers the same question by starting a+ subprocess for every registered CLI, which is far too heavy for something+ a dialog polls every few seconds while a user watches npm run.++ Re-augments PATH first, because the binary that has just appeared may live+ somewhere a GUI-launched process never had on its PATH (an npm global+ prefix, ``~/.local/bin``). Without that the install genuinely succeeds and+ the app keeps reporting the entry as missing, which reads as a broken+ installer.++ Returns ``None`` for a name that is not registered. Always invalidates the+ sweep cache, even on a negative answer: whatever the user just did, the+ cached list is no longer something to trust.+ """+ agent = get_agent(name)+ if agent is None:+ return None+ invalidate_agent_detection()+ await asyncio.to_thread(_augment_path)+ if agent.spec is not None:+ status = await CliStatusProber().probe(agent.spec)+ return _agent_info(agent, status=status, shell=None, on_path=False)+ if agent.is_coding_agent:+ on_path = await asyncio.to_thread(_on_path, agent.executable)+ return _agent_info(agent, status=None, shell=None, on_path=on_path)+ return _agent_info(agent, status=None, shell=default_shell(), on_path=False)def _build_pty_argv(command: str) -> tuple[str, ...] | None:@@ -1449,6 +1508,7 @@ __all__ = ["needs_trust","plain_terminal_argv","pty_available",+ "recheck_agent","refresh_custom_agents","register_agent","reserved_call_signs",diff --git a/tests/integration/test_workspace_recheck_route.py b/tests/integration/test_workspace_recheck_route.pynew file mode 100644index 0000000000..1e20df01bb--- /dev/null+++ b/tests/integration/test_workspace_recheck_route.py@@ -0,0 +1,76 @@+"""``POST /api/workspace/agents/{name}/recheck`` — "did that install work?".++The route an install dialog polls while a package manager runs, and the reason+it is not simply ``GET /agents``: that read answers from a 30-second cache and+probes every registered CLI at once, so it can neither be polled nor tell the+truth about a binary that appeared two seconds ago.+"""++from __future__ import annotations++import pytest+from fastapi import FastAPI+from fastapi.testclient import TestClient++from jarvis.clis.spec import CliStatus+from jarvis.workspace import agents as registry+++class OneProber:+ """Answers a single probe and refuses to be used as a sweep."""++ def __init__(self, status: CliStatus) -> None:+ self.status = status+ self.probed: list[str] = []++ async def probe(self, spec) -> CliStatus: # noqa: ANN001+ self.probed.append(spec.name)+ return self.status++ async def probe_all(self, specs) -> dict[str, CliStatus]: # noqa: ANN001+ raise AssertionError("the recheck route must not run the full sweep")+++def client():+ from jarvis.ui.web import workspace_routes++ app = FastAPI()+ app.include_router(workspace_routes.router)+ registry.invalidate_agent_detection()+ yield TestClient(app)+ registry.invalidate_agent_detection()+++def test_a_freshly_installed_cli_is_reported_as_installed(+ client: TestClient, monkeypatch: pytest.MonkeyPatch+) -> None:+ prober = OneProber(CliStatus(installed=True, version="0.1.1"))+ monkeypatch.setattr(registry, "CliStatusProber", lambda: prober)++ body = client.post("/api/workspace/agents/deepseek-harness/recheck").json()++ assert body == {+ "name": "deepseek-harness",+ "display_name": "DeepSeek Harness",+ "installed": True,+ "version": "0.1.1",+ }+ assert prober.probed == ["deepseek-harness"]+++def test_a_failed_install_is_reported_as_still_missing(+ client: TestClient, monkeypatch: pytest.MonkeyPatch+) -> None:+ """The route reports what it found, never what the user was hoping for."""+ monkeypatch.setattr(registry, "CliStatusProber", lambda: OneProber(CliStatus(installed=False)))++ body = client.post("/api/workspace/agents/deepseek-harness/recheck").json()++ assert body["installed"] is False+ assert body["version"] is None+++def test_an_unregistered_name_is_a_404_and_not_an_invented_row(client: TestClient) -> None:+ response = client.post("/api/workspace/agents/no-such-cli/recheck")+ assert response.status_code == 404diff --git a/tests/unit/workspace/test_agents.py b/tests/unit/workspace/test_agents.pyindex d8ffca0f79..0885082184 100644--- a/tests/unit/workspace/test_agents.py+++ b/tests/unit/workspace/test_agents.py@@ -335,3 +335,100 @@ async def test_an_explicit_prober_never_reads_or_fills_the_cache(infos = {i.name: i for i in await detect_agents(mine)}assert infos["claude"].version == "9.9.9"assert registry._detection_cache is None+++# ------------------------------------------------- one entry, probed on demand+++class OneProber:+ """Answers a single probe, and counts how many entries it was asked about."""++ def __init__(self, status: CliStatus) -> None:+ self.status = status+ self.probed: list[str] = []++ async def probe(self, spec) -> CliStatus: # noqa: ANN001+ self.probed.append(spec.name)+ return self.status++ async def probe_all(self, specs) -> dict[str, CliStatus]: # noqa: ANN001+ raise AssertionError("a single-entry recheck must never run the full sweep")+++async def test_a_recheck_probes_one_entry_and_not_the_others(+ monkeypatch, _no_cached_detection+) -> None:+ """The reason this exists at all.++ ``detect_agents(force=True)`` answers the same question by starting a+ subprocess for every registered CLI. An install dialog polls this every few+ seconds while someone watches npm run, so a sweep per ask would spend seven+ processes to learn one fact — and stall the loop the wake microphone is+ delivered on while doing it.+ """+ from jarvis.workspace import agents as registry++ prober = OneProber(CliStatus(installed=True, version="0.1.1"))+ monkeypatch.setattr(registry, "CliStatusProber", lambda: prober)++ info = await registry.recheck_agent("deepseek-harness")++ assert info is not None+ assert info.installed is True+ assert info.version == "0.1.1"+ assert prober.probed == ["deepseek-harness"]+++async def test_a_recheck_drops_the_cached_sweep(monkeypatch, _no_cached_detection) -> None:+ """Whatever the user just did, the cached list is no longer trustworthy.++ Without this the entry they installed keeps reading as missing for up to+ the TTL everywhere ELSE in the app — which looks exactly like an installer+ that did nothing.+ """+ from jarvis.workspace import agents as registry++ counting = CountingProber()+ monkeypatch.setattr(registry, "CliStatusProber", lambda: counting)+ await detect_agents()+ assert counting.sweeps == 1+ await detect_agents()+ assert counting.sweeps == 1, "precondition: the second read came from the cache"++ monkeypatch.setattr(+ registry, "CliStatusProber", lambda: OneProber(CliStatus(installed=True, version="1.0.0"))+ )+ await registry.recheck_agent("deepseek-harness")++ monkeypatch.setattr(registry, "CliStatusProber", lambda: counting)+ await detect_agents()+ assert counting.sweeps == 2+++async def test_a_recheck_answers_for_every_kind_of_entry(monkeypatch) -> None:+ """A shell and a user-added CLI are not probed with ``--version``.++ The recheck reuses the sweep's own three branches rather than a second+ copy, so an entry that has no spec answers the way it always did instead of+ reaching for a subprocess that would never work on it.+ """+ from jarvis.workspace import agents as registry++ monkeypatch.setattr(registry, "CliStatusProber", lambda: OneProber(CliStatus(installed=False)))+ shell = await registry.recheck_agent(PLAIN_TERMINAL)+ assert shell is not None+ assert shell.kind == "shell"+ # Whatever this host has, the answer came from the shell lookup and not+ # from a probe — a shell cannot answer ``--version``.+ assert shell.installed is (plain_terminal_argv() is not None)+++async def test_a_recheck_of_something_unregistered_is_not_an_answer() -> None:+ """``None``, so the route can 404 rather than invent a row."""+ from jarvis.workspace import agents as registry++ assert await registry.recheck_agent("no-such-cli") is None