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.

refactor(agentic-ide): the workspace has no prompt bar — a pane is typed into, not written to from underneath

rubenluetke10-beepc165dedf013f
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 93a9e41b63..55be5d74c1 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.test.tsx
@@ -140,6 +140,7 @@ vi.mock("./AgenticTerminal", () => ({
onRename,
onClose,
onArrangeStart,
+ onFocus,
arranging,
layoutBusy,
fontSize,
@@ -158,6 +159,7 @@ vi.mock("./AgenticTerminal", () => ({
onRename?: (name: string) => Promise<boolean>;
onClose?: () => void;
onArrangeStart?: (event: PointerEventLike) => void;
+ onFocus?: () => void;
arranging?: boolean;
layoutBusy?: boolean;
fontSize?: number;
@@ -231,6 +233,11 @@ vi.mock("./AgenticTerminal", () => ({
<button data-testid={`pane-restart-${name}`} onClick={onRestart}>
restart
</button>
+ {/* Clicking into the real terminal focuses it, and a focused agent pane
+ is the one voice speaks to. Here that is a button. */}
+ <button data-testid={`pane-focus-${name}`} onClick={onFocus}>
+ focus
+ </button>
</div>
);
},
@@ -325,16 +332,6 @@ const BASE = sessionWith([
["Nova", 1],
]);
-/*
- * Open the prompt bar for the suites that are ABOUT the prompt bar.
- *
- * A fresh workspace now opens with it collapsed (the panes are what the user
- * came for — see the seam suite at the bottom), so every test that types an
- * instruction, picks a target or drops a file has to open it first. Doing that
- * through the remembered height rather than a click keeps those tests about
- * what they are testing; the seam suite clears the key again and drives the
- * collapse/reopen behaviour itself.
- */
beforeEach(() => {
// Pane sizes are remembered per workspace, and every test here uses the same
// workspace id — so without this a test that splits or drags a seam would
@@ -342,7 +339,6 @@ beforeEach(() => {
// the order the tests happen to run in.
window.localStorage.clear();
paneActiveHistory.clear();
- window.localStorage.setItem("jarvis.agenticIde.composerHeight.v2", "176");
// Seam drags post their result fire-and-forget; an auto-mock returning
// undefined would crash the `.catch` chain rather than fail an assertion.
vi.mocked(api.saveLayoutWeights).mockResolvedValue(sessionWith([]));
@@ -415,12 +411,12 @@ function renderGrid(session = BASE, extra: Record<string, unknown> = {}) {
}
describe("prompt target bridge", () => {
- it("keeps the voice orb aimed at the written prompt target", async () => {
+ it("keeps the voice orb aimed at the pane the user is working in", async () => {
const onPromptTargetChange = vi.fn();
renderGrid(BASE, { onPromptTargetChange });
await waitFor(() => expect(onPromptTargetChange).toHaveBeenCalledWith("Mika"));
- fireEvent.click(screen.getByTestId("prompt-target-Nova"));
+ fireEvent.click(screen.getByTestId("pane-focus-Nova"));
await waitFor(() => expect(onPromptTargetChange).toHaveBeenLastCalledWith("Nova"));
});
});
@@ -477,18 +473,19 @@ describe("pane actions", () => {
});
it("a new pane becomes the prompt target", async () => {
- renderGrid();
+ const onPromptTargetChange = vi.fn();
+ renderGrid(BASE, { onPromptTargetChange });
fireEvent.click(screen.getByTestId("pane-split-right-Mika"));
- // The freshly added pane is the one the user just asked for, so the prompt
- // bar should already point at it.
+ // The freshly added pane is the one the user just asked for, so what they
+ // say next should go there.
await waitFor(() =>
- expect(screen.getByLabelText(/instruction for Aria/i)).toBeTruthy(),
+ expect(onPromptTargetChange).toHaveBeenLastCalledWith("Aria"),
);
});
- it("keeps a plain terminal out of the prompt bar's targets", () => {
+ it("never aims a spoken prompt at a plain terminal", async () => {
// A plain terminal is a shell prompt: Jarvis does not type into one, so
- // offering it as a target would promise a delivery that is always refused.
+ // aiming at it would promise a delivery that is always refused.
const session = sessionWith([
["Mika", 0],
["Nova", 1],
@@ -499,12 +496,13 @@ describe("pane actions", () => {
display_name: "Plain Terminal",
accepts_prompts: false,
};
- renderGrid(session);
+ const onPromptTargetChange = vi.fn();
+ renderGrid(session, { onPromptTargetChange });
- expect(screen.getByRole("button", { name: /^Mika/ })).toBeTruthy();
- expect(screen.queryByRole("button", { name: /^Nova live$/ })).toBeNull();
- // The agent pane, not the shell, is what the prompt goes to.
- expect(screen.getByLabelText(/instruction for Mika/i)).toBeTruthy();
+ await waitFor(() => expect(onPromptTargetChange).toHaveBeenCalledWith("Mika"));
+ // Focusing the shell leaves the target where it was.
+ fireEvent.click(screen.getByTestId("pane-focus-Nova"));
+ expect(onPromptTargetChange).not.toHaveBeenCalledWith("Nova");
});
it("does not make a new plain terminal the prompt target", async () => {
@@ -520,14 +518,15 @@ describe("pane actions", () => {
accepts_prompts: false,
};
vi.mocked(api.addTerminal).mockResolvedValue(next);
- renderGrid();
+ const onPromptTargetChange = vi.fn();
+ renderGrid(BASE, { onPromptTargetChange });
fireEvent.click(screen.getByTestId("pane-split-right-Mika"));
await waitFor(() => expect(api.addTerminal).toHaveBeenCalled());
- // The prompt bar stays pointed at the agent it was on — a shell pane that
- // stole the target would silently swallow the next instruction.
- expect(screen.getByLabelText(/instruction for Mika/i)).toBeTruthy();
+ // The target stays on the agent it was on — a shell pane that stole it
+ // would silently swallow the next spoken instruction.
+ expect(onPromptTargetChange).not.toHaveBeenCalledWith("Aria");
});
it("reports a refused split instead of pretending it worked", async () => {
@@ -919,15 +918,16 @@ describe("selecting several terminals", () => {
failed: [{ name: "Nova", detail: "Still stopping." }],
session: sessionWith([["Nova", 0]]),
});
- renderGrid();
- fireEvent.click(screen.getByTestId("prompt-target-Nova"));
+ const onPromptTargetChange = vi.fn();
+ renderGrid(BASE, { onPromptTargetChange });
+ fireEvent.click(screen.getByTestId("pane-focus-Nova"));
fireEvent.click(screen.getByTestId("terminal-selection-toggle"));
fireEvent.click(screen.getByRole("button", { name: "Select all" }));
fireEvent.click(screen.getByTestId("close-selected-terminals"));
fireEvent.click(screen.getByTestId("confirm-close-selection-confirm"));
await waitFor(() =>
- expect(screen.getByLabelText(/instruction for Nova/i)).toBeTruthy(),
+ expect(onPromptTargetChange).toHaveBeenLastCalledWith("Nova"),
);
expect(
screen.getByTestId("select-terminal-Nova").getAttribute("aria-pressed"),
@@ -995,9 +995,10 @@ describe("closing the workspace", () => {
it("hides workspace controls from assistive technology while confirmation is open", () => {
renderGrid();
fireEvent.click(screen.getByTitle("Close the workspace and stop every agent in it"));
- const prompt = screen.getByLabelText(/instruction for Mika/i);
- expect(prompt.closest('[aria-hidden="true"]')).toBeTruthy();
+ expect(
+ screen.getByTestId("pane-Mika").closest('[aria-hidden="true"]'),
+ ).toBeTruthy();
});
it("escape safely cancels and restores focus to the close trigger", async () => {
@@ -1054,392 +1055,6 @@ describe("restarting a dead pane", () => {
});
});
-describe("the prompt bar composes as it sends", () => {
- const type = (text: string) => {
- const box = screen.getByLabelText(/instruction for Mika/i);
- fireEvent.change(box, { target: { value: text } });
- fireEvent.keyDown(box, { key: "Enter" });
- };
-
- it("asks the backend to compose in the same request that sends", async () => {
- // One step, exactly like the spoken "prompt Mika …": the backend writes
- // the brief and types it in. The retired approval preview held the brief
- // for a click here, and its fallback paths sent the raw text.
- renderGrid();
- type("run the tests");
-
- await waitFor(() =>
- expect(api.promptTerminal).toHaveBeenCalledWith("Mika", "run the tests", {
- compose: true,
- attachments: [],
- }),
- );
- });
-
- it("clears the editor once the instruction was delivered", async () => {
- renderGrid();
- type("run the tests");
-
- await waitFor(() =>
- expect(
- (screen.getByLabelText(/instruction for Mika/i) as HTMLTextAreaElement).value,
- ).toBe(""),
- );
- });
-
- it("keeps the draft when the request fails, instead of sending it raw", async () => {
- // A failed request typed nothing anywhere. Retrying it verbatim would
- // reintroduce the exact behaviour this path exists to rule out, so the
- // words stay in the editor and the failure is said out loud.
- vi.mocked(api.promptTerminal).mockRejectedValue(new Error("no session"));
- renderGrid();
- type("run the tests");
-
- await waitFor(() => expect(pushToast).toHaveBeenCalledWith("error", "no session"));
- expect(api.promptTerminal).toHaveBeenCalledTimes(1);
- expect(
- (screen.getByLabelText(/instruction for Mika/i) as HTMLTextAreaElement).value,
- ).toBe("run the tests");
- });
-
- it("warns when the pane held the prompt without starting on it", async () => {
- vi.mocked(api.promptTerminal).mockResolvedValue({
- terminal: "Mika",
- sent: "## Task\nRun the tests.",
- composed_by: "llm",
- files: [],
- submitted: false,
- detail: "Mika did not accept the prompt.",
- });
- renderGrid();
- type("run the tests");
-
- await waitFor(() =>
- expect(pushToast).toHaveBeenCalledWith("warning", "Mika did not accept the prompt."),
- );
- });
-});
-
-describe("the compose narration line", () => {
- // Composition is 10-30 s of model work; the backend narrates each beat over
- // the app socket, and the bar shows the latest line so a working composer
- // and a wedged one stop looking identical.
- const beat = (detail: Record<string, unknown>) =>
- fireEvent(
- window,
- new CustomEvent("jarvis:agentic-ide-compose", { detail }),
- );
-
- it("shows the latest beat while the brief is being written", () => {
- renderGrid();
-
- beat({
- session_id: "ide_test",
- terminal: "Mika",
- stage: "thinking",
- message: "Reading the code before Mika is briefed - 3 file outlines.",
- });
-
- expect(screen.getByTestId("agentic-compose-progress").textContent).toContain(
- "Reading the code before Mika is briefed",
- );
- });
-
- it("clears the line once the delivery is announced", () => {
- renderGrid();
- beat({ session_id: "ide_test", terminal: "Mika", stage: "drafting", message: "Writing." });
-
- fireEvent(
- window,
- new CustomEvent("jarvis:agentic-ide-prompt", {
- detail: { terminal: "Mika", submitted: true },
- }),
- );
-
- expect(screen.queryByTestId("agentic-compose-progress")).toBeNull();
- });
-
- it("ignores beats that belong to another workspace", () => {
- renderGrid();
-
- beat({ session_id: "ide_other", terminal: "Mika", stage: "start", message: "Writing." });
-
- expect(screen.queryByTestId("agentic-compose-progress")).toBeNull();
- });
-});
-
-/*
- * Dropping a screenshot on the prompt bar.
- *
- * This is the gesture the whole feature exists for, and its failure mode is
- * quiet: a user drops a picture of a broken layout, types "fix this", and the
- * agent — which frequently cannot open an image at all — receives a path and a
- * pronoun. So what is pinned here is that the CONTENTS of the file reach the
- * composition, not merely that a drop was accepted.
- */
-describe("dropping files on the prompt bar", () => {
- /** A DataTransfer stand-in; jsdom cannot construct a real one. */
- function transfer(types: string[]) {
- return {
- types,
- files: [],
- items: [],
- dropEffect: "none",
- getData: (kind: string) =>
- kind === "text/uri-list" ? "file:///C:/work/shot.png" : "",
- } as unknown as DataTransfer;
- }
-
- const drop = (types: string[] = ["Files"]) =>
- fireEvent.drop(screen.getByTestId("agentic-composer"), {
- dataTransfer: transfer(types),
- });
-
- it("reads the dropped file instead of typing its path into the pane", async () => {
- renderGrid();
-
- drop();
-
- await waitFor(() => expect(api.attachToTerminal).toHaveBeenCalled());
- const [name, payload] = vi.mocked(api.attachToTerminal).mock.calls[0];
- expect(name).toBe("Mika");
- expect(payload.analyze).toBe(true);
- // Held rather than typed: the user is still writing the sentence that
- // explains the file, and it goes in with that sentence.
- expect(payload.deliver).toBe(false);
- expect(payload.paths).toEqual(["C:/work/shot.png"]);
- });
-
- it("shows what was read out of the file, not just its name", async () => {
- renderGrid();
-
- drop();
-
- await waitFor(() => expect(screen.getByTestId("agentic-attachments")).toBeTruthy());
- const strip = screen.getByTestId("agentic-attachments");
- expect(strip.textContent).toContain("shot.png");
- expect(strip.textContent).toContain("described");
- });
-
- it("carries the analysis into the composition", async () => {
- renderGrid();
- drop();
- await waitFor(() => expect(screen.getByTestId("agentic-attachments")).toBeTruthy());
-
- const box = screen.getByLabelText(/instruction for Mika/i);
- fireEvent.change(box, { target: { value: "fix this" } });
- fireEvent.keyDown(box, { key: "Enter" });
-
- await waitFor(() => expect(api.promptTerminal).toHaveBeenCalled());
- const options = vi.mocked(api.promptTerminal).mock.calls[0][2];
- expect(options?.compose).toBe(true);
- expect(options?.attachments).toHaveLength(1);
- expect(options?.attachments?.[0].detail).toContain("submit button overflows");
- });
-
- it("lets an attachment be taken back off", async () => {
- renderGrid();
- drop();
- await waitFor(() => expect(screen.getByTestId("agentic-attachments")).toBeTruthy());
-
- fireEvent.click(screen.getByTestId("agentic-attachment-remove-shot.png"));
-
- expect(screen.queryByTestId("agentic-attachment-shot.png")).toBeNull();
- });
-
- it("clears the attachments once they have been sent", async () => {
- renderGrid();
- drop();
- await waitFor(() => expect(screen.getByTestId("agentic-attachments")).toBeTruthy());
-
- const box = screen.getByLabelText(/instruction for Mika/i);
- fireEvent.change(box, { target: { value: "fix this" } });
- fireEvent.keyDown(box, { key: "Enter" });
-
- // Otherwise the next, unrelated instruction would silently carry the old
- // screenshot along with it.
- await waitFor(() => expect(screen.queryByTestId("agentic-attachments")).toBeNull());
- });
-
- it("ignores a drag carrying only selected text", async () => {
- renderGrid();
-
- drop(["text/plain"]);
-
- expect(api.attachToTerminal).not.toHaveBeenCalled();
- });
-
- it("reports an analysis that came back empty rather than pretending", async () => {
- vi.mocked(api.attachToTerminal).mockResolvedValue({
- terminal: "Mika",
- references: [],
- files: [],
- copied: 0,
- submitted: false,
- delivered: false,
- analysis: [],
- });
- renderGrid();
-
- drop();
-
- await waitFor(() => expect(pushToast).toHaveBeenCalled());
- expect(pushToast.mock.calls[0][0]).toBe("warning");
- });
-
- it("surfaces a failed attach instead of losing the drop silently", async () => {
- vi.mocked(api.attachToTerminal).mockRejectedValue(new Error("pane is gone"));
- renderGrid();
-
- drop();
-
- await waitFor(() => expect(pushToast).toHaveBeenCalledWith("error", "pane is gone"));
- });
-});
-
-/*
- * The seam between the terminals and the prompt bar.
- *
- * jsdom reports every element as 0×0, so the measured ceiling falls back to the
- * designed height — which is why these tests exercise the directions that do
- * not need a taller window: collapsing the bar, reopening it, and remembering
- * the choice. Growing it is verified live in the browser.
- */
-describe("prompt bar seam", () => {
- const HEIGHT_KEY = "jarvis.agenticIde.composerHeight.v2";
- /** The height the strip collapses to, and the one it opens back up to. */
- const SHUT = "28";
- const OPEN = "176";
-
- // This suite owns the remembered height — drop what the file-wide setup put
- // there so each test below starts from the state it actually describes.
- beforeEach(() => window.localStorage.removeItem(HEIGHT_KEY));
- afterEach(() => window.localStorage.clear());
-
- /** Drag the seam from `fromY` to `toY`, start to finish. */
- function dragSeam(fromY: number, toY: number) {
- const seam = screen.getByTestId("pane-resizer-horizontal");
- fireEvent.pointerDown(seam, { clientY: fromY });
- act(() => {
- window.dispatchEvent(new MouseEvent("pointermove", { clientY: toY }));
- });
- act(() => {
- window.dispatchEvent(new MouseEvent("pointerup"));
- });
- }
-
- it("puts a draggable seam above the prompt bar", () => {
- renderGrid();
- const seam = screen.getByTestId("pane-resizer-horizontal");
- expect(seam.getAttribute("role")).toBe("separator");
- expect(seam.getAttribute("aria-orientation")).toBe("horizontal");
- });
-
- /*
- * A workspace this view has never been sized in opens with the bar SHUT.
- *
- * The panes are what the user came for; a 176 px writing surface held open
- * under a dozen of them took a sixth of each pane's height for an input box
- * that is empty most of the time — and everything typed there can be said out
- * loud instead. The strip below it is what keeps that recoverable.
- */
- it("starts collapsed, with the way to open it on screen", () => {
- renderGrid();
-
- expect(screen.queryByTestId("agentic-composer")).toBeNull();
- expect(screen.getByTestId("agentic-composer-collapsed")).toBeTruthy();
- expect(screen.getByTestId("agentic-composer-reopen")).toBeTruthy();
- expect(screen.getByTestId("pane-resizer-horizontal")).toBeTruthy();
- expect(
- screen
- .getByLabelText("Instruction for Mika")
- .closest('[aria-hidden="true"]')
- ?.classList.contains("hidden"),
- ).toBe(true);
- });
-
- it("dragging the seam to the bottom collapses an opened bar to a strip", () => {
- window.localStorage.setItem(HEIGHT_KEY, OPEN);
- renderGrid();
- expect(screen.getByTestId("agentic-composer")).toBeTruthy();
-
- dragSeam(700, 1400);
-
- expect(screen.queryByTestId("agentic-composer")).toBeNull();
- expect(screen.getByTestId("agentic-composer-collapsed")).toBeTruthy();
- // The collapsed strip is a strip, not a disappearance: the way back has to
- // stay on screen, or the workspace loses its input box for good.
- expect(screen.getByTestId("agentic-composer-reopen")).toBeTruthy();
- expect(screen.getByTestId("pane-resizer-horizontal")).toBeTruthy();
- });
-
- it("keeps a draft when the prompt bar is collapsed and reopened", () => {
- window.localStorage.setItem(HEIGHT_KEY, OPEN);
- renderGrid();
- const editor = screen.getByLabelText("Instruction for Mika");
- fireEvent.change(editor, { target: { value: "Keep this draft" } });
-
- dragSeam(700, 1400);
- fireEvent.click(screen.getByTestId("agentic-composer-reopen"));
-
- expect(
- (screen.getByLabelText("Instruction for Mika") as HTMLTextAreaElement).value,
- ).toBe("Keep this draft");
- });
-
- it("the reopen button brings the prompt bar back at its designed height", () => {
- renderGrid();
- expect(screen.getByTestId("agentic-composer-collapsed")).toBeTruthy();
-
- fireEvent.click(screen.getByTestId("agentic-composer-reopen"));
-
- const composer = screen.getByTestId("agentic-composer");
- expect(composer.style.height).toBe(`${OPEN}px`);
- expect(screen.getByLabelText(/instruction for Mika/i)).toBeTruthy();
- });
-
- it("remembers an opened bar across a remount", () => {
- // The stored height is the whole reason the default can be "shut": someone
- // who wants the writing surface opens it once and keeps it.
- renderGrid();
- fireEvent.click(screen.getByTestId("agentic-composer-reopen"));
- expect(window.localStorage.getItem(HEIGHT_KEY)).toBe(OPEN);
-
- cleanup();
- renderGrid();
- expect(screen.getByTestId("agentic-composer")).toBeTruthy();
- });
-
- it("remembers a collapsed bar across a remount", () => {
- window.localStorage.setItem(HEIGHT_KEY, OPEN);
- renderGrid();
- dragSeam(700, 1400);
- expect(window.localStorage.getItem(HEIGHT_KEY)).toBe(SHUT);
-
- cleanup();
- renderGrid();
- expect(screen.getByTestId("agentic-composer-collapsed")).toBeTruthy();
- });
-
- /*
- * Double-click TOGGLES rather than resets.
- *
- * `reset` means "back to the default", and the default is now the shut strip
- * — so wiring the seam to it would give a closed bar a double-click that
- * visibly does nothing, which reads as a dead control.
- */
- it("double-clicking the seam opens a shut bar and shuts an open one", () => {
- renderGrid();
-
- fireEvent.doubleClick(screen.getByTestId("pane-resizer-horizontal"));
- expect(screen.getByTestId("agentic-composer").style.height).toBe(`${OPEN}px`);
-
- fireEvent.doubleClick(screen.getByTestId("pane-resizer-horizontal"));
- expect(screen.getByTestId("agentic-composer-collapsed")).toBeTruthy();
- });
-});
-
-
/*
* Sizing the workspace by hand.
*
@@ -1683,19 +1298,6 @@ describe("resizing the workspace", () => {
}
});
- /* The prompt bar changes every pane's height, so it counts as the same kind
- of motion — a pane must not refit for each frame of that drag either. */
- it("counts a prompt-bar drag as the workspace moving too", () => {
- renderGrid(sessionWith([["Mika", 0], ["Nova", 1]]));
- const busy = () => screen.getByTestId("pane-Mika").getAttribute("data-layout-busy");
-
- fireEvent.pointerDown(screen.getByTestId("pane-resizer-horizontal"), { clientY: 700 });
- expect(busy()).toBe("yes");
-
- act(() => window.dispatchEvent(new MouseEvent("pointerup")));
- expect(busy()).toBe("no");
- });
-
it("posts the sizes so a restart brings the workspace back as it was", async () => {
const restore = measured(1000, 600);
try {
@@ -2722,17 +2324,20 @@ describe("renaming a pane", () => {
);
});
- it("keeps the prompt bar pointed at the pane it was pointed at", async () => {
+ it("keeps the prompt target on the pane it was on", async () => {
vi.mocked(api.renameTerminal).mockResolvedValue(RENAMED);
- const { rerender } = renderGrid();
+ const onPromptTargetChange = vi.fn();
+ const { rerender } = renderGrid(BASE, { onPromptTargetChange });
- expect(screen.getByLabelText(/instruction for Mika/i)).toBeTruthy();
+ await waitFor(() => expect(onPromptTargetChange).toHaveBeenCalledWith("Mika"));
fireEvent.click(screen.getByTestId("pane-rename-Mika"));
await waitFor(() => expect(api.renameTerminal).toHaveBeenCalled());
rerender({ session: RENAMED });
- expect(screen.getByLabelText(/instruction for Frontend/i)).toBeTruthy();
+ await waitFor(() =>
+ expect(onPromptTargetChange).toHaveBeenLastCalledWith("Frontend"),
+ );
});
it("says what went wrong and leaves the workspace alone", async () => {
@@ -2753,16 +2358,13 @@ describe("renaming a pane", () => {
});
});
-describe("the surface the backend is told about", () => {
+describe("chat view", () => {
/*
- * The grid used to have a second reading mode of its own — one pane on a
- * stage, the rest in a rail. That is gone: the IDE's chat is the AGENT chat
- * now, a separate surface owned by `views/AgenticIdeView`, and this
- * component is the wall of terminals and nothing else.
- *
- * What survives is the report: the browser is the only layer that knows
- * which surface is in front of the user, and voice resolves "this terminal"
- * from it.
+ * The workspace read like a conversation: a rail of agents on the left, one
+ * pane on a centred stage, the prompt bar as the composer. What these tests
+ * pin is not the styling but the two contracts underneath it — switching
+ * modes must not remount a pane (a remount kills the coding agent), and
+ * every action the grid offers keeps working from the other mode.
*/
const FOUR = sessionWith([
["Mika", 0],
@@ -2771,43 +2373,282 @@ describe("the surface the backend is told about", () => {
["Kai", 3],
]);
- 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",
- },
- ];
+ const cellClass = (name: string) =>
+ screen.getByTestId(`pane-cell-${name}`).className;
+
+ /*
+ * The reading modes are three separate buttons, not one cycling control:
+ * past two states "click again" stops telling you where you land, and the
+ * third mode changes the assistant's behaviour rather than only the layout.
+ */
+ const toChat = () => fireEvent.click(screen.getByTestId("agentic-view-mode-toggle"));
+ const toGrid = () => fireEvent.click(screen.getByTestId("agentic-view-mode-grid"));
+
+ const railOrder = () =>
+ screen
+ .getAllByTestId(/^chat-rail-item-/)
+ .map((item) => item.dataset.terminal);
+
+ function placeRailItem(name: string, top: number) {
+ const item = screen.getByTestId(`chat-rail-item-${name}`);
+ item.getBoundingClientRect = () =>
+ ({
+ left: 0,
+ top,
+ width: 200,
+ height: 36,
+ right: 200,
+ bottom: top + 36,
+ x: 0,
+ y: top,
+ toJSON: () => ({}),
+ }) as DOMRect;
+ }
+
+ it("starts in the grid, with the rail hidden", () => {
+ renderGrid(FOUR);
+ expect(screen.getByTestId("agentic-chat-rail").className).toContain("hidden");
+ for (const name of ["Mika", "Nova", "Aria", "Kai"]) {
+ expect(cellClass(name)).not.toContain("hidden");
+ }
+ });
+
+ it("shows one pane on the stage and the rest in the rail", () => {
+ renderGrid(FOUR);
+ toChat();
+ expect(screen.getByTestId("agentic-chat-rail").className).not.toContain("hidden");
+ // Mika is the prompt target, so it takes the stage; the others hide.
+ expect(cellClass("Mika")).not.toContain("hidden");
+ for (const name of ["Nova", "Aria", "Kai"]) {
+ expect(cellClass(name)).toContain("hidden");
+ // Hidden, never unmounted — the agent behind the pane lives on.
+ expect(screen.getByTestId(`pane-${name}`)).toBeTruthy();
+ expect(screen.getByTestId(`chat-rail-${name}`)).toBeTruthy();
+ }
+ });
+
+ it("uses the live task recap as the rail title, behind the agent's mark", async () => {
+ const mixed = sessionWith([
+ ["Mika", 0],
+ ["Nova", 1],
+ ]);
+ mixed.terminals[1] = {
+ ...mixed.terminals[1],
+ agent: "codex",
+ display_name: "Codex",
+ };
+ vi.mocked(api.fetchTerminalRecaps).mockResolvedValue({
+ workspace_id: "ide_test",
+ terminals: [
+ {
+ key: "nova",
+ name: "Nova",
+ status: "live",
+ recap: "Fix provider selection priority",
+ recap_detail: "Correct the fallback order used by the provider picker.",
+ },
+ ],
+ });
+
+ renderGrid(mixed);
+ toChat();
+
+ const title = await screen.findByTestId("chat-rail-title-Nova");
+ expect(title.textContent).toBe("Fix provider selection priority");
+ // The mark LEADS the row and the title follows it, the way a list of
+ // conversations reads: the title is the subject, the mark says which CLI
+ // is having it. The title sits inside its tooltip anchor, so the mark is
+ // the ANCHOR's previous sibling.
+ const mark = title.parentElement?.previousElementSibling;
+ expect(mark?.getAttribute("data-testid")).toBe("agent-mark-codex");
+ // `data-logo` rather than the <img>: a single-colour mark is drawn as a
+ // CSS mask so it follows the theme's ink, and jsdom does not model masks.
+ expect(mark?.getAttribute("data-logo")).toBe("/provider-logos/openai.svg");
+ });
+
+ it("uses the last prompt as the title while a recap is not available", () => {
+ const session = sessionWith([["Mika", 0]]);
+ session.terminals[0].last_prompt = "Analyze transcription omissions";
+
+ renderGrid(session);
+ toChat();
+
+ expect(screen.getByTestId("chat-rail-title-Mika").textContent).toBe(
+ "Analyze transcription omissions",
+ );
+ });
+
+ it("keeps the very same pane elements across every mode and back", () => {
+ // The iron rule of this component, and the one a new reading mode is most
+ // likely to break: element identity is the mounting guarantee. A remounted
+ // pane is a NEW element, and a new element means the WebSocket died with
+ // the old one — which kills the coding agent behind it.
+ renderGrid(FOUR);
+ const before = screen.getByTestId("pane-Nova");
- it("names no staged terminal — the grid shows all of them", async () => {
+ toChat();
+ expect(screen.getByTestId("pane-Nova")).toBe(before);
+ toGrid();
+
+ expect(screen.getByTestId("pane-Nova")).toBe(before);
+ expect(screen.getByTestId("agentic-chat-rail").className).toContain("hidden");
+ expect(cellClass("Kai")).not.toContain("hidden");
+ });
+
+ it("a rail click puts that pane on the stage", () => {
renderGrid(FOUR);
+ toChat();
+ fireEvent.click(screen.getByTestId("chat-rail-Aria"));
+ expect(cellClass("Aria")).not.toContain("hidden");
+ expect(cellClass("Mika")).toContain("hidden");
+ });
+ it("activates an externally added pane on its first chat-stage render", () => {
+ const { rerender } = renderGrid(FOUR);
+ toChat();
+ paneActiveHistory.clear();
+
+ rerender({
+ session: sessionWith([
+ ["Mika", 0],
+ ["Nova", 1],
+ ["Aria", 2],
+ ["Kai", 3],
+ ["Fresh", 4],
+ ]),
+ });
+
+ // Connecting once while inactive gives the PTY the narrow hidden-grid
+ // geometry. The pane must own the full stage before its first effect runs.
+ expect(paneActiveHistory.get("Fresh")?.[0]).toBe(true);
+ expect(screen.getByTestId("pane-Fresh").getAttribute("data-active")).toBe(
+ "yes",
+ );
+ });
+
+ it("swaps two rail positions by dragging without moving or remounting the panes", async () => {
+ renderGrid(FOUR);
+ const paneBefore = screen.getByTestId("pane-Mika");
+ toChat();
+ placeRailItem("Mika", 0);
+ placeRailItem("Nova", 36);
+ placeRailItem("Aria", 72);
+ placeRailItem("Kai", 108);
+
+ fireEvent(
+ screen.getByTestId("chat-rail-Mika"),
+ new MouseEvent("pointerdown", {
+ bubbles: true,
+ clientX: 40,
+ clientY: 18,
+ button: 0,
+ }),
+ );
+ act(() => {
+ window.dispatchEvent(
+ new MouseEvent("pointermove", { clientX: 40, clientY: 90 }),
+ );
+ });
+
+ expect(screen.getByTestId("chat-rail-arrange-ghost").textContent).toContain(
+ "Mika",
+ );
+ expect(screen.getByTestId("chat-rail-item-Aria").className).toContain(
+ "ring-primary/70",
+ );
+
+ await act(async () => {
+ window.dispatchEvent(new MouseEvent("pointerup"));
+ });
+
+ expect(railOrder()).toEqual(["Aria", "Nova", "Mika", "Kai"]);
+ expect(api.moveTerminal).not.toHaveBeenCalled();
+ expect(screen.getByTestId("pane-Mika")).toBe(paneBefore);
+ // Chromium follows a drag release with a compatibility click on the row
+ // below it. That click belongs to the drag and must not switch the stage.
+ fireEvent.click(screen.getByTestId("chat-rail-Aria"));
+ expect(cellClass("Mika")).not.toContain("hidden");
+ expect(cellClass("Aria")).toContain("hidden");
await waitFor(() =>
- expect(api.syncAgenticIdeSurface).toHaveBeenLastCalledWith(
- expect.objectContaining({ view: "grid", onScreen: true, terminal: null }),
- ),
+ expect(
+ JSON.parse(
+ window.localStorage.getItem("jarvis.agenticIde.chatOrder.v1.ide_test") ??
+ "[]",
+ ),
+ ).toEqual(["aria@0", "nova@0", "mika@0", "kai@0"]),
);
+
+ cleanup();
+ renderGrid(FOUR);
+ expect(railOrder()).toEqual(["Aria", "Nova", "Mika", "Kai"]);
});
- it("passes on the surface its owner says is showing", async () => {
- renderGrid(FOUR, { view: "chat" });
+ it("grounds deictic voice references in the pane visibly on stage", async () => {
+ renderGrid(FOUR);
+ await waitFor(() =>
+ expect(api.syncAgenticIdeSurface).toHaveBeenLastCalledWith({
+ workspaceId: "ide_test",
+ view: "grid",
+ onScreen: true,
+ terminal: null,
+ promptTarget: "Mika",
+ }),
+ );
+
+ toChat();
+ fireEvent.click(screen.getByTestId("chat-rail-Aria"));
+
+ await waitFor(() =>
+ expect(api.syncAgenticIdeSurface).toHaveBeenLastCalledWith({
+ workspaceId: "ide_test",
+ view: "chat",
+ onScreen: true,
+ terminal: "Aria",
+ promptTarget: "Aria",
+ }),
+ );
+
+ toGrid();
+ await waitFor(() =>
+ expect(api.syncAgenticIdeSurface).toHaveBeenLastCalledWith({
+ workspaceId: "ide_test",
+ view: "grid",
+ onScreen: true,
+ terminal: null,
+ promptTarget: "Aria",
+ }),
+ );
+ });
+
+ /*
+ * The view travels to the backend by NAME rather than as a boolean, so that
+ * a third mode added later reads correctly everywhere without re-deriving
+ * what "not chat" was supposed to mean. Pinned separately from the pane
+ * above because it is a separate claim.
+ */
+ it("tells the backend which mode is on screen", async () => {
+ renderGrid(FOUR);
+
+ toChat();
await waitFor(() =>
expect(api.syncAgenticIdeSurface).toHaveBeenLastCalledWith(
- expect.objectContaining({ view: "chat" }),
+ expect.objectContaining({ view: "chat", onScreen: true }),
),
);
});
- it("reports nothing on screen once the section is left", async () => {
+ it("reports the grid while the section is off screen, whatever it shows", async () => {
// A workspace nobody is looking at must not answer "this terminal". This
// grid stays mounted behind another section, so "on screen" is the only
// thing that can stop it — see the matching backend test.
const { rerender } = renderGrid(FOUR);
- await waitFor(() => expect(api.syncAgenticIdeSurface).toHaveBeenCalled());
+ toChat();
+ await waitFor(() =>
+ expect(api.syncAgenticIdeSurface).toHaveBeenLastCalledWith(
+ expect.objectContaining({ view: "chat" }),
+ ),
+ );
rerender({ onScreen: false });
@@ -2818,7 +2659,148 @@ describe("the surface the backend is told about", () => {
);
});
- it("an emptied workspace asks which CLI to open", async () => {
+ it("remembers the chosen view for the next workspace", () => {
+ renderGrid(FOUR);
+ toChat();
+ cleanup();
+ renderGrid(FOUR);
+ expect(screen.getByTestId("agentic-chat-rail").className).not.toContain("hidden");
+ });
+
+ it("maximize on the stage hands over to the grid, maximized", () => {
+ renderGrid(FOUR);
+ toChat();
+ fireEvent.click(screen.getByTestId("pane-maximize-Mika"));
+ expect(screen.getByTestId("agentic-chat-rail").className).toContain("hidden");
+ expect(screen.getByTestId("pane-Mika").getAttribute("data-maximized")).toBe("yes");
+ });
+
+ it("the rail's plus opens a terminal at the end of the row", async () => {
+ renderGrid(FOUR);
+ toChat();
+ fireEvent.click(screen.getByTestId("chat-rail-new-terminal"));
+ await waitFor(() =>
+ expect(api.addTerminal).toHaveBeenCalledWith({
+ anchor: undefined,
+ direction: "right",
+ agent: undefined,
+ }),
+ );
+ });
+
+ /*
+ * 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();
+ });
+
+ /*
+ * Closing ONE terminal from the rail.
+ *
+ * Chat view shows a single pane and hides the other eleven — and with them
+ * the pane header that used to be the only per-terminal close. So the rail
+ * carries its own, and it goes through the same confirmation as the header:
+ * closing a pane kills whatever its agent was doing, and there is no undo.
+ */
+ it("closes one terminal from its row in the rail", async () => {
+ const survivors = sessionWith([
+ ["Mika", 0],
+ ["Nova", 1],
+ ["Kai", 3],
+ ]);
+ vi.mocked(api.closeTerminal).mockResolvedValue(survivors);
+ const { onSessionChanged } = renderGrid(FOUR);
+ toChat();
+
+ fireEvent.click(screen.getByTestId("chat-rail-close-Aria"));
+ // Asked, never done on the spot — closing a pane kills a working agent.
+ expect(api.closeTerminal).not.toHaveBeenCalled();
+ expect(screen.getByText(/Close Aria\?/)).toBeTruthy();
+
+ fireEvent.click(screen.getByTestId("confirm-close-terminal-confirm"));
+ await waitFor(() => expect(api.closeTerminal).toHaveBeenCalledWith("Aria"));
+ // The grid does not own the workspace; it reports the new one upwards.
+ await waitFor(() => expect(onSessionChanged).toHaveBeenCalledWith(survivors));
+ await waitFor(() =>
+ expect(screen.queryByTestId("confirm-close-terminal")).toBeNull(),
+ );
+ });
+
+ it("keeps the rail's close out of selection mode", () => {
+ // That mode is here to close SEVERAL panes; a per-row close beside a
+ // checkbox is two answers to one question.
+ renderGrid(FOUR);
+ toChat();
+ expect(screen.getByTestId("chat-rail-close-Nova")).toBeTruthy();
+
+ fireEvent.click(screen.getByTestId("terminal-selection-toggle"));
+
+ expect(screen.queryByTestId("chat-rail-close-Nova")).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 });
@@ -2832,17 +2814,6 @@ describe("the surface the backend is told about", () => {
}),
);
});
-
- it("keeps a way to another workspace where the rail's rows used to be", () => {
- const onNewSession = vi.fn();
- const onAddProject = vi.fn();
- renderGrid(sessionWith([]), { onNewSession, onAddProject });
-
- fireEvent.click(screen.getByTestId("empty-workspace-new-session"));
- expect(onNewSession).toHaveBeenCalled();
- fireEvent.click(screen.getByTestId("empty-workspace-add-project"));
- expect(onAddProject).toHaveBeenCalled();
- });
});
describe("terminal text size", () => {
diff --git a/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.tsx b/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.tsx
index 149ac284c8..22f6527a2b 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.tsx
@@ -16,23 +16,27 @@ import {
AudioLines,
Brain,
Check,
- ChevronUp,
Files,
FolderGit2,
+ FolderPlus,
GripVertical,
+ LayoutGrid,
ListChecks,
- Loader2,
+ MessagesSquare,
Minus,
MoveHorizontal,
Moon,
MoreHorizontal,
Plus,
Power,
+ Search,
SlidersHorizontal,
+ SquarePen,
Sun,
Trash2,
Type,
X,
+ type LucideIcon,
} from "lucide-react";
import { cn } from "@/lib/utils";
import { useT } from "@/i18n";
@@ -40,8 +44,10 @@ import { useThemeValue } from "@/hooks/useTheme";
import { useDocumentVisible } from "@/hooks/useDocumentVisible";
import { useResizablePane } from "@/hooks/useResizablePane";
import { PaneResizer } from "@/components/layout/PaneResizer";
+import { QuickTooltip } from "@/components/ui/tooltip";
import { useEventStore, type VoiceState } from "@/store/events";
import { AgenticTerminal, type PaneStatus, type SplitDirection } from "./AgenticTerminal";
+import { AgentMark } from "./AgentMark";
import { PaneActivityPill } from "./PaneActivityPill";
import { AgentPickerMenu, offersAgentChoice, type SplitAgentChoice } from "./AgentPicker";
import type { TerminalAppearance } from "./terminalThemes";
@@ -70,15 +76,19 @@ import {
import { ContinueInterrupted } from "./ContinueInterrupted";
import { PaneNotifications } from "./PaneNotifications";
import { isVoiceActive } from "./useVoiceCall";
-import { PromptEditor } from "./PromptEditor";
// One strip of chips, one drop handler and one paste handler for every
// surface that writes to an agent (see ./PromptAttachments).
-import { AttachmentStrip, usePromptAttachments } from "./PromptAttachments";
import { WorkspaceSettings } from "./WorkspaceSettings";
import { WorkspaceExplorer } from "./WorkspaceExplorer";
import { WorkspaceFileViewer } from "./WorkspaceFileViewer";
-import { sameRows } from "./paneRows";
-import type { WorkspaceView } from "./workspaceView";
+import {
+ chatTerminalIdentity,
+ initialChatOrder,
+ orderChatTerminals,
+ reconcileChatOrder,
+ sameRows,
+ swapChatOrder,
+} from "./chatState";
import { usePaneArrange, type DropZone } from "./paneArrange";
import {
addTerminal,
@@ -94,7 +104,6 @@ import {
saveTerminalFontSize,
syncAgenticIdeSurface,
setTerminalRecap,
- promptTerminal,
type IdeAccountState,
type IdeState,
type PaneNotification,
@@ -106,16 +115,6 @@ import {
interface AgenticGridProps {
session: SessionState;
- /**
- * Which surface the Agentic IDE is showing — owned by `AgenticIdeView`.
- *
- * The grid does not switch it and is not hidden by itself: in `chat` the
- * view above keeps this component MOUNTED and merely takes it off screen,
- * because unmounting a pane kills the coding agent behind it. The value is
- * here so the backend hears which surface the user is actually reading (see
- * `syncAgenticIdeSurface`).
- */
- view?: WorkspaceView;
focusMode: boolean;
onToggleFocus: (enabled: boolean) => void;
onClose: () => void;
@@ -270,6 +269,34 @@ const TOOLBAR_BTN =
/** The same button, switched ON — the only yellow the toolbar spends. */
const TOOLBAR_BTN_ON = "bg-primary/15 text-primary hover:bg-primary/20 hover:text-primary";
+/**
+ * The reading-mode switch, one entry per view.
+ *
+ * A table rather than two hand-written buttons because the set is a contract
+ * (see `WorkspaceView`): a third mode should be one row here, and a mode with
+ * no row is a mode the user cannot reach — which is the failure this shape
+ * makes obvious instead of silent.
+ */
+const VIEW_BUTTONS: ReadonlyArray<{
+ view: WorkspaceView;
+ testId: string;
+ icon: LucideIcon;
+ title: string;
+}> = [
+ {
+ view: "grid",
+ testId: "agentic-view-mode-grid",
+ icon: LayoutGrid,
+ title: "Terminal grid — every pane on screen at once.",
+ },
+ {
+ view: "chat",
+ testId: "agentic-view-mode-toggle",
+ icon: MessagesSquare,
+ title: "Chat view — read one agent at a time, like a conversation.",
+ },
+];
+
/**
* The part of the hovered pane a drop would take, drawn as it will look.
*
@@ -332,39 +359,6 @@ const ACTIVITY_POLL_IDLE_MS = 5000;
*/
const SENT_BRIDGE_MS = 2 * ACTIVITY_POLL_MS;
-/*
- * How tall the prompt bar is — dragged by its top edge, and remembered.
- *
- * The split between "watch the agents" and "write to them" is not the same for
- * everyone or even for the same person an hour later: dictating a long brief
- * wants a tall input, watching eight agents build wants none of it. So the seam
- * is draggable rather than a value someone guessed once.
- *
- * Pulled all the way down the bar COLLAPSES to a thin strip instead of
- * vanishing. A control that can be dragged out of existence has no way back —
- * the strip keeps both the seam and a one-click reopen on screen.
- *
- * It now STARTS collapsed (see `defaultSize` below), which is the honest default
- * for what this view is: a wall of running terminals you mostly watch. A 176 px
- * writing surface held open under twelve panes cost each of them a sixth of
- * their height for an input box that is empty most of the time — and everything
- * typed there can be said out loud instead. One drag, one double-click on the
- * seam, or the strip's own button opens it, and that choice is remembered.
- */
-const COMPOSER_DEFAULT_PX = 176;
-/** Height of the collapsed strip: its reopen button and nothing else. */
-const COMPOSER_COLLAPSED_PX = 28;
-/** Below this dragged height the bar snaps shut rather than half-showing. */
-const COMPOSER_COLLAPSE_AT_PX = 96;
-/**
- * Room the toolbar and a still-usable grid keep for themselves.
- *
- * Without it a tall prompt bar plus a short window squeezes the grid to zero,
- * every pane measures 0×0, and the panes' fit logic refuses to resize a
- * terminal to no columns — the workspace would look frozen rather than small.
- */
-const GRID_RESERVED_PX = 200;
-
/** The file explorer starts compact, but its left seam can resize it. */
const EXPLORER_WIDTH_KEY = "jarvis.agenticIde.explorerWidth.v1";
const EXPLORER_DEFAULT_PX = 280;
@@ -501,12 +495,70 @@ function writePosition(node: HTMLElement, style: React.CSSProperties): void {
*/
const APPEARANCE_KEY = "jarvis.agenticIde.terminalAppearance";
-export {
- WORKSPACE_VIEWS,
- rememberViewMode,
- storedViewMode,
- type WorkspaceView,
-} from "./workspaceView";
+/**
+ * The two ways of looking at one workspace.
+ *
+ * `grid` is the wall of terminals — every pane visible at once, sized by the
+ * dragged seams. `chat` is the same workspace read like a conversation: a rail
+ * of agents on the left and ONE terminal on a calm centred stage, typed into
+ * the way every other pane is.
+ *
+ * Talking to the assistant is not a mode: the floating voice orb is summoned
+ * from the toolbar and drawn over whichever of these two is on screen, so
+ * reaching for the microphone never costs the user the layout they chose.
+ *
+ * No mode owns the panes — switching is a pure restyle of the same mounted
+ * elements, because unmounting a pane kills the coding agent behind it (see
+ * the grid container's comment below). That rule is what makes a further mode
+ * cheap to add and is the one thing it must not break.
+ *
+ * Layer 4 of the enum contract; `jarvis/agentic_ide/workspace_view.py` is the
+ * source of truth and the backend asserts the two agree at import.
+ */
+export type WorkspaceView = "grid" | "chat";
+
+/** Every value, in the order the toolbar and the wizard offer them. */
+export const WORKSPACE_VIEWS: readonly WorkspaceView[] = ["grid", "chat"];
+
+function isWorkspaceView(raw: string): raw is WorkspaceView {
+ return (WORKSPACE_VIEWS as readonly string[]).includes(raw);
+}
+
+const VIEW_KEY = "jarvis.agenticIde.workspaceView";
+const CHAT_ORDER_KEY_PREFIX = "jarvis.agenticIde.chatOrder.v1";
+
+export function storedViewMode(): WorkspaceView | null {
+ return readStored(VIEW_KEY, (raw) => (isWorkspaceView(raw) ? raw : null));
+}
+
+/**
+ * Record which way the workspace should be read, ahead of the grid mounting.
+ *
+ * Exported for the workspace wizard: its last step asks grid-or-chat before
+ * anything opens, and the grid then simply reads the answer on mount — the
+ * same stored preference the toolbar toggle below keeps, so the wizard's
+ * choice and a later toggle can never disagree about where the answer lives.
+ */
+export function rememberViewMode(next: WorkspaceView): void {
+ writeStored(VIEW_KEY, next);
+}
+
+function storedChatOrder(workspaceId: string): readonly string[] | null {
+ return readStored(`${CHAT_ORDER_KEY_PREFIX}.${workspaceId}`, (raw) => {
+ try {
+ const parsed: unknown = JSON.parse(raw);
+ return Array.isArray(parsed) && parsed.every((item) => typeof item === "string")
+ ? parsed
+ : null;
+ } catch {
+ return null;
+ }
+ });
+}
+
+function rememberChatOrder(workspaceId: string, identities: readonly string[]): void {
+ writeStored(`${CHAT_ORDER_KEY_PREFIX}.${workspaceId}`, JSON.stringify(identities));
+}
function readStored<T>(key: string, parse: (raw: string) => T | null): T | null {
try {
@@ -566,7 +618,6 @@ function storedAppearance(): TerminalAppearance | null {
export function AgenticGrid({
session,
- view = "grid",
focusMode,
onToggleFocus,
onClose,
@@ -698,63 +749,6 @@ export function AgenticGrid({
// claim a fresh pane is working, done, or describing somebody else's task.
const recaps: Record<string, TerminalRecap> =
recapCache.workspaceId === session.id ? recapCache.rows : {};
- // The editor owns ordinary keystrokes so typing does not re-render every
- // xterm pane in this very large component. This seed changes only when the
- // parent intentionally replaces the draft (successful send).
- const [promptSeed, setPromptSeed] = useState({ value: "", revision: 0 });
- const replacePrompt = useCallback((value: string) => {
- setPromptSeed((current) => ({ value, revision: current.revision + 1 }));
- }, []);
- const [sending, setSending] = useState(false);
- // The live line about the brief being written for a pane of THIS workspace.
- // Composition is 10-30 s of real model work; without this line the bar
- // showed a silent spinner for all of it, and a working composer and a
- // wedged one looked identical. Fed by the backend's own beats over the app
- // socket, so it also narrates a compose another window of this workspace
- // started; cleared by the delivery event, a failed send, or a stale timer.
- const [composeBeat, setComposeBeat] = useState<{
- terminal: string;
- stage: string;
- message: string;
- } | null>(null);
- useEffect(() => {
- let staleTimer: number | undefined;
- const onBeat = (event: Event) => {
- const detail = (event as CustomEvent).detail as {
- session_id?: string;
- terminal?: string;
- stage?: string;
- message?: string;
- };
- if (detail.session_id && detail.session_id !== session.id) return;
- if (!detail.terminal || !detail.message) return;
- setComposeBeat({
- terminal: detail.terminal,
- stage: detail.stage ?? "",
- message: detail.message,
- });
- window.clearTimeout(staleTimer);
- // A beat never followed by a delivery (a killed backend, a dropped
- // socket) must not leave a "writing…" line standing forever.
- staleTimer = window.setTimeout(() => setComposeBeat(null), 120_000);
- };
- const onDelivered = (event: Event) => {
- const detail = (event as CustomEvent).detail as { terminal?: string };
- setComposeBeat((current) =>
- current && (!detail.terminal || detail.terminal === current.terminal)
- ? null
- : current,
- );
- };
- window.addEventListener("jarvis:agentic-ide-compose", onBeat);
- window.addEventListener("jarvis:agentic-ide-prompt", onDelivered);
- return () => {
- window.clearTimeout(staleTimer);
- window.removeEventListener("jarvis:agentic-ide-compose", onBeat);
- window.removeEventListener("jarvis:agentic-ide-prompt", onDelivered);
- };
- }, [session.id]);
-
// Bumping a pane's token reconnects just that pane, which respawns its agent.
// Keyed by call-sign so closing or splitting never disturbs the others.
const [restartTokens, setRestartTokens] = useState<Record<string, number>>({});
@@ -774,11 +768,29 @@ export function AgenticGrid({
* panes of that one agent while the grid's split buttons were asking properly
* (maintainer report 2026-07-31).
*/
- const [picking, setPicking] = useState<"empty" | null>(null);
+ 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
+ * screen, not workspace state worth a round-trip.
+ */
+ const [viewMode, setViewModeState] = useState<WorkspaceView>(() => storedViewMode() ?? "grid");
const [explorerOpen, setExplorerOpen] = useState(false);
const [openedWorkspaceFile, setOpenedWorkspaceFile] = useState<string | null>(null);
const openedWorkspaceFileTrigger = useRef<HTMLElement | null>(null);
+ const setViewMode = useCallback((next: WorkspaceView) => {
+ setViewModeState(next);
+ rememberViewMode(next);
+ // Chat shows one pane at most; a leftover maximize from the grid would
+ // silently pin the stage to a pane the chat rail does not highlight.
+ if (next !== "grid") 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";
+
useEffect(() => {
setOpenedWorkspaceFile(null);
openedWorkspaceFileTrigger.current = null;
@@ -794,9 +806,29 @@ export function AgenticGrid({
setOpenedWorkspaceFile(path);
}, []);
+ /*
+ * Which pane the chat stage shows. Kept apart from `target` (the pane the
+ * prompt bar types into) because the two answer different questions: a plain
+ * shell pane can be WATCHED on the stage but never prompted, and looking at
+ * it must not silently redirect the next instruction into a pane that
+ * refuses it. The effective selection is derived rather than repaired in
+ * effects, so a pane closed by another client simply falls back.
+ */
+ const [chatPane, setChatPane] = useState<string | null>(null);
// Null until the first render has been seen: on mount every pane is "new",
// and announcing a restored workspace's eight panes would be a light show.
+ // Kept beside the stage selection because a newly arrived pane must be
+ // selected during render, before its terminal's connection effect measures
+ // the otherwise-hidden grid cell.
const knownPanes = useRef<Set<string> | null>(null);
+ const [chatOrder, setChatOrder] = useState<{
+ workspaceId: string;
+ keys: readonly string[];
+ }>(() => ({
+ workspaceId: session.id,
+ keys: storedChatOrder(session.id) ?? initialChatOrder(session.terminals),
+ }));
+ const chatRailRef = useRef<HTMLDivElement | null>(null);
const [pendingClose, setPendingClose] = useState<string | null>(null);
const [selectionMode, setSelectionMode] = useState(false);
const [selectedTerminals, setSelectedTerminals] = useState<Set<string>>(() => new Set());
@@ -1140,47 +1172,27 @@ export function AgenticGrid({
}, []);
/*
- * The prompt bar's height, and the ceiling it may not cross.
+ * The frame's own width, and the ceiling the explorer may not cross.
*
- * The ceiling is measured rather than guessed: on a 1440-tall window a 520 px
- * prompt bar is comfortable, on a 700-tall laptop the same value leaves the
- * panes unreadable. So the frame reports its height and the bar may take
- * everything except what the toolbar and a minimum grid need.
+ * The ceiling is measured rather than guessed: on a 2560-wide window a 640 px
+ * explorer is comfortable, on a 1280-wide laptop the same value leaves the
+ * terminals unreadable. So the frame reports its width and the explorer may
+ * take everything except what a still-usable grid needs.
*/
const frameRef = useRef<HTMLDivElement | null>(null);
const [frameWidth, setFrameWidth] = useState(0);
- const [frameHeight, setFrameHeight] = useState(0);
useEffect(() => {
const node = frameRef.current;
if (!node) return;
setFrameWidth(node.clientWidth);
- setFrameHeight(node.clientHeight);
const observer = new ResizeObserver((entries) => {
const width = entries[0]?.contentRect.width ?? node.clientWidth;
- const height = entries[0]?.contentRect.height ?? node.clientHeight;
setFrameWidth(Math.round(width));
- setFrameHeight(Math.round(height));
});
observer.observe(node);
return () => observer.disconnect();
}, []);
- const composerMax = Math.max(
- COMPOSER_COLLAPSED_PX,
- (frameHeight || COMPOSER_DEFAULT_PX + GRID_RESERVED_PX) - GRID_RESERVED_PX,
- );
- const composer = useResizablePane({
- // v2: the default changed from "open at 176 px" to "collapsed", and a key
- // people already have a value under would have kept the old behaviour for
- // every existing install — which is precisely who asked for the change.
- storageKey: "jarvis.agenticIde.composerHeight.v2",
- defaultSize: COMPOSER_COLLAPSED_PX,
- min: COMPOSER_COLLAPSED_PX,
- max: composerMax,
- axis: "y",
- // The grip is the bar's TOP edge: dragging up must make the bar taller.
- handle: "start",
- });
const explorerMax = Math.max(
EXPLORER_MIN_PX,
Math.min(
@@ -1200,26 +1212,6 @@ export function AgenticGrid({
});
// Keep a wider stored preference intact when the window temporarily narrows.
const requestedExplorer = Math.min(explorerPane.size, explorerMax);
- // Clamped again on render, because the window can shrink under a height that
- // was legal when it was stored — the remembered value stays untouched, so a
- // maximised window gets the tall prompt bar back.
- const requestedComposer = Math.min(composer.size, composerMax);
- const composerCollapsed = requestedComposer < COMPOSER_COLLAPSE_AT_PX;
- const composerHeight = composerCollapsed ? COMPOSER_COLLAPSED_PX : requestedComposer;
-
- /*
- * Double-clicking the seam TOGGLES rather than resets.
- *
- * `reset` means "back to the default", and the default is now the closed
- * strip — so wiring the seam to it would give a shut bar a double-click that
- * visibly does nothing, which reads as a dead control. Toggling keeps one
- * gesture for both directions, which is what a double-click on a collapsed
- * splitter does in every editor.
- */
- const { resize: resizeComposer } = composer;
- const toggleComposer = useCallback(() => {
- resizeComposer(composerCollapsed ? COMPOSER_DEFAULT_PX : COMPOSER_COLLAPSED_PX);
- }, [composerCollapsed, resizeComposer]);
/*
* The sizes the panes are drawn at, and the seams between them.
@@ -1373,35 +1365,145 @@ export function AgenticGrid({
* hold still while the seam moves and take their new size in one pass when it
* stops — which is also when the terminal's contents stop lagging behind the
* frame around them.
- *
- * The prompt bar counts: dragging it changes the height of every pane above
- * it just as a seam does.
*/
- const layoutBusy =
- sizes.dragging !== null || composer.isResizing || explorerPane.isResizing;
+ const layoutBusy = sizes.dragging !== null || explorerPane.isResizing;
const atLimit = session.terminals.length >= maxTerminals;
+ /*
+ * Chat is a conversation history, so its rail follows ARRIVAL order. The
+ * backend's terminal array follows grid coordinates and is deliberately
+ * re-sorted after every split or drag; rendering that array directly made a
+ * newly spawned Codex session appear in the middle of an existing chat.
+ */
+ const stableChatKeys = useMemo(
+ () =>
+ reconcileChatOrder(
+ chatOrder.workspaceId === session.id
+ ? chatOrder.keys
+ : (storedChatOrder(session.id) ?? initialChatOrder(session.terminals)),
+ session.terminals,
+ ),
+ [chatOrder, session.id, session.terminals],
+ );
+ const chatTerminals = useMemo(
+ () => orderChatTerminals(session.terminals, stableChatKeys),
+ [session.terminals, stableChatKeys],
+ );
+ /*
+ * The rail's own filter over those panes.
+ *
+ * Matched against what the row SHOWS — its headline, the prompt behind it,
+ * the CLI's name — rather than against the internal call-sign, because
+ * "T7" is not what anybody is looking for when they type into a search box.
+ * Purely local: no request fires, so it stays instant with a dozen panes.
+ */
+ const [railFilter, setRailFilter] = useState("");
+ const railTerminals = useMemo(() => {
+ const needle = railFilter.trim().toLowerCase();
+ if (!needle) return chatTerminals;
+ return chatTerminals.filter((term) =>
+ [term.recap, term.last_prompt, term.display_name, term.agent, term.name]
+ .filter(Boolean)
+ .some((field) => String(field).toLowerCase().includes(needle)),
+ );
+ }, [chatTerminals, railFilter]);
+
+ /*
+ * The chat rail is a user's reading order, independent of the pane grid.
+ * Dropping one row on another exchanges only their stable lifetime keys: no
+ * terminal moves, remounts or reconnects, and the existing storage effect
+ * below makes the chosen order survive the next visit.
+ */
+ const suppressRailClickUntil = useRef(0);
+ const swapRailTerminals = useCallback(
+ (moved: string, targetName: string) => {
+ const movedTerminal = session.terminals.find((terminal) => terminal.name === moved);
+ const targetTerminal = session.terminals.find(
+ (terminal) => terminal.name === targetName,
+ );
+ if (!movedTerminal || !targetTerminal) return;
+ const next = swapChatOrder(
+ stableChatKeys,
+ chatTerminalIdentity(movedTerminal),
+ chatTerminalIdentity(targetTerminal),
+ );
+ if (next === stableChatKeys) return;
+ // Releasing over a row also produces a click in Chromium. Suppress that
+ // compatibility click so a reorder does not unexpectedly change stages.
+ suppressRailClickUntil.current = Date.now() + 250;
+ setChatOrder({ workspaceId: session.id, keys: next });
+ },
+ [session.id, session.terminals, stableChatKeys],
+ );
+ const railArrange = usePaneArrange(
+ useCallback(
+ (moved: string, targetName: string) => swapRailTerminals(moved, targetName),
+ [swapRailTerminals],
+ ),
+ );
+ const canReorderRail =
+ chatView && !selectionMode && !busy && !working && railTerminals.length > 1;
+
+ useEffect(() => {
+ rememberChatOrder(session.id, stableChatKeys);
+ if (chatOrder.workspaceId === session.id && chatOrder.keys === stableChatKeys) {
+ return;
+ }
+ setChatOrder({ workspaceId: session.id, keys: stableChatKeys });
+ }, [chatOrder, session.id, stableChatKeys]);
+
+ /*
+ * A pane can arrive through voice, the CLI, or another client. Effects run
+ * after child effects, which is too late to put that pane on the chat stage:
+ * its terminal would already have connected from a hidden, grid-sized cell
+ * and handed the PTY a tiny column count. Derive the arrival synchronously so
+ * the new terminal's first measurement is the full stage.
+ */
+ const knownBeforeRender = knownPanes.current;
+ const arrivingChatPane =
+ chatView && knownBeforeRender !== null
+ ? (session.terminals
+ .filter((term) => !knownBeforeRender.has(term.name))
+ .at(-1)?.name ?? null)
+ : null;
+
+ /** The pane on the chat stage: the newest arrival, chosen pane, then fallback. */
+ const chatSelected = useMemo(() => {
+ const names = session.terminals.map((term) => term.name);
+ if (arrivingChatPane && names.includes(arrivingChatPane)) return arrivingChatPane;
+ if (chatPane && names.includes(chatPane)) return chatPane;
+ if (target && names.includes(target)) return target;
+ return names[0] ?? null;
+ }, [arrivingChatPane, chatPane, target, session.terminals]);
+
/*
* The browser is the only layer that knows what is actually on screen. Hand
* that fact to the backend so voice and chat can resolve "this terminal"
* from what the user sees.
*
- * No pane is ever THE one on screen here: the grid shows all of them, and
- * guessing among a dozen visible terminals would be less honest than making
- * the user name one. The prompt target is the aim that does exist.
+ * `stagedPane` is the ONE pane the view puts in front of the user: chat's
+ * stage. Grid has no such pane and reports none — guessing among a dozen
+ * visible terminals would be less honest than making the user name one.
*/
+ const stagedPane = chatView ? chatSelected : null;
useEffect(() => {
void syncAgenticIdeSurface({
workspaceId: session.id,
- view,
+ view: viewMode,
onScreen,
- terminal: null,
+ terminal: onScreen ? stagedPane : null,
promptTarget: onScreen ? target || null : null,
}).catch((error) => {
console.warn("Agentic IDE: could not sync the visible terminal:", error);
});
- }, [onScreen, session.id, target, view]);
+ }, [onScreen, session.id, stagedPane, target, viewMode]);
+
+ /** Rail click: show the pane, and aim voice at it when it can listen. */
+ const selectChatPane = useCallback((name: string, promptable: boolean) => {
+ setChatPane(name);
+ if (promptable) setTarget(name);
+ }, []);
const split = async (anchor: string | null, direction: SplitDirection, agent?: string) => {
setWorking(true);
@@ -1422,6 +1524,10 @@ export function AgenticGrid({
// stealing the target would silently redirect the next prompt into a pane
// that refuses it.
if (added && takesPrompts(added)) setTarget(added.name);
+ // The chat stage shows what was just opened — in the grid the new pane
+ // simply appears, but on a one-pane stage an unshown terminal would read
+ // as a split that did nothing.
+ if (added) setChatPane(added.name);
} catch (e) {
pushToast("error", (e as Error).message);
} finally {
@@ -1436,7 +1542,7 @@ export function AgenticGrid({
* 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: "empty") => {
+ const openTerminal = (surface: "rail" | "empty") => {
if (offersChoice) setPicking((current) => (current === surface ? null : surface));
else void split(null, "right");
};
@@ -1574,6 +1680,7 @@ export function AgenticGrid({
const guardActive =
onScreen &&
documentVisible &&
+ !chatView &&
maximized === null &&
arrange.held === null &&
!layoutBusy;
@@ -1731,13 +1838,31 @@ export function AgenticGrid({
const fresh = names.filter((name) => !known.has(name));
if (fresh.length === 0) return;
setJustOpened(new Set(fresh));
+ // On the chat stage, "seen appearing" means TAKING the stage: a pane
+ // opened by voice would otherwise exist only as a rail entry behind the
+ // one being read, which is the 2026-07-28 "terminals just don't load"
+ // report in new clothes.
+ let frame: number | undefined;
+ if (chatView) {
+ setChatPane(fresh[fresh.length - 1]);
+ // Chat rows are arrival-ordered, so the new session belongs at the rail's
+ // tail. Scrolling the hidden grid cell used to move the whole workspace
+ // and then snap the terminal again after its delayed fit.
+ frame = requestAnimationFrame(() => {
+ const rail = chatRailRef.current;
+ if (rail) rail.scrollTop = rail.scrollHeight;
+ });
+ }
// In the grid there is nothing to scroll to: the workspace is one screenful
// by rule, so a pane that just opened is already in view and the ring below
// is the whole announcement. This used to call `scrollIntoView` on the
// newest pane, which was the honest answer while a workspace could be wider
// or taller than its window.
const timer = window.setTimeout(() => setJustOpened(new Set()), 2600);
- return () => window.clearTimeout(timer);
+ return () => {
+ if (frame !== undefined) cancelAnimationFrame(frame);
+ window.clearTimeout(timer);
+ };
}, [session.terminals]);
/*
@@ -1771,8 +1896,10 @@ export function AgenticGrid({
pushToast("warning", t("agentic_grid.notifications.gone").replace("{0}", wanted));
return;
}
- // The jump means "let me READ that pane", which in the grid is a maximize.
- setMaximized(wanted);
+ // The jump means "let me READ that pane". In the grid that is a maximize;
+ // on the chat stage it is the stage showing that pane.
+ if (chatView) setChatPane(wanted);
+ else setMaximized(wanted);
setJustOpened(new Set([wanted]));
const timer = window.setTimeout(() => setJustOpened(new Set()), 2600);
return () => window.clearTimeout(timer);
@@ -1876,6 +2003,7 @@ export function AgenticGrid({
*/
const canArrange =
!selectionMode &&
+ !chatView &&
maximized === null &&
!busy &&
!working &&
@@ -1931,89 +2059,6 @@ export function AgenticGrid({
setStatuses((prev) => ({ ...prev, [name]: { status, detail } }));
}, []);
- /*
- * Files dropped onto the PROMPT BAR, and what is in them.
- *
- * A drop on a pane and a drop here mean different things. The pane types a
- * path, which is right for "read this file" — the agent opens it. But a
- * screenshot is the case where that breaks down: several of the coding CLIs
- * cannot open an image at all, so the user drops a picture of a broken
- * layout, types "fix this", and the agent receives a path and a pronoun.
- *
- * So a drop here is READ first — described if it is an image, extracted if it
- * is a document — and the result rides along into the composition. The file
- * is still saved and still referenced; the description is the floor under it,
- * not a replacement for it.
- */
- const {
- attachments,
- analyzing,
- dragging,
- dragHandlers,
- attachFiles,
- onPaste: onComposerPaste,
- remove: dropAttachment,
- clear: clearAttachments,
- } = usePromptAttachments(
- target,
- useCallback(
- (message: string, severity: "warning" | "error") => pushToast(severity, message),
- [pushToast],
- ),
- );
-
-
- /**
- * Compose and deliver in one request — the same thing "prompt Mika …" does
- * by voice.
- *
- * The backend rewrites the typed instruction into a briefed task with the
- * relevant `@file` references attached and types THAT into the pane. It owns
- * every failure mode: a slow writer is hedged, a dead one is substituted,
- * and when no capable model is reachable the deterministic rendering ships
- * instead — so the pane always receives a prompt, never nothing. An earlier
- * version composed in a dry run first and held the result for approval, with
- * a "Send verbatim" escape; the maintainer retired that detour (2026-08-12)
- * because its fallback paths sent the raw text, and the typed bar must
- * behave exactly like the spoken one.
- *
- * On a failed REQUEST nothing was typed anywhere, so the draft stays in the
- * editor rather than being retried verbatim — silently downgrading to the
- * raw text is the one behaviour this path exists to rule out.
- */
- const send = async (draft: string) => {
- const text = draft.trim();
- if (!text || !target) return;
- setSending(true);
- try {
- const result = await promptTerminal(target, text, { compose: true, attachments });
- replacePrompt("");
- clearAttachments();
- // The pane's badge flips to "working" NOW, not when the poll catches the
- // screen moving: the user just watched this send succeed, and a badge
- // still saying "done" for the next several seconds reads as a send that
- // silently failed. See `sentAt` for how the backend takes back over.
- if (!result || result.submitted !== false) {
- setSentAt((current) => ({ ...current, [target]: Date.now() }));
- }
- // The text is typed either way — but if the agent did not accept it, say
- // so instead of leaving the user to wonder why nothing happened.
- if (result && result.submitted === false) {
- pushToast(
- "warning",
- result.detail ||
- `${target} did not accept the prompt — the text is waiting in its input box.`,
- );
- }
- } catch (e) {
- pushToast("error", (e as Error).message);
- // No delivery event will arrive to clear the narration for this send.
- setComposeBeat(null);
- } finally {
- setSending(false);
- }
- };
-
const project = session.project;
const branchLabel = useMemo(
() => (project.is_repo && project.branch ? `on ${project.branch}` : ""),
@@ -2078,6 +2123,31 @@ export function AgenticGrid({
<Brain className="h-4 w-4 shrink-0" />
</button>
+ {/* Grid or chat — how the same agents are read.
+
+ Two buttons rather than one cycling through both states, because
+ the switch stays readable when a third mode is added: "click
+ again" stops telling you where you will land. They are ordinary
+ toolbar glyphs, not a segmented group in a box — the row's rule is
+ one button shape throughout, with colour reserved for what is ON.
+
+ `agentic-view-mode-toggle` stays on the chat button: it is the one
+ this control used to be, and the tests that press it are about
+ chat view rather than about the switch. */}
+ {VIEW_BUTTONS.map(({ view, testId, icon: Icon, title }) => (
+ <button
+ key={view}
+ type="button"
+ data-testid={testId}
+ aria-pressed={viewMode === view}
+ onClick={() => setViewMode(view)}
+ title={title}
+ className={cn(TOOLBAR_BTN, viewMode === view && TOOLBAR_BTN_ON)}
+ >
+ <Icon className="h-4 w-4 shrink-0" />
+ </button>
+ ))}
+
{/* The current workspace's files, in the familiar editor-explorer
position. It is an independent panel rather than a fourth reading
mode: opening it must not hide or remount a live terminal. */}
@@ -2095,20 +2165,22 @@ export function AgenticGrid({
<Files className="h-4 w-4 shrink-0" aria-hidden />
</button>
- {/* Even out the sizes. Before the appearance controls because it
- changes the panes themselves, not how their text is drawn.
+ {/* Even out the sizes. Beside the grid/chat toggle because both are
+ about the SHAPE of the workspace rather than what is in it, and
+ before the appearance controls because it changes the panes
+ themselves, not how their text is drawn.
- Off while a pane is maximized: that hides the boundaries this evens
- out, so the click would be a change nobody can see — and a control
- whose effect is invisible reads as a dead one. The tooltip says
- which of the reasons applies. */}
+ Off in chat view and while a pane is maximized: both hide the
+ boundaries this evens out, so the click would be a change nobody
+ can see — and a control whose effect is invisible reads as a dead
+ one. The tooltip says which of the reasons applies. */}
<button
type="button"
data-testid="agentic-even-panes"
onClick={evenPanes}
- disabled={maximized !== null || alreadyEven}
+ disabled={chatView || maximized !== null || alreadyEven}
title={
- maximized !== null
+ chatView || maximized !== null
? t("agentic_grid.even.grid_only")
: alreadyEven
? t("agentic_grid.even.already")
@@ -2285,8 +2357,288 @@ export function AgenticGrid({
CSS, never removed, and the maximized one is told to fill the container
instead of keeping its own rectangle.
+ Chat view is the same trick one step further: the rail on the left is
+ ALWAYS in the tree (hidden in grid mode), and switching modes only
+ flips class names — the scroller and every cell keep their place in
+ the element tree, so React re-parents nothing and no agent dies for a
+ change of clothes.
*/}
<div className="flex min-h-0 flex-1">
+ {/* ------------------------------------------------------ chat rail */}
+ <aside
+ data-testid="agentic-chat-rail"
+ className={cn(
+ /*
+ * 224 px, and the header is the same 44 px rule-under-a-label as
+ * the voice column opposite it. Chat view puts THREE vertical
+ * bands in front of the one pane being read — the app's own
+ * navigation, this list, and the voice column — so the two this
+ * view owns at least agree with each other about how a column
+ * begins.
+ */
+ "w-56 shrink-0 flex-col border-r border-border",
+ chatView ? "flex" : "hidden",
+ )}
+ >
+ {/*
+ The column's own head and name.
+
+ Not "AGENTS" in small caps any more. This column lists the
+ conversations you are having, grouped by the folder they are in —
+ "Chat" is what that is.
+ */}
+ <div className="flex h-11 shrink-0 items-center gap-1 px-2">
+ <span className="flex-1 truncate px-1 text-sm font-semibold tracking-tight">
+ Chat
+ </span>
+ </div>
+
+ <div className="px-2 pb-2">
+ <div className="relative flex items-center">
+ <Search className="pointer-events-none absolute left-2 h-3.5 w-3.5 text-muted-foreground/70" />
+ <input
+ value={railFilter}
+ onChange={(event) => setRailFilter(event.target.value)}
+ placeholder="Search"
+ aria-label="Search chats"
+ className="h-8 w-full rounded-md border border-transparent bg-foreground/[0.045] pl-7 pr-2 text-xs outline-none placeholder:text-muted-foreground/60 focus-visible:border-border focus-visible:bg-transparent"
+ />
+ </div>
+ </div>
+
+ {/*
+ The three things a person arrives wanting to do, as rows with words
+ on them. They used to be one bare "+" in the header, which cannot
+ say which of the three it is.
+ */}
+ <div className="relative px-1.5 pb-1">
+ <RailAction
+ icon={SquarePen}
+ label="New chat"
+ testId="chat-rail-new-terminal"
+ disabled={atLimit || busy || working}
+ onClick={() => openTerminal("rail")}
+ />
+ {onNewSession && (
+ <RailAction
+ icon={Plus}
+ label="New session"
+ hint="A workspace with no project folder"
+ testId="chat-rail-new-session"
+ disabled={busy || working}
+ onClick={onNewSession}
+ />
+ )}
+ {onAddProject && (
+ <RailAction
+ icon={FolderPlus}
+ label="Add project"
+ testId="chat-rail-add-project"
+ disabled={busy || working}
+ onClick={onAddProject}
+ />
+ )}
+ {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="left-2 top-full"
+ onDismiss={() => setPicking(null)}
+ onInstalled={() => onAgentsChanged?.()}
+ onPick={(agent) => {
+ setPicking(null);
+ void split(null, "right", agent);
+ }}
+ />
+ )}
+ </div>
+
+ <div
+ ref={chatRailRef}
+ className="min-h-0 flex-1 overflow-y-auto scrollbar-jarvis px-1.5 pb-2"
+ >
+ <RailBand>Projects</RailBand>
+ {/*
+ The folder these panes are in, named and coloured like the
+ project it is. Every row under it belongs to it — which is the
+ whole reason this band exists: with two workspaces open, a flat
+ list of eleven conversations says nothing about which repository
+ any of them is touching.
+ */}
+ <div className="flex items-center gap-1.5 rounded-md px-2 py-1.5">
+ <span
+ className="h-1.5 w-1.5 shrink-0 rounded-full"
+ style={{ background: folderColor(project.path || project.name) }}
+ aria-hidden
+ />
+ <span className="min-w-0 flex-1 truncate text-xs font-medium">
+ {project.name}
+ </span>
+ </div>
+
+ {railTerminals.map((term) => {
+ const state = statusOf(term);
+ const headline = recaps[term.name]?.recap ?? term.recap;
+ const title =
+ headline?.trim() ||
+ term.last_prompt?.trim() ||
+ `${term.display_name || term.name} session`;
+ const marked = selectedTerminals.has(term.name);
+ const active = chatSelected === term.name;
+ return (
+ /*
+ * The row and its close button are SIBLINGS, never nested: a
+ * button inside a button is invalid HTML, and browsers resolve
+ * it by dropping one of them — usually the one you wanted.
+ */
+ <div
+ key={term.key}
+ ref={railArrange.registerCell(term.name)}
+ data-testid={`chat-rail-item-${term.name}`}
+ data-terminal={term.name}
+ className={cn(
+ "group relative ml-3 mb-0.5 rounded-md transition-[opacity,box-shadow,background-color]",
+ railArrange.held === term.name && "opacity-50",
+ railArrange.hover?.target === term.name &&
+ "bg-primary/10 ring-2 ring-inset ring-primary/70",
+ )}
+ >
+ <button
+ type="button"
+ data-testid={`chat-rail-${term.name}`}
+ aria-label={`${title}, ${term.display_name || term.agent}`}
+ aria-pressed={selectionMode ? marked : active}
+ onPointerDown={
+ canReorderRail
+ ? (event) => railArrange.start(term.name, event)
+ : undefined
+ }
+ onClick={(event) => {
+ if (Date.now() < suppressRailClickUntil.current) {
+ event.preventDefault();
+ return;
+ }
+ // Selection mode borrows the rail: in chat view the grid's
+ // per-pane overlays are hidden with their panes, so the
+ // rail is where a multi-close is composed.
+ selectionMode
+ ? toggleTerminalSelection(term.name)
+ : selectChatPane(term.name, takesPrompts(term));
+ }}
+ /*
+ * Selection is a barely-there lift of the surface — no hue,
+ * no border, no fill. Eleven rows of tinted boxes turn a
+ * list into a heat map and leave the accent with nothing
+ * distinct to say when a row actually wants attention. The
+ * one exception is a MARKED row in selection mode, which is
+ * a deliberate armed state and should look like one.
+ */
+ className={cn(
+ "w-full rounded-md px-2 py-[5px] text-left transition-colors",
+ selectionMode && marked
+ ? "bg-primary/15"
+ : active && !selectionMode
+ ? "bg-foreground/[0.09]"
+ : "hover:bg-foreground/[0.055]",
+ canReorderRail &&
+ (railArrange.held === term.name
+ ? "cursor-grabbing"
+ : "cursor-grab"),
+ )}
+ style={{ touchAction: canReorderRail ? "none" : undefined }}
+ >
+ {/* The right padding is permanent, not applied on hover:
+ the close button appears where the badge would otherwise
+ be, and a status pill that jumps sideways under the
+ cursor is a row nobody can aim at. */}
+ <span className="flex items-center gap-1.5 pr-5">
+ {selectionMode && (
+ <Check
+ className={cn(
+ "h-3.5 w-3.5 shrink-0",
+ marked ? "text-primary" : "text-transparent",
+ )}
+ />
+ )}
+ <span className="flex min-w-0 flex-1 items-center gap-2">
+ {/* The mark leads, at the weight of the text beside it
+ — it says which CLI this is, it is not the subject
+ of the row. The title is. */}
+ <AgentMark
+ agent={term.agent}
+ label={term.display_name || term.agent}
+ size="sm"
+ variant="plain"
+ />
+ {/* The app's own bubble, not `title=`: the native
+ tooltip takes over a second to appear and is drawn
+ in the OS's grey box — a foreign artifact over a
+ rail whose whole point is the title. */}
+ <QuickTooltip
+ content={title}
+ side="right"
+ className="min-w-0 flex-1"
+ >
+ <span
+ data-testid={`chat-rail-title-${term.name}`}
+ className={cn(
+ "block truncate text-[12px]",
+ active ? "text-foreground" : "text-foreground/75",
+ )}
+ >
+ {title}
+ </span>
+ </QuickTooltip>
+ </span>
+ {/* Not "live". Every pane in this list is live, all day —
+ what the user is scanning for is which of them still
+ owes them something. See ./PaneActivityPill. */}
+ <PaneActivityPill
+ status={state.status}
+ detail={state.detail}
+ {...activityOf(term)}
+ />
+ </span>
+ </button>
+ {/*
+ Closing one terminal from the list itself.
+ Chat view hides every pane but the one on the stage, and with
+ it the header that used to be the only place a single
+ terminal could be closed — so the eleven panes you are NOT
+ looking at could only be closed by switching to the grid or
+ by composing a multi-select. This is the row's own button.
+
+ Left out of selection mode on purpose: that mode is here to
+ close SEVERAL, and a per-row close beside a checkbox is two
+ answers to one question.
+ */}
+ {!selectionMode && (
+ <button
+ type="button"
+ data-testid={`chat-rail-close-${term.name}`}
+ disabled={busy || working}
+ onClick={() => setPendingClose(term.name)}
+ title={`Close ${term.name} and stop what is running in it`}
+ aria-label={`Close ${term.name}`}
+ className={cn(
+ "absolute right-1 top-1.5 flex h-5 w-5 items-center justify-center rounded",
+ "text-muted-foreground opacity-0 transition-opacity",
+ "hover:bg-destructive/20 hover:text-destructive",
+ "group-hover:opacity-100 group-focus-within:opacity-100",
+ "focus-visible:opacity-100 disabled:cursor-not-allowed",
+ )}
+ >
+ <X className="h-3.5 w-3.5" />
+ </button>
+ )}
+ </div>
+ );
+ })}
+ </div>
+ </aside>
<div
ref={gridRef}
data-testid="agentic-grid"
@@ -2306,7 +2658,7 @@ export function AgenticGrid({
)}
// Inline rather than a utility class so ONE number drives both the
// rendered outer margin and the width the column count is computed from.
- style={{ padding: GRID_GAP_PX }}
+ style={{ padding: chatView ? 12 : GRID_GAP_PX }}
>
{/*
The surface the fractions resolve against — always exactly the window.
@@ -2326,6 +2678,9 @@ export function AgenticGrid({
{session.terminals.map((term, index) => {
const box = layout.boxes[index];
const isMaximized = maximized === term.name;
+ // The one pane the single-pane view is showing. It stages one and
+ // hides the rest — the others are hidden and NEVER unmounted.
+ const onStage = chatView && chatSelected === term.name;
return (
<div
key={term.key}
@@ -2339,7 +2694,8 @@ export function AgenticGrid({
// imperatively (`paintDraggedLayout`) and must track the
// pointer, not ease after it — and off for the stage/maximize
// style, which swaps to `inset` and cannot tween from here.
- !isMaximized &&
+ !chatView &&
+ !isMaximized &&
!layoutBusy &&
"transition-[left,top,width,height] duration-300 ease-out motion-reduce:transition-none",
/*
@@ -2372,9 +2728,29 @@ export function AgenticGrid({
justMoved?.name === term.name &&
!selectedTerminals.has(term.name) &&
"ring-2 ring-primary/70",
- maximized !== null && !isMaximized && "hidden",
+ chatView
+ ? onStage
+ ? /*
+ * ONE edge per pane, in every view.
+ *
+ * This cell used to add `rounded-xl border border-border`
+ * of its own around a pane that already draws a rounded
+ * border in the TERMINAL's colours — two hairlines, at
+ * two different radii (12 px outside an 8 px corner), so
+ * every corner of the staged pane showed a sliver of app
+ * chrome curving around the pane's own. In grid view the
+ * same pane has a single edge, which is what made the
+ * switch to chat look like a different component rather
+ * than the same one enlarged.
+ *
+ * The lift stays: a staged pane genuinely IS raised above
+ * the rail beside it.
+ */
+ "shadow-lg"
+ : "hidden"
+ : maximized !== null && !isMaximized && "hidden",
)}
- style={isMaximized ? MAXIMIZED_BOX : paneBoxStyle(box)}
+ style={isMaximized || chatView ? MAXIMIZED_BOX : paneBoxStyle(box)}
>
<AgenticTerminal
name={term.name}
@@ -2408,7 +2784,7 @@ export function AgenticGrid({
fontSize={fontSize}
geometryReady={gridMeasured}
focused={target === term.name}
- active
+ active={!chatView || onStage}
maximized={isMaximized}
layoutBusy={layoutBusy}
splitDisabled={atLimit || busy || working}
@@ -2418,9 +2794,17 @@ export function AgenticGrid({
if (takesPrompts(term)) setTarget(term.name);
}}
onStatus={(status, detail) => setStatus(term.name, status, detail)}
- onToggleMaximize={() =>
- setMaximized((current) => (current === term.name ? null : term.name))
- }
+ onToggleMaximize={() => {
+ // On the chat stage the pane already fills the surface, so
+ // "maximize" honestly means "give me the full-width grid
+ // version of this pane".
+ if (chatView) {
+ setViewMode("grid");
+ setMaximized(term.name);
+ } else {
+ setMaximized((current) => (current === term.name ? null : term.name));
+ }
+ }}
onSplit={(direction, agent) => void split(term.name, direction, agent)}
onRename={(next) => renamePane(term, next)}
onClose={() => setPendingClose(term.name)}
@@ -2521,7 +2905,8 @@ export function AgenticGrid({
panes are being selected or dragged (those gestures own the pointer),
and, naturally, when there is only one pane.
*/}
- {maximized === null &&
+ {!chatView &&
+ maximized === null &&
!selectionMode &&
arrange.held === null &&
layout.seams.map((seam) => (
@@ -2578,38 +2963,6 @@ export function AgenticGrid({
/>
)}
</div>
- {/*
- The rail used to carry these two beside "New chat"; with the rail
- gone this is where they live. An emptied workspace is exactly the
- moment somebody wants a DIFFERENT one — quiet links rather than
- buttons, because opening a terminal here is still the answer.
- */}
- {(onNewSession || onAddProject) && (
- <div className="flex items-center gap-4 text-xs">
- {onNewSession && (
- <button
- type="button"
- data-testid="empty-workspace-new-session"
- disabled={busy || working}
- onClick={onNewSession}
- className="text-muted-foreground underline-offset-4 transition-colors hover:text-foreground hover:underline disabled:cursor-not-allowed disabled:opacity-50"
- >
- New session
- </button>
- )}
- {onAddProject && (
- <button
- type="button"
- data-testid="empty-workspace-add-project"
- disabled={busy || working}
- onClick={onAddProject}
- className="text-muted-foreground underline-offset-4 transition-colors hover:text-foreground hover:underline disabled:cursor-not-allowed disabled:opacity-50"
- >
- Add project
- </button>
- )}
- </div>
- )}
</div>
)}
</div>
@@ -2708,177 +3061,6 @@ export function AgenticGrid({
)}
</Dialog.Root>
- {/* ------------------------------------------------- prompt bar + seam */}
- {/*
- The seam replaces the bar's top border, so there is exactly one line
- there — and that line is the control. Hovering it lights it up; dragging
- it up opens the bar to whatever height you pull, and a double-click
- toggles between shut and the designed 176 px.
- */}
- <PaneResizer
- orientation="horizontal"
- onPointerDown={composer.startResize}
- onDoubleClick={toggleComposer}
- onNudge={composer.nudge}
- active={composer.isResizing}
- title={
- composerCollapsed
- ? "Drag up to open the prompt bar — double-click to open it fully"
- : "Drag to resize the prompt bar — double-click to close it, drag all the way down to collapse"
- }
- />
-
- {composerCollapsed && (
- <div
- data-testid="agentic-composer-collapsed"
- style={{ height: COMPOSER_COLLAPSED_PX }}
- className="flex shrink-0 items-center justify-between gap-2 px-3"
- >
- <span className="truncate text-[11px] text-muted-foreground/70">
- {target
- ? `Say it out loud and ${target} gets it.`
- : "Say it out loud and the agents get it."}
- </span>
- <button
- type="button"
- data-testid="agentic-composer-reopen"
- onClick={() => composer.resize(COMPOSER_DEFAULT_PX)}
- className="flex shrink-0 items-center gap-1.5 rounded-control px-2 py-0.5 text-[11px] text-muted-foreground transition-colors hover:bg-secondary hover:text-foreground"
- >
- <ChevronUp className="h-3.5 w-3.5" />
- Write instead
- </button>
- </div>
- )}
- <div
- data-testid={composerCollapsed ? undefined : "agentic-composer"}
- aria-hidden={composerCollapsed || undefined}
- hidden={composerCollapsed}
- style={{ height: composerHeight }}
- {...dragHandlers}
- onPaste={onComposerPaste}
- className={cn(
- /*
- * The height the seam dragged belongs to THIS element; the padding
- * that insets the writing surface from the window edge belongs to
- * it too, so that the surface inside can be `h-full` and the bar
- * still occupies exactly the pixels the seam promised. Putting the
- * inset on the surface as a margin instead would have made the bar
- * 16 px taller than its own stated height — silently, and at the
- * expense of the panes above it.
- */
- "relative shrink-0 flex-col p-2",
- composerCollapsed ? "hidden" : "flex",
- )}
- >
- <div
- className={cn(
- /*
- * ONE surface, and the reason it is one is the reason this bar
- * used to look assembled: a target row, a bordered textarea and a
- * pill button, each with its own edge and its own radius, stacked
- * in a padded strip. Four frames, none of which was the edge of
- * the thing. The border, the radius and the focus treatment now
- * belong to this element alone; everything inside it is bare.
- */
- "relative flex h-full min-h-0 flex-col overflow-hidden rounded-surface border transition-colors",
- "border-border/70 bg-card/40 focus-within:border-primary/40",
- dragging && "border-primary/60 bg-primary/5",
- )}
- >
- {dragging && (
- <div
- data-testid="agentic-composer-dropzone"
- className="pointer-events-none absolute inset-0 z-10 flex items-center justify-center rounded-surface bg-background/85 text-xs font-medium text-primary"
- >
- Drop a screenshot or document — {target || "the agent"} gets what is in it
- </div>
- )}
- {/*
- Which agent hears this — a row of tabs across the head of the
- surface rather than a "Send to" label followed by loose chips.
- The label was answering a question the chips already answer, and
- spending a line of the bar to do it; a selected tab is marked by a
- rule under it, which is the one place in this view where yellow
- still means "this is the choice you made" without shouting it.
-
- Agent panes only. A plain terminal is a shell prompt — it is typed
- into by hand, so listing it here would offer a target that refuses
- every instruction sent to it.
- */}
- {/* One line that scrolls sideways, never two that wrap: a bar whose
- head silently grows a second row takes that row off the panes
- above it, and it did so at exactly the moment a workspace got
- busy enough to need them. */}
- <div className="flex shrink-0 items-stretch gap-0.5 overflow-x-auto border-b border-border/60 px-1.5 scrollbar-jarvis">
- {session.terminals.filter(takesPrompts).map((term) => {
- const state = statusOf(term);
- const picked = target === term.name;
- return (
- <button
- key={term.key}
- type="button"
- data-testid={`prompt-target-${term.name}`}
- onClick={() => setTarget(term.name)}
- aria-pressed={picked}
- className={cn(
- "flex shrink-0 items-center gap-1.5 border-b-2 px-2.5 py-1.5 text-xs transition-colors",
- picked
- ? "border-primary font-medium text-foreground"
- : "border-transparent text-muted-foreground hover:text-foreground",
- )}
- >
- <span>{term.name}</span>
- <PaneActivityPill
- status={state.status}
- detail={state.detail}
- {...activityOf(term)}
- />
- </button>
- );
- })}
- </div>
- {(attachments.length > 0 || analyzing > 0) && (
- <div className="shrink-0 px-2 pt-2">
- <AttachmentStrip
- attachments={attachments}
- analyzing={analyzing}
- onRemove={dropAttachment}
- />
- </div>
- )}
- {composeBeat && (
- <div
- data-testid="agentic-compose-progress"
- className="flex shrink-0 items-center gap-2 px-3 pt-2 text-[11px] text-muted-foreground"
- >
- <Loader2 className="h-3 w-3 shrink-0 animate-spin text-primary" />
- <span className="truncate">{composeBeat.message}</span>
- </div>
- )}
- {/*
- The input takes whatever the seam left over, which is the point of
- dragging it: pull the bar up and you get a real writing surface, not a
- two-line box with empty space under it. Its own resize grip is gone —
- two ways to change one height fight each other.
- */}
- {/*
- No standing "you can also say this out loud" note under the input.
- It was a tip printed permanently into the writing surface, and a tip
- that cannot be dismissed is read once and then occupies the bar
- forever — the collapsed strip already says the same thing in the one
- state where it is news (see `agentic-composer-collapsed`).
- */}
- <PromptEditor
- target={target}
- sending={sending}
- seed={promptSeed}
- onSend={send}
- onAttach={attachFiles}
- />
- </div>
- </div>
-
{/* The pane in hand, following the cursor.
A label rather than a copy of the terminal: an xterm canvas cannot be
cloned without a second WebSocket, and what the user needs to see mid-
@@ -2912,6 +3094,24 @@ export function AgenticGrid({
)}
</div>
)}
+ {railArrange.held !== null && railArrange.point !== null && (
+ <div
+ data-testid="chat-rail-arrange-ghost"
+ className="pointer-events-none fixed z-50 flex items-center gap-1.5 rounded-lg border border-primary/60 bg-card px-2.5 py-1.5 text-xs font-semibold shadow-xl"
+ style={{ left: railArrange.point.x + 14, top: railArrange.point.y + 14 }}
+ >
+ <GripVertical className="h-3.5 w-3.5 text-primary" />
+ {railArrange.held}
+ <span className="font-normal text-muted-foreground">
+ {railArrange.hover === null
+ ? t("agentic_grid.arrange.carrying")
+ : t("agentic_grid.arrange.swap").replace(
+ "{0}",
+ railArrange.hover.target,
+ )}
+ </span>
+ </div>
+ )}
</div>
);
}
@@ -3345,3 +3545,77 @@ function ConfirmClose({
</div>
);
}
+
+/**
+ * One of the rail's standing actions — a word, an icon, a whole row to hit.
+ *
+ * Rows rather than a toolbar of glyphs: these are the three things a person
+ * arrives wanting to do, and each has to be able to say which one it is
+ * without being hovered first.
+ */
+function RailAction({
+ icon: Icon,
+ label,
+ hint,
+ onClick,
+ disabled,
+ testId,
+}: {
+ icon: LucideIcon;
+ label: string;
+ hint?: string;
+ onClick: () => void;
+ disabled?: boolean;
+ testId?: string;
+}) {
+ return (
+ <button
+ type="button"
+ data-testid={testId}
+ onClick={onClick}
+ disabled={disabled}
+ title={hint ?? label}
+ className={cn(
+ "flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-xs font-medium",
+ "text-foreground/85 transition-colors hover:bg-foreground/[0.055]",
+ "disabled:cursor-not-allowed disabled:opacity-40 disabled:hover:bg-transparent",
+ )}
+ >
+ <Icon className="h-3.5 w-3.5 shrink-0 text-muted-foreground" aria-hidden />
+ {label}
+ </button>
+ );
+}
+
+/** A section heading in the rail. Quiet enough to be scanned past. */
+function RailBand({ children }: { children: React.ReactNode }) {
+ return (
+ <div className="px-2 pb-1 pt-3 text-[10px] font-medium uppercase tracking-wider text-muted-foreground/60">
+ {children}
+ </div>
+ );
+}
+
+/**
+ * A stable colour for a folder, so the same project reads the same everywhere.
+ *
+ * Derived from the path rather than stored, which means it needs no setting and
+ * survives a lost store. The palette is fixed rather than a free hue rotation:
+ * arbitrary HSL produces colours that vanish against one of the two themes.
+ */
+const FOLDER_COLORS = [
+ "#e7c46e",
+ "#7dd3fc",
+ "#a5b4fc",
+ "#86efac",
+ "#fca5a5",
+ "#f0abfc",
+ "#fdba74",
+ "#5eead4",
+] as const;
+
+function folderColor(key: string): string {
+ let sum = 0;
+ for (const char of key) sum = (sum + char.charCodeAt(0)) % 4096;
+ return FOLDER_COLORS[sum % FOLDER_COLORS.length];
+}
diff --git a/jarvis/ui/web/frontend/src/components/agentic/PromptAttachments.test.ts b/jarvis/ui/web/frontend/src/components/agentic/PromptAttachments.test.ts
deleted file mode 100644
index 4eac17b8a1..0000000000
--- a/jarvis/ui/web/frontend/src/components/agentic/PromptAttachments.test.ts
+++ /dev/null
@@ -1,194 +0,0 @@
-import { act, renderHook, waitFor } from "@testing-library/react";
-import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
-
-import { usePromptAttachments } from "@/components/agentic/PromptAttachments";
-import * as api from "@/lib/agenticIdeApi";
-import { NATIVE_DROP_EVENT } from "@/lib/nativeDrop";
-
-/**
- * Holding a file for an agent's next instruction.
- *
- * The case worth a test of its own is the desktop shell's: a file dragged out
- * of Explorer reaches the page as BYTES with no path, and the host reports the
- * real location a moment later. Attaching the bytes anyway would hand the agent
- * a copy in `.jarvis/drops` — it would answer about a file the user cannot see
- * and cannot have edited, which looks exactly like the agent ignoring them.
- */
-
-vi.mock("@/lib/agenticIdeApi", () => ({ attachToTerminal: vi.fn() }));
-
-const analysed = (name: string) => ({
- name,
- reference: `@${name}`,
- kind: "image" as const,
- detail: "a screenshot",
- described_by: "vision" as const,
- note: "",
-});
-
-function reply(names: string[]) {
- return {
- terminal: "T1",
- references: [],
- files: [],
- copied: 0,
- submitted: false,
- delivered: false,
- analysis: names.map(analysed),
- };
-}
-
-/** A drag out of Explorer as the desktop shell delivers it: bytes, no path. */
-function bytesOnly(file: File): DataTransfer {
- return {
- types: ["Files"],
- files: [file],
- items: [],
- getData: () => "",
- dropEffect: "none",
- } as unknown as DataTransfer;
-}
-
-/** Pretend to be the pywebview shell, which answers a drop it has resolved. */
-function shellAnswers(detail: { paths: string[]; names: string[] } | null) {
- (window as unknown as { pywebview?: unknown }).pywebview = {};
- if (detail === null) return;
- queueMicrotask(() =>
- window.dispatchEvent(new CustomEvent(NATIVE_DROP_EVENT, { detail })),
- );
-}
-
-describe("usePromptAttachments", () => {
- beforeEach(() => {
- vi.clearAllMocks();
- vi.mocked(api.attachToTerminal).mockResolvedValue(reply(["shot.png"]));
- });
-
- afterEach(() => {
- delete (window as unknown as { pywebview?: unknown }).pywebview;
- });
-
- it("attaches a browser drop as bytes — outside the shell there is no path", async () => {
- const problem = vi.fn();
- const { result } = renderHook(() => usePromptAttachments("T1", problem));
-
- act(() => {
- result.current.dragHandlers.onDrop({
- preventDefault: () => {},
- dataTransfer: bytesOnly(new File(["x"], "shot.png", { type: "image/png" })),
- } as never);
- });
-
- await waitFor(() => expect(api.attachToTerminal).toHaveBeenCalled());
- const [, payload] = vi.mocked(api.attachToTerminal).mock.calls[0];
- expect(payload.files?.map((f) => f.name)).toEqual(["shot.png"]);
- expect(payload.paths ?? []).toEqual([]);
- // Held for the message being written, and read so a text-only CLI can
- // still be told what is in the picture.
- expect(payload).toMatchObject({ analyze: true, deliver: false });
- expect(problem).not.toHaveBeenCalled();
- });
-
- it("prefers the path the desktop shell reports over uploading the same bytes", async () => {
- shellAnswers({ paths: ["C:\\work\\app\\src\\main.ts"], names: ["main.ts"] });
- const { result } = renderHook(() => usePromptAttachments("T1", vi.fn()));
-
- act(() => {
- result.current.dragHandlers.onDrop({
- preventDefault: () => {},
- dataTransfer: bytesOnly(new File(["x"], "main.ts", { type: "text/plain" })),
- } as never);
- });
-
- await waitFor(() => expect(api.attachToTerminal).toHaveBeenCalled());
- const [, payload] = vi.mocked(api.attachToTerminal).mock.calls[0];
- expect(payload.paths).toEqual(["C:\\work\\app\\src\\main.ts"]);
- // The byte copy of the very same file is dropped, or the agent would be
- // handed the file twice — once where it lives and once as a copy.
- expect(payload.files ?? []).toEqual([]);
- });
-
- it("still attaches the bytes when the shell resolves nothing", async () => {
- shellAnswers(null); // in the shell, but no answer for this drop
- const { result } = renderHook(() => usePromptAttachments("T1", vi.fn()));
-
- act(() => {
- result.current.dragHandlers.onDrop({
- preventDefault: () => {},
- dataTransfer: bytesOnly(new File(["x"], "shot.png", { type: "image/png" })),
- } as never);
- });
-
- await waitFor(() => expect(api.attachToTerminal).toHaveBeenCalled(), { timeout: 4000 });
- const [, payload] = vi.mocked(api.attachToTerminal).mock.calls[0];
- expect(payload.files?.map((f) => f.name)).toEqual(["shot.png"]);
- });
-
- it("renames a pasted screenshot and leaves pasted text alone", async () => {
- const { result } = renderHook(() => usePromptAttachments("T1", vi.fn()));
-
- act(() => {
- result.current.onPaste({
- preventDefault: () => {},
- clipboardData: { items: [], types: ["text/plain"], files: [] },
- } as never);
- });
- expect(api.attachToTerminal).not.toHaveBeenCalled();
-
- const image = new File(["png"], "image.png", { type: "image/png" });
- act(() => {
- result.current.onPaste({
- preventDefault: () => {},
- clipboardData: { items: [{ kind: "file", getAsFile: () => image }] },
- } as never);
- });
-
- await waitFor(() => expect(api.attachToTerminal).toHaveBeenCalled());
- const [, payload] = vi.mocked(api.attachToTerminal).mock.calls[0];
- // Every clipboard calls its image `image.png`; two screenshots must not
- // arrive under one name.
- expect(payload.files?.[0].name).not.toBe("image.png");
- expect(payload.files?.[0].name).toContain("t1-paste-");
- });
-
- it("holds the same file once, however often it is dropped", async () => {
- const { result } = renderHook(() => usePromptAttachments("T1", vi.fn()));
-
- for (let i = 0; i < 2; i += 1) {
- act(() => {
- result.current.attachFiles([new File(["x"], "shot.png", { type: "image/png" })]);
- });
- await waitFor(() => expect(result.current.attachments).toHaveLength(1));
- }
- expect(api.attachToTerminal).toHaveBeenCalledTimes(2);
- // Two attempts, one chip: a repeated reference has the agent read the same
- // file twice for nothing.
- expect(result.current.attachments.map((a) => a.name)).toEqual(["shot.png"]);
- });
-
- it("tells a failure apart from a drop that carried nothing", async () => {
- const problem = vi.fn();
- const { result } = renderHook(() => usePromptAttachments("T1", problem));
-
- vi.mocked(api.attachToTerminal).mockResolvedValueOnce(reply([]));
- act(() => result.current.attachFiles([new File(["x"], "empty.bin")]));
- await waitFor(() => expect(problem).toHaveBeenCalled());
- expect(problem.mock.calls[0][1]).toBe("warning");
-
- vi.mocked(api.attachToTerminal).mockRejectedValueOnce(new Error("pane is gone"));
- act(() => result.current.attachFiles([new File(["x"], "again.bin")]));
- await waitFor(() => expect(problem).toHaveBeenCalledTimes(2));
- expect(problem.mock.calls[1]).toEqual(["pane is gone", "error"]);
- });
-
- it("refuses a drop with no session picked instead of swallowing it", async () => {
- const problem = vi.fn();
- const { result } = renderHook(() => usePromptAttachments("", problem));
-
- act(() => result.current.attachFiles([new File(["x"], "shot.png")]));
-
- await waitFor(() => expect(problem).toHaveBeenCalled());
- expect(problem.mock.calls[0][1]).toBe("warning");
- expect(api.attachToTerminal).not.toHaveBeenCalled();
- });
-});
diff --git a/jarvis/ui/web/frontend/src/components/agentic/PromptAttachments.tsx b/jarvis/ui/web/frontend/src/components/agentic/PromptAttachments.tsx
deleted file mode 100644
index 5165e1b913..0000000000
--- a/jarvis/ui/web/frontend/src/components/agentic/PromptAttachments.tsx
+++ /dev/null
@@ -1,254 +0,0 @@
-/**
- * Files going in with the next instruction — the drop, the paste, and the strip
- * of chips that shows what is waiting.
- *
- * Extracted from the grid's composer so every surface that writes to an agent
- * behaves the same. A drop that works in one place and does nothing one click
- * away is read as the app being broken, not as two surfaces with different
- * features (maintainer, 2026-08-24) — and this repo has had two such surfaces
- * more than once.
- *
- * The desktop shell is why the drop handler is not three lines. Inside it a
- * dragged file usually arrives with NO path — the page is handed bytes and a
- * name, by design — while the host process can see where the file really lies
- * and reports it a moment later (jarvis/ui/native_drop.py). Waiting for that
- * answer is the difference between the agent opening the user's own file and
- * the agent opening a copy of it that nothing else knows about.
- *
- * What a drop DOES here is deliberately not what a drop on a terminal pane
- * does. The pane types a path, which is right for "read this file". A prompt
- * bar holds the file instead, has it READ — an image described, a document
- * extracted — and sends that along with the sentence being typed. Several
- * coding CLIs cannot open an image at all, so without the description the user
- * drops a picture of a broken layout, types "fix this", and the agent receives
- * a path and a pronoun.
- */
-import { useCallback, useState } from "react";
-import { FileText, ImageIcon, Loader2, X } from "lucide-react";
-
-import { usePaneFileDrag } from "@/components/agentic/paneFileDrag";
-import {
- extractPaneDrop,
- extractPasteFiles,
- isEmptyPayload,
- nameClipboardFile,
- type PaneDropPayload,
-} from "@/components/agentic/paneDrop";
-import { waitForNativeDrop } from "@/lib/nativeDrop";
-import { attachToTerminal, type DropAttachment } from "@/lib/agenticIdeApi";
-import { cn } from "@/lib/utils";
-
-export interface PromptAttachments {
- /** What will travel with the next instruction. */
- attachments: DropAttachment[];
- /** How many files are being read right now — 0 when nothing is in flight. */
- analyzing: number;
- /** True while a file drag hovers the surface; drives the drop styling. */
- dragging: boolean;
- /** Spread onto the element that should accept drops. */
- dragHandlers: ReturnType<typeof usePaneFileDrag>["handlers"];
- /** Attach files chosen by hand (the paperclip) or read off the clipboard. */
- attachFiles: (files: File[]) => void;
- /** Put on the element that should take pasted images; text paste is left alone. */
- onPaste: (event: React.ClipboardEvent) => void;
- remove: (name: string) => void;
- clear: () => void;
-}
-
-/**
- * Hold files for one agent's next instruction.
- *
- * `target` is the pane's call-sign; with none, a drop is refused through
- * `onProblem` rather than silently swallowed. `onProblem` is where the caller
- * puts its own toast or inline error — this hook does not decide how a surface
- * reports things. It DOES decide how bad the news is, and the two are not the
- * same: a drop that carried nothing usable is a warning about what was
- * dragged, while an attach that threw is an error about the app. Collapsing
- * them into one level buries the second.
- */
-export function usePromptAttachments(
- target: string,
- onProblem: (message: string, severity: "warning" | "error") => void,
-): PromptAttachments {
- const [attachments, setAttachments] = useState<DropAttachment[]>([]);
- const [analyzing, setAnalyzing] = useState(0);
-
- const attach = useCallback(
- async (payload: PaneDropPayload) => {
- if (isEmptyPayload(payload)) return;
- if (!target) {
- onProblem("Pick a session first — a dropped file belongs to one.", "warning");
- return;
- }
- setAnalyzing((n) => n + 1);
- try {
- const result = await attachToTerminal(target, {
- ...payload,
- analyze: true,
- // Held, not typed: the user is still writing the sentence that says
- // what to do with the file, and it goes in with that sentence.
- deliver: false,
- });
- const found = result.analysis ?? [];
- if (found.length === 0) {
- onProblem("That drop carried nothing this prompt could use.", "warning");
- return;
- }
- // Keyed by name so the same file dropped twice is held once — a
- // repeated reference has the agent read it again for nothing.
- setAttachments((prev) => [
- ...prev,
- ...found.filter((item) => !prev.some((held) => held.name === item.name)),
- ]);
- } catch (e) {
- onProblem((e as Error).message, "error");
- } finally {
- setAnalyzing((n) => Math.max(0, n - 1));
- }
- },
- [target, onProblem],
- );
-
- const { dragging, handlers: dragHandlers } = usePaneFileDrag(
- useCallback(
- (dt: DataTransfer) => {
- // Both reads happen BEFORE any await, and they have to: a DataTransfer
- // empties the moment this handler returns, and the desktop shell only
- // answers a listener that was already in place when the drop happened.
- const payload = extractPaneDrop(dt);
- void waitForNativeDrop().then((detail) => {
- if (!detail?.paths.length) return void attach(payload);
- // Inside the desktop shell the host knows where the file really
- // lies. Prefer that over uploading its bytes — same file, no copy —
- // and drop the byte copies the shell just accounted for so nothing
- // is attached twice.
- const named = new Set(detail.names.map((n) => n.toLowerCase()));
- return void attach({
- paths: Array.from(new Set([...payload.paths, ...detail.paths])),
- files: payload.files.filter((f) => !named.has(f.name.toLowerCase())),
- });
- });
- },
- [attach],
- ),
- );
-
- const attachFiles = useCallback(
- (files: File[]) => {
- if (files.length > 0) void attach({ paths: [], files });
- },
- [attach],
- );
-
- const onPaste = useCallback(
- (event: React.ClipboardEvent) => {
- // Text paste belongs to the browser and must keep working — this only
- // claims what a text box would otherwise discard: an IMAGE on the
- // clipboard, which is what PrintScreen and Ctrl+V produce.
- const files = extractPasteFiles(event.clipboardData).map((f) =>
- nameClipboardFile(f, target || "chat"),
- );
- if (files.length === 0) return;
- event.preventDefault();
- void attach({ paths: [], files });
- },
- [attach, target],
- );
-
- const remove = useCallback((name: string) => {
- setAttachments((prev) => prev.filter((a) => a.name !== name));
- }, []);
-
- const clear = useCallback(() => setAttachments([]), []);
-
- return {
- attachments,
- analyzing,
- dragging,
- dragHandlers,
- attachFiles,
- onPaste,
- remove,
- clear,
- };
-}
-
-/**
- * The files waiting to go in with the next prompt.
- *
- * Each chip says what was actually LEARNED from the file, not just that one was
- * attached. That distinction is the whole feature: "screenshot.png" tells the
- * user nothing about whether the agent will be able to see it, while "described"
- * and "not described" are the two outcomes they need to be able to tell apart
- * before they press Send — and the second one happens for real, on any install
- * whose providers cannot see images.
- */
-export function AttachmentStrip({
- attachments,
- analyzing,
- onRemove,
-}: {
- attachments: DropAttachment[];
- analyzing: number;
- onRemove: (name: string) => void;
-}) {
- return (
- <div
- data-testid="agentic-attachments"
- className="mb-2 flex max-h-20 shrink-0 flex-wrap items-center gap-1.5 overflow-y-auto scrollbar-jarvis"
- >
- {attachments.map((item) => {
- const read = item.described_by !== "none" && item.detail.length > 0;
- return (
- <span
- key={item.name}
- data-testid={`agentic-attachment-${item.name}`}
- title={
- read
- ? `${item.detail.slice(0, 400)}${item.detail.length > 400 ? "…" : ""}`
- : item.note || "Attached as a file."
- }
- className={cn(
- "flex items-center gap-1.5 rounded-md border px-2 py-1 text-[11px]",
- read
- ? "border-primary/40 bg-primary/10 text-foreground"
- : "border-border text-muted-foreground",
- )}
- >
- {item.kind === "image" ? (
- <ImageIcon className="h-3 w-3 shrink-0" />
- ) : (
- <FileText className="h-3 w-3 shrink-0" />
- )}
- <span className="max-w-[12rem] truncate font-mono">{item.name}</span>
- <span className="shrink-0 text-[10px] text-muted-foreground">
- {read
- ? item.described_by === "vision"
- ? "described"
- : "text read"
- : "not described"}
- </span>
- <button
- type="button"
- aria-label={`Remove ${item.name}`}
- data-testid={`agentic-attachment-remove-${item.name}`}
- onClick={() => onRemove(item.name)}
- className="shrink-0 rounded text-muted-foreground hover:text-destructive"
- >
- <X className="h-3 w-3" />
- </button>
- </span>
- );
- })}
- {analyzing > 0 && (
- <span
- data-testid="agentic-attachment-working"
- className="flex items-center gap-1.5 rounded-md border border-dashed border-border px-2 py-1 text-[11px] text-muted-foreground"
- >
- <Loader2 className="h-3 w-3 animate-spin" />
- Reading {analyzing === 1 ? "the dropped file" : `${analyzing} dropped files`}…
- </span>
- )}
- </div>
- );
-}
diff --git a/jarvis/ui/web/frontend/src/components/agentic/PromptEditor.test.tsx b/jarvis/ui/web/frontend/src/components/agentic/PromptEditor.test.tsx
deleted file mode 100644
index fe5718ea21..0000000000
--- a/jarvis/ui/web/frontend/src/components/agentic/PromptEditor.test.tsx
+++ /dev/null
@@ -1,76 +0,0 @@
-import { fireEvent, render, screen } from "@testing-library/react";
-import { describe, expect, it, vi } from "vitest";
-import { PromptEditor } from "./PromptEditor";
-
-describe("PromptEditor", () => {
- it("keeps ordinary typing local and sends the draft on Enter", () => {
- const onSend = vi.fn(async () => undefined);
- let parentRenders = 0;
- function Parent() {
- parentRenders += 1;
- return (
- <PromptEditor
- target="Nova"
- sending={false}
- seed={{ value: "", revision: 0 }}
- onSend={onSend}
- />
- );
- }
- render(<Parent />);
- const editor = screen.getByLabelText("Instruction for Nova");
-
- fireEvent.change(editor, { target: { value: "Run the tests" } });
- expect(parentRenders).toBe(1);
- fireEvent.keyDown(editor, { key: "Enter" });
-
- expect(onSend).toHaveBeenCalledWith("Run the tests");
- });
-
- it("replaces the draft only when the reset revision changes", () => {
- const onSend = vi.fn(async () => undefined);
- const view = render(
- <PromptEditor
- target="Nova"
- sending={false}
- seed={{ value: "old", revision: 0 }}
- onSend={onSend}
- />,
- );
- fireEvent.change(screen.getByLabelText("Instruction for Nova"), {
- target: { value: "local edit" },
- });
-
- view.rerender(
- <PromptEditor
- target="Nova"
- sending={false}
- seed={{ value: "restored", revision: 1 }}
- onSend={onSend}
- />,
- );
-
- expect((screen.getByLabelText("Instruction for Nova") as HTMLTextAreaElement).value).toBe(
- "restored",
- );
- });
-
- it("does not send an unfinished IME composition", () => {
- const onSend = vi.fn(async () => undefined);
- render(
- <PromptEditor
- target="Nova"
- sending={false}
- seed={{ value: "draft", revision: 0 }}
- onSend={onSend}
- />,
- );
-
- fireEvent.keyDown(screen.getByLabelText("Instruction for Nova"), {
- key: "Enter",
- isComposing: true,
- });
-
- expect(onSend).not.toHaveBeenCalled();
- });
-});
diff --git a/jarvis/ui/web/frontend/src/components/agentic/PromptEditor.tsx b/jarvis/ui/web/frontend/src/components/agentic/PromptEditor.tsx
deleted file mode 100644
index 34dd928a2f..0000000000
--- a/jarvis/ui/web/frontend/src/components/agentic/PromptEditor.tsx
+++ /dev/null
@@ -1,153 +0,0 @@
-import { useLayoutEffect, useRef, useState } from "react";
-import { ArrowUp, Loader2, Paperclip } from "lucide-react";
-import { cn } from "@/lib/utils";
-
-export interface PromptSeed {
- value: string;
- revision: number;
-}
-
-/**
- * The hot typing path, isolated from the terminal wall around it.
- *
- * A workspace may hold dozens of xterm canvases. Keeping the draft in the
- * grid made every character reconcile all of them, so composer lag grew with
- * the number of sessions. Only intentional resets travel down from the grid;
- * ordinary keystrokes stay in this small component.
- *
- * ## Shape
- *
- * The editor is the BODY of the composer surface, not a boxed control sitting
- * inside one: the border, the radius and the focus treatment belong to the
- * surface (see the composer in AgenticGrid), so what is drawn here is a bare
- * writing area with one row of controls under it. A field with its own border
- * inside a bordered panel is the single most reliable way to make an interface
- * read as assembled rather than designed — two frames, 4 px apart, neither of
- * which is the edge of anything.
- *
- * The placeholder names the target and stops there. It used to carry the
- * keyboard contract as well ("Enter sends, Shift+Enter adds a line"), which put
- * a permanent instruction manual in the largest empty area on screen; that
- * contract now lives in the footer, at label size, where it is available
- * without being the loudest text in the view.
- */
-export function PromptEditor({
- target,
- sending,
- seed,
- onSend,
- onAttach,
-}: {
- target: string;
- sending: boolean;
- seed: PromptSeed;
- onSend: (draft: string) => Promise<void>;
- /**
- * Pick files by hand, for the people who do not drag them.
- *
- * Optional: dropping and pasting are the primary paths and neither needs
- * this, so a caller that has no attachment pipeline simply gets no button
- * rather than a dead one.
- */
- onAttach?: (files: File[]) => void;
-}) {
- const [value, setValue] = useState(seed.value);
- const fileRef = useRef<HTMLInputElement>(null);
- useLayoutEffect(() => setValue(seed.value), [seed.revision, seed.value]);
- const ready = Boolean(target) && !sending && value.trim().length > 0;
- const submit = () => {
- if (!ready) return;
- void onSend(value);
- };
-
- return (
- <div className="flex min-h-0 flex-1 flex-col gap-1.5">
- <textarea
- name="agent-instruction"
- aria-label={target ? `Instruction for ${target}` : "Agent instruction"}
- value={value}
- onChange={(event) => setValue(event.target.value)}
- onKeyDown={(event) => {
- if (event.key === "Enter" && !event.shiftKey && !event.nativeEvent.isComposing) {
- event.preventDefault();
- submit();
- }
- }}
- placeholder={target ? `Message ${target}` : "Pick a terminal first"}
- className={
- "min-h-0 w-full flex-1 resize-none bg-transparent px-3 pt-2.5 text-sm leading-relaxed " +
- "text-foreground outline-none placeholder:text-muted-foreground/60"
- }
- />
- <div className="flex shrink-0 items-center gap-2 px-2 pb-2">
- {onAttach && (
- <>
- <input
- ref={fileRef}
- type="file"
- multiple
- className="sr-only"
- tabIndex={-1}
- onChange={(event) => {
- const files = Array.from(event.currentTarget.files ?? []);
- event.currentTarget.value = "";
- if (files.length > 0) onAttach(files);
- }}
- />
- <button
- type="button"
- data-testid="agentic-composer-attach"
- aria-label="Attach files to this instruction"
- title="Attach files — you can also drop or paste them here"
- disabled={!target}
- onClick={() => fileRef.current?.click()}
- className={
- "flex h-7 w-7 shrink-0 items-center justify-center rounded-control " +
- "text-muted-foreground transition-colors hover:bg-secondary hover:text-foreground " +
- "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60 " +
- "disabled:cursor-not-allowed disabled:opacity-40"
- }
- >
- <Paperclip className="h-3.5 w-3.5" />
- </button>
- </>
- )}
- {/* The keyboard contract, at the weight of a footnote. Hidden on a
- narrow window before anything that can be clicked is: it is the one
- thing in this row a reader can do without. */}
- <span className="ml-auto hidden shrink-0 items-center gap-2 text-[11px] text-muted-foreground/70 sm:flex">
- <kbd className="rounded border border-border/80 px-1 font-sans text-[10px]">
- ↵
- </kbd>
- send
- <kbd className="rounded border border-border/80 px-1 font-sans text-[10px]">
- ⇧↵
- </kbd>
- new line
- </span>
- <button
- type="button"
- aria-label={sending ? "Preparing the instruction" : "Send the instruction"}
- title={sending ? "Preparing the instruction…" : "Send"}
- className={cn(
- "ml-auto flex h-7 w-7 shrink-0 items-center justify-center rounded-control",
- "transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",
- "sm:ml-0",
- ready
- ? "bg-primary text-primary-foreground hover:bg-primary/90"
- : "bg-secondary text-muted-foreground/60",
- !ready && "cursor-not-allowed",
- )}
- disabled={!ready}
- onClick={submit}
- >
- {sending ? (
- <Loader2 className="h-3.5 w-3.5 animate-spin" />
- ) : (
- <ArrowUp className="h-3.5 w-3.5" />
- )}
- </button>
- </div>
- </div>
- );
-}
diff --git a/jarvis/ui/web/frontend/src/views/AgenticIdeView.test.tsx b/jarvis/ui/web/frontend/src/views/AgenticIdeView.test.tsx
index a51789d49c..9621fbf74b 100644
--- a/jarvis/ui/web/frontend/src/views/AgenticIdeView.test.tsx
+++ b/jarvis/ui/web/frontend/src/views/AgenticIdeView.test.tsx
@@ -42,21 +42,10 @@ const launcherEnglish = vi.hoisted<Record<string, string>>(() => ({
}));
vi.mock("@/i18n", () => ({
useT: () => (key: string) => launcherEnglish[key] ?? key,
- // The chat surface's greeting fills a placeholder in its own string.
- fill: (text: string, values: Record<string, string>) =>
- Object.entries(values).reduce(
- (out, [name, value]) => out.replaceAll(`{${name}}`, value),
- text,
- ),
}));
// The workspace grid follows the app theme for its terminal colours; this test
// renders the view outside the provider, so the hook is stubbed.
-// The chat surface greets by name, and the name comes from a react-query
-// read of the profile. This view is rendered bare here, with no provider —
-// no name is a state the greeting already handles.
-vi.mock("@/hooks/useUserName", () => ({ useUserName: () => null }));
-
vi.mock("@/hooks/useTheme", () => ({
useTheme: () => ({ theme: "dark", setTheme: vi.fn(), toggle: vi.fn() }),
useThemeValue: () => "dark",
@@ -150,7 +139,6 @@ import { AgenticIdeView } from "./AgenticIdeView";
import { workspaceLaunchShortcut } from "@/components/agentic/WorkspaceLauncher";
import * as api from "@/lib/agenticIdeApi";
import { GRID_HORIZONTAL_PADDING_PX } from "@/components/agentic/layout";
-import { useIdeChatStore } from "@/store/ideChat";
const AGENTS: api.AgentsResponse = {
terminal_available: true,
@@ -309,16 +297,10 @@ function sessionWith(names: string[], focus = false): api.SessionState {
}
beforeEach(() => {
- // A workspace now opens with its prompt bar collapsed — the panes are what
- // the user came for. The tests below that type an instruction want it open,
- // and the remembered height is how a user who wants it open gets it.
- window.localStorage.setItem("jarvis.agenticIde.composerHeight.v2", "176");
// The wizard's view step preselects the remembered reading mode, and the
- // open workspace reads the same answer — a value left behind by one test
- // must not decide how the next one's workspace opens. The store is a module
- // singleton, so the key alone is not enough: reset the live state too.
+ // grid reads the same key on mount — a value left behind by one test must
+ // not decide how the next one's workspace opens.
window.localStorage.removeItem("jarvis.agenticIde.workspaceView");
- useIdeChatStore.setState({ view: "grid", workspace: null, sidebarFace: "chats" });
vi.mocked(api.fetchIdeAgents).mockResolvedValue(AGENTS);
vi.mocked(api.fetchIdeState).mockResolvedValue(EMPTY_STATE);
vi.mocked(api.fetchFolders).mockResolvedValue({
@@ -524,14 +506,15 @@ describe("Agentic IDE launcher", () => {
expect(screen.getByTestId("review-view-mode").textContent).toBe("Chat");
fireEvent.click(screen.getByRole("button", { name: /open workspace/i }));
- // The workspace comes up on the CHAT surface — the agent chat in this
- // folder — while every terminal stays mounted behind it.
- expect(await screen.findByTestId("ide-chat-surface")).toBeTruthy();
+ // The grid reads the stored preference on mount, so the workspace comes up
+ // with the chat rail showing instead of the wall of terminals.
+ expect(await screen.findByTestId("pane-Mika")).toBeTruthy();
expect(
window.localStorage.getItem("jarvis.agenticIde.workspaceView"),
).toBe("chat");
- expect(screen.getByTestId("pane-Mika")).toBeTruthy();
- expect(screen.getByTestId("agentic-grid-layer").className).toContain("opacity-0");
+ const rail = screen.getByTestId("agentic-chat-rail");
+ expect(rail.className).toContain("flex");
+ expect(rail.className).not.toContain("hidden");
});
it("keeps every reading-mode miniature visible on the dark workspace", async () => {
@@ -831,63 +814,6 @@ describe("Agentic IDE running workspace", () => {
expect(screen.queryByTestId("workspace-launcher")).toBeNull();
});
- it("offers no surface switch while the wizard is the screen", async () => {
- // Nothing is open, so neither surface has anything to show — and a
- // control that changes nothing visible reads as broken.
- render(<AgenticIdeView />);
- await waitFor(() => expect(api.fetchIdeAgents).toHaveBeenCalled());
-
- expect(screen.queryByTestId("agentic-view-switch")).toBeNull();
- });
-
- it("switches between the chat and the grid from one control in the bar", async () => {
- vi.mocked(api.fetchIdeState).mockResolvedValue(
- stateWith(sessionWith(["Mika"])),
- );
- render(<AgenticIdeView />);
- await screen.findByTestId("pane-Mika");
- expect(screen.queryByTestId("ide-chat-surface")).toBeNull();
-
- fireEvent.click(screen.getByTestId("agentic-view-mode-toggle"));
- expect(await screen.findByTestId("ide-chat-surface")).toBeTruthy();
- // The switch has to be reachable from the surface it switched TO, or
- // pressing "Chat" would take the way back off screen with it.
- fireEvent.click(screen.getByTestId("agentic-view-mode-grid"));
- expect(screen.queryByTestId("ide-chat-surface")).toBeNull();
- });
-
- it("covers the panes for the chat instead of unmounting them", async () => {
- // The one rule this pair of surfaces must not break: every pane is a live
- // coding agent, and unmounting one kills it.
- vi.mocked(api.fetchIdeState).mockResolvedValue(
- stateWith(sessionWith(["Mika", "Nova"])),
- );
- render(<AgenticIdeView />);
- const mika = await screen.findByTestId("pane-Mika");
-
- fireEvent.click(screen.getByTestId("agentic-view-mode-toggle"));
- await screen.findByTestId("ide-chat-surface");
- expect(screen.getByTestId("pane-Mika")).toBe(mika);
- expect(screen.getByTestId("agentic-grid-layer").className).toContain("opacity-0");
-
- fireEvent.click(screen.getByTestId("agentic-view-mode-grid"));
- expect(screen.getByTestId("pane-Mika")).toBe(mika);
- expect(screen.getByTestId("agentic-grid-layer").className).not.toContain("opacity-0");
- });
-
- it("runs the chat in the folder of the workspace that is open", async () => {
- vi.mocked(api.fetchIdeState).mockResolvedValue(
- stateWith(sessionWith(["Mika"])),
- );
- render(<AgenticIdeView />);
- await screen.findByTestId("pane-Mika");
-
- fireEvent.click(screen.getByTestId("agentic-view-mode-toggle"));
-
- const surface = await screen.findByTestId("ide-chat-surface");
- expect(surface.dataset.folder).toBe("/work/project");
- });
-
it("toggles focus mode through the API, not just locally", async () => {
vi.mocked(api.fetchIdeState).mockResolvedValue(
stateWith(sessionWith(["Mika"])),
@@ -980,58 +906,6 @@ describe("Agentic IDE running workspace", () => {
);
});
- it("sends a prompt to the selected terminal through the same endpoint voice uses", async () => {
- vi.mocked(api.fetchIdeState).mockResolvedValue(
- stateWith(sessionWith(["Mika", "Nova"])),
- );
- vi.mocked(api.promptTerminal).mockResolvedValue({
- terminal: "Mika",
- sent: "run the tests",
- composed_by: "raw",
- files: [],
- submitted: true,
- });
- render(<AgenticIdeView />);
-
- await screen.findByTestId("pane-Mika");
- const box = screen.getByLabelText(/instruction for mika/i);
- fireEvent.change(box, { target: { value: "run the tests" } });
- fireEvent.click(screen.getByRole("button", { name: /send/i }));
-
- await waitFor(() =>
- // ``compose`` is what makes this the same endpoint the spoken
- // "prompt Mika …" uses: the backend briefs the instruction and types
- // THAT into the pane. The third argument also carries files dropped on
- // the prompt bar — empty here, because nothing was attached.
- expect(api.promptTerminal).toHaveBeenCalledWith("Mika", "run the tests", {
- compose: true,
- attachments: [],
- }),
- );
- });
-
- it("reports a refused prompt instead of pretending it landed", async () => {
- vi.mocked(api.fetchIdeState).mockResolvedValue(
- stateWith(sessionWith(["Mika"])),
- );
- vi.mocked(api.promptTerminal).mockRejectedValue(
- new Error("Mika is not running right now"),
- );
- render(<AgenticIdeView />);
-
- await screen.findByTestId("pane-Mika");
- fireEvent.change(screen.getByLabelText(/instruction for/i), {
- target: { value: "hello" },
- });
- fireEvent.click(screen.getByRole("button", { name: /send/i }));
-
- await waitFor(() =>
- expect(pushToast).toHaveBeenCalledWith(
- "error",
- "Mika is not running right now",
- ),
- );
- });
it("shows panes that voice opened, without a reload", async () => {
/*
* The regression this guards: a spoken "spawn three more terminals" adds the