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): ask which CLI to open from the chat rail

Ruben Lütkeb8eae291057b
diff --git a/jarvis/ui/web/frontend/src/components/agentic/AgentPicker.tsx b/jarvis/ui/web/frontend/src/components/agentic/AgentPicker.tsx
new file mode 100644
index 0000000000..7e68e964af
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/components/agentic/AgentPicker.tsx
@@ -0,0 +1,133 @@
+/**
+ * "What should run in the new terminal?" — the one menu behind every action
+ * that opens a pane.
+ *
+ * It lives on its own rather than inside the pane header because opening a
+ * terminal is not something only a pane does: the grid's split buttons ask it,
+ * the chat view's rail asks it, and an empty workspace asks it. Those surfaces
+ * used to disagree — a split offered the choice while the rail silently started
+ * whatever CLI happened to be first, so the chat view could only ever add more
+ * of the same agent (maintainer report 2026-07-31). One component keeps them
+ * telling the same story.
+ *
+ * Before any of them asked, a new pane inherited the anchor's agent silently,
+ * which made running a Codex pane next to a Claude Code one impossible from the
+ * workspace — you had to close it and start again from the wizard. The backend
+ * always accepted an agent per terminal; this is the surface that asks.
+ *
+ * The list is whatever the backend registered, so it is not a fixed pair of
+ * 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.
+ */
+import { cn } from "@/lib/utils";
+
+/** A coding CLI an "open a terminal" action may start. */
+export interface SplitAgentChoice {
+ /** Backend id — "claude", "codex", "shell". */
+ name: string;
+ /** What the user reads — "Claude Code", "Plain Terminal". */
+ displayName: string;
+ installed: boolean;
+ /**
+ * `"cli"` for a coding agent, `"shell"` for a plain terminal on this
+ * machine's own shell. Carried so the menu can say what a choice actually
+ * opens without knowing any entry by name.
+ */
+ kind?: string;
+ /** One line under the name — the shell that would open, for instance. */
+ description?: string;
+}
+
+/**
+ * Is there anything to pick?
+ *
+ * With one installed CLI the menu would hold a single entry, which is a click
+ * tax rather than a choice — the caller opens that one straight away. Shared so
+ * every surface draws the same line instead of each counting for itself.
+ */
+export function offersAgentChoice(agents?: SplitAgentChoice[]): boolean {
+ return (agents ?? []).filter((a) => a.installed).length > 1;
+}
+
+export function AgentPickerMenu({
+ title,
+ ariaLabel,
+ agents,
+ onPick,
+ onDismiss,
+ testId,
+ itemTestId,
+ className,
+}: {
+ /** The line above the entries — "Open beside — what?". */
+ title: string;
+ ariaLabel: string;
+ agents: SplitAgentChoice[];
+ onPick: (agent: string) => void;
+ onDismiss: () => void;
+ testId: string;
+ /** Per-entry test id, so each surface keeps its own established names. */
+ itemTestId: (agent: string) => string;
+ /** Where the menu hangs — the caller owns the anchoring. */
+ className?: string;
+}) {
+ const first = agents.find((a) => a.installed);
+ return (
+ <>
+ {/* Click-anywhere-else to dismiss, without a global listener that would
+ outlive the surface that opened this. */}
+ <div className="fixed inset-0 z-40" onMouseDown={onDismiss} />
+ <div
+ role="menu"
+ aria-label={ariaLabel}
+ data-testid={testId}
+ className={cn(
+ "absolute z-50 w-60 rounded-lg border border-border bg-card p-1 shadow-xl",
+ className,
+ )}
+ onMouseDown={(e) => e.stopPropagation()}
+ onKeyDown={(e) => {
+ if (e.key === "Escape") onDismiss();
+ }}
+ >
+ <p className="px-2 py-1.5 text-[11px] uppercase tracking-wider text-muted-foreground">
+ {title}
+ </p>
+ {agents.map((agent) => (
+ <button
+ key={agent.name}
+ type="button"
+ role="menuitem"
+ autoFocus={agent === first}
+ disabled={!agent.installed}
+ data-testid={itemTestId(agent.name)}
+ onClick={(e) => {
+ e.stopPropagation();
+ onPick(agent.name);
+ }}
+ 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">
+ <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
+ entry's own words rather than a name this menu recognises. */}
+ {agent.description && (
+ <span className="block truncate text-[11px] text-muted-foreground">
+ {agent.description}
+ </span>
+ )}
+ </span>
+ {!agent.installed && (
+ <span className="shrink-0 text-[10px] uppercase tracking-wide text-muted-foreground">
+ {agent.kind === "shell" ? "no shell here" : "not installed"}
+ </span>
+ )}
+ </button>
+ ))}
+ </div>
+ </>
+ );
+}
diff --git a/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.test.tsx b/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.test.tsx
index c07c04908b..e17fac1364 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.test.tsx
@@ -2279,4 +2279,87 @@ describe("chat view", () => {
}),
);
});
+
+ /*
+ * The rail's plus offers the same choice the grid's split buttons do.
+ *
+ * It used to open whatever CLI the backend listed first, so a workspace read
+ * in chat view could only ever grow more panes of that one agent — the one
+ * thing the grid had been asking about since the split menus landed.
+ */
+ const CLI_CHOICES = [
+ { name: "claude", displayName: "Claude Code", installed: true },
+ { name: "codex", displayName: "Codex", installed: true },
+ {
+ name: "shell",
+ displayName: "Plain Terminal",
+ installed: false,
+ kind: "shell",
+ },
+ ];
+
+ it("the rail's plus asks which CLI when more than one is installed", async () => {
+ renderGrid(FOUR, { agents: CLI_CHOICES });
+ toChat();
+ fireEvent.click(screen.getByTestId("chat-rail-new-terminal"));
+
+ // Uninstalled entries stay listed but disabled, so the absence is visible.
+ expect(
+ (screen.getByTestId("chat-rail-new-shell") as HTMLButtonElement).disabled,
+ ).toBe(true);
+
+ fireEvent.click(screen.getByTestId("chat-rail-new-codex"));
+ await waitFor(() =>
+ expect(api.addTerminal).toHaveBeenCalledWith({
+ anchor: undefined,
+ direction: "right",
+ agent: "codex",
+ }),
+ );
+ // The menu closes with the pick — it was a question, and it was answered.
+ expect(screen.queryByTestId("chat-rail-agent-menu")).toBeNull();
+ });
+
+ it("the rail's plus just opens one when a single CLI is installed", async () => {
+ // A menu with one entry is a click tax, not a choice.
+ renderGrid(FOUR, {
+ agents: [CLI_CHOICES[0], { ...CLI_CHOICES[1], installed: false }],
+ });
+ toChat();
+ fireEvent.click(screen.getByTestId("chat-rail-new-terminal"));
+ expect(screen.queryByTestId("chat-rail-agent-menu")).toBeNull();
+ await waitFor(() =>
+ expect(api.addTerminal).toHaveBeenCalledWith({
+ anchor: undefined,
+ direction: "right",
+ agent: undefined,
+ }),
+ );
+ });
+
+ it("leaving chat view closes an open picker", () => {
+ renderGrid(FOUR, { agents: CLI_CHOICES });
+ toChat();
+ fireEvent.click(screen.getByTestId("chat-rail-new-terminal"));
+ expect(screen.getByTestId("chat-rail-agent-menu")).toBeTruthy();
+ toChat();
+ // The button that opened it just left the screen; it must not be waiting
+ // there on the way back.
+ expect(screen.queryByTestId("chat-rail-agent-menu")).toBeNull();
+ });
+
+ it("an emptied workspace asks the same question", async () => {
+ // The message shown when every pane is closed opens a terminal too, and it
+ // is the only way back — so it offers the same list rather than guessing.
+ renderGrid(sessionWith([]), { agents: CLI_CHOICES });
+ fireEvent.click(screen.getByTestId("empty-workspace-new-terminal"));
+ fireEvent.click(screen.getByTestId("empty-workspace-new-codex"));
+ await waitFor(() =>
+ expect(api.addTerminal).toHaveBeenCalledWith({
+ anchor: undefined,
+ direction: "right",
+ agent: "codex",
+ }),
+ );
+ });
});
diff --git a/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.tsx b/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.tsx
index 12ed42b2e9..f53384909f 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.tsx
@@ -52,9 +52,13 @@ import {
AgenticTerminal,
PaneStatusPill,
type PaneStatus,
- type SplitAgentChoice,
type SplitDirection,
} from "./AgenticTerminal";
+import {
+ AgentPickerMenu,
+ offersAgentChoice,
+ type SplitAgentChoice,
+} from "./AgentPicker";
import type { TerminalAppearance } from "./terminalThemes";
import {
bandCapacityFor,
@@ -549,6 +553,18 @@ export function AgenticGrid({
const [maximized, setMaximized] = useState<string | null>(null);
+ /**
+ * Which "open a terminal" button has its CLI picker open, if any.
+ *
+ * The panes carry their own (see `AgenticTerminal`); these are the two places
+ * that open a terminal without a pane to hang it off — the chat view's rail,
+ * and the message an emptied workspace shows. Both used to start whatever CLI
+ * the backend listed first, so a chat-view workspace could only ever grow more
+ * panes of that one agent while the grid's split buttons were asking properly
+ * (maintainer report 2026-07-31).
+ */
+ const [picking, setPicking] = useState<"rail" | "empty" | null>(null);
+
/*
* Grid or chat — remembered per browser profile, like the appearance above:
* which way someone reads their agents is a display preference of this
@@ -563,6 +579,9 @@ export function AgenticGrid({
// Chat shows exactly one pane already; a leftover maximize from the grid
// would silently pin the stage to a pane the rail no longer highlights.
if (next === "chat") setMaximized(null);
+ // An open CLI picker belongs to the button that opened it, and that button
+ // just left the screen — it must not be waiting there on the way back.
+ setPicking(null);
}, []);
const chatView = viewMode === "chat";
@@ -1075,6 +1094,19 @@ export function AgenticGrid({
}
};
+ const offersChoice = offersAgentChoice(agents);
+
+ /**
+ * Open a terminal at the end of the row — asking WHAT first when the machine
+ * has more than one CLI installed. With a single one there is nothing to pick,
+ * so the click opens it straight away rather than showing a one-entry menu.
+ */
+ const openTerminal = (surface: "rail" | "empty") => {
+ if (offersChoice)
+ setPicking((current) => (current === surface ? null : surface));
+ else void split(null, "right");
+ };
+
/*
* A pane was dragged onto another one.
*
@@ -1779,7 +1811,8 @@ export function AgenticGrid({
chatView ? "flex" : "hidden",
)}
>
- <div className="flex items-center justify-between px-3 py-2">
+ {/* `relative` so the CLI picker hangs under the plus button. */}
+ <div className="relative flex items-center justify-between px-3 py-2">
<span className="text-[10px] font-semibold uppercase tracking-wider text-muted-foreground">
Agents
</span>
@@ -1788,12 +1821,28 @@ export function AgenticGrid({
data-testid="chat-rail-new-terminal"
className={TOOLBAR_BTN}
disabled={atLimit || busy || working}
- onClick={() => void split(null, "right")}
+ aria-expanded={offersChoice ? picking === "rail" : undefined}
+ onClick={() => openTerminal("rail")}
title="Open another terminal"
aria-label="Open another terminal"
>
<Plus className="h-4 w-4" />
</button>
+ {picking === "rail" && (
+ <AgentPickerMenu
+ title="Open a terminal — what?"
+ ariaLabel="What should run in the new terminal?"
+ agents={agents ?? []}
+ testId="chat-rail-agent-menu"
+ itemTestId={(agent) => `chat-rail-new-${agent}`}
+ className="right-2 top-full"
+ onDismiss={() => setPicking(null)}
+ onPick={(agent) => {
+ setPicking(null);
+ void split(null, "right", agent);
+ }}
+ />
+ )}
</div>
<div className="min-h-0 flex-1 overflow-y-auto scrollbar-jarvis px-2 pb-2">
{session.terminals.map((term) => {
@@ -2113,15 +2162,36 @@ export function AgenticGrid({
{session.terminals.length === 0 && (
<div className="absolute inset-0 flex flex-col items-center justify-center gap-3 text-sm text-muted-foreground">
<span>Every terminal in this workspace is closed.</span>
- <button
- type="button"
- className="btn-primary"
- disabled={busy || working}
- onClick={() => void split(null, "right")}
- >
- <Plus className="h-4 w-4" />
- Open a terminal
- </button>
+ {/* `relative` so the picker hangs under the button rather than off
+ the grid canvas. */}
+ <div className="relative">
+ <button
+ type="button"
+ data-testid="empty-workspace-new-terminal"
+ className="btn-primary"
+ disabled={busy || working}
+ aria-expanded={offersChoice ? picking === "empty" : undefined}
+ onClick={() => openTerminal("empty")}
+ >
+ <Plus className="h-4 w-4" />
+ Open a terminal
+ </button>
+ {picking === "empty" && (
+ <AgentPickerMenu
+ title="Open a terminal — what?"
+ ariaLabel="What should run in the new terminal?"
+ agents={agents ?? []}
+ testId="empty-workspace-agent-menu"
+ itemTestId={(agent) => `empty-workspace-new-${agent}`}
+ className="left-1/2 top-full mt-1 -translate-x-1/2"
+ onDismiss={() => setPicking(null)}
+ onPick={(agent) => {
+ setPicking(null);
+ void split(null, "right", agent);
+ }}
+ />
+ )}
+ </div>
</div>
)}
</div>
diff --git a/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx b/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx
index d5857d8645..225aeedcf5 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx
@@ -76,6 +76,11 @@ import {
type PaneDropPayload,
} from "./paneDrop";
import { usePaneFileDrag } from "./paneFileDrag";
+import {
+ AgentPickerMenu,
+ offersAgentChoice,
+ type SplitAgentChoice,
+} from "./AgentPicker";
import { describeExit, explainExit } from "./paneExit";
import { PaneRecap } from "./PaneRecap";
import { attachToTerminal } from "@/lib/agenticIdeApi";
@@ -138,22 +143,15 @@ function documentHidden(): boolean {
return typeof document !== "undefined" && document.hidden === true;
}
-/** A coding CLI a split may start, as offered by the pane's split menu. */
-export interface SplitAgentChoice {
- /** Backend id — "claude", "codex", "shell". */
- name: string;
- /** What the user reads — "Claude Code", "Plain Terminal". */
- displayName: string;
- installed: boolean;
- /**
- * `"cli"` for a coding agent, `"shell"` for a plain terminal on this
- * machine's own shell. Carried so the menu can say what a choice actually
- * opens without knowing any entry by name.
- */
- kind?: string;
- /** One line under the name — the shell that would open, for instance. */
- description?: string;
-}
+/**
+ * A coding CLI a split may start.
+ *
+ * Re-exported rather than declared here: the same list is offered by the chat
+ * view's rail and by an empty workspace, so it belongs to the picker they all
+ * share (see `AgentPicker`). Kept exported from this module because that is
+ * where every caller already imports it from.
+ */
+export type { SplitAgentChoice };
export type SplitDirection = "right" | "down";
@@ -1379,7 +1377,7 @@ function PaneHeader({
// With one installed CLI there is nothing to pick, so the button splits
// straight away — a menu with a single entry is a click tax, not a choice.
const choices = agents ?? [];
- const offersChoice = choices.filter((a) => a.installed).length > 1;
+ const offersChoice = offersAgentChoice(choices);
const startSplit = (direction: SplitDirection) => {
if (offersChoice)
@@ -1654,10 +1652,15 @@ function PaneHeader({
</div>
{picking && (
- <SplitAgentMenu
- paneName={name}
- direction={picking}
+ <AgentPickerMenu
+ title={
+ picking === "right" ? "Open beside — what?" : "Split below — what?"
+ }
+ ariaLabel={`What should run ${picking === "right" ? "beside" : "below"} ${name}?`}
agents={choices}
+ testId={`pane-split-menu-${picking}-${name}`}
+ itemTestId={(agent) => `pane-split-${picking}-${name}-${agent}`}
+ className="right-2 top-full mt-1"
onDismiss={() => setPicking(null)}
onPick={(agent) => {
setPicking(null);
@@ -1669,92 +1672,6 @@ function PaneHeader({
);
}
-/**
- * The picker a split button opens: what should run in the new pane?
- *
- * Splitting used to inherit the anchor's agent silently, which made running a
- * Codex pane next to a Claude Code one impossible from the grid — you had to
- * close the workspace and start it again from the wizard. The backend always
- * accepted an agent per terminal; this is the surface that finally asks.
- *
- * The list is whatever the backend registered, so it is not a fixed pair of
- * 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.
- */
-function SplitAgentMenu({
- paneName,
- direction,
- agents,
- onPick,
- onDismiss,
-}: {
- paneName: string;
- direction: SplitDirection;
- agents: SplitAgentChoice[];
- onPick: (agent: string) => void;
- onDismiss: () => void;
-}) {
- return (
- <>
- {/* Click-anywhere-else to dismiss, without a global listener that would
- outlive the pane. */}
- <div className="fixed inset-0 z-40" onMouseDown={onDismiss} />
- <div
- role="menu"
- aria-label={`What should run ${direction === "right" ? "beside" : "below"} ${paneName}?`}
- data-testid={`pane-split-menu-${direction}-${paneName}`}
- className="absolute right-2 top-full z-50 mt-1 w-60 rounded-lg border border-border bg-card p-1 shadow-xl"
- onMouseDown={(e) => e.stopPropagation()}
- onKeyDown={(e) => {
- if (e.key === "Escape") onDismiss();
- }}
- >
- <p className="px-2 py-1.5 text-[11px] uppercase tracking-wider text-muted-foreground">
- {direction === "right"
- ? "Open beside — what?"
- : "Split below — what?"}
- </p>
- {agents.map((agent) => (
- <button
- key={agent.name}
- type="button"
- role="menuitem"
- autoFocus={
- agent.installed && agent === agents.find((a) => a.installed)
- }
- disabled={!agent.installed}
- data-testid={`pane-split-${direction}-${paneName}-${agent.name}`}
- onClick={(e) => {
- e.stopPropagation();
- onPick(agent.name);
- }}
- 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">
- <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
- entry's own words rather than a name this menu recognises. */}
- {agent.description && (
- <span className="block truncate text-[11px] text-muted-foreground">
- {agent.description}
- </span>
- )}
- </span>
- {!agent.installed && (
- <span className="shrink-0 text-[10px] uppercase tracking-wide text-muted-foreground">
- {agent.kind === "shell" ? "no shell here" : "not installed"}
- </span>
- )}
- </button>
- ))}
- </div>
- </>
- );
-}
-
function PaneAction({
label,
testId,