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): wrap panes by available width, and let a dead pane restart

Ruben Lütkeb589ac9235f8
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 142d4be6d0..7895f4a3ce 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.test.tsx
@@ -437,13 +437,18 @@ describe("closing a pane", () => {
});
describe("closing the workspace", () => {
- it("asks before stopping every coding agent", () => {
+ it("asks before stopping every coding agent and focuses the safe action", async () => {
const { onClose } = renderGrid();
fireEvent.click(screen.getByTitle("Close the workspace and stop every agent in it"));
expect(screen.getByTestId("confirm-close-workspace")).toBeTruthy();
expect(screen.getByText(/Close this workspace\?/i)).toBeTruthy();
expect(screen.getByText(/stops all 2 coding agents/i)).toBeTruthy();
+ await waitFor(() =>
+ expect(document.activeElement).toBe(
+ screen.getByRole("button", { name: /keep workspace open/i }),
+ ),
+ );
expect(onClose).not.toHaveBeenCalled();
});
@@ -464,12 +469,24 @@ describe("closing the workspace", () => {
expect(onClose).toHaveBeenCalledTimes(1);
});
- it("escape safely cancels the workspace dialog", () => {
- const { onClose } = renderGrid();
+ 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"));
- fireEvent.keyDown(screen.getByTestId("confirm-close-workspace"), { key: "Escape" });
+ const prompt = screen.getByPlaceholderText(/instruction for Mika/i);
- expect(screen.queryByTestId("confirm-close-workspace")).toBeNull();
+ expect(prompt.closest('[aria-hidden="true"]')).toBeTruthy();
+ });
+
+ it("escape safely cancels and restores focus to the close trigger", async () => {
+ const { onClose } = renderGrid();
+ const trigger = screen.getByTitle("Close the workspace and stop every agent in it");
+ fireEvent.click(trigger);
+ const cancel = screen.getByRole("button", { name: /keep workspace open/i });
+ await waitFor(() => expect(document.activeElement).toBe(cancel));
+ fireEvent.keyDown(cancel, { key: "Escape" });
+
+ await waitFor(() => expect(screen.queryByTestId("confirm-close-workspace")).toBeNull());
+ await waitFor(() => expect(document.activeElement).toBe(trigger));
expect(onClose).not.toHaveBeenCalled();
});
});
diff --git a/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.tsx b/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.tsx
index 37421d9181..ffd751849f 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.tsx
@@ -10,6 +10,7 @@
* differently.
*/
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
+import * as Dialog from "@radix-ui/react-dialog";
import {
ArrowUp,
Brain,
@@ -339,27 +340,31 @@ export function AgenticGrid({
</button>
</div>
- <button
- type="button"
- className="btn-ghost shrink-0"
- onClick={() => setWorkspaceCloseRequested(true)}
- disabled={busy}
- title="Close the workspace and stop every agent in it"
+ <Dialog.Root
+ open={workspaceCloseRequested}
+ onOpenChange={(open) => {
+ if (!busy) setWorkspaceCloseRequested(open);
+ }}
>
- <Power className="h-4 w-4" />
- Close
- </button>
+ <Dialog.Trigger asChild>
+ <button
+ type="button"
+ className="btn-ghost shrink-0"
+ disabled={busy}
+ title="Close the workspace and stop every agent in it"
+ >
+ <Power className="h-4 w-4" />
+ Close
+ </button>
+ </Dialog.Trigger>
+ <ConfirmWorkspaceClose
+ terminalCount={session.terminals.length}
+ busy={busy}
+ onConfirm={onClose}
+ />
+ </Dialog.Root>
</div>
- {workspaceCloseRequested && (
- <ConfirmWorkspaceClose
- terminalCount={session.terminals.length}
- busy={busy}
- onCancel={() => setWorkspaceCloseRequested(false)}
- onConfirm={onClose}
- />
- )}
-
{/* ------------------------------------------------------------- grid */}
{/*
ONE grid, and every pane is a direct child of it — placed by the
@@ -532,43 +537,45 @@ export function AgenticGrid({
function ConfirmWorkspaceClose({
terminalCount,
busy,
- onCancel,
onConfirm,
}: {
terminalCount: number;
busy: boolean;
- onCancel: () => void;
onConfirm: () => void;
}) {
const agentLabel = terminalCount === 1 ? "coding agent" : "coding agents";
return (
- <div
- role="dialog"
- aria-modal="true"
- aria-label="Close workspace"
- data-testid="confirm-close-workspace"
- className="absolute inset-0 z-40 flex items-center justify-center bg-background/70 p-6 backdrop-blur-sm"
- onKeyDown={(e) => {
- if (e.key === "Escape" && !busy) onCancel();
- }}
- >
- <div className="w-full max-w-sm rounded-xl border border-border bg-card p-5 shadow-xl">
- <h3 className="font-display text-base font-semibold">Close this workspace?</h3>
- <p className="mt-2 text-sm text-muted-foreground">
+ <Dialog.Portal>
+ <Dialog.Overlay className="fixed inset-0 z-50 bg-background/70 backdrop-blur-sm" />
+ <Dialog.Content
+ data-testid="confirm-close-workspace"
+ className="fixed left-1/2 top-1/2 z-50 w-[min(24rem,calc(100vw-3rem))] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-border bg-card p-5 shadow-xl"
+ onEscapeKeyDown={(event) => {
+ if (busy) event.preventDefault();
+ }}
+ onPointerDownOutside={(event) => {
+ if (busy) event.preventDefault();
+ }}
+ >
+ <Dialog.Title className="font-display text-base font-semibold">
+ Close this workspace?
+ </Dialog.Title>
+ <Dialog.Description className="mt-2 text-sm text-muted-foreground">
This stops all {terminalCount} {agentLabel} and closes every terminal
session. Anything already written to disk stays.
- </p>
+ </Dialog.Description>
<div className="mt-5 flex items-center justify-end gap-2">
- <button
- type="button"
- className="btn-ghost"
- autoFocus
- disabled={busy}
- onClick={onCancel}
- >
- Keep workspace open
- </button>
+ <Dialog.Close asChild>
+ <button
+ type="button"
+ className="btn-ghost"
+ autoFocus
+ disabled={busy}
+ >
+ Keep workspace open
+ </button>
+ </Dialog.Close>
<button
type="button"
data-testid="confirm-close-workspace-confirm"
@@ -579,8 +586,8 @@ function ConfirmWorkspaceClose({
Close workspace
</button>
</div>
- </div>
- </div>
+ </Dialog.Content>
+ </Dialog.Portal>
);
}
diff --git a/jarvis/ui/web/frontend/src/components/agentic/layout.width.test.ts b/jarvis/ui/web/frontend/src/components/agentic/layout.width.test.ts
new file mode 100644
index 0000000000..61d90ca31b
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/components/agentic/layout.width.test.ts
@@ -0,0 +1,74 @@
+import { describe, expect, it } from "vitest";
+import {
+ MAX_PANES_PER_BAND,
+ MIN_PANE_WIDTH_PX,
+ bandCapacityFor,
+ paneColumns,
+ paneGrid,
+} from "./layout";
+
+/**
+ * Reported 2026-07-25: eight terminals in one band left each pane about 18
+ * characters wide. Claude Code then truncates every line and breaks single words
+ * across rows ("Clau/de/Max"), so the panes were unreadable — measured directly
+ * against a real agent at 20 columns.
+ *
+ * The cause was a FIXED cap of ten panes per band. Ten is fine on a 4K display
+ * and ruinous on a laptop, so capacity has to come from the available width.
+ */
+describe("bandCapacityFor", () => {
+ it("keeps every pane at least as wide as the readable floor", () => {
+ for (const width of [800, 1280, 1440, 1920, 2560, 3840]) {
+ const capacity = bandCapacityFor(width);
+ expect(width / capacity).toBeGreaterThanOrEqual(MIN_PANE_WIDTH_PX);
+ }
+ });
+
+ it("would have prevented the reported case", () => {
+ // The workspace in the report was ~2400 px wide with eight panes in one band.
+ expect(bandCapacityFor(2400)).toBeLessThan(8);
+ });
+
+ it("gives a laptop fewer columns than a large display", () => {
+ expect(bandCapacityFor(1440)).toBeLessThan(bandCapacityFor(2560));
+ });
+
+ it("never returns zero — one cramped pane still beats none", () => {
+ expect(bandCapacityFor(120)).toBe(1);
+ expect(bandCapacityFor(1)).toBe(1);
+ });
+
+ it("falls back to the static ceiling when the width is unknown", () => {
+ // Before the first measurement the grid reports 0; wrapping to a single
+ // column then would make the layout jump on mount.
+ expect(bandCapacityFor(0)).toBe(MAX_PANES_PER_BAND);
+ expect(bandCapacityFor(Number.NaN)).toBe(MAX_PANES_PER_BAND);
+ });
+
+ it("never exceeds the static ceiling", () => {
+ expect(bandCapacityFor(100_000)).toBe(MAX_PANES_PER_BAND);
+ });
+});
+
+describe("wrapping with a measured capacity", () => {
+ const panes = Array.from({ length: 8 }, (_, i) => ({ column: i, slot: 0 }));
+
+ it("spreads eight panes over several bands on a normal window", () => {
+ const capacity = bandCapacityFor(1920);
+ const grid = paneGrid(panes, capacity);
+ expect(grid.columns).toBeLessThanOrEqual(capacity);
+ const bands = new Set(grid.placements.map((p) => Math.floor((p.row - 1) / p.rowSpan)));
+ expect(bands.size).toBeGreaterThan(1);
+ });
+
+ it("balances the bands instead of leaving a stub row", () => {
+ // 8 panes at capacity 5 → 4 + 4, not 5 + 3.
+ expect(paneColumns(8, 5)).toBe(4);
+ });
+
+ it("still places every pane exactly once", () => {
+ const grid = paneGrid(panes, bandCapacityFor(1440));
+ expect(grid.placements).toHaveLength(panes.length);
+ expect(grid.placements.every((p) => p.column >= 1 && p.row >= 1)).toBe(true);
+ });
+});
diff --git a/tests/unit/agentic_ide/test_panes.py b/tests/unit/agentic_ide/test_panes.py
index 74711821d1..5f155cb8f5 100644
--- a/tests/unit/agentic_ide/test_panes.py
+++ b/tests/unit/agentic_ide/test_panes.py
@@ -1,10 +1,10 @@
"""Adding and closing panes in a running workspace.
-The row model is what makes the two split buttons mean something: "right" joins
-the anchor's row so the panes render side by side, "down" opens a new row
-beneath it. These tests pin that arithmetic, because an off-by-one in the row
-numbers renders as an empty band in the grid or as two panes stacked where one
-was expected.
+The workspace is COLUMNS of stacked panes, which is what makes the two split
+buttons mean something: "right" opens a new column beside the anchor, "down" adds
+a pane to the anchor's OWN column and leaves every other column at full height.
+These tests pin that arithmetic, because an off-by-one renders as a blank stripe
+in the grid, or squashes panes that should not have moved.
"""
from __future__ import annotations
@@ -34,9 +34,13 @@ async def _open(registry: Registry, folder: Path, count: int = 2):
)
-def _layout(registry: Registry) -> list[tuple[str, int]]:
- """(name, row) in render order — the shape the grid draws."""
- return [(t.name, t.row) for t in registry.session.terminals]
+def _layout(registry: Registry) -> list[tuple[str, int, int]]:
+ """(name, column, slot) in render order — the shape the grid draws.
+
+ The workspace is columns of stacked panes: `column` runs left to right,
+ `slot` top to bottom inside one column.
+ """
+ return [(t.name, t.column, t.slot) for t in registry.session.terminals]
async def _noop(_text: str) -> None:
@@ -48,21 +52,23 @@ async def _noop_exit(_code: int) -> None:
# --------------------------------------------------------------- initial rows
-async def test_a_fresh_workspace_puts_every_pane_in_row_zero(
+async def test_a_fresh_workspace_puts_every_pane_in_its_own_column(
registry: Registry, tmp_path: Path
) -> None:
- """The wizard's grid is one row; splitting is what creates more."""
+ """The wizard's panes stand side by side: one column each, top slot."""
await _open(registry, tmp_path, 3)
- assert _layout(registry) == [("Mika", 0), ("Nova", 0), ("Aria", 0)]
+ assert _layout(registry) == [("Mika", 0, 0), ("Nova", 1, 0), ("Aria", 2, 0)]
# ---------------------------------------------------------------- split right
-async def test_split_right_joins_the_anchor_row(registry: Registry, tmp_path: Path) -> None:
+async def test_split_right_opens_a_column_next_to_the_anchor(
+ registry: Registry, tmp_path: Path
+) -> None:
await _open(registry, tmp_path, 2)
term = await registry.add_terminal(anchor="Mika", direction="right")
- assert term.row == 0
- # Inserted directly after its anchor, not appended at the end.
- assert _layout(registry) == [("Mika", 0), (term.name, 0), ("Nova", 0)]
+ # Immediately right of its anchor — not appended at the end — and everything
+ # further right shifts over rather than being overwritten.
+ assert _layout(registry) == [("Mika", 0, 0), (term.name, 1, 0), ("Nova", 2, 0)]
async def test_split_right_inherits_the_anchor_agent(
@@ -83,26 +89,28 @@ async def test_an_explicit_agent_wins_over_the_anchor(
# ----------------------------------------------------------------- split down
-async def test_split_down_opens_a_new_row_below_the_anchor(
+async def test_split_down_stacks_inside_the_anchor_column(
registry: Registry, tmp_path: Path
) -> None:
+ """The point of the column model: splitting one pane must not squash the
+ others. Nova keeps its own full-height column."""
await _open(registry, tmp_path, 2)
term = await registry.add_terminal(anchor="Mika", direction="down")
- assert term.row == 1
- assert _layout(registry) == [("Mika", 0), (term.name, 1), ("Nova", 0)]
+ assert (term.column, term.slot) == (0, 1)
+ assert _layout(registry) == [("Mika", 0, 0), (term.name, 0, 1), ("Nova", 1, 0)]
-async def test_split_down_pushes_existing_lower_rows_down(
+async def test_split_down_pushes_the_existing_stack_down(
registry: Registry, tmp_path: Path
) -> None:
- """Inserting between rows must not collide with the row already there."""
+ """Inserting into the middle of a stack must not collide with what is there."""
await _open(registry, tmp_path, 1)
bottom = await registry.add_terminal(anchor="Mika", direction="down")
middle = await registry.add_terminal(anchor="Mika", direction="down")
- rows = {name: row for name, row in _layout(registry)}
- assert rows["Mika"] == 0
- assert rows[middle.name] == 1, "the newest pane sits directly under its anchor"
- assert rows[bottom.name] == 2, "the older row moved down"
+ slots = {name: (column, slot) for name, column, slot in _layout(registry)}
+ assert slots["Mika"] == (0, 0)
+ assert slots[middle.name] == (0, 1), "the newest pane sits under its anchor"
+ assert slots[bottom.name] == (0, 2), "the older pane moved down"
# --------------------------------------------------------------------- naming
@@ -178,15 +186,24 @@ async def test_closing_a_pane_stops_its_agent(
assert [t.name for t in registry.session.terminals] == ["Nova"]
-async def test_closing_repacks_the_rows(registry: Registry, tmp_path: Path) -> None:
- """A row left empty would render as a blank band, so rows are re-packed."""
+async def test_closing_repacks_the_stack(registry: Registry, tmp_path: Path) -> None:
+ """A gap in a stack would render as a blank cell, so slots are re-packed."""
await _open(registry, tmp_path, 1)
middle = await registry.add_terminal(anchor="Mika", direction="down")
bottom = await registry.add_terminal(anchor=middle.name, direction="down")
- assert [row for _n, row in _layout(registry)] == [0, 1, 2]
+ assert [slot for _n, _c, slot in _layout(registry)] == [0, 1, 2]
await registry.close_terminal(middle.name)
- assert _layout(registry) == [("Mika", 0), (bottom.name, 1)]
+ assert _layout(registry) == [("Mika", 0, 0), (bottom.name, 0, 1)]
+
+
+async def test_closing_a_whole_column_repacks_the_columns(
+ registry: Registry, tmp_path: Path
+) -> None:
+ """An emptied column would render as a blank stripe."""
+ await _open(registry, tmp_path, 3)
+ await registry.close_terminal("Nova")
+ assert _layout(registry) == [("Mika", 0, 0), ("Aria", 1, 0)]
async def test_closing_the_last_pane_leaves_an_empty_workspace(