Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

feat(agentic-ide): add and edit your own CLIs from the terminal step

rubenluetke10-beep3ecbe41089f5
diff --git a/jarvis/ui/web/frontend/src/components/agentic/AgentAllocation.tsx b/jarvis/ui/web/frontend/src/components/agentic/AgentAllocation.tsx
index 52f50652ca..321e8dfda9 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/AgentAllocation.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/AgentAllocation.tsx
@@ -2,13 +2,20 @@
* Allocate terminal slots by agent instead of editing every pane separately.
* The backend still receives its existing one-entry-per-terminal plan.
*/
-import { Check, Minus, Plus } from "lucide-react";
+import { useState } from "react";
+import { Check, Minus, Pencil, Plus, Trash2 } from "lucide-react";
import { useT } from "@/i18n";
import { cn } from "@/lib/utils";
import type { AgentAccount } from "@/lib/agentAccountsApi";
import type { AgentStatus } from "@/lib/agenticIdeApi";
+import {
+ deleteCustomCli,
+ fetchCustomClis,
+ type CustomCli,
+} from "@/lib/workspaceClisApi";
import { AgentMark } from "./AgentMark";
-import { Button, SectionLabel } from "./controls";
+import { Button, IconButton, SectionLabel } from "./controls";
+import { CustomCliDialog } from "./CustomCliDialog";
import { BrandedSelect } from "@/components/ui/select";
export interface PlannedTerminal {
@@ -27,6 +34,16 @@ export interface AgentAllocationProps {
onPlanned: (
update: (previous: PlannedTerminal[]) => PlannedTerminal[],
) => void;
+ /**
+ * Re-read the agent list, because the user just added, edited or removed a
+ * CLI of their own.
+ *
+ * Passed in rather than done here: this component RENDERS the list it is
+ * given, and the owner of that list is the one that can replace it. Without
+ * it the new CLI would be stored, registered and offered everywhere — except
+ * in the very screen the user added it from, until the next full refresh.
+ */
+ onAgentsChanged?: () => void;
}
/** Count assigned panes without treating the unassigned sentinel as an agent. */
@@ -123,8 +140,63 @@ export function AgentAllocation({
agents,
accountsFor,
onPlanned,
+ onAgentsChanged,
}: AgentAllocationProps) {
const t = useT();
+ /*
+ * The dialog needs the FULL stored record — the command, the logo, how a
+ * dropped file is written — and `/agents` carries only what a picker shows.
+ * Fetched on demand, when the user reaches for edit or add, rather than kept
+ * in step with the list: on the common path (nobody touches their own CLIs)
+ * that is a request this screen never makes.
+ */
+ const [editing, setEditing] = useState<CustomCli | null>(null);
+ const [dialogOpen, setDialogOpen] = useState(false);
+ const [busy, setBusy] = useState("");
+ const [error, setError] = useState("");
+
+ const openDialog = async (agent?: AgentStatus) => {
+ setError("");
+ if (!agent) {
+ setEditing(null);
+ setDialogOpen(true);
+ return;
+ }
+ setBusy(agent.name);
+ try {
+ const stored = await fetchCustomClis();
+ const found = stored.clis.find((cli) => cli.id === agent.name) ?? null;
+ if (!found) throw new Error(t("custom_cli.gone"));
+ setEditing(found);
+ setDialogOpen(true);
+ } catch (reason: unknown) {
+ setError(reason instanceof Error ? reason.message : String(reason));
+ } finally {
+ setBusy("");
+ }
+ };
+
+ const removeCli = async (agent: AgentStatus) => {
+ setError("");
+ setBusy(agent.name);
+ try {
+ await deleteCustomCli(agent.name);
+ // Free the slots it held. A pane planned for a CLI that no longer exists
+ // would be rejected by /launch, so the count goes back to unassigned
+ // rather than leaving the user to notice at the end of the wizard.
+ onPlanned((previous) =>
+ previous.map((pane) =>
+ pane.agent === agent.name ? { name: pane.name, agent: "" } : pane,
+ ),
+ );
+ onAgentsChanged?.();
+ } catch (reason: unknown) {
+ setError(reason instanceof Error ? reason.message : String(reason));
+ } finally {
+ setBusy("");
+ }
+ };
+
const counts = allocationCounts(planned);
const assigned = Object.values(counts).reduce((sum, value) => sum + value, 0);
const total = planned.length;
@@ -251,7 +323,7 @@ export function AgentAllocation({
<div
key={agent.name}
className={cn(
- "grid gap-3 border-b border-border/50 px-1 py-3 last:border-b-0 sm:grid-cols-[minmax(0,1fr)_auto] sm:items-center",
+ "group grid gap-3 border-b border-border/50 px-1 py-3 last:border-b-0 sm:grid-cols-[minmax(0,1fr)_auto] sm:items-center",
count > 0 && "bg-primary/[0.035]",
)}
>
@@ -273,6 +345,7 @@ export function AgentAllocation({
<AgentMark
agent={agent.name}
label={agent.display_name}
+ logoUrl={agent.logo_url || undefined}
className={cn(
"transition-colors",
count > 0
@@ -297,6 +370,40 @@ export function AgentAllocation({
t("workspace_launcher.agents.installed")
: t("workspace_launcher.agents.not_installed")}
</span>
+ {/* Editing lives on the row it belongs to, and only on the
+ rows it CAN belong to — a shipped CLI has nothing here
+ to change. Quiet until the row is hovered or a key
+ reaches them, so six built-in rows do not grow two
+ buttons each for a feature most of them cannot use. */}
+ {agent.custom && (
+ <span className="flex items-center gap-0.5 opacity-0 transition-opacity focus-within:opacity-100 group-hover:opacity-100">
+ <IconButton
+ size="sm"
+ label={t("custom_cli.edit_named").replace(
+ "{0}",
+ agent.display_name,
+ )}
+ disabled={busy === agent.name}
+ data-testid={`custom-cli-edit-${agent.name}`}
+ onClick={() => void openDialog(agent)}
+ >
+ <Pencil className="h-3 w-3" aria-hidden="true" />
+ </IconButton>
+ <IconButton
+ size="sm"
+ label={t("custom_cli.remove_named").replace(
+ "{0}",
+ agent.display_name,
+ )}
+ disabled={busy === agent.name}
+ data-testid={`custom-cli-remove-${agent.name}`}
+ onClick={() => void removeCli(agent)}
+ className="hover:text-destructive"
+ >
+ <Trash2 className="h-3 w-3" aria-hidden="true" />
+ </IconButton>
+ </span>
+ )}
</div>
{agent.description && (
<p className="truncate text-[11px] text-muted-foreground">
@@ -411,9 +518,46 @@ export function AgentAllocation({
})}
</div>
+ {/* Adding your own sits at the END of the list rather than in a settings
+ page, because this is where the question comes up: the user is
+ looking at six CLIs and the one they wanted is not among them. */}
+ <div className="flex flex-wrap items-center justify-between gap-3 border-b border-border/70 px-1 py-3">
+ <div className="min-w-0">
+ <p className="text-sm text-foreground">{t("custom_cli.add_title")}</p>
+ <p className="text-[11px] leading-relaxed text-muted-foreground">
+ {t("custom_cli.add_hint")}
+ </p>
+ </div>
+ <Button
+ variant="quiet"
+ data-testid="custom-cli-add"
+ onClick={() => void openDialog()}
+ >
+ <Plus className="h-3.5 w-3.5" aria-hidden="true" />
+ {t("custom_cli.add_button")}
+ </Button>
+ </div>
+
+ {error && (
+ <p
+ role="alert"
+ data-testid="custom-cli-list-error"
+ className="mt-3 border-l-2 border-destructive/70 py-1 pl-3 text-sm text-destructive"
+ >
+ {error}
+ </p>
+ )}
+
<p className="mt-3 text-[11px] leading-relaxed text-muted-foreground">
{t("workspace_launcher.agents.auto_names")}
</p>
+
+ <CustomCliDialog
+ open={dialogOpen}
+ onOpenChange={setDialogOpen}
+ editing={editing}
+ onSaved={() => onAgentsChanged?.()}
+ />
</div>
);
}
diff --git a/jarvis/ui/web/frontend/src/components/agentic/AgentMark.tsx b/jarvis/ui/web/frontend/src/components/agentic/AgentMark.tsx
index 5640c173f3..18087f32cb 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/AgentMark.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/AgentMark.tsx
@@ -16,6 +16,16 @@ interface AgentMarkProps {
label: string;
className?: string;
size?: "sm" | "md" | "lg";
+ /**
+ * An image to draw instead of the built-in table's — the mark a user uploaded
+ * for a CLI of their own.
+ *
+ * Passed in rather than looked up, because this component cannot know it: the
+ * table below is a fixed list of brands that ship with the app, and an entry
+ * added at runtime has no place in it. An entry with no logo (and every
+ * shipped one) leaves this undefined and the table decides as before.
+ */
+ logoUrl?: string;
/**
* How much of a mark this is.
*
@@ -42,9 +52,19 @@ export function AgentMark({
className,
size = "md",
variant = "boxed",
+ logoUrl,
}: AgentMarkProps) {
- const [failed, setFailed] = useState(false);
- const logo = AGENT_LOGOS[agent];
+ /*
+ * WHICH logo failed, not merely "one did".
+ *
+ * A boolean would stick: a user who replaces a broken upload with a working
+ * one keeps seeing the monogram, because the component is the same instance
+ * and its flag never clears. Storing the URL that failed makes the next one a
+ * fresh attempt without an effect to keep in step.
+ */
+ const [failedLogo, setFailedLogo] = useState<string | null>(null);
+ const logo = logoUrl || AGENT_LOGOS[agent];
+ const failed = failedLogo != null && failedLogo === logo;
const monogram = label.trim().slice(0, 2).toUpperCase() || "?";
const plain = variant === "plain";
const sizeClass = plain
@@ -91,7 +111,7 @@ export function AgentMark({
? "h-6 w-6"
: "h-5 w-5",
)}
- onError={() => setFailed(true)}
+ onError={() => setFailedLogo(logo)}
/>
) : (
<span className="font-mono">{monogram}</span>
diff --git a/jarvis/ui/web/frontend/src/components/agentic/AgentPicker.tsx b/jarvis/ui/web/frontend/src/components/agentic/AgentPicker.tsx
index fe6e6c5718..2c2357d773 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/AgentPicker.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/AgentPicker.tsx
@@ -24,6 +24,7 @@
import { useEffect, useState } from "react";
import { createPortal } from "react-dom";
import { cn } from "@/lib/utils";
+import { AgentMark } from "./AgentMark";
/** A coding CLI an "open a terminal" action may start. */
export interface SplitAgentChoice {
@@ -40,6 +41,11 @@ export interface SplitAgentChoice {
kind?: string;
/** One line under the name — the shell that would open, for instance. */
description?: string;
+ /**
+ * The mark for an entry this bundle has no asset for — a CLI the user added.
+ * Absent for everything else, where `AgentMark`'s own table answers.
+ */
+ logoUrl?: string;
}
/**
@@ -213,7 +219,20 @@ export function AgentPickerMenu({
}}
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:opacity-40 disabled:hover:bg-transparent"
>
- <span className="min-w-0">
+ {/* The mark, at list weight rather than as a framed tile: this is a
+ menu of choices, and forty boxes down a column read as a grid
+ instead of a list. It earns its place because the entries are no
+ longer a fixed set of names a user can learn — one of them may
+ be a CLI they added and named themselves. */}
+ <AgentMark
+ agent={agent.name}
+ label={agent.displayName}
+ variant="plain"
+ size="sm"
+ logoUrl={agent.logoUrl}
+ className="mt-0.5"
+ />
+ <span className="min-w-0 flex-1">
<span className="block truncate">{agent.displayName}</span>
{/* What this choice actually opens — "no agent, just a prompt"
is the difference a user needs before clicking, and it is the
diff --git a/jarvis/ui/web/frontend/src/components/agentic/CustomCliDialog.test.tsx b/jarvis/ui/web/frontend/src/components/agentic/CustomCliDialog.test.tsx
new file mode 100644
index 0000000000..2183bb047c
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/components/agentic/CustomCliDialog.test.tsx
@@ -0,0 +1,298 @@
+import { useState } from "react";
+import {
+ cleanup,
+ fireEvent,
+ render,
+ screen,
+ waitFor,
+} from "@testing-library/react";
+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
+
+import type { AgentAccount } from "@/lib/agentAccountsApi";
+import type { AgentStatus } from "@/lib/agenticIdeApi";
+import { AgentAllocation, type PlannedTerminal } from "./AgentAllocation";
+import { CustomCliDialog, runsThroughShell } from "./CustomCliDialog";
+
+vi.mock("@/i18n", () => ({
+ useT: () => (key: string) => key,
+}));
+
+vi.mock("@/lib/workspaceClisApi", () => ({
+ fetchCustomClis: vi.fn(),
+ createCustomCli: vi.fn(),
+ updateCustomCli: vi.fn(),
+ deleteCustomCli: vi.fn(),
+ uploadCustomCliLogo: vi.fn(),
+ removeCustomCliLogo: vi.fn(),
+}));
+
+import * as api from "@/lib/workspaceClisApi";
+
+/** No jest-dom in this repo — assertions read the elements directly. */
+function field(testId: string): HTMLInputElement {
+ return screen.getByTestId(testId) as HTMLInputElement;
+}
+
+function text(testId: string): string {
+ return screen.getByTestId(testId).textContent ?? "";
+}
+
+const STORED: api.CustomCli = {
+ id: "antigravity",
+ display_name: "Antigravity",
+ command: "agy",
+ description: "Google's terminal coding CLI.",
+ file_reference: "quoted",
+ logo_url: "",
+ runs_through_shell: false,
+ binary: "agy",
+};
+
+const AGENTS: AgentStatus[] = [
+ {
+ name: "claude",
+ display_name: "Claude Code",
+ installed: true,
+ version: "2.1",
+ install_command: null,
+ },
+ {
+ name: "antigravity",
+ display_name: "Antigravity",
+ installed: true,
+ version: null,
+ install_command: null,
+ custom: true,
+ description: "Google's terminal coding CLI.",
+ },
+];
+
+function Harness({ count = 4 }: { count?: number }) {
+ const [planned, setPlanned] = useState<PlannedTerminal[]>(
+ Array.from({ length: count }, (_, index) => ({
+ agent: index === 0 ? "antigravity" : "",
+ name: `T${index + 1}`,
+ })),
+ );
+ const [reloads, setReloads] = useState(0);
+ return (
+ <>
+ <AgentAllocation
+ planned={planned}
+ agents={AGENTS}
+ accountsFor={(): AgentAccount[] => []}
+ onPlanned={(update) => setPlanned((previous) => update(previous))}
+ onAgentsChanged={() => setReloads((n) => n + 1)}
+ />
+ <output data-testid="plan">{JSON.stringify(planned)}</output>
+ <output data-testid="reloads">{reloads}</output>
+ </>
+ );
+}
+
+afterEach(cleanup);
+beforeEach(() => {
+ vi.clearAllMocks();
+ // jsdom ships no object-URL implementation, and the logo preview asks for
+ // one the moment a file is picked.
+ Object.assign(URL, {
+ createObjectURL: vi.fn(() => "blob:preview"),
+ revokeObjectURL: vi.fn(),
+ });
+});
+
+describe("recognising shell source", () => {
+ // Mirrors custom_clis.needs_shell — the two must agree, because the backend's
+ // answer decides how the pane starts and this one decides what the user was
+ // told would happen.
+ it.each([
+ ["agy", false],
+ ["npx -y some-cli", false],
+ ["agy | tee log.txt", true],
+ ["agy && echo done", true],
+ ["FOO=1 agy", true],
+ ["agy --model $MODEL", true],
+ ])("%s", (command, expected) => {
+ expect(runsThroughShell(command)).toBe(expected);
+ });
+});
+
+describe("CustomCliDialog", () => {
+ it("cannot be saved without both a name and a command", () => {
+ render(
+ <CustomCliDialog open onOpenChange={() => {}} onSaved={() => {}} />,
+ );
+ const save = screen.getByTestId("custom-cli-save") as HTMLButtonElement;
+ expect(save.disabled).toBe(true);
+
+ fireEvent.change(field("custom-cli-name"), {
+ target: { value: "Antigravity" },
+ });
+ expect(save.disabled).toBe(true);
+
+ fireEvent.change(screen.getByTestId("custom-cli-command"), {
+ target: { value: "agy" },
+ });
+ expect(save.disabled).toBe(false);
+ });
+
+ it("warns while typing that a shell will wrap the command", () => {
+ render(
+ <CustomCliDialog open onOpenChange={() => {}} onSaved={() => {}} />,
+ );
+ fireEvent.change(screen.getByTestId("custom-cli-command"), {
+ target: { value: "agy" },
+ });
+ expect(screen.getByText("custom_cli.command_hint")).toBeTruthy();
+
+ fireEvent.change(screen.getByTestId("custom-cli-command"), {
+ target: { value: "agy | tee log.txt" },
+ });
+ expect(screen.getByText("custom_cli.command_shell_hint")).toBeTruthy();
+ });
+
+ it("creates the entry and reports it", async () => {
+ vi.mocked(api.createCustomCli).mockResolvedValue(STORED);
+ const onSaved = vi.fn();
+ render(
+ <CustomCliDialog open onOpenChange={() => {}} onSaved={onSaved} />,
+ );
+
+ fireEvent.change(screen.getByTestId("custom-cli-name"), {
+ target: { value: "Antigravity" },
+ });
+ fireEvent.change(screen.getByTestId("custom-cli-command"), {
+ target: { value: "agy" },
+ });
+ fireEvent.click(screen.getByTestId("custom-cli-save"));
+
+ await waitFor(() => expect(api.createCustomCli).toHaveBeenCalled());
+ expect(api.createCustomCli).toHaveBeenCalledWith({
+ display_name: "Antigravity",
+ command: "agy",
+ description: "",
+ file_reference: "quoted",
+ });
+ expect(onSaved).toHaveBeenCalledWith(STORED);
+ });
+
+ it("shows the server's own complaint instead of a status code", async () => {
+ vi.mocked(api.createCustomCli).mockRejectedValue(
+ new Error("Give the command that starts this CLI."),
+ );
+ render(
+ <CustomCliDialog open onOpenChange={() => {}} onSaved={() => {}} />,
+ );
+ fireEvent.change(screen.getByTestId("custom-cli-name"), {
+ target: { value: "Antigravity" },
+ });
+ fireEvent.change(screen.getByTestId("custom-cli-command"), {
+ target: { value: "agy" },
+ });
+ fireEvent.click(screen.getByTestId("custom-cli-save"));
+
+ await waitFor(() =>
+ expect(text("custom-cli-error")).toContain(
+ "Give the command that starts this CLI.",
+ ),
+ );
+ });
+
+ it("uploads a picked logo after the entry exists", async () => {
+ // The id the file is named after is assigned on creation, so a logo cannot
+ // be stored before the entry it belongs to.
+ vi.mocked(api.createCustomCli).mockResolvedValue(STORED);
+ vi.mocked(api.uploadCustomCliLogo).mockResolvedValue({
+ ...STORED,
+ logo_url: "/api/workspace-clis/antigravity/logo",
+ });
+ render(
+ <CustomCliDialog open onOpenChange={() => {}} onSaved={() => {}} />,
+ );
+
+ fireEvent.change(screen.getByTestId("custom-cli-name"), {
+ target: { value: "Antigravity" },
+ });
+ fireEvent.change(screen.getByTestId("custom-cli-command"), {
+ target: { value: "agy" },
+ });
+ const file = new File(["<svg />"], "mark.svg", { type: "image/svg+xml" });
+ fireEvent.change(screen.getByTestId("custom-cli-logo-input"), {
+ target: { files: [file] },
+ });
+ fireEvent.click(screen.getByTestId("custom-cli-save"));
+
+ await waitFor(() => expect(api.uploadCustomCliLogo).toHaveBeenCalled());
+ expect(api.uploadCustomCliLogo).toHaveBeenCalledWith("antigravity", file);
+ });
+
+ it("fills its fields from the entry being edited", () => {
+ render(
+ <CustomCliDialog
+ open
+ onOpenChange={() => {}}
+ editing={{ ...STORED, file_reference: "at" }}
+ onSaved={() => {}}
+ />,
+ );
+ expect(field("custom-cli-name").value).toBe("Antigravity");
+ expect(field("custom-cli-command").value).toBe("agy");
+ expect(field("custom-cli-at-reference").checked).toBe(true);
+ });
+});
+
+describe("AgentAllocation with a CLI of your own", () => {
+ it("offers editing only on the rows that have something to edit", () => {
+ render(<Harness />);
+ expect(screen.getByTestId("custom-cli-edit-antigravity")).toBeTruthy();
+ expect(screen.queryByTestId("custom-cli-edit-claude")).toBeNull();
+ });
+
+ it("loads the stored record before opening the editor", async () => {
+ // `/agents` carries what a picker shows; the dialog needs the command.
+ vi.mocked(api.fetchCustomClis).mockResolvedValue({
+ clis: [STORED],
+ max_name_length: 60,
+ max_command_length: 500,
+ max_logo_bytes: 1024,
+ logo_extensions: [".svg"],
+ });
+ render(<Harness />);
+ fireEvent.click(screen.getByTestId("custom-cli-edit-antigravity"));
+
+ await waitFor(() =>
+ expect(field("custom-cli-command").value).toBe("agy"),
+ );
+ });
+
+ it("frees the slots a removed CLI held", async () => {
+ vi.mocked(api.deleteCustomCli).mockResolvedValue({ ok: true });
+ render(<Harness />);
+ expect(JSON.parse(screen.getByTestId("plan").textContent ?? "[]")[0]).toEqual(
+ { agent: "antigravity", name: "T1" },
+ );
+
+ fireEvent.click(screen.getByTestId("custom-cli-remove-antigravity"));
+
+ await waitFor(() =>
+ expect(
+ JSON.parse(screen.getByTestId("plan").textContent ?? "[]")[0],
+ ).toEqual({ agent: "", name: "T1" }),
+ );
+ // And the list is re-read, or the entry stays on screen after removal.
+ expect(text("reloads")).toBe("1");
+ });
+
+ it("reports a failed removal instead of pretending it worked", async () => {
+ vi.mocked(api.deleteCustomCli).mockRejectedValue(new Error("store is busy"));
+ render(<Harness />);
+ fireEvent.click(screen.getByTestId("custom-cli-remove-antigravity"));
+
+ await waitFor(() =>
+ expect(text("custom-cli-list-error")).toContain("store is busy"),
+ );
+ expect(JSON.parse(screen.getByTestId("plan").textContent ?? "[]")[0]).toEqual(
+ { agent: "antigravity", name: "T1" },
+ );
+ });
+});
diff --git a/jarvis/ui/web/frontend/src/components/agentic/CustomCliDialog.tsx b/jarvis/ui/web/frontend/src/components/agentic/CustomCliDialog.tsx
new file mode 100644
index 0000000000..c41e66203c
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/components/agentic/CustomCliDialog.tsx
@@ -0,0 +1,340 @@
+/**
+ * Add or edit a terminal CLI of your own.
+ *
+ * The form behind "this app should also be able to open X" — where X is any
+ * interactive CLI this build has never heard of. Four fields, because that is
+ * everything the backend needs to treat it exactly like a shipped one: a name,
+ * the command that starts it, a line of description for the picker, and a logo.
+ *
+ * ## Why the command is checked here at all
+ *
+ * The server validates it too, and its answer is the one that counts. What this
+ * side adds is the reading the server cannot give in time: a command containing
+ * a pipe, a `&&` or a `VAR=x` prefix is shell source, so the pane will run a
+ * shell around it — which changes what "the terminal exited" means later. Saying
+ * that WHILE the user types beats discovering it when a pane closes unexpectedly
+ * three days on.
+ *
+ * ## Why the logo is uploaded separately from the fields
+ *
+ * An entry has to exist before it can own a file, and the id that file is named
+ * after is assigned on creation. So a new CLI is saved first and its logo lands
+ * immediately after — one save from the user's side, two requests underneath. A
+ * failed logo upload therefore reports itself without throwing away a perfectly
+ * good entry the user just typed.
+ */
+import { useEffect, useMemo, useRef, useState } from "react";
+import * as Dialog from "@radix-ui/react-dialog";
+import { ImagePlus, Terminal, Trash2, X } from "lucide-react";
+
+import { useT } from "@/i18n";
+import { cn } from "@/lib/utils";
+import {
+ createCustomCli,
+ removeCustomCliLogo,
+ updateCustomCli,
+ uploadCustomCliLogo,
+ type CustomCli,
+} from "@/lib/workspaceClisApi";
+import { AgentMark } from "./AgentMark";
+import { Button, Field, SectionLabel } from "./controls";
+
+/** Shell characters that mean the command is source rather than an argv. */
+const SHELL_META = /[|&;<>()$`\n]/;
+const ASSIGNMENT = /^[A-Za-z_][A-Za-z0-9_]*=/;
+
+/** Mirrors `custom_clis.needs_shell` — see this file's header for why. */
+export function runsThroughShell(command: string): boolean {
+ if (SHELL_META.test(command)) return true;
+ const first = command.trim().split(/\s+/)[0] ?? "";
+ return ASSIGNMENT.test(first);
+}
+
+function message(reason: unknown): string {
+ return reason instanceof Error ? reason.message : String(reason);
+}
+
+export function CustomCliDialog({
+ open,
+ onOpenChange,
+ /** The entry being edited, or null to add a new one. */
+ editing,
+ onSaved,
+}: {
+ open: boolean;
+ onOpenChange: (open: boolean) => void;
+ editing?: CustomCli | null;
+ onSaved: (entry: CustomCli) => void;
+}): JSX.Element {
+ const t = useT();
+ const [name, setName] = useState("");
+ const [command, setCommand] = useState("");
+ const [description, setDescription] = useState("");
+ const [atReference, setAtReference] = useState(false);
+ const [logoFile, setLogoFile] = useState<File | null>(null);
+ const [logoPreview, setLogoPreview] = useState("");
+ const [clearedLogo, setClearedLogo] = useState(false);
+ const [saving, setSaving] = useState(false);
+ const [error, setError] = useState("");
+ const pickerRef = useRef<HTMLInputElement | null>(null);
+
+ /*
+ * Refill from the entry every time the dialog opens.
+ *
+ * Keyed on `open` as well as on the entry, because the same instance is
+ * reused for "edit A", then "add new", then "edit A again": without the
+ * reopen in the dependency list the second visit to A would still show
+ * whatever was half-typed during the "add new" that came between.
+ */
+ useEffect(() => {
+ if (!open) return;
+ setName(editing?.display_name ?? "");
+ setCommand(editing?.command ?? "");
+ setDescription(editing?.description ?? "");
+ setAtReference(editing?.file_reference === "at");
+ setLogoFile(null);
+ setClearedLogo(false);
+ setError("");
+ }, [open, editing]);
+
+ /* A local preview of the picked file, revoked when it is replaced. */
+ useEffect(() => {
+ if (!logoFile) {
+ setLogoPreview("");
+ return;
+ }
+ const url = URL.createObjectURL(logoFile);
+ setLogoPreview(url);
+ return () => URL.revokeObjectURL(url);
+ }, [logoFile]);
+
+ const trimmedName = name.trim();
+ const trimmedCommand = command.trim();
+ const canSave = Boolean(trimmedName && trimmedCommand) && !saving;
+ const throughShell = useMemo(
+ () => Boolean(trimmedCommand) && runsThroughShell(trimmedCommand),
+ [trimmedCommand],
+ );
+ const shownLogo = clearedLogo
+ ? ""
+ : logoPreview || editing?.logo_url || "";
+
+ const save = async () => {
+ if (!canSave) return;
+ setSaving(true);
+ setError("");
+ try {
+ const draft = {
+ display_name: trimmedName,
+ command: trimmedCommand,
+ description: description.trim(),
+ file_reference: atReference ? ("at" as const) : ("quoted" as const),
+ };
+ let entry = editing
+ ? await updateCustomCli(editing.id, draft)
+ : await createCustomCli(draft);
+ // The entry is stored either way by this point. A logo that fails from
+ // here on is reported as exactly that, rather than as a failed save.
+ if (logoFile) entry = await uploadCustomCliLogo(entry.id, logoFile);
+ else if (clearedLogo && editing?.logo_url) {
+ entry = await removeCustomCliLogo(entry.id);
+ }
+ onSaved(entry);
+ onOpenChange(false);
+ } catch (reason: unknown) {
+ setError(message(reason));
+ } finally {
+ setSaving(false);
+ }
+ };
+
+ return (
+ <Dialog.Root open={open} onOpenChange={onOpenChange}>
+ <Dialog.Portal>
+ <Dialog.Overlay className="fixed inset-0 z-[80] bg-[#090909]/75 backdrop-blur-sm data-[state=open]:animate-in data-[state=open]:fade-in-0 motion-reduce:animate-none" />
+ <Dialog.Content
+ data-testid="custom-cli-dialog"
+ className={cn(
+ "fixed left-1/2 top-1/2 z-[90] flex max-h-[min(88dvh,44rem)] w-[min(560px,calc(100vw-2rem))]",
+ "-translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-border",
+ "bg-card shadow-[0_28px_90px_-24px_rgba(0,0,0,0.75)] outline-none",
+ "data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 motion-reduce:animate-none",
+ )}
+ >
+ <header className="flex items-start justify-between gap-4 border-b border-border px-5 py-4">
+ <div className="min-w-0">
+ <div className="mb-1 flex items-center gap-2">
+ <Terminal className="h-4 w-4 text-primary" aria-hidden="true" />
+ <Dialog.Title className="font-display text-base font-semibold tracking-tight text-foreground">
+ {editing
+ ? t("custom_cli.title_edit")
+ : t("custom_cli.title_add")}
+ </Dialog.Title>
+ </div>
+ <Dialog.Description className="text-xs leading-relaxed text-muted-foreground">
+ {t("custom_cli.description")}
+ </Dialog.Description>
+ </div>
+ <Dialog.Close asChild>
+ <button
+ type="button"
+ aria-label={t("custom_cli.close")}
+ className="flex h-8 w-8 shrink-0 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:bg-muted hover:text-foreground"
+ >
+ <X className="h-4 w-4" aria-hidden="true" />
+ </button>
+ </Dialog.Close>
+ </header>
+
+ <div className="flex min-h-0 flex-1 flex-col gap-5 overflow-y-auto px-5 py-5 scrollbar-jarvis">
+ {/* Identity: the mark and the name, side by side, because the mark
+ is what the name will be seen next to in every picker. */}
+ <div className="flex items-start gap-4">
+ <div className="flex shrink-0 flex-col items-center gap-1.5">
+ <AgentMark
+ agent={editing?.id ?? "new"}
+ label={trimmedName || "?"}
+ size="lg"
+ logoUrl={shownLogo || undefined}
+ />
+ <div className="flex items-center gap-0.5">
+ <button
+ type="button"
+ onClick={() => pickerRef.current?.click()}
+ aria-label={t("custom_cli.pick_logo")}
+ title={t("custom_cli.pick_logo")}
+ data-testid="custom-cli-pick-logo"
+ className="flex h-6 w-6 items-center justify-center rounded-control text-muted-foreground transition-colors hover:bg-secondary hover:text-foreground"
+ >
+ <ImagePlus className="h-3.5 w-3.5" aria-hidden="true" />
+ </button>
+ {shownLogo && (
+ <button
+ type="button"
+ onClick={() => {
+ setLogoFile(null);
+ setClearedLogo(true);
+ }}
+ aria-label={t("custom_cli.remove_logo")}
+ title={t("custom_cli.remove_logo")}
+ className="flex h-6 w-6 items-center justify-center rounded-control text-muted-foreground transition-colors hover:bg-secondary hover:text-foreground"
+ >
+ <Trash2 className="h-3.5 w-3.5" aria-hidden="true" />
+ </button>
+ )}
+ </div>
+ <input
+ ref={pickerRef}
+ type="file"
+ accept=".svg,.png,.jpg,.jpeg,.webp,.gif,image/*"
+ className="hidden"
+ data-testid="custom-cli-logo-input"
+ onChange={(event) => {
+ const picked = event.currentTarget.files?.[0] ?? null;
+ if (picked) {
+ setLogoFile(picked);
+ setClearedLogo(false);
+ }
+ // Cleared so picking the SAME file twice still fires.
+ event.currentTarget.value = "";
+ }}
+ />
+ </div>
+
+ <label className="flex min-w-0 flex-1 flex-col gap-1.5">
+ <SectionLabel>{t("custom_cli.name")}</SectionLabel>
+ <Field
+ value={name}
+ autoFocus
+ maxLength={60}
+ data-testid="custom-cli-name"
+ placeholder={t("custom_cli.name_placeholder")}
+ onChange={(event) => setName(event.currentTarget.value)}
+ />
+ <span className="text-[11px] leading-relaxed text-muted-foreground">
+ {t("custom_cli.name_hint")}
+ </span>
+ </label>
+ </div>
+
+ <label className="flex flex-col gap-1.5">
+ <SectionLabel>{t("custom_cli.command")}</SectionLabel>
+ <Field
+ value={command}
+ maxLength={500}
+ spellCheck={false}
+ autoCapitalize="off"
+ autoCorrect="off"
+ data-testid="custom-cli-command"
+ placeholder={t("custom_cli.command_placeholder")}
+ className="font-mono"
+ onChange={(event) => setCommand(event.currentTarget.value)}
+ onKeyDown={(event) => {
+ if (event.key === "Enter" && canSave) void save();
+ }}
+ />
+ <span className="text-[11px] leading-relaxed text-muted-foreground">
+ {throughShell
+ ? t("custom_cli.command_shell_hint")
+ : t("custom_cli.command_hint")}
+ </span>
+ </label>
+
+ <label className="flex flex-col gap-1.5">
+ <SectionLabel>{t("custom_cli.description_label")}</SectionLabel>
+ <Field
+ value={description}
+ maxLength={200}
+ data-testid="custom-cli-description"
+ placeholder={t("custom_cli.description_placeholder")}
+ onChange={(event) => setDescription(event.currentTarget.value)}
+ />
+ </label>
+
+ <label className="flex cursor-pointer items-start gap-2.5">
+ <input
+ type="checkbox"
+ checked={atReference}
+ data-testid="custom-cli-at-reference"
+ onChange={(event) => setAtReference(event.currentTarget.checked)}
+ className="mt-0.5 h-4 w-4 shrink-0 accent-primary"
+ />
+ <span className="min-w-0">
+ <span className="block text-sm text-foreground">
+ {t("custom_cli.at_reference")}
+ </span>
+ <span className="block text-[11px] leading-relaxed text-muted-foreground">
+ {t("custom_cli.at_reference_hint")}
+ </span>
+ </span>
+ </label>
+
+ {error && (
+ <p
+ role="alert"
+ data-testid="custom-cli-error"
+ className="border-l-2 border-destructive/70 py-1 pl-3 text-sm text-destructive"
+ >
+ {error}
+ </p>
+ )}
+ </div>
+
+ <footer className="flex shrink-0 items-center justify-end gap-2 border-t border-border px-5 py-4">
+ <Dialog.Close asChild>
+ <Button variant="quiet">{t("custom_cli.cancel")}</Button>
+ </Dialog.Close>
+ <Button
+ variant="primary"
+ disabled={!canSave}
+ data-testid="custom-cli-save"
+ onClick={() => void save()}
+ >
+ {saving ? t("custom_cli.saving") : t("custom_cli.save")}
+ </Button>
+ </footer>
+ </Dialog.Content>
+ </Dialog.Portal>
+ </Dialog.Root>
+ );
+}
diff --git a/jarvis/ui/web/frontend/src/components/agentic/WorkspaceLauncher.tsx b/jarvis/ui/web/frontend/src/components/agentic/WorkspaceLauncher.tsx
index f4596bb5a5..63f49f7c69 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/WorkspaceLauncher.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/WorkspaceLauncher.tsx
@@ -58,6 +58,8 @@ export interface WorkspaceLauncherProps {
agents: AgentStatus[];
/** The registered subscriptions of one CLI, for the per-pane picker. */
accountsFor: (platform: string) => AgentAccount[];
+ /** Re-read the entries above — the user just changed a CLI of their own. */
+ onAgentsChanged?: () => void;
/** False when this machine has no PTY backend, so no pane could run. */
terminalAvailable: boolean;
@@ -131,6 +133,7 @@ export function WorkspaceLauncher({
onPlanned,
agents,
accountsFor,
+ onAgentsChanged,
terminalAvailable,
nothingInstalled,
onOpenClis,
@@ -323,6 +326,7 @@ export function WorkspaceLauncher({
agents={agents}
accountsFor={accountsFor}
onPlanned={onPlanned}
+ onAgentsChanged={onAgentsChanged}
/>
)}
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/de.json b/jarvis/ui/web/frontend/src/i18n/locales/de.json
index cb0b3fab9b..30d0ece438 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/de.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/de.json
@@ -3738,6 +3738,34 @@
"workspace_summary_many": "{workspace}, Arbeitsbereich {index}, {count} Terminals",
"new_workspace": "Neuer Arbeitsbereich"
},
+ "custom_cli": {
+ "title_add": "Eigenes CLI hinzufügen",
+ "title_edit": "Dieses CLI bearbeiten",
+ "description": "Jedes interaktive Terminal-CLI kann hier in einem Pane laufen. Name und Startbefehl genügen — danach erscheint es überall dort, wo auch die mitgelieferten stehen.",
+ "close": "Schließen",
+ "cancel": "Abbrechen",
+ "save": "Speichern",
+ "saving": "Wird gespeichert…",
+ "name": "Name",
+ "name_placeholder": "Antigravity",
+ "name_hint": "So steht es in den Auswahllisten — und so sprichst du es an.",
+ "command": "Befehl",
+ "command_placeholder": "agy",
+ "command_hint": "Genau das, was du im Terminal eintippen würdest, um es zu starten.",
+ "command_shell_hint": "Das läuft über eine Shell, weil der Befehl aus mehr als einem Programm besteht. Der Pane schließt sich, wenn die ganze Zeile durch ist.",
+ "description_label": "Beschreibung",
+ "description_placeholder": "Eine Zeile, was dieses CLI ist.",
+ "at_reference": "Abgelegte Dateien als @Pfad schreiben",
+ "at_reference_hint": "Die meisten modernen Coding-CLIs lesen @Pfad als zu öffnende Datei. Ohne Haken werden Pfade in Anführungszeichen eingefügt.",
+ "pick_logo": "Logo auswählen",
+ "remove_logo": "Logo entfernen",
+ "edit_named": "{0} bearbeiten",
+ "remove_named": "{0} entfernen",
+ "gone": "Dieses CLI steht nicht mehr in der Liste.",
+ "add_title": "Dein eigenes CLI",
+ "add_hint": "Nicht dabei? Füge jedes Terminal-CLI mit seinem Startbefehl hinzu.",
+ "add_button": "CLI hinzufügen"
+ },
"workspace_launcher": {
"wizard": {
"new_workspace": "Neuer Arbeitsbereich",
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/en.json b/jarvis/ui/web/frontend/src/i18n/locales/en.json
index d59b6d73b3..27e1260841 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/en.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/en.json
@@ -3738,6 +3738,34 @@
"workspace_summary_many": "{workspace}, workspace {index}, {count} terminals",
"new_workspace": "New workspace"
},
+ "custom_cli": {
+ "title_add": "Add a CLI of your own",
+ "title_edit": "Edit this CLI",
+ "description": "Any interactive terminal CLI can run in a pane here. Give it a name and the command that starts it, and it appears everywhere the built-in ones do.",
+ "close": "Close",
+ "cancel": "Cancel",
+ "save": "Save",
+ "saving": "Saving…",
+ "name": "Name",
+ "name_placeholder": "Antigravity",
+ "name_hint": "What you will see in the pickers and say out loud.",
+ "command": "Command",
+ "command_placeholder": "agy",
+ "command_hint": "Exactly what you would type in a terminal to start it.",
+ "command_shell_hint": "This runs through a shell, because the command is more than one program. The pane closes when the whole line is done.",
+ "description_label": "Description",
+ "description_placeholder": "One line explaining what this CLI is.",
+ "at_reference": "Write dropped files as @path",
+ "at_reference_hint": "Most modern coding CLIs read @path as a file to open. Leave this off and paths are pasted in quotes instead.",
+ "pick_logo": "Choose a logo",
+ "remove_logo": "Remove the logo",
+ "edit_named": "Edit {0}",
+ "remove_named": "Remove {0}",
+ "gone": "That CLI is not in the list any more.",
+ "add_title": "Your own CLI",
+ "add_hint": "Not in the list? Add any terminal CLI with the command that starts it.",
+ "add_button": "Add a CLI"
+ },
"workspace_launcher": {
"wizard": {
"new_workspace": "New workspace",
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/es.json b/jarvis/ui/web/frontend/src/i18n/locales/es.json
index 70ad0b9b97..f76c3ac567 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/es.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/es.json
@@ -3738,6 +3738,34 @@
"workspace_summary_many": "{workspace}, espacio de trabajo {index}, {count} terminales",
"new_workspace": "Nuevo espacio de trabajo"
},
+ "custom_cli": {
+ "title_add": "Añadir una CLI propia",
+ "title_edit": "Editar esta CLI",
+ "description": "Cualquier CLI interactiva de terminal puede ejecutarse aquí en un panel. Dale un nombre y el comando que la inicia, y aparecerá en todos los sitios donde están las incluidas.",
+ "close": "Cerrar",
+ "cancel": "Cancelar",
+ "save": "Guardar",
+ "saving": "Guardando…",
+ "name": "Nombre",
+ "name_placeholder": "Antigravity",
+ "name_hint": "Lo que verás en los selectores y dirás en voz alta.",
+ "command": "Comando",
+ "command_placeholder": "agy",
+ "command_hint": "Exactamente lo que escribirías en una terminal para iniciarla.",
+ "command_shell_hint": "Esto se ejecuta a través de un shell, porque el comando es más de un programa. El panel se cierra cuando termina la línea entera.",
+ "description_label": "Descripción",
+ "description_placeholder": "Una línea que explique qué es esta CLI.",
+ "at_reference": "Escribir los archivos soltados como @ruta",
+ "at_reference_hint": "La mayoría de las CLI de programación modernas leen @ruta como un archivo que abrir. Sin marcar, las rutas se pegan entre comillas.",
+ "pick_logo": "Elegir un logotipo",
+ "remove_logo": "Quitar el logotipo",
+ "edit_named": "Editar {0}",
+ "remove_named": "Quitar {0}",
+ "gone": "Esa CLI ya no está en la lista.",
+ "add_title": "Tu propia CLI",
+ "add_hint": "¿No está en la lista? Añade cualquier CLI de terminal con el comando que la inicia.",
+ "add_button": "Añadir una CLI"
+ },
"workspace_launcher": {
"wizard": {
"new_workspace": "Nuevo espacio de trabajo",
diff --git a/jarvis/ui/web/frontend/src/i18n/workspace-launcher-i18n-parity.test.ts b/jarvis/ui/web/frontend/src/i18n/workspace-launcher-i18n-parity.test.ts
index 1ec2dfa545..ef5b6fd07d 100644
--- a/jarvis/ui/web/frontend/src/i18n/workspace-launcher-i18n-parity.test.ts
+++ b/jarvis/ui/web/frontend/src/i18n/workspace-launcher-i18n-parity.test.ts
@@ -14,13 +14,25 @@ function flatten(value: Locale, prefix = ""): string[] {
});
}
-const keys = (locale: Locale) =>
- flatten((locale.workspace_launcher ?? {}) as Locale).sort();
+const keys = (locale: Locale, section: string) =>
+ flatten((locale[section] ?? {}) as Locale).sort();
describe("workspace launcher i18n parity", () => {
for (const [language, locale] of Object.entries({ de, es })) {
it(`${language} has the same workspace launcher keys as en`, () => {
- expect(keys(locale as Locale)).toEqual(keys(en as Locale));
+ expect(keys(locale as Locale, "workspace_launcher")).toEqual(
+ keys(en as Locale, "workspace_launcher"),
+ );
+ });
+
+ // Its own section rather than part of the launcher's: the dialog is reached
+ // from the launcher's agent step but is about the CLI registry, not about
+ // this workspace. Covered here because it is the same screen's vocabulary
+ // and would otherwise be the one part of it with no parity check at all.
+ it(`${language} has the same custom-CLI keys as en`, () => {
+ expect(keys(locale as Locale, "custom_cli")).toEqual(
+ keys(en as Locale, "custom_cli"),
+ );
});
}
});
diff --git a/jarvis/ui/web/frontend/src/lib/agenticIdeApi.ts b/jarvis/ui/web/frontend/src/lib/agenticIdeApi.ts
index 96c64e1413..c919d9b7b6 100644
--- a/jarvis/ui/web/frontend/src/lib/agenticIdeApi.ts
+++ b/jarvis/ui/web/frontend/src/lib/agenticIdeApi.ts
@@ -16,6 +16,18 @@ export interface AgentStatus {
kind?: string;
/** One line a picker can show under the name. */
description?: string;
+ /**
+ * True for a CLI the user added themselves (`workspaceClisApi`). Surfaces use
+ * it to offer editing or removing the entry, which makes no sense for one
+ * this app ships.
+ */
+ custom?: boolean;
+ /**
+ * Where to fetch this entry's mark. Empty for a shipped entry — whose logo is
+ * an asset this bundle already carries — and for a custom one with no logo,
+ * which falls back to a monogram.
+ */
+ logo_url?: string;
}
export interface AgentsResponse {
diff --git a/jarvis/ui/web/frontend/src/lib/workspaceClisApi.ts b/jarvis/ui/web/frontend/src/lib/workspaceClisApi.ts
new file mode 100644
index 0000000000..3f43c42959
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/lib/workspaceClisApi.ts
@@ -0,0 +1,119 @@
+// REST client for the terminal CLIs the user added themselves.
+//
+// Its own module rather than a corner of `agenticIdeApi`, because these are
+// writes against a small, self-contained store while that file is the read path
+// for a live IDE session. What the two share is the RESULT: an entry created
+// here shows up in `fetchIdeAgents()` on the next read, because the backend puts
+// it in the same registry the shipped CLIs live in.
+
+export interface CustomCli {
+ /** Stable registry key. Never changes, not even on a rename. */
+ id: string;
+ display_name: string;
+ /** The command line that starts this CLI. */
+ command: string;
+ description: string;
+ /** `"at"` writes a dropped file as `@path`, `"quoted"` as `"path"`. */
+ file_reference: "at" | "quoted";
+ /** Where to fetch this entry's mark; empty when it has none. */
+ logo_url: string;
+ /**
+ * True when the command is shell source — a pipeline, an environment
+ * assignment, two commands chained — and therefore starts inside a shell
+ * rather than as the pane's own process. Shown to the user because it changes
+ * what "the pane exited" means.
+ */
+ runs_through_shell: boolean;
+ /** The word that has to be on PATH for this command to start. */
+ binary: string;
+}
+
+export interface CustomCliList {
+ clis: CustomCli[];
+ max_name_length: number;
+ max_command_length: number;
+ max_logo_bytes: number;
+ logo_extensions: string[];
+}
+
+export interface CustomCliDraft {
+ display_name: string;
+ command: string;
+ description?: string;
+ file_reference?: "at" | "quoted";
+}
+
+const BASE = "/api/workspace-clis";
+
+/**
+ * The server's own complaint, or a generic one.
+ *
+ * These endpoints answer a form the user is looking at, and every validation
+ * message they return is written to be read by that person ("Give the command
+ * that starts this CLI"). Throwing away that text for a status code would turn
+ * a fixable typo into a mystery.
+ */
+async function detail(res: Response): Promise<string> {
+ try {
+ const body = (await res.json()) as { detail?: string };
+ if (body?.detail) return body.detail;
+ } catch {
+ /* fall through */
+ }
+ return `request failed: ${res.status}`;
+}
+
+async function send<T>(url: string, init?: RequestInit): Promise<T> {
+ const res = await fetch(url, { cache: "no-store", ...init });
+ if (!res.ok) throw new Error(await detail(res));
+ return (await res.json()) as T;
+}
+
+export function fetchCustomClis(): Promise<CustomCliList> {
+ return send<CustomCliList>(BASE);
+}
+
+export function createCustomCli(draft: CustomCliDraft): Promise<CustomCli> {
+ return send<CustomCli>(BASE, {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify(draft),
+ });
+}
+
+export function updateCustomCli(
+ id: string,
+ changes: Partial<CustomCliDraft>,
+): Promise<CustomCli> {
+ return send<CustomCli>(`${BASE}/${encodeURIComponent(id)}`, {
+ method: "PATCH",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify(changes),
+ });
+}
+
+export function deleteCustomCli(id: string): Promise<{ ok: boolean }> {
+ return send<{ ok: boolean }>(`${BASE}/${encodeURIComponent(id)}`, {
+ method: "DELETE",
+ });
+}
+
+export function uploadCustomCliLogo(
+ id: string,
+ file: File,
+): Promise<CustomCli> {
+ const body = new FormData();
+ body.append("file", file);
+ // No Content-Type header on purpose: the browser has to set the multipart
+ // boundary itself, and naming the type by hand omits it.
+ return send<CustomCli>(`${BASE}/${encodeURIComponent(id)}/logo`, {
+ method: "PUT",
+ body,
+ });
+}
+
+export function removeCustomCliLogo(id: string): Promise<CustomCli> {
+ return send<CustomCli>(`${BASE}/${encodeURIComponent(id)}/logo`, {
+ method: "DELETE",
+ });
+}
diff --git a/jarvis/ui/web/frontend/src/views/AgenticIdeView.tsx b/jarvis/ui/web/frontend/src/views/AgenticIdeView.tsx
index 112c7925a1..008c094991 100644
--- a/jarvis/ui/web/frontend/src/views/AgenticIdeView.tsx
+++ b/jarvis/ui/web/frontend/src/views/AgenticIdeView.tsx
@@ -177,6 +177,25 @@ export function AgenticIdeView({ onScreen = true }: AgenticIdeViewProps) {
// answered the offer either way.
const [offer, setOffer] = useState<ResumeOffer | null>(null);
+ /**
+ * Re-read the agent sweep alone, without disturbing the workspace state.
+ *
+ * The user just added, edited or removed a CLI of their own, and that is the
+ * ONE thing this read answers differently than a second ago. Going through
+ * `refresh()` would also re-read the session and the workspace list — several
+ * hundred milliseconds of work whose answer has not changed, and one of them
+ * closes the wizard when it finds a workspace open.
+ */
+ const reloadAgents = useCallback(
+ () =>
+ fetchIdeAgents().then(setMeta, () => {
+ /* Same bargain as the sweep in `refresh`: the entry is already stored
+ and registered, so a failed re-read costs an out-of-date list, not
+ the change itself. */
+ }),
+ [],
+ );
+
const refresh = useCallback(async () => {
/*
* Both reads start together, but the workspace is applied WITHOUT waiting
@@ -399,6 +418,7 @@ export function AgenticIdeView({ onScreen = true }: AgenticIdeViewProps) {
displayName: a.display_name,
installed: a.installed,
kind: a.kind ?? "cli",
+ logoUrl: a.logo_url || 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:
@@ -903,6 +923,7 @@ export function AgenticIdeView({ onScreen = true }: AgenticIdeViewProps) {
onPlanned={setPlanned}
agents={agents}
accountsFor={accountsFor}
+ onAgentsChanged={() => void reloadAgents()}
/* Before the sweep lands `meta` is null, and this screen is not
reached in that state at all (see the `loading` branch above). The
optimistic default is still the right one: a machine is assumed