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.

fix(agentic-ide): stop a maximized pane leaving its terminal in the old cell

Ruben Lütkee795e6ff311e
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 a5fba39000..544bf00335 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.test.tsx
@@ -437,6 +437,21 @@ describe("grid layout", () => {
// the workspace is blank.
expect(cellStyle("T3")).toContain("grid-column: 1 / -1");
expect(cellStyle("T3")).toContain("grid-row: 1 / -1");
+ // ...and the grid it now spans is ONE track filling the window, not the
+ // twelve-pane template. Spanning that template made the maximized pane
+ // taller than the visible area in any workspace big enough to scroll, so
+ // the terminal fitted itself to rows below the clip — which is where the
+ // CLI keeps its prompt box.
+ expect(gridEl().style.gridTemplateRows).toBe("minmax(0, 1fr)");
+ expect(gridEl().style.gridTemplateColumns).toBe("minmax(0, 1fr)");
+ });
+
+ it("gives the tracks back when the pane is restored", () => {
+ const panes = Array.from({ length: 12 }, (_, i) => [`T${i + 1}`, i] as [string, number]);
+ renderGrid(sessionWith(panes));
+ fireEvent.click(screen.getByTestId("pane-maximize-T3"));
+ fireEvent.click(screen.getByTestId("pane-maximize-T3"));
+ expect(gridEl().style.gridTemplateColumns).toBe("repeat(6, minmax(0, 1fr))");
});
});
diff --git a/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.tsx b/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.tsx
index cff7c3deec..acfdbecb15 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.tsx
@@ -854,12 +854,26 @@ export function AgenticGrid({
maximized !== null ? "overflow-hidden" : "overflow-y-auto scrollbar-jarvis",
)}
style={{
- gridTemplateColumns: `repeat(${Math.max(1, grid.columns)}, minmax(0, 1fr))`,
+ // While one pane is maximized the grid IS that pane: a single track
+ // filling exactly what the window shows. Spanning the full template
+ // instead was wrong in a workspace large enough to scroll — the
+ // tracks then add up to more than the window, so the maximized pane
+ // was taller than the visible area and the terminal fitted itself to
+ // rows nobody could see, putting the CLI's prompt box below the clip.
+ // A grid that had been scrolled also kept its offset, so the pane
+ // came up part-way past its own header.
+ gridTemplateColumns:
+ maximized !== null
+ ? "minmax(0, 1fr)"
+ : `repeat(${Math.max(1, grid.columns)}, minmax(0, 1fr))`,
// A floor on row height, not a free 1fr. Panes used to share the
// window height in equal parts however many there were, so a large
// workspace ended up with three text rows per pane — readable width,
// unusable height. Below the floor the grid grows and scrolls instead.
- gridTemplateRows: `repeat(${Math.max(1, grid.rows)}, minmax(${MIN_PANE_HEIGHT_PX}px, 1fr))`,
+ gridTemplateRows:
+ maximized !== null
+ ? "minmax(0, 1fr)"
+ : `repeat(${Math.max(1, grid.rows)}, minmax(${MIN_PANE_HEIGHT_PX}px, 1fr))`,
}}
>
{session.terminals.map((term, index) => {
diff --git a/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.test.tsx b/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.test.tsx
index 904517c6fe..db9a2c0761 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.test.tsx
@@ -1,17 +1,34 @@
-import { render, screen } from "@testing-library/react";
+import { act, fireEvent, render, screen } from "@testing-library/react";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
const terminalHarness = vi.hoisted(() => ({
open: vi.fn(),
observe: vi.fn(),
+ fit: vi.fn(),
+ /** What the terminal reports after a fit — a test moves it to grow the pane. */
+ size: { cols: 80, rows: 24 },
+ /** Every frame the pane hands its socket. Returns whether it went out. */
+ send: vi.fn<(payload: unknown) => boolean>(() => true),
+ /** The live socket's handlers, so a test can play a reconnect. */
+ handlers: { current: null as Record<string, (...args: never[]) => void> | null },
}));
vi.mock("@xterm/xterm", () => ({
Terminal: class {
- cols = 80;
- rows = 24;
+ get cols() {
+ return terminalHarness.size.cols;
+ }
+ get rows() {
+ return terminalHarness.size.rows;
+ }
options: Record<string, unknown> = {};
unicode = { activeVersion: "" };
+ // The pane silences xterm's own answers to the agent's protocol queries
+ // (see ./terminalQueries). The double only has to accept the handlers.
+ parser = {
+ registerOscHandler: () => ({ dispose() {} }),
+ registerCsiHandler: () => ({ dispose() {} }),
+ };
loadAddon() {}
open(host: HTMLElement) {
@@ -34,7 +51,9 @@ vi.mock("@xterm/xterm", () => ({
vi.mock("@xterm/addon-fit", () => ({
FitAddon: class {
- fit() {}
+ fit() {
+ terminalHarness.fit();
+ }
},
}));
vi.mock("@xterm/addon-web-links", () => ({ WebLinksAddon: class {} }));
@@ -42,7 +61,16 @@ vi.mock("@xterm/addon-canvas", () => ({ CanvasAddon: class {} }));
vi.mock("@xterm/addon-unicode11", () => ({ Unicode11Addon: class {} }));
vi.mock("./paneSocket", () => ({
- openPaneSocket: () => ({ send() {}, close() {} }),
+ openPaneSocket: (
+ _options: unknown,
+ handlers: Record<string, (...args: never[]) => void>,
+ ) => {
+ terminalHarness.handlers.current = handlers;
+ return {
+ send: (payload: unknown) => terminalHarness.send(payload),
+ close() {},
+ };
+ },
}));
vi.mock("./terminalPaste", () => ({
installPasteBridge: () => () => undefined,
@@ -100,3 +128,315 @@ describe("AgenticTerminal layout", () => {
expect(terminalHarness.observe).toHaveBeenCalledWith(host);
});
});
+
+describe("pane header recap", () => {
+ beforeEach(() => {
+ globalThis.ResizeObserver = ResizeObserverHarness;
+ });
+
+ afterEach(() => {
+ vi.restoreAllMocks();
+ });
+
+ it("shows the session recap instead of the agent name", () => {
+ render(
+ <AgenticTerminal
+ name="Dana"
+ displayName="Claude Code"
+ recap="Running pytest tests/unit/test_login.py"
+ recapDetail='Last asked to: "Fix the failing login test". Working now, last output 4s ago: Running pytest tests/unit/test_login.py.'
+ appearance="dark"
+ fontSize={13}
+ />,
+ );
+
+ expect(screen.getByTestId("pane-recap-Dana").textContent).toBe(
+ "Running pytest tests/unit/test_login.py",
+ );
+ // The agent name is not gone, only moved out of the header line.
+ expect(screen.queryByTestId("pane-agent-Dana")).toBeNull();
+ });
+
+ it("offers the longer recap in a tooltip the clipped line points at", () => {
+ render(
+ <AgenticTerminal
+ name="Dana"
+ displayName="Claude Code"
+ recap="Running pytest tests/unit/test_login.py"
+ recapDetail='Last asked to: "Fix the failing login test". Working now: Running pytest tests/unit/test_login.py.'
+ appearance="dark"
+ fontSize={13}
+ />,
+ );
+
+ const line = screen.getByTestId("pane-recap-Dana");
+ const tooltip = screen.getByTestId("pane-recap-tooltip-Dana");
+
+ expect(tooltip.textContent).toContain("Fix the failing login test");
+ // Which CLI runs here stays one hover away rather than being lost.
+ expect(tooltip.textContent).toContain("Claude Code");
+ expect(tooltip.getAttribute("role")).toBe("tooltip");
+ // The clipped line names its own explanation, so a screen reader reaches
+ // the full sentence the same way a mouse does.
+ expect(line.getAttribute("aria-describedby")).toBe(tooltip.id);
+ expect(line.getAttribute("tabindex")).toBe("0");
+ });
+
+ it("falls back to the agent name while a pane has no recap yet", () => {
+ render(
+ <AgenticTerminal
+ name="Dana"
+ displayName="Claude Code"
+ appearance="dark"
+ fontSize={13}
+ />,
+ );
+
+ expect(screen.getByTestId("pane-agent-Dana").textContent).toBe(
+ "Claude Code",
+ );
+ expect(screen.queryByTestId("pane-recap-tooltip-Dana")).toBeNull();
+ });
+
+ it("adds no tooltip when the recap already says everything", () => {
+ render(
+ <AgenticTerminal
+ name="Dana"
+ displayName="Claude Code"
+ recap="Not started yet."
+ recapDetail="Not started yet."
+ appearance="dark"
+ fontSize={13}
+ />,
+ );
+
+ // jsdom measures no widths, so nothing is clipped here — with an identical
+ // detail there is genuinely nothing more to reveal.
+ expect(screen.queryByTestId("pane-recap-tooltip-Dana")).toBeNull();
+ });
+});
+
+describe("pane split menu", () => {
+ const CHOICES = [
+ { name: "claude", displayName: "Claude Code", installed: true, kind: "cli" },
+ { name: "codex", displayName: "Codex", installed: true, kind: "cli" },
+ {
+ name: "shell",
+ displayName: "Plain Terminal",
+ installed: true,
+ kind: "shell",
+ description: "PowerShell 7 — no agent, just a prompt",
+ },
+ ];
+
+ beforeEach(() => {
+ globalThis.ResizeObserver = ResizeObserverHarness;
+ });
+
+ afterEach(() => {
+ vi.restoreAllMocks();
+ });
+
+ it("offers a plain terminal beside the coding agents", () => {
+ render(
+ <AgenticTerminal
+ name="Dana"
+ displayName="Claude Code"
+ appearance="dark"
+ fontSize={13}
+ agents={CHOICES}
+ onSplit={() => undefined}
+ />,
+ );
+
+ fireEvent.click(screen.getByTestId("pane-split-right-Dana"));
+
+ expect(screen.getByTestId("pane-split-right-Dana-claude").textContent).toContain(
+ "Claude Code",
+ );
+ expect(screen.getByTestId("pane-split-right-Dana-codex").textContent).toContain(
+ "Codex",
+ );
+ const plain = screen.getByTestId("pane-split-right-Dana-shell");
+ expect(plain.textContent).toContain("Plain Terminal");
+ // ...and it says what that actually opens, which is the whole difference.
+ expect(plain.textContent).toContain("no agent");
+ });
+
+ it("splits with the plain-terminal entry the user picked", () => {
+ const onSplit = vi.fn();
+ render(
+ <AgenticTerminal
+ name="Dana"
+ displayName="Claude Code"
+ appearance="dark"
+ fontSize={13}
+ agents={CHOICES}
+ onSplit={onSplit}
+ />,
+ );
+
+ fireEvent.click(screen.getByTestId("pane-split-down-Dana"));
+ fireEvent.click(screen.getByTestId("pane-split-down-Dana-shell"));
+
+ expect(onSplit).toHaveBeenCalledWith("down", "shell");
+ });
+
+ it("disables the plain terminal on a host with no shell, and says why", () => {
+ render(
+ <AgenticTerminal
+ name="Dana"
+ displayName="Claude Code"
+ appearance="dark"
+ fontSize={13}
+ agents={[
+ CHOICES[0],
+ CHOICES[1],
+ { name: "shell", displayName: "Plain Terminal", installed: false, kind: "shell" },
+ ]}
+ onSplit={() => undefined}
+ />,
+ );
+
+ fireEvent.click(screen.getByTestId("pane-split-right-Dana"));
+ const plain = screen.getByTestId("pane-split-right-Dana-shell") as HTMLButtonElement;
+
+ // Listed but unusable, so the absence explains itself instead of the entry
+ // simply not being there — and in the terms of what is missing.
+ expect(plain.disabled).toBe(true);
+ expect(plain.textContent).toContain("no shell here");
+ });
+});
+
+describe("pane refit", () => {
+ /** jsdom measures nothing; the pane refuses to fit a host it reads as 0x0. */
+ const giveTheHostASize = () => {
+ for (const [property, value] of [
+ ["clientWidth", 600],
+ ["clientHeight", 400],
+ ] as const) {
+ Object.defineProperty(HTMLElement.prototype, property, {
+ configurable: true,
+ value,
+ });
+ }
+ };
+
+ const settle = () => {
+ act(() => {
+ vi.advanceTimersByTime(600);
+ });
+ };
+
+ const pane = (maximized: boolean) => (
+ <AgenticTerminal
+ name="Dana"
+ displayName="Claude Code"
+ appearance="dark"
+ fontSize={13}
+ maximized={maximized}
+ />
+ );
+
+ beforeEach(() => {
+ vi.useFakeTimers();
+ globalThis.ResizeObserver = ResizeObserverHarness;
+ giveTheHostASize();
+ terminalHarness.fit.mockClear();
+ terminalHarness.send.mockClear();
+ terminalHarness.send.mockImplementation(() => true);
+ terminalHarness.handlers.current = null;
+ terminalHarness.size = { cols: 80, rows: 24 };
+ });
+
+ afterEach(() => {
+ vi.useRealTimers();
+ Reflect.deleteProperty(HTMLElement.prototype, "clientWidth");
+ Reflect.deleteProperty(HTMLElement.prototype, "clientHeight");
+ });
+
+ it("re-measures itself when the pane is maximized", () => {
+ // The ResizeObserver harness never calls anyone back, which is the point:
+ // this proves the pane no longer DEPENDS on that notification arriving.
+ // When it went missing, the pane was maximized while the agent inside it
+ // kept drawing at its old cell's width.
+ const view = render(pane(false));
+ settle();
+ terminalHarness.fit.mockClear();
+
+ view.rerender(pane(true));
+ settle();
+
+ expect(terminalHarness.fit).toHaveBeenCalled();
+ });
+
+ it("re-measures again when the pane is restored to its cell", () => {
+ const view = render(pane(true));
+ settle();
+ terminalHarness.fit.mockClear();
+
+ view.rerender(pane(false));
+ settle();
+
+ expect(terminalHarness.fit).toHaveBeenCalled();
+ });
+
+ it("does not re-announce a size the terminal process already has", () => {
+ // Refitting is nearly free; telling the agent makes it redraw its whole
+ // screen. A pane settles over several passes, so only changes go out.
+ const view = render(pane(false));
+ settle();
+ terminalHarness.send.mockClear();
+
+ view.rerender(pane(true));
+ settle();
+
+ expect(terminalHarness.send).not.toHaveBeenCalled();
+ });
+
+ it("keeps offering a size the socket could not carry", () => {
+ // A pane measured while its backend was restarting must not treat the
+ // frame as delivered. Nothing measures a pane again on its own, so a size
+ // counted as sent when it never left is lost for good — and the agent goes
+ // on formatting for a size the pane no longer has.
+ const view = render(pane(false));
+ settle();
+
+ terminalHarness.send.mockImplementation(() => false);
+ terminalHarness.size.cols = 200;
+ view.rerender(pane(true));
+ settle();
+ terminalHarness.send.mockClear();
+
+ // Same size, still undelivered — so it goes out again rather than being
+ // deduplicated away.
+ terminalHarness.send.mockImplementation(() => true);
+ view.rerender(pane(false));
+ settle();
+
+ expect(terminalHarness.send).toHaveBeenCalledWith({
+ t: "r",
+ cols: 200,
+ rows: 24,
+ });
+ });
+
+ it("tells a fresh socket the pane's size whatever the last one heard", () => {
+ render(pane(false));
+ settle();
+ terminalHarness.send.mockClear();
+
+ // A reconnect gets a process that knows nothing about this pane, so the
+ // size is announced again even though it has not changed.
+ act(() => {
+ terminalHarness.handlers.current?.onOpen?.();
+ vi.advanceTimersByTime(600);
+ });
+
+ expect(terminalHarness.send).toHaveBeenCalledWith({
+ t: "r",
+ cols: 80,
+ rows: 24,
+ });
+ });
+});
diff --git a/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx b/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx
index edccec28fe..024e2f5fef 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx
@@ -84,11 +84,19 @@ export type PaneStatus = "connecting" | "live" | "exited" | "error";
/** A coding CLI a split may start, as offered by the pane's split menu. */
export interface SplitAgentChoice {
- /** Backend id — "claude", "codex". */
+ /** Backend id — "claude", "codex", "shell". */
name: string;
- /** What the user reads — "Claude Code". */
+ /** What the user reads — "Claude Code", "Plain Terminal". */
displayName: string;
installed: boolean;
+ /**
+ * `"cli"` for a coding agent, `"shell"` for a plain terminal on this
+ * machine's own shell. Carried so the menu can say what a choice actually
+ * opens without knowing any entry by name.
+ */
+ kind?: string;
+ /** One line under the name — the shell that would open, for instance. */
+ description?: string;
}
export type SplitDirection = "right" | "down";
@@ -107,6 +115,17 @@ interface AgenticTerminalProps {
workspaceId?: string;
/** Agent label shown in the pane header ("Claude Code"). */
displayName: string;
+ /**
+ * What this session is doing, in one clause — the header's main label.
+ *
+ * It REPLACES the agent name there when present, because the agent name is
+ * the same for every pane in the grid and this is the part that differs. The
+ * CLI is still one hover away (the tooltip names it) and the pane's call-sign
+ * badge never moves.
+ */
+ recap?: string;
+ /** The one-or-two-sentence version of `recap`, revealed on hover. */
+ recapDetail?: string;
/**
* Which subscription this pane runs on ("Work seat"), when that is worth
* saying. Undefined for everyone with a single login — the header must not
@@ -158,6 +177,8 @@ export function AgenticTerminal({
name,
workspaceId,
displayName,
+ recap,
+ recapDetail,
accountLabel,
appearance,
fontSize,
@@ -358,6 +379,21 @@ export function AgenticTerminal({
if (offscreen.full) term.write(offscreen.drain());
};
+ /*
+ * The size the terminal PROCESS has actually been told.
+ *
+ * Recorded only when the socket took the frame, and that is the whole
+ * point. A pane's socket is not open at all times — a backend restart, a
+ * moment of unreachability, a reconnect in flight — and anything handed to
+ * one in those states goes nowhere. Treating a size as delivered because
+ * it was offered is what let one go missing for good: the pane looked
+ * right, and the agent inside it went on formatting for the size it last
+ * heard about, drawing its screen into a corner of a pane that had become
+ * much larger. Left un-recorded, the next fit offers it again, and a fresh
+ * socket is told unconditionally.
+ */
+ let sentSize: { cols: number; rows: number } | null = null;
+
const sendResize = () => {
// A hidden pane measures 0x0 (maximizing another one hides this one), and
// fitting to that would resize the PTY to zero columns — which permanently
@@ -370,7 +406,14 @@ export function AgenticTerminal({
return;
}
if (term.cols < 2 || term.rows < 2) return;
- socket?.send({ t: "r", cols: term.cols, rows: term.rows });
+ const size = { cols: term.cols, rows: term.rows };
+ // Already delivered and unchanged: the fit above was the whole job.
+ // Re-announcing a size makes the agent on the other end redraw its
+ // entire screen, and a pane refits several times per settling layout.
+ if (sentSize && sentSize.cols === size.cols && sentSize.rows === size.rows) {
+ return;
+ }
+ if (socket?.send({ t: "r", ...size })) sentSize = size;
};
resizeRef.current = sendResize;
@@ -385,6 +428,11 @@ export function AgenticTerminal({
{
onOpen: () => {
report("connecting");
+ // A fresh socket has been told nothing about this pane, whatever the
+ // one before it heard — so the size goes out again unconditionally.
+ // This is also what hands over a size that was measured while the
+ // pane was unreachable.
+ sentSize = null;
// The spawn used a best-effort size (the mount-time fit usually runs
// before the grid cell is measured), and resizes sent while the socket
// was connecting were dropped — without this the agent's full-screen
@@ -542,6 +590,36 @@ export function AgenticTerminal({
resizeRef.current?.();
}, [fontSize]);
+ /*
+ * Refit when the pane is maximized, and again when it is restored.
+ *
+ * Maximizing is by far the largest size change a pane ever makes — a cell in
+ * a grid of ten becomes the whole window — and until now the terminal inside
+ * it only found out through its ResizeObserver. That is a single debounced
+ * notification, competing with everything else the grid re-lays out in the
+ * same breath, and delivered when the browser gets round to it. Usually it
+ * arrives and the pane fills. Occasionally it did not, and the result was the
+ * reported bug: a pane visibly maximized with its agent still drawing at the
+ * old cell's width, the rest of the window left blank.
+ *
+ * So the one size change the pane genuinely KNOWS about is driven from that
+ * knowledge instead of waited for. Three passes because the grid settles over
+ * a frame or two — and they are nearly free: a fit that lands on the size the
+ * terminal already has sends nothing at all.
+ */
+ useEffect(() => {
+ const refit = () => resizeRef.current?.();
+ const frame = requestAnimationFrame(refit);
+ const timers = [
+ window.setTimeout(refit, 120),
+ window.setTimeout(refit, 400),
+ ];
+ return () => {
+ cancelAnimationFrame(frame);
+ for (const timer of timers) window.clearTimeout(timer);
+ };
+ }, [maximized]);
+
/*
* Drag a file onto the pane, or paste a screenshot into it.
*
@@ -637,6 +715,8 @@ export function AgenticTerminal({
onRestart={onRestart}
name={name}
displayName={displayName}
+ recap={recap}
+ recapDetail={recapDetail}
accountLabel={accountLabel}
appearance={appearance}
focused={focused}
@@ -703,6 +783,8 @@ export function AgenticTerminal({
function PaneHeader({
name,
displayName,
+ recap,
+ recapDetail,
accountLabel,
appearance,
focused,
@@ -717,6 +799,8 @@ function PaneHeader({
}: {
name: string;
displayName: string;
+ recap?: string;
+ recapDetail?: string;
accountLabel?: string | null;
appearance: TerminalAppearance;
focused: boolean;
@@ -752,10 +836,10 @@ function PaneHeader({
background: light ? "rgba(0,0,0,0.025)" : "rgba(255,255,255,0.03)",
}}
>
- <div className="flex min-w-0 items-center gap-2">
+ <div className="flex min-w-0 flex-1 items-center gap-2">
<span
className={cn(
- "rounded-md px-2 py-0.5 font-display text-[13px] font-semibold tracking-tight",
+ "shrink-0 rounded-md px-2 py-0.5 font-display text-[13px] font-semibold tracking-tight",
focused ? "bg-primary/20 text-primary" : "",
)}
style={
@@ -766,19 +850,20 @@ function PaneHeader({
>
{name}
</span>
- <span
- className="truncate text-[11px] uppercase tracking-wider"
- style={{ color: light ? "#77777f" : "#8a8a95" }}
- >
- {displayName}
- </span>
+ <PaneRecap
+ name={name}
+ displayName={displayName}
+ recap={recap}
+ detail={recapDetail}
+ light={light}
+ />
{/* Which of several subscriptions this pane is spending. Only rendered
when the user actually has more than one, so the header stays quiet
for everybody else — but with two seats open side by side, knowing
which pane bills which plan is the whole point. */}
{accountLabel && (
<span
- className="truncate rounded-full px-1.5 text-[10px] tracking-wide"
+ className="max-w-[8rem] shrink-0 truncate rounded-full px-1.5 text-[10px] tracking-wide"
style={{
color: light ? "#6b6b73" : "#9a9aa5",
backgroundColor: light ? "#00000010" : "#ffffff12",
@@ -875,15 +960,147 @@ function PaneHeader({
}
/**
- * The CLI picker a split button opens.
+ * Is this element showing all of its text, or has CSS clipped it?
+ *
+ * `scrollWidth > clientWidth` is the only honest answer: whether a sentence fits
+ * depends on the pane's width, the font that ended up loading and how long the
+ * agent's last line happened to be — none of which can be guessed from the
+ * string. Re-measured whenever the text changes or the element is resized, which
+ * in a draggable grid of terminals is constantly.
+ *
+ * Environments without a ResizeObserver (jsdom, very old engines) simply keep
+ * the first measurement, which is the behaviour this replaces rather than a
+ * regression.
+ */
+function useIsTruncated(
+ ref: React.RefObject<HTMLElement | null>,
+ text: string,
+): boolean {
+ const [truncated, setTruncated] = useState(false);
+ useEffect(() => {
+ const node = ref.current;
+ if (!node) {
+ setTruncated(false);
+ return;
+ }
+ // A one-pixel slack: sub-pixel font metrics make scrollWidth exceed
+ // clientWidth on text that visibly fits, and a tooltip that appears for
+ // nothing is worse than one that occasionally does not.
+ const measure = () => setTruncated(node.scrollWidth > node.clientWidth + 1);
+ measure();
+ if (typeof ResizeObserver === "undefined") return;
+ const observer = new ResizeObserver(measure);
+ observer.observe(node);
+ return () => observer.disconnect();
+ }, [ref, text]);
+ return truncated;
+}
+
+/**
+ * The pane header's headline: what this session is doing, in one line.
+ *
+ * Two things happen here and both matter for a grid of eight terminals:
+ *
+ * 1. **The recap replaces the agent name.** "CLAUDE CODE" is identical on every
+ * pane, so as a label it answers nothing; the recap is the part that differs
+ * pane to pane. Without one — a pane that has just been opened, or a backend
+ * that predates the field — the agent name is shown exactly as before.
+ * 2. **The clipped part is one hover away.** A header is a few centimetres wide
+ * and a recap is a sentence, so it WILL be cut. The tooltip carries the
+ * longer form, and it is offered when the line is actually clipped or when
+ * the longer form says more than the line does — never merely because there
+ * is text.
+ *
+ * A native `title` would have been free, but it appears after a browser-chosen
+ * delay, renders as unstyled OS chrome, and cannot show the two-part layout
+ * (which CLI, then the recap) that makes this readable at a glance.
+ */
+function PaneRecap({
+ name,
+ displayName,
+ recap,
+ detail,
+ light,
+}: {
+ name: string;
+ displayName: string;
+ recap?: string;
+ detail?: string;
+ light: boolean;
+}) {
+ const lineRef = useRef<HTMLSpanElement | null>(null);
+ const headline = (recap ?? "").trim();
+ const clipped = useIsTruncated(lineRef, headline);
+
+ if (!headline) {
+ return (
+ <span
+ className="truncate text-[11px] uppercase tracking-wider"
+ style={{ color: light ? "#77777f" : "#8a8a95" }}
+ data-testid={`pane-agent-${name}`}
+ >
+ {displayName}
+ </span>
+ );
+ }
+
+ const body = (detail ?? "").trim() || headline;
+ const showsTooltip = clipped || body !== headline;
+ const tipId = `pane-recap-tip-${name}`;
+
+ return (
+ <span className="group/recap min-w-0 flex-1">
+ <span
+ ref={lineRef}
+ // Reachable without a mouse: the tooltip opens on focus too, so the
+ // clipped half of the sentence is not mouse-only information.
+ tabIndex={showsTooltip ? 0 : undefined}
+ aria-describedby={showsTooltip ? tipId : undefined}
+ className="block truncate rounded-sm text-[11px] leading-tight outline-none focus-visible:ring-1 focus-visible:ring-primary/60"
+ style={{ color: light ? "#5f5f68" : "#9b9ba6" }}
+ data-testid={`pane-recap-${name}`}
+ >
+ {headline}
+ </span>
+ {showsTooltip && (
+ /*
+ * Positioned against the HEADER, not against this span: the header is
+ * the only positioned ancestor that spans the pane, so the card can be
+ * wide enough to read without hanging off a narrow pane's edge. The
+ * pane clips its own overflow, so a card anchored to a 60 px label
+ * would be cut in half.
+ */
+ <span
+ role="tooltip"
+ id={tipId}
+ data-testid={`pane-recap-tooltip-${name}`}
+ className="pointer-events-none absolute left-3 top-full z-50 mt-1 hidden w-max max-w-[calc(100%-1.5rem)] flex-col gap-1 rounded-lg border border-border bg-card p-2.5 text-left shadow-xl group-focus-within/recap:flex group-hover/recap:flex"
+ >
+ <span className="block text-[10px] uppercase tracking-wider text-muted-foreground">
+ {displayName} · {name}
+ </span>
+ <span className="block text-[11px] leading-relaxed text-foreground">
+ {body}
+ </span>
+ </span>
+ )}
+ </span>
+ );
+}
+
+/**
+ * The picker a split button opens: what should run in the new pane?
*
* Splitting used to inherit the anchor's agent silently, which made running a
* Codex pane next to a Claude Code one impossible from the grid — you had to
* close the workspace and start it again from the wizard. The backend always
* accepted an agent per terminal; this is the surface that finally asks.
*
- * A CLI that is not installed stays listed but disabled, so the absence is
- * visible and explains itself rather than the entry simply not being there.
+ * The list is whatever the backend registered, so it is not a fixed pair of
+ * CLIs: a plain terminal (this machine's own shell, no agent around it) sits in
+ * the same menu, and a CLI registered later appears here without a change on
+ * this side. An entry that is not installed stays listed but disabled, so the
+ * absence is visible and explains itself rather than silently not being there.
*/
function SplitAgentMenu({
paneName,
@@ -905,16 +1122,16 @@ function SplitAgentMenu({
<div className="fixed inset-0 z-40" onMouseDown={onDismiss} />
<div
role="menu"
- aria-label={`Which CLI should run ${direction === "right" ? "beside" : "below"} ${paneName}?`}
+ aria-label={`What should run ${direction === "right" ? "beside" : "below"} ${paneName}?`}
data-testid={`pane-split-menu-${direction}-${paneName}`}
- className="absolute right-2 top-full z-50 mt-1 w-56 rounded-lg border border-border bg-card p-1 shadow-xl"
+ className="absolute right-2 top-full z-50 mt-1 w-60 rounded-lg border border-border bg-card p-1 shadow-xl"
onMouseDown={(e) => e.stopPropagation()}
onKeyDown={(e) => {
if (e.key === "Escape") onDismiss();
}}
>
<p className="px-2 py-1.5 text-[11px] uppercase tracking-wider text-muted-foreground">
- {direction === "right" ? "Open beside — which CLI?" : "Split below — which CLI?"}
+ {direction === "right" ? "Open beside — what?" : "Split below — what?"}
</p>
{agents.map((agent) => (
<button
@@ -928,12 +1145,22 @@ function SplitAgentMenu({
e.stopPropagation();
onPick(agent.name);
}}
- className="flex w-full items-center justify-between gap-2 rounded-md px-2 py-1.5 text-left text-sm transition-colors hover:bg-primary/10 disabled:cursor-not-allowed disabled:opacity-40 disabled:hover:bg-transparent"
+ className="flex w-full items-start justify-between gap-2 rounded-md px-2 py-1.5 text-left text-sm transition-colors hover:bg-primary/10 disabled:cursor-not-allowed disabled:opacity-40 disabled:hover:bg-transparent"
>
- <span>{agent.displayName}</span>
+ <span className="min-w-0">
+ <span className="block truncate">{agent.displayName}</span>
+ {/* What this choice actually opens — "no agent, just a prompt"
+ is the difference a user needs before clicking, and it is the
+ entry's own words rather than a name this menu recognises. */}
+ {agent.description && (
+ <span className="block truncate text-[11px] text-muted-foreground">
+ {agent.description}
+ </span>
+ )}
+ </span>
{!agent.installed && (
- <span className="text-[10px] uppercase tracking-wide text-muted-foreground">
- not installed
+ <span className="shrink-0 text-[10px] uppercase tracking-wide text-muted-foreground">
+ {agent.kind === "shell" ? "no shell here" : "not installed"}
</span>
)}
</button>
diff --git a/jarvis/ui/web/frontend/src/components/agentic/paneSocket.ts b/jarvis/ui/web/frontend/src/components/agentic/paneSocket.ts
index 7f4ba18c39..913e24f0ba 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/paneSocket.ts
+++ b/jarvis/ui/web/frontend/src/components/agentic/paneSocket.ts
@@ -118,7 +118,13 @@ export interface PaneSocketHandlers {
}
export interface PaneSocket {
- send(payload: unknown): void;
+ /**
+ * Hand a frame to the server. Returns whether it actually went out — a
+ * socket that is connecting, retrying or gone accepts nothing, and a caller
+ * that must not lose what it was saying (a pane's measured size) needs to
+ * know that rather than assume it arrived.
+ */
+ send(payload: unknown): boolean;
close(): void;
}
@@ -301,9 +307,15 @@ export function openPaneSocket(
open();
return {
- send(payload: unknown): void {
- if (ws && ws.readyState === WebSocket.OPEN) {
+ send(payload: unknown): boolean {
+ if (!ws || ws.readyState !== WebSocket.OPEN) return false;
+ try {
ws.send(typeof payload === "string" ? payload : JSON.stringify(payload));
+ return true;
+ } catch {
+ // The socket died between the check and the write. Reported as not
+ // sent, which is exactly what happened.
+ return false;
}
},
close(): void {