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 wrapping the workspace, scroll it sideways instead

rubenluetke10-beep7c01f733d710
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 2783956d87..f97b305818 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.test.tsx
@@ -583,14 +583,17 @@ describe("grid layout", () => {
expect(box("Vega").width).toBe(box("Nova").width);
});
- it("wraps a crowded workspace by overflow, never by re-dealing", () => {
- // 12 columns are past the ten-per-band ceiling, so the overflow starts a
- // second band: ten above, two below. The first ten keep their places —
- // filling greedily is what stops an opened pane from moving the others.
+ it("keeps a crowded workspace on ONE line, never re-dealing it", () => {
+ // Reported 2026-08-03: past a width-derived ceiling the extra columns used
+ // to start a second line — which paid for them with the height of every
+ // pane already open, and moved a pane the user was reading. Twelve columns
+ // are twelve columns now; the workspace is wider than the window and the
+ // grid scrolls sideways.
const panes = Array.from({ length: 12 }, (_, i) => [`T${i + 1}`, i] as [string, number]);
renderGrid(sessionWith(panes));
- expect(box("T1")).toMatchObject({ left: 0, top: 0 });
- expect(box("T11")).toMatchObject({ left: 0, top: 50 });
+ expect(box("T1")).toMatchObject({ left: 0, top: 0, height: 100 });
+ expect(box("T11")).toMatchObject({ top: 0, height: 100 });
+ expect(box("T11").left).toBeGreaterThan(box("T10").left);
// Same parent for every pane — a pane that moves to another parent element
// is remounted, and remounting kills the agent behind it.
expect(screen.getByTestId("pane-cell-T12").parentElement).toBe(
@@ -618,9 +621,10 @@ describe("grid layout", () => {
it("gives the panes their own rectangles back when one is restored", () => {
const panes = Array.from({ length: 12 }, (_, i) => [`T${i + 1}`, i] as [string, number]);
renderGrid(sessionWith(panes));
+ const before = box("T11");
fireEvent.click(screen.getByTestId("pane-maximize-T3"));
fireEvent.click(screen.getByTestId("pane-maximize-T3"));
- expect(box("T11")).toMatchObject({ left: 0, top: 50 });
+ expect(box("T11")).toMatchObject(before);
});
});
@@ -1420,15 +1424,17 @@ describe("resizing the workspace", () => {
expect(screen.getByTestId("pane-seam-pane:Mika:Nova")).toBeTruthy();
});
- it("puts one between two rows of terminals as well", () => {
+ it("offers one seam per boundary the USER made, and no others", () => {
+ // A crowded workspace used to grow an extra horizontal seam per wrap, for a
+ // row boundary nobody asked for. Twelve columns are one line now, so the
+ // eleven seams between them are the only ones there are.
const panes = Array.from({ length: 12 }, (_, i) => [`T${i + 1}`, i] as [string, number]);
renderGrid(sessionWith(panes));
- expect(screen.getByTestId("pane-seam-band:0:1")).toBeTruthy();
+ expect(screen.queryAllByTestId(/^pane-seam-/)).toHaveLength(11);
+ expect(screen.queryAllByTestId(/^pane-seam-band:/)).toHaveLength(0);
});
it("moves width between the two panes a seam divides and no others", () => {
- // Wide enough that all three panes share one line — below ~1140 px they
- // wrap, and a wrapped pane is not a neighbour of the seam being dragged.
const restore = measured(1800, 600);
try {
renderGrid(sessionWith([["Mika", 0], ["Nova", 1], ["Aria", 2]]));
@@ -1779,16 +1785,28 @@ describe("a workspace with far more panes than the window fits", () => {
// rows, 40 gave 7 and 100 gave 3 — readable width, unusable height, and
// nothing crashed to tell anyone.
//
- // 40 panes one per column wrap into 4 bands of 10, and a band never gets
- // less than one minimum pane height, so the workspace is drawn 4 × 240 px
- // tall however short the window is.
- renderGrid(manyPanes(40));
+ // A column four panes deep is drawn 4 × 240 px tall however short the
+ // window is, and the workspace scrolls down to the rest.
+ renderGrid(
+ sessionWith(
+ Array.from({ length: 4 }, (_, i) => [`T${i}`, 0, i] as [string, number, number]),
+ ),
+ );
expect(screen.getByTestId("agentic-grid-canvas").style.height).toBe("960px");
});
- it("scrolls once the panes stop fitting, rather than squeezing them", () => {
+ it("keeps every pane readable instead of sharing the WIDTH N ways", () => {
+ // The 2026-08-03 half of the same rule. Forty columns used to wrap into
+ // four lines of ten — which fixed the width by taking three quarters of
+ // every pane's height, and moved panes the user was reading. Now the
+ // workspace is drawn 40 × 380 px wide and scrolls sideways instead.
+ renderGrid(manyPanes(40));
+ expect(screen.getByTestId("agentic-grid-canvas").style.width).toBe("15200px");
+ });
+
+ it("scrolls on either axis once the panes stop fitting, rather than squeezing them", () => {
renderGrid(manyPanes(40));
- expect(screen.getByTestId("agentic-grid").className).toContain("overflow-y-auto");
+ expect(screen.getByTestId("agentic-grid").className).toContain("overflow-auto");
});
it("renders a pane for every one of a hundred terminals", () => {
diff --git a/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.tsx b/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.tsx
index 4d6612cf7f..9678d72fef 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.tsx
@@ -45,7 +45,11 @@ import { AgentMark } from "./AgentMark";
import { PaneActivityPill } from "./PaneActivityPill";
import { AgentPickerMenu, offersAgentChoice, type SplitAgentChoice } from "./AgentPicker";
import type { TerminalAppearance } from "./terminalThemes";
-import { bandCapacityFor, GRID_HORIZONTAL_PADDING_PX, MIN_PANE_HEIGHT_PX } from "./layout";
+import {
+ GRID_HORIZONTAL_PADDING_PX,
+ MIN_PANE_HEIGHT_PX,
+ workspaceWidthFor,
+} from "./layout";
import {
paneArrangement,
paneLayout,
@@ -834,33 +838,25 @@ export function AgenticGrid({
// Where each pane sits in the one grid below — coordinates, not nested
// lists, so a layout change never re-parents a pane (see ./layout).
- // How many panes may share one band is a question about WIDTH, not a constant:
- // eight side by side leave ~18 characters each and the agent's output becomes
- // unreadable. So the grid measures itself and wraps once panes would starve.
/*
- * CONTENT width — the box the grid tracks actually occupy, padding excluded.
+ * How big the workspace's VISIBLE area is — the grid's content box, padding
+ * excluded on both axes.
*
- * Which of the two widths this holds matters, and getting it wrong was a real
- * defect. `contentRect.width` already excludes this element's 12 px of padding
- * a side, but the value was then passed to `workspaceBandCapacityFor`, which
- * subtracts that same padding AGAIN — so the grid laid itself out 24 px
- * narrower than it is. The wizard preview measures an UNPADDED element, where
- * that helper is right, so the two flipped to a new column count at different
- * window widths and the preview appeared to lie. The seed value made it worse:
- * it came from `clientWidth`, which INCLUDES padding, so the grid could
- * silently re-column itself on the first resize after opening.
+ * Neither number decides the arrangement; the panes do. Both are the size a
+ * percentage resolves against, and both carry a floor (`canvasWidth` and
+ * `canvasHeight` below): once the columns would fall under
+ * `MIN_PANE_WIDTH_PX` or the stacks under `MIN_PANE_HEIGHT_PX`, the canvas
+ * grows past this box and the grid scrolls rather than shrinking panes
+ * further.
*
- * Now each side states which width it holds: this one is already content, so
- * it calls `bandCapacityFor` directly; the wizard, holding an outer width,
- * subtracts the padding the grid will have via `workspaceBandCapacityFor`.
+ * Which of the two widths this holds matters, and getting it wrong was a real
+ * defect back when the column COUNT came from it: `contentRect.width` already
+ * excludes this element's padding, and a helper that subtracted it a second
+ * time laid the grid out narrower than it is. The seed value has to agree —
+ * `clientWidth` INCLUDES padding, hence the subtraction in `fallback`.
*/
const gridRef = useRef<HTMLDivElement | null>(null);
const [gridWidth, setGridWidth] = useState(0);
- // How tall the workspace's visible area is. Panes are sized as FRACTIONS of
- // it now rather than by grid tracks, so unlike the width this is not only a
- // wrapping question — it is the number a percentage height resolves against,
- // and the floor under it (below) is what makes the workspace scroll instead
- // of squeezing every pane to three unreadable rows.
const [gridHeight, setGridHeight] = useState(0);
useEffect(() => {
const node = gridRef.current;
@@ -938,14 +934,6 @@ export function AgenticGrid({
resizeComposer(composerCollapsed ? COMPOSER_DEFAULT_PX : COMPOSER_COLLAPSED_PX);
}, [composerCollapsed, resizeComposer]);
- // How many columns share a row depends on WIDTH alone — the readability
- // floor under each pane. It once also shrank with the window's aspect ratio
- // ("four tall panes waste their lower half, wrap them 2 x 2"), which second-
- // guessed the split buttons: the fourth split re-dealt the workspace and a
- // pane the user was reading jumped to another row. Rows are the user's
- // choice; the layout only wraps when panes would become unreadable.
- const perBand = bandCapacityFor(gridWidth);
-
/*
* The sizes the panes are drawn at, and the seams between them.
*
@@ -996,7 +984,7 @@ export function AgenticGrid({
*/
const paintDraggedLayout = useCallback(
(next: PaneWeights) => {
- const live = paneLayout(session.terminals, perBand, next);
+ const live = paneLayout(session.terminals, next);
session.terminals.forEach((term, index) => {
const node = paneNodes.current.get(term.name);
const box = live.boxes[index];
@@ -1009,7 +997,7 @@ export function AgenticGrid({
if (node) writePosition(node, seamStyle(seam));
}
},
- [session.terminals, perBand],
+ [session.terminals],
);
const sizes = usePaneWeights(
@@ -1024,8 +1012,8 @@ export function AgenticGrid({
paintDraggedLayout,
);
const layout = useMemo(
- () => paneLayout(session.terminals, perBand, sizes.weights),
- [session.terminals, perBand, sizes.weights],
+ () => paneLayout(session.terminals, sizes.weights),
+ [session.terminals, sizes.weights],
);
/*
@@ -1133,14 +1121,22 @@ export function AgenticGrid({
const layoutBusy = sizes.dragging !== null || composer.isResizing;
/*
- * How tall the workspace is drawn, which is not always how tall it looks.
+ * How big the workspace is DRAWN, which is not always how big it looks.
+ *
+ * Panes take a percentage of these two numbers, so they are also the floor
+ * that keeps them readable. Once the columns cannot fit at
+ * `MIN_PANE_WIDTH_PX` each, or the tallest stack at `MIN_PANE_HEIGHT_PX` per
+ * pane, the canvas grows past the window and the workspace scrolls — rather
+ * than shrinking every pane further, or (as it did until 2026-08-03)
+ * rearranging the workspace behind the user's back to make the new pane fit.
+ * A workspace bigger than its window is an ordinary thing; a workspace that
+ * re-deals itself when you open a terminal is not.
*
- * Panes take a percentage of this, so it is also the floor that keeps them
- * readable: once the bands' tallest stacks cannot fit at `MIN_PANE_HEIGHT_PX`
- * each, the canvas grows past the window and the workspace scrolls rather
- * than shrinking every pane further. A maximized pane is exactly the window,
- * so it can never end up taller than the area it is being read in.
+ * A maximized pane is exactly the window on both axes, so it can never end up
+ * larger than the area it is being read in.
*/
+ const canvasWidth =
+ maximized !== null ? gridWidth : workspaceWidthFor(layout.columns, gridWidth);
const canvasHeight =
maximized !== null
? gridHeight
@@ -1235,7 +1231,6 @@ export function AgenticGrid({
next.terminals,
anchor,
added.name,
- perBand,
)
: remapColumnWeights(current, session.terminals, next.terminals),
);
@@ -1375,11 +1370,14 @@ export function AgenticGrid({
});
} else {
// The LAST one: panes are appended, so the newest is the one whose arrival
- // could have pushed the grid past its viewport. Probed rather than assumed —
- // `scrollIntoView` is absent in jsdom and in some embedded WebViews.
+ // could have pushed the grid past its viewport — SIDEWAYS as often as
+ // down, now that a workspace grows to the right instead of wrapping, so
+ // both axes are named rather than left to the browser's default.
+ // Probed rather than assumed: `scrollIntoView` is absent in jsdom and in
+ // some embedded WebViews.
const newest = paneNodes.current.get(fresh[fresh.length - 1]);
if (typeof newest?.scrollIntoView === "function") {
- newest.scrollIntoView({ block: "nearest", behavior: "auto" });
+ newest.scrollIntoView({ block: "nearest", inline: "nearest", behavior: "auto" });
}
}
const timer = window.setTimeout(() => setJustOpened(new Set()), 2600);
@@ -1429,7 +1427,7 @@ export function AgenticGrid({
// Probed rather than assumed — `scrollIntoView` is absent in jsdom and in
// some embedded WebViews, and a maximized pane fills the grid anyway.
if (typeof node?.scrollIntoView === "function") {
- node.scrollIntoView({ block: "nearest", behavior: "auto" });
+ node.scrollIntoView({ block: "nearest", inline: "nearest", behavior: "auto" });
}
const timer = window.setTimeout(() => setJustOpened(new Set()), 2600);
return () => window.clearTimeout(timer);
@@ -2151,11 +2149,13 @@ export function AgenticGrid({
data-testid="agentic-grid"
className={cn(
"relative min-h-0 min-w-0 flex-1",
- // Scrolls only once the panes would be squeezed below a readable
- // height. With a workspace that fits, this is `overflow-hidden`
- // behaviour and nothing moves. The chat stage never scrolls — its
- // one pane fills it, and the terminal scrolls inside itself.
- chatView || maximized !== null ? "overflow-hidden" : "overflow-y-auto scrollbar-jarvis",
+ // Scrolls on EITHER axis, and only once the panes would be squeezed
+ // below a readable size — sideways past `MIN_PANE_WIDTH_PX` per
+ // column, down past `MIN_PANE_HEIGHT_PX` per stacked pane. With a
+ // workspace that fits, this is `overflow-hidden` behaviour and
+ // nothing moves. The chat stage never scrolls — its one pane fills
+ // it, and the terminal scrolls inside itself.
+ chatView || maximized !== null ? "overflow-hidden" : "overflow-auto scrollbar-jarvis",
// A drag across the grid would otherwise sweep a text selection over
// every header and label it crosses.
arrange.held !== null && "select-none",
@@ -2167,23 +2167,28 @@ export function AgenticGrid({
{/*
The surface the fractions resolve against.
- Separate from the scroller because the two have different heights on
+ Separate from the scroller because the two have different sizes on
purpose: the scroller is the window, this is the workspace, and a
- workspace whose panes would fall below `MIN_PANE_HEIGHT_PX` grows past
- the window and scrolls rather than shrinking them further.
+ workspace whose panes would fall below `MIN_PANE_WIDTH_PX` or
+ `MIN_PANE_HEIGHT_PX` grows past the window on that axis and scrolls
+ rather than shrinking them further.
*/}
<div
ref={canvasRef}
data-testid="agentic-grid-canvas"
className={cn(
- "relative w-full",
+ "relative",
// The chat stage fills everything between the rail and the voice
// column. It started as a centred, capped column; the maintainer
// wants the terminal at full size (2026-07-31), and the calm framing
// comes from the rail and the card border, not from margins.
- chatView && "h-full",
+ chatView && "h-full w-full",
)}
- style={{ height: chatView ? undefined : canvasHeight || undefined }}
+ style={
+ chatView
+ ? undefined
+ : { width: canvasWidth || "100%", height: canvasHeight || undefined }
+ }
>
{session.terminals.map((term, index) => {
const box = layout.boxes[index];
diff --git a/jarvis/ui/web/frontend/src/components/agentic/WorkspaceShape.tsx b/jarvis/ui/web/frontend/src/components/agentic/WorkspaceShape.tsx
index a8643a606f..602ae4f489 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/WorkspaceShape.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/WorkspaceShape.tsx
@@ -37,12 +37,10 @@ import { Minus, Plus } from "lucide-react";
import { cn } from "@/lib/utils";
import { IconButton } from "./controls";
import {
- MAX_PANES_PER_BAND,
+ columnsWithoutScrolling,
paneGrid,
- paneLines,
- widthForOneBand,
+ widthForAllVisible,
wizardPanes,
- workspaceBandCapacityFor,
} from "./layout";
/**
@@ -113,27 +111,33 @@ export function WorkspaceShape({
names,
workspaceWidthPx,
}: WorkspaceShapeProps) {
- const perBand = useMemo(
- () => workspaceBandCapacityFor(workspaceWidthPx),
+ const grid = useMemo(() => paneGrid(wizardPanes(count)), [count]);
+ /*
+ * How many of those columns the window shows at once.
+ *
+ * The stage draws all of them — the workspace really is `count` columns wide
+ * whatever the window does — and the readout says how many are on screen
+ * before it scrolls. Two different questions since 2026-08-03, when the
+ * workspace stopped wrapping: the ARRANGEMENT no longer depends on the window
+ * at all, only the view onto it does.
+ */
+ const visible = useMemo(
+ () => columnsWithoutScrolling(workspaceWidthPx),
[workspaceWidthPx],
);
- const grid = useMemo(
- () => paneGrid(wizardPanes(count), perBand),
- [count, perBand],
- );
- const bands = useMemo(() => paneLines(count, perBand), [count, perBand]);
return (
<div className="flex flex-col gap-3 p-3">
<WorkspaceStage
columns={grid.columns}
- rows={bands}
+ visible={visible}
+ rows={grid.rows}
count={count}
names={names}
/>
<Readout
columns={grid.columns}
- bands={bands}
+ visible={visible}
count={count}
workspaceWidthPx={workspaceWidthPx}
/>
@@ -302,14 +306,22 @@ export function CountTrack({
* Every pane is placed by `paneGrid` — the function the running workspace uses
* — over the panes the backend will actually create (`wizardPanes`). The two
* cannot drift apart without the running grid changing too.
+ *
+ * The stage is the WINDOW, not the workspace. Past `visible` columns the grid
+ * inside it is drawn wider than the frame and the remainder is clipped at the
+ * right edge — which is exactly what the running workspace does, and says it
+ * more plainly than any sentence could: this many fit, the rest are a scroll
+ * away.
*/
function WorkspaceStage({
columns,
+ visible,
rows,
count,
names,
}: {
columns: number;
+ visible: number;
rows: number;
count: number;
names: string[];
@@ -340,6 +352,9 @@ function WorkspaceStage({
const safeColumns = Math.max(1, columns);
const safeRows = Math.max(1, rows);
+ // How much wider than the frame the workspace is drawn. 1 while everything
+ // fits, so the common case is an ordinary full-width grid.
+ const overshoot = Math.max(1, safeColumns / Math.max(1, visible));
const paneWidth = size.width > 0 ? size.width / safeColumns : 0;
const paneHeight = size.height > 0 ? size.height / safeRows : 0;
// Panes are laid out as a grid of equal cells, so one pane's detail level is
@@ -369,8 +384,9 @@ function WorkspaceStage({
<div
ref={stageRef}
data-testid="workspace-stage-grid"
- className="grid h-full w-full gap-1 p-1"
+ className="grid h-full gap-1 p-1"
style={{
+ width: `${overshoot * 100}%`,
gridTemplateColumns: `repeat(${safeColumns}, minmax(0, 1fr))`,
gridTemplateRows: `repeat(${safeRows}, minmax(0, 1fr))`,
}}
@@ -445,33 +461,29 @@ function StagePane({
*/
function Readout({
columns,
- bands,
+ visible,
count,
workspaceWidthPx,
}: {
columns: number;
- bands: number;
+ visible: number;
count: number;
workspaceWidthPx: number;
}) {
- const oneBandAt = widthForOneBand(count);
- const wrapped = bands > 1;
- const canUnwrap =
- wrapped && oneBandAt !== null && oneBandAt > Math.round(workspaceWidthPx);
+ const allVisibleAt = widthForAllVisible(count);
+ const scrolls = columns > visible;
let condition: string;
- if (!wrapped) {
+ if (!scrolls) {
condition = "All side by side — this window is wide enough.";
- } else if (canUnwrap) {
- condition = `Wrapped to keep every pane readable. From ${formatPx(
- oneBandAt,
- )} px wide they would all fit on one line — this window is ${formatPx(
+ } else if (allVisibleAt !== null) {
+ condition = `All side by side, ${visible} of them on screen — scroll sideways for the rest. From ${formatPx(
+ allVisibleAt,
+ )} px wide they all fit at once; this window is ${formatPx(
Math.round(workspaceWidthPx),
)} px.`;
- } else if (count > MAX_PANES_PER_BAND) {
- condition = `More than ${MAX_PANES_PER_BAND} side by side is unreadable at any window size, so they wrap.`;
} else {
- condition = "Wrapped to keep every pane readable.";
+ condition = "All side by side — scroll sideways for the rest.";
}
return (
@@ -480,7 +492,7 @@ function Readout({
className="text-xs leading-relaxed text-muted-foreground"
>
<span className="font-mono tabular-nums text-foreground">
- {columns} across × {bands} down
+ {columns} across
</span>{" "}
· {condition}
</p>
diff --git a/jarvis/ui/web/frontend/src/components/agentic/layout.test.ts b/jarvis/ui/web/frontend/src/components/agentic/layout.test.ts
index b3f8c3f7fe..cbd686d23c 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/layout.test.ts
+++ b/jarvis/ui/web/frontend/src/components/agentic/layout.test.ts
@@ -1,15 +1,12 @@
import { describe, expect, it } from "vitest";
import {
GRID_HORIZONTAL_PADDING_PX,
- MAX_PANES_PER_BAND,
MIN_PANE_WIDTH_PX,
- bandCapacityFor,
- paneColumns,
+ columnsWithoutScrolling,
paneGrid,
- paneLines,
- widthForOneBand,
+ widthForAllVisible,
wizardPanes,
- workspaceBandCapacityFor,
+ workspaceWidthFor,
} from "./layout";
/*
@@ -18,47 +15,71 @@ import {
*
* Those literals were what made this file break when the grid was tightened
* from 12 px of padding a side to 4 — a purely visual change that has no
- * business moving a column threshold, and did not: only the OUTER width at
- * which it is crossed moved, by exactly the padding. Written this way the tests
- * still pin the real contract (both helpers answer for the same window) and
- * stop failing over the frame around it.
+ * business moving a threshold, and did not: only the OUTER width at which it is
+ * crossed moved, by exactly the padding.
*/
const FOUR_COLUMNS_AT = 4 * MIN_PANE_WIDTH_PX;
const SIX_COLUMNS_AT = 6 * MIN_PANE_WIDTH_PX;
-describe("workspaceBandCapacityFor", () => {
+describe("workspaceWidthFor", () => {
+ it("is exactly the window while the columns are readable in it", () => {
+ // Nothing scrolls in the ordinary case: four columns in a window wide
+ // enough for six are four columns of a quarter of the window each.
+ expect(workspaceWidthFor(4, SIX_COLUMNS_AT)).toBe(SIX_COLUMNS_AT);
+ });
+
+ it("grows past the window rather than squeezing the columns", () => {
+ // The 2026-08-03 report: a sixth terminal on a five-column window used to
+ // wrap onto a second line, which halved the five panes the user was already
+ // reading. Now the workspace is six columns wide and the grid scrolls.
+ const window = 5 * MIN_PANE_WIDTH_PX;
+ expect(workspaceWidthFor(6, window)).toBe(6 * MIN_PANE_WIDTH_PX);
+ });
+
+ it("never lets a column fall below the readable floor, at any count", () => {
+ // Measured against a real agent on 2026-07-25: below ~380 px Claude Code
+ // truncates every line and breaks single words across rows.
+ for (const columns of [1, 2, 6, 7, 12, 40, 100]) {
+ const width = workspaceWidthFor(columns, 1440);
+ expect(width / columns).toBeGreaterThanOrEqual(MIN_PANE_WIDTH_PX);
+ }
+ });
+
+ it("is the window itself for an empty workspace", () => {
+ expect(workspaceWidthFor(0, 1440)).toBe(1440);
+ });
+});
+
+describe("columnsWithoutScrolling", () => {
it("uses the grid content width on both sides of the four-column threshold", () => {
const outer = FOUR_COLUMNS_AT + GRID_HORIZONTAL_PADDING_PX;
- expect(workspaceBandCapacityFor(outer - 1)).toBe(3);
- expect(workspaceBandCapacityFor(outer)).toBe(4);
+ expect(columnsWithoutScrolling(outer - 1)).toBe(3);
+ expect(columnsWithoutScrolling(outer)).toBe(4);
});
it("uses the grid content width on both sides of the six-column threshold", () => {
const outer = SIX_COLUMNS_AT + GRID_HORIZONTAL_PADDING_PX;
- expect(workspaceBandCapacityFor(outer - 1)).toBe(5);
- expect(workspaceBandCapacityFor(outer)).toBe(6);
+ expect(columnsWithoutScrolling(outer - 1)).toBe(5);
+ expect(columnsWithoutScrolling(outer)).toBe(6);
+ });
+
+ it("gives a laptop fewer visible columns than a large display", () => {
+ expect(columnsWithoutScrolling(1440)).toBeLessThan(
+ columnsWithoutScrolling(2560),
+ );
});
-});
-describe("the two width helpers say which width they take", () => {
- it("separates the grid's own content width from the outer width", () => {
- // The defect they exist to prevent: the running grid measures its CONTENT
- // box (padding already excluded) while the wizard measures an unpadded
- // element. Feeding both to one helper made the grid lay itself out a
- // padding's width narrower than it is, so the preview and the workspace
- // changed column count at different window widths and the preview looked
- // like a liar.
- expect(bandCapacityFor(FOUR_COLUMNS_AT)).toBe(4);
- expect(
- workspaceBandCapacityFor(FOUR_COLUMNS_AT + GRID_HORIZONTAL_PADDING_PX),
- ).toBe(4);
- // Same physical window, same answer — which is the whole point.
- expect(bandCapacityFor(FOUR_COLUMNS_AT - 1)).toBe(3);
- expect(
- workspaceBandCapacityFor(
- FOUR_COLUMNS_AT - 1 + GRID_HORIZONTAL_PADDING_PX,
- ),
- ).toBe(3);
+ it("never returns zero — one cramped column still beats none", () => {
+ expect(columnsWithoutScrolling(120)).toBe(1);
+ expect(columnsWithoutScrolling(0)).toBe(1);
+ expect(columnsWithoutScrolling(Number.NaN)).toBe(1);
+ });
+
+ it("has no ceiling — a wide enough window shows however many there are", () => {
+ // The old capacity helper stopped at ten whatever the display. A 4K wall
+ // really does fit more than ten readable columns, and nothing about the
+ // count is capped any more.
+ expect(columnsWithoutScrolling(100_000)).toBeGreaterThan(10);
});
});
@@ -80,99 +101,37 @@ describe("wizardPanes", () => {
expect(wizardPanes(-4)).toEqual([]);
});
- it("lays out exactly like the workspace it stands for", () => {
- // 8 terminals in a window wide enough for 4 columns: 4 across, 2 down —
- // the arrangement reported as missing from the preview on 2026-07-26.
- const grid = paneGrid(wizardPanes(8), 4);
- expect(grid.columns).toBe(4);
- expect(paneLines(8, 4)).toBe(2);
- // The same 8 in a narrow window really are 2 across and 4 down. Both are
- // correct; the preview has to say which one it is showing.
- expect(paneGrid(wizardPanes(8), 2).columns).toBe(2);
- expect(paneLines(8, 2)).toBe(4);
+ it("lays out exactly like the workspace it stands for, at any window size", () => {
+ // 8 terminals are 8 columns — on a 4K display and on a laptop alike. The
+ // window decides how many are ON SCREEN, never how they are arranged.
+ const grid = paneGrid(wizardPanes(8));
+ expect(grid.columns).toBe(8);
+ expect(grid.rows).toBe(1);
});
});
-describe("widthForOneBand", () => {
- it("names the width at which a count stops wrapping", () => {
- // What the readout tells the user so a maximise cannot turn the preview
- // into a broken promise: eight panes need 8 × 380 px plus the grid padding.
- expect(widthForOneBand(8)).toBe(
+describe("widthForAllVisible", () => {
+ it("names the width at which a count stops needing a sideways scroll", () => {
+ // What the readout tells the user, so a workspace that scrolls is never a
+ // surprise: eight panes need 8 × 380 px plus the grid padding.
+ expect(widthForAllVisible(8)).toBe(
8 * MIN_PANE_WIDTH_PX + GRID_HORIZONTAL_PADDING_PX,
);
// And it agrees with the helper the wizard measures through, rather than
// being a second opinion about the same threshold.
- expect(workspaceBandCapacityFor(widthForOneBand(8) as number)).toBe(8);
- });
-
- it("has nothing to offer when there is no wrap to undo", () => {
- expect(widthForOneBand(1)).toBeNull();
- });
-
- it("has nothing to offer past the readable cap, where no width is enough", () => {
- expect(widthForOneBand(MAX_PANES_PER_BAND + 1)).toBeNull();
- });
-});
-
-describe("paneColumns", () => {
- it("keeps a small workspace on one line", () => {
- // What the grid actually does today for every one of these: one band,
- // columns side by side. The wizard preview has to say the same thing.
- for (const n of [1, 2, 3, 4, 6, 8, 10]) {
- expect(paneColumns(n)).toBe(n);
- }
- });
-
- it("wraps beyond the readable width instead of shrinking panes further", () => {
- // 12 columns on one line leaves each of them too narrow to read, so the
- // overflow starts a second band: 10 above, 2 below.
- expect(paneColumns(11)).toBe(10);
- expect(paneColumns(12)).toBe(10);
+ expect(columnsWithoutScrolling(widthForAllVisible(8) as number)).toBe(8);
});
- it("fills the first band up rather than re-balancing the workspace", () => {
- // Balanced bands (21 → 7 + 7 + 7) looked tidier in a still picture, but
- // re-dealt every pane whenever one was added: the user's fourth split
- // moved a terminal they were reading to another row (2026-07-31). Greedy
- // filling keeps every existing column exactly where it is — only the
- // newest can start a band.
- expect(paneColumns(21)).toBe(10);
- expect(paneColumns(20)).toBe(10);
- });
-
- it("never moves an existing column when one more is opened", () => {
- // The user-facing contract behind greedy filling, pinned directly: for any
- // count, adding a column changes no existing placement.
- for (let count = 1; count < 24; count += 1) {
- const before = paneGrid(wizardPanes(count)).placements;
- const after = paneGrid(wizardPanes(count + 1)).placements;
- expect(after.slice(0, count)).toEqual(before);
- }
- });
-
- it("has no columns for an empty workspace", () => {
- expect(paneColumns(0)).toBe(0);
- });
-
- it("exposes the cap it wraps at", () => {
- expect(MAX_PANES_PER_BAND).toBe(10);
- });
-});
-
-describe("paneLines", () => {
- it("is one band while the workspace fits", () => {
- expect(paneLines(1)).toBe(1);
- expect(paneLines(10)).toBe(1);
- });
-
- it("grows with the wrap, so a wrapped workspace gets the height for it", () => {
- expect(paneLines(11)).toBe(2);
- expect(paneLines(12)).toBe(2);
- expect(paneLines(21)).toBe(3);
+ it("has an answer for every count — no width is ever 'not enough'", () => {
+ // The old helper returned null past ten, where the wrap was unavoidable.
+ // Nothing wraps now, so every count has a width that shows all of it.
+ expect(widthForAllVisible(24)).toBe(
+ 24 * MIN_PANE_WIDTH_PX + GRID_HORIZONTAL_PADDING_PX,
+ );
});
- it("is nothing for an empty workspace", () => {
- expect(paneLines(0)).toBe(0);
+ it("has nothing to offer when one column is the whole workspace", () => {
+ expect(widthForAllVisible(1)).toBeNull();
});
});
@@ -190,6 +149,19 @@ describe("paneGrid", () => {
]);
});
+ it("keeps every column on one line however many there are", () => {
+ // The 2026-08-03 report, at the layout level: the twelfth column is the
+ // twelfth column, not the second one of a new row. Only the user's split
+ // buttons decide which panes share space.
+ const grid = paneGrid(Array.from({ length: 12 }, (_, i) => pane(i, 0)));
+ expect(grid.columns).toBe(12);
+ expect(grid.rows).toBe(1);
+ expect(grid.placements.map((p) => p.column)).toEqual([
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
+ ]);
+ expect(grid.placements.every((p) => p.row === 1)).toBe(true);
+ });
+
it("splits DOWN inside one column and leaves the others full height", () => {
// The whole point of the two-axis model: splitting the middle pane must not
// halve the panes beside it, which is what a full-width row used to do.
@@ -224,14 +196,14 @@ describe("paneGrid", () => {
]);
});
- it("wraps a crowded workspace into a second band", () => {
- const panes = Array.from({ length: 12 }, (_, i) => pane(i, 0));
- const grid = paneGrid(panes);
- expect(grid.columns).toBe(10);
- expect(grid.rows).toBe(2);
- // The eleventh column starts the second band, back at the left edge.
- expect(grid.placements[10]).toEqual({ column: 1, row: 2, rowSpan: 1 });
- expect(grid.placements[11]).toEqual({ column: 2, row: 2, rowSpan: 1 });
+ it("never moves an existing column when one more is opened", () => {
+ // The user-facing contract, pinned directly: for any count, adding a column
+ // changes no existing placement. It used to hold only below the wrap.
+ for (let count = 1; count < 40; count += 1) {
+ const before = paneGrid(wizardPanes(count)).placements;
+ const after = paneGrid(wizardPanes(count + 1)).placements;
+ expect(after.slice(0, count)).toEqual(before);
+ }
});
it("closes gaps the backend left in the column numbers", () => {
diff --git a/jarvis/ui/web/frontend/src/components/agentic/layout.ts b/jarvis/ui/web/frontend/src/components/agentic/layout.ts
index 10253ad793..70d1f63248 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/layout.ts
+++ b/jarvis/ui/web/frontend/src/components/agentic/layout.ts
@@ -34,20 +34,28 @@
* siblings inside one grid container that never changes, and a layout change is
* only ever a change of numbers on each pane. Nothing is re-parented, so
* nothing remounts.
- */
-
-/**
- * Most columns that may share one band (one line of columns) when the available
- * width is unknown — a last-resort ceiling, not the number to lay out by.
*
- * Use `bandCapacityFor(widthPx)` wherever the width IS known, which is every
- * real render. A fixed count cannot work: ten columns in a 2560 px window give
- * each pane ~256 px, but the same ten in a 1440 px window give ~144 px — about
- * 18 characters. Measured at that width, Claude Code truncates every line and
- * breaks single words across rows ("Clau/de/Max"), which is exactly the
- * unreadable pane reported on 2026-07-25 with eight terminals in one band.
+ * ## One line of columns, however many there are
+ *
+ * The workspace never wraps. Opening a column always puts it beside the last
+ * one, and a workspace of twenty columns is twenty columns across.
+ *
+ * It used to wrap at the point where the panes would fall below
+ * `MIN_PANE_WIDTH_PX` — six on a normal desktop — and that was the wrong
+ * trade. Wrapping does not create room; it takes the height of every existing
+ * pane to pay for the new one, so the sixth split silently halved the five
+ * panes the user was already reading and dropped the new one onto a second
+ * line. The arrangement the user built changed SHAPE because of a pane they
+ * added at the end, which is exactly what a workspace must not do (reported
+ * 2026-08-03).
+ *
+ * Readability is still a floor — it is just paid for the same way the vertical
+ * one is. Below `MIN_PANE_WIDTH_PX` per column the workspace grows WIDER than
+ * the window and scrolls sideways, the way it already grows taller and scrolls
+ * down when the stacks get short (`MIN_PANE_HEIGHT_PX`). A workspace larger
+ * than the window is an ordinary thing that every editor does; a workspace
+ * that rearranges itself is not.
*/
-export const MAX_PANES_PER_BAND = 10;
/**
* Narrowest a pane may get before its agent's output stops being readable.
@@ -57,6 +65,12 @@ export const MAX_PANES_PER_BAND = 10;
* 13 px monospace a character is ~7.8 px wide, so 45 characters plus the pane's
* frame and padding lands near 380 px. Deliberately a floor on WIDTH rather than
* a count, so the same rule holds on a laptop and on a 4K display.
+ *
+ * It is the width the workspace stops SHRINKING at, not a count it stops
+ * growing at: past it the columns keep their width and the workspace scrolls
+ * sideways. Measured against a real agent on 2026-07-25 — at ~18 characters
+ * Claude Code truncates every line and breaks single words across rows
+ * ("Clau/de/Max"), which is what this number exists to prevent.
*/
export const MIN_PANE_WIDTH_PX = 380;
@@ -88,31 +102,39 @@ export const MIN_PANE_HEIGHT_PX = 240;
export const GRID_HORIZONTAL_PADDING_PX = 8;
/**
- * How many columns fit in ``widthPx`` without starving them.
+ * How wide the workspace has to be drawn to hold ``columns`` readable columns.
+ *
+ * The horizontal twin of the canvas height rule: normally the workspace is
+ * exactly the width it was given and nothing scrolls, and once the columns
+ * would be squeezed below `MIN_PANE_WIDTH_PX` it grows past the window instead
+ * and the grid scrolls sideways.
*
- * Returns at least 1 — one unreadably narrow pane still beats no pane — and
- * never more than `MAX_PANES_PER_BAND`.
+ * ``availableWidthPx`` is the grid's CONTENT width, so the return value is one
+ * too — the caller's padding is already off both.
*/
-export function bandCapacityFor(
- widthPx: number,
- minPaneWidth: number = MIN_PANE_WIDTH_PX,
+export function workspaceWidthFor(
+ columns: number,
+ availableWidthPx: number,
): number {
- if (!Number.isFinite(widthPx) || widthPx <= 0) return MAX_PANES_PER_BAND;
- const fits = Math.floor(widthPx / Math.max(1, minPaneWidth));
- return Math.max(1, Math.min(MAX_PANES_PER_BAND, fits));
+ const wanted = Math.max(0, columns) * MIN_PANE_WIDTH_PX;
+ return Math.max(availableWidthPx, wanted);
}
/**
- * Columns that fit inside the grid's content box.
+ * How many columns are visible at ``containerWidthPx`` before it scrolls.
+ *
+ * Nothing lays out by this — it is what the wizard's readout says out loud, so
+ * someone picking twelve terminals on a laptop learns they are getting a
+ * workspace they scroll rather than one that silently rearranged itself.
*
- * `clientWidth` includes padding while CSS grid tracks occupy the content box.
- * Keeping this subtraction here gives the running grid and wizard preview the
- * exact same answer at width thresholds.
+ * Takes an OUTER width (the wizard measures an unpadded element) and subtracts
+ * the padding the grid will have, so it answers for the same physical window
+ * the running grid does. Never 0: one cramped column still beats none.
*/
-export function workspaceBandCapacityFor(containerWidthPx: number): number {
- return bandCapacityFor(
- Math.max(0, containerWidthPx - GRID_HORIZONTAL_PADDING_PX),
- );
+export function columnsWithoutScrolling(containerWidthPx: number): number {
+ const content = Math.max(0, containerWidthPx - GRID_HORIZONTAL_PADDING_PX);
+ if (!Number.isFinite(content) || content <= 0) return 1;
+ return Math.max(1, Math.floor(content / MIN_PANE_WIDTH_PX));
}
/**
@@ -141,8 +163,8 @@ export interface Positioned {
* (`agentic_ide/session.py`: "A wizard-opened workspace is one row of columns").
*
* It exists so the preview cannot describe a workspace the backend would never
- * build. The old preview took a shortcut and fed the raw terminal COUNT into
- * `paneColumns`, which happens to agree here only because every terminal gets
+ * build. An earlier preview took a shortcut and derived its dots from the raw
+ * terminal COUNT, which happens to agree here only because every terminal gets
* its own column at the start. Feed `paneGrid` the same panes the grid will
* receive and the preview stops being a second opinion.
*/
@@ -154,21 +176,16 @@ export function wizardPanes(count: number): Positioned[] {
}
/**
- * Width at which ``count`` wizard-opened terminals would fit on ONE line.
+ * Window width at which ``count`` terminals are all visible at once.
*
- * The preview promises an arrangement that depends on a number the user is not
- * thinking about — how wide the window happens to be right now. Pick 8 in a
- * 1050 px window and the honest answer is "2 across, 4 down"; maximise the same
- * window and it becomes "4 across, 2 down". Reporting only the first reads as a
- * broken promise the moment the second one happens, which is exactly what was
- * reported on 2026-07-26.
- *
- * So the preview also says what a wider window would buy. Returns null when the
- * count is already on one line, or when it never can be (past
- * `MAX_PANES_PER_BAND` no width is enough — the wrap is the point).
+ * The arrangement no longer depends on the window — `count` terminals are
+ * `count` columns at every size — but how much of it you can SEE does, and the
+ * preview says so rather than letting a workspace that scrolls come as a
+ * surprise. Returns null when one column is the whole workspace and there is
+ * nothing to scroll past.
*/
-export function widthForOneBand(count: number): number | null {
- if (count <= 1 || count > MAX_PANES_PER_BAND) return null;
+export function widthForAllVisible(count: number): number | null {
+ if (count <= 1) return null;
return count * MIN_PANE_WIDTH_PX + GRID_HORIZONTAL_PADDING_PX;
}
@@ -189,38 +206,6 @@ export interface PaneGrid {
placements: PanePlacement[];
}
-/**
- * Columns per band for a workspace of ``count`` columns: the grid's width.
- *
- * Also the wizard's preview width, which is the point — the dots the user sees
- * before starting are the arrangement they get.
- *
- * Bands fill up GREEDILY: the first band takes the full capacity and only the
- * overflow starts a new one. An earlier version balanced the bands instead
- * (7 columns at capacity 6 became 4 + 3), which read as tidier in a static
- * picture but moved panes the user never touched: splitting a pane to the
- * right re-dealt the whole workspace, and a terminal that was mid-read jumped
- * to another row (reported 2026-07-31). Which panes share a row is the user's
- * decision — the split buttons are exactly that choice — so the layout's only
- * job is the readability wrap, done with the least possible movement: every
- * existing column keeps its place, and only the newest can start a band.
- */
-export function paneColumns(count: number, maxPerBand: number = MAX_PANES_PER_BAND): number {
- if (count <= 0) return 0;
- return Math.min(count, Math.max(1, maxPerBand));
-}
-
-/**
- * Bands a workspace of ``count`` columns occupies once wrapped.
- *
- * A wrapped workspace is taller, so the grid needs proportionally more rows —
- * otherwise two bands share the height of one and every pane is half as tall.
- */
-export function paneLines(count: number, maxPerBand: number = MAX_PANES_PER_BAND): number {
- const width = paneColumns(count, maxPerBand);
- return width === 0 ? 0 : Math.ceil(count / width);
-}
-
function greatestCommonDivisor(a: number, b: number): number {
let [x, y] = [Math.abs(a), Math.abs(b)];
while (y) [x, y] = [y, x % y];
@@ -240,10 +225,7 @@ function greatestCommonDivisor(a: number, b: number): number {
* pane where a column of 3 spans 2 — and every column fills exactly the same
* height whatever it holds.
*/
-export function paneGrid<T extends Positioned>(
- panes: readonly T[],
- maxPerBand: number = MAX_PANES_PER_BAND,
-): PaneGrid {
+export function paneGrid<T extends Positioned>(panes: readonly T[]): PaneGrid {
if (panes.length === 0) return { columns: 0, rows: 0, placements: [] };
// Column index by the pane's own column number, gaps closed.
@@ -257,9 +239,6 @@ export function paneGrid<T extends Positioned>(
stack.sort((a, b) => panes[a].slot - panes[b].slot);
}
- const perBand = Math.max(1, paneColumns(ordered.length, maxPerBand));
- const bands = Math.ceil(ordered.length / perBand);
-
let unit = 1;
for (const stack of stacks) {
const height = Math.max(1, stack.length);
@@ -271,17 +250,15 @@ export function paneGrid<T extends Positioned>(
const placements: PanePlacement[] = new Array(panes.length);
stacks.forEach((stack, index) => {
- const band = Math.floor(index / perBand);
- const column = (index % perBand) + 1;
const span = Math.max(1, Math.floor(unit / Math.max(1, stack.length)));
stack.forEach((pane, position) => {
placements[pane] = {
- column,
- row: band * unit + position * span + 1,
+ column: index + 1,
+ row: position * span + 1,
rowSpan: span,
};
});
});
- return { columns: perBand, rows: bands * unit, placements };
+ return { columns: ordered.length, rows: unit, placements };
}
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
index 9dc498ff0e..46facc0cd2 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/layout.width.test.ts
+++ b/jarvis/ui/web/frontend/src/components/agentic/layout.width.test.ts
@@ -1,87 +1,78 @@
import { describe, expect, it } from "vitest";
import {
- MAX_PANES_PER_BAND,
MIN_PANE_WIDTH_PX,
- bandCapacityFor,
- paneColumns,
+ columnsWithoutScrolling,
paneGrid,
+ workspaceWidthFor,
} 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.
+ * Readability is a floor on WIDTH, and the two reports that shaped it pull in
+ * opposite directions.
*
- * 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.
+ * Reported 2026-07-25: eight terminals sharing one window left each pane about
+ * 18 characters wide. Claude Code then truncates every line and breaks single
+ * words across rows ("Clau/de/Max") — measured directly against a real agent.
+ *
+ * Reported 2026-08-03: the answer to that, a wrap onto a second line, was
+ * worse. It paid for the new pane with the HEIGHT of every existing one, so a
+ * sixth terminal silently halved the five the user was reading and changed the
+ * shape of a workspace they had arranged themselves.
+ *
+ * So the floor stayed and the wrap went: past it the workspace is drawn wider
+ * than the window and scrolls, exactly as it already grows taller and scrolls
+ * down when the stacks get short.
*/
-describe("bandCapacityFor", () => {
- it("keeps every pane at least as wide as the readable floor", () => {
+describe("the readable floor under every column", () => {
+ it("holds at every window size and every count", () => {
for (const width of [800, 1280, 1440, 1920, 2560, 3840]) {
- const capacity = bandCapacityFor(width);
- expect(width / capacity).toBeGreaterThanOrEqual(MIN_PANE_WIDTH_PX);
+ for (const columns of [1, 4, 8, 16, 60]) {
+ const canvas = workspaceWidthFor(columns, width);
+ expect(canvas / columns).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("would have prevented the 2026-07-25 case, by scrolling rather than squeezing", () => {
+ // The workspace in the report was ~2400 px wide with eight panes across.
+ const canvas = workspaceWidthFor(8, 2400);
+ expect(canvas).toBeGreaterThan(2400);
+ expect(canvas / 8).toBeGreaterThanOrEqual(MIN_PANE_WIDTH_PX);
});
- it("never exceeds the static ceiling", () => {
- expect(bandCapacityFor(100_000)).toBe(MAX_PANES_PER_BAND);
+ it("costs nothing while the workspace fits", () => {
+ // Four panes on a 2K desktop: the canvas is the window, and no scrollbar
+ // appears for a workspace that was never too big.
+ expect(workspaceWidthFor(4, 2048)).toBe(2048);
});
});
-describe("splitting stays in the row", () => {
- it("keeps four splits side by side on a 2K desktop", () => {
- // Reported 2026-07-31: the fourth "split right" re-wrapped the workspace
- // to 2 x 2 — a pane the user was reading jumped to a lower row, and the
- // new one appeared above. An aspect-ratio rule used to force that wrap;
- // it is gone, because the split buttons ARE the user's row choice. Width
- // is the only thing that may wrap a workspace.
- const capacity = bandCapacityFor(2048);
- expect(paneColumns(4, capacity)).toBe(4);
- });
-});
-
-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("fills the first band before starting the next", () => {
- // 8 panes at capacity 5 → 5 + 3, never a re-balanced 4 + 4: balancing
- // moved existing panes to another row whenever one was added.
- expect(paneColumns(8, 5)).toBe(5);
+describe("splitting never re-deals the workspace", () => {
+ it("keeps splits side by side however many there are", () => {
+ // Reported 2026-07-31 as a re-wrap at the fourth split, and again
+ // 2026-08-03 at the sixth. Both had one cause: the layout decided how many
+ // panes may share a line. It does not any more — the split buttons ARE the
+ // user's arrangement, and the window only decides how much of it is on
+ // screen.
+ for (const count of [4, 6, 7, 12, 30]) {
+ const panes = Array.from({ length: count }, (_, i) => ({
+ column: i,
+ slot: 0,
+ }));
+ const grid = paneGrid(panes);
+ expect(grid.columns).toBe(count);
+ expect(grid.placements.every((p) => p.row === 1)).toBe(true);
+ }
});
- 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);
+ it("puts the seventh terminal beside the sixth on a five-column window", () => {
+ // The exact case reported on 2026-08-03, with the maintainer's screenshot:
+ // five panes across, and the sixth landing on a row of its own below.
+ const window = 5 * MIN_PANE_WIDTH_PX;
+ expect(columnsWithoutScrolling(window)).toBeLessThan(7);
+ const panes = Array.from({ length: 7 }, (_, i) => ({ column: i, slot: 0 }));
+ const grid = paneGrid(panes);
+ expect(grid.placements[5]).toEqual({ column: 6, row: 1, rowSpan: 1 });
+ expect(grid.placements[6]).toEqual({ column: 7, row: 1, rowSpan: 1 });
});
});
diff --git a/jarvis/ui/web/frontend/src/components/agentic/paneLayout.test.ts b/jarvis/ui/web/frontend/src/components/agentic/paneLayout.test.ts
index 7da0cbd927..c290f0a817 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/paneLayout.test.ts
+++ b/jarvis/ui/web/frontend/src/components/agentic/paneLayout.test.ts
@@ -29,7 +29,7 @@ function seamOf(seams: PaneSeam[], id: string): PaneSeam {
describe("paneLayout", () => {
it("splits an untouched workspace evenly, which is where it starts", () => {
- const { boxes } = paneLayout([pane("A", 0), pane("B", 1), pane("C", 2)], 10);
+ const { boxes } = paneLayout([pane("A", 0), pane("B", 1), pane("C", 2)]);
expect(boxes.map((box) => round(box.w))).toEqual([0.33, 0.33, 0.33]);
expect(boxes.map((box) => round(box.x))).toEqual([0, 0.33, 0.67]);
expect(boxes.every((box) => box.h === 1)).toBe(true);
@@ -39,7 +39,7 @@ describe("paneLayout", () => {
// The whole point of weights: the middle column is twice as wide, and the
// two beside it are unchanged relative to each other.
const weights: PaneWeights = { ...evenWeights(), columns: [1, 2, 1] };
- const { boxes } = paneLayout([pane("A", 0), pane("B", 1), pane("C", 2)], 10, weights);
+ const { boxes } = paneLayout([pane("A", 0), pane("B", 1), pane("C", 2)], weights);
expect(boxes.map((box) => round(box.w))).toEqual([0.25, 0.5, 0.25]);
});
@@ -47,48 +47,58 @@ describe("paneLayout", () => {
const weights: PaneWeights = { ...evenWeights(), panes: { B: 3 } };
const { boxes } = paneLayout(
[pane("A", 0), pane("B", 0, 1), pane("C", 0, 2)],
- 10,
weights,
);
expect(boxes.map((box) => round(box.h))).toEqual([0.2, 0.6, 0.2]);
expect(boxes.map((box) => round(box.y))).toEqual([0, 0.2, 0.8]);
});
- it("lets two bands have DIFFERENT column widths", () => {
+ it("keeps every column on one line, however many there are", () => {
+ // The 2026-08-03 report: a sixth terminal used to start a second line and
+ // halve the five panes the user was already reading. Twelve columns are
+ // twelve full-height columns now; the grid scrolls sideways instead.
+ const panes = Array.from({ length: 12 }, (_, i) => pane(`T${i}`, i));
+ const { boxes, columns } = paneLayout(panes);
+ expect(columns).toBe(12);
+ expect(boxes.every((box) => box.y === 0 && box.h === 1)).toBe(true);
+ expect(round(boxes[11].x + boxes[11].w)).toBe(1);
+ });
+
+ it("lets each column have its OWN width beside stacks of its own heights", () => {
// A CSS grid cannot express this — `grid-template-columns` is shared by
// every row — and that limitation is why the workspace stopped being one.
- const panes = Array.from({ length: 4 }, (_, i) => pane(`T${i}`, i));
- const weights: PaneWeights = { ...evenWeights(), columns: [3, 1, 1, 1] };
- const { boxes } = paneLayout(panes, 2, weights);
+ const panes = [pane("A", 0), pane("B", 1), pane("C", 1, 1)];
+ const weights: PaneWeights = {
+ columns: [3, 1],
+ panes: { C: 3 },
+ };
+ const { boxes } = paneLayout(panes, weights);
expect(round(boxes[0].w)).toBe(0.75);
expect(round(boxes[1].w)).toBe(0.25);
- // The second band never saw the first band's weights.
- expect(round(boxes[2].w)).toBe(0.5);
- expect(round(boxes[3].w)).toBe(0.5);
+ // ...and the narrow column's two panes keep their own split of the height.
+ expect(round(boxes[1].h)).toBe(0.25);
+ expect(round(boxes[2].h)).toBe(0.75);
});
it("offers a seam for every boundary and none for an edge", () => {
- const { seams } = paneLayout(
- [pane("A", 0), pane("B", 0, 1), pane("C", 1)],
- 10,
- );
+ const { seams } = paneLayout([pane("A", 0), pane("B", 0, 1), pane("C", 1)]);
expect(seams.map((seam) => seam.id).sort()).toEqual(["column:0:1", "pane:A:B"]);
expect(seamOf(seams, "column:0:1").orientation).toBe("vertical");
expect(seamOf(seams, "pane:A:B").orientation).toBe("horizontal");
});
- it("offers a seam between two bands", () => {
- const panes = Array.from({ length: 4 }, (_, i) => pane(`T${i}`, i));
- const { seams } = paneLayout(panes, 2);
- const band = seamOf(seams, "band:0:1");
- expect(band.orientation).toBe("horizontal");
- expect(band.y).toBe(0.5);
- expect(band.w).toBe(1);
+ it("has no band seams, because a workspace is one line of columns", () => {
+ // There used to be a horizontal seam per wrap. Nothing wraps, so a
+ // workspace of any size offers exactly the boundaries the user built.
+ const panes = Array.from({ length: 8 }, (_, i) => pane(`T${i}`, i));
+ const { seams } = paneLayout(panes);
+ expect(seams.every((seam) => seam.kind === "column")).toBe(true);
+ expect(seams).toHaveLength(7);
});
it("reports the height below which the workspace scrolls instead of shrinking", () => {
- // Two bands whose tallest columns hold 2 and 1 panes: three minimum pane
- // heights, not the six a least-common-multiple row grid used to demand.
+ // The tallest stack in the workspace: two panes deep, so two minimum pane
+ // heights — not the six a least-common-multiple row grid used to demand.
const panes = [
pane("A", 0),
pane("B", 0, 1),
@@ -96,43 +106,52 @@ describe("paneLayout", () => {
pane("D", 2),
pane("E", 3),
];
- expect(paneLayout(panes, 2).minHeightUnits).toBe(3);
+ expect(paneLayout(panes).minHeightUnits).toBe(2);
+ });
+
+ it("reports the columns the canvas has to be wide enough for", () => {
+ // What the grid multiplies by MIN_PANE_WIDTH_PX to decide whether the
+ // workspace is bigger than its window.
+ const panes = Array.from({ length: 7 }, (_, i) => pane(`T${i}`, i));
+ expect(paneLayout(panes).columns).toBe(7);
+ // Stacked panes share a column and do not widen the workspace.
+ expect(paneLayout([pane("A", 0), pane("B", 0, 1)]).columns).toBe(1);
});
it("closes gaps in column numbers rather than rendering a blank stripe", () => {
- const { boxes } = paneLayout([pane("A", 0), pane("B", 7)], 10);
+ const { boxes } = paneLayout([pane("A", 0), pane("B", 7)]);
expect(boxes.map((box) => round(box.x))).toEqual([0, 0.5]);
});
it("has nothing to lay out for an empty workspace", () => {
- expect(paneLayout([], 10)).toEqual({
+ expect(paneLayout([])).toEqual({
boxes: [],
seams: [],
- bands: 0,
+ columns: 0,
minHeightUnits: 0,
});
});
});
describe("dragSeam", () => {
- const twoColumns = paneLayout([pane("A", 0), pane("B", 1)], 10);
+ const twoColumns = paneLayout([pane("A", 0), pane("B", 1)]);
const seam = seamOf(twoColumns.seams, "column:0:1");
it("moves width from one side to the other and nowhere else", () => {
// 1000 px wide, dragged 250 px right: the left pane takes three quarters.
const next = dragSeam(evenWeights(), seam, 250, 1000);
- const { boxes } = paneLayout([pane("A", 0), pane("B", 1)], 10, next);
+ const { boxes } = paneLayout([pane("A", 0), pane("B", 1)], next);
expect(round(boxes[0].w)).toBe(0.75);
expect(round(boxes[1].w)).toBe(0.25);
});
it("leaves a third column untouched while its neighbours trade", () => {
const panes = [pane("A", 0), pane("B", 1), pane("C", 2)];
- const three = paneLayout(panes, 10);
+ const three = paneLayout(panes);
// 900 px wide, dragged 300 px right: A would swallow B whole, so B stops at
// its 120 px minimum and A takes the rest of the two-thirds they share.
const next = dragSeam(evenWeights(), seamOf(three.seams, "column:0:1"), 300, 900);
- const { boxes } = paneLayout(panes, 10, next);
+ const { boxes } = paneLayout(panes, next);
expect(round(boxes[0].w)).toBe(0.53);
expect(round(boxes[1].w)).toBe(0.13);
// The one that was not part of the drag keeps exactly its third.
@@ -142,27 +161,28 @@ describe("dragSeam", () => {
it("stops a pane at the minimum instead of dragging it out of existence", () => {
// A control that can be dragged to nothing has no way back.
const next = dragSeam(evenWeights(), seam, 100000, 1000);
- const { boxes } = paneLayout([pane("A", 0), pane("B", 1)], 10, next);
+ const { boxes } = paneLayout([pane("A", 0), pane("B", 1)], next);
expect(Math.round(boxes[1].w * 1000)).toBe(MIN_SEAM_PANE_PX);
});
it("shares evenly when neither side can meet the minimum", () => {
const next = dragSeam(evenWeights(), seam, 500, MIN_SEAM_PANE_PX);
- const { boxes } = paneLayout([pane("A", 0), pane("B", 1)], 10, next);
+ const { boxes } = paneLayout([pane("A", 0), pane("B", 1)], next);
expect(round(boxes[0].w)).toBe(0.5);
});
- it("converts pixels against the BAND's height, not the window's", () => {
- // Two panes stacked in a column of a two-band workspace share half the
- // height, so 100 px is twice the fraction it would be across the whole one.
+ it("converts pixels against the workspace's full height", () => {
+ // Two panes stacked in a column span the whole workspace, whatever the
+ // columns beside them hold — so 100 px of a 1000 px workspace is a tenth,
+ // moved from B to A.
const panes = [pane("A", 0), pane("B", 0, 1), pane("C", 1), pane("D", 2)];
- const layout = paneLayout(panes, 2);
+ const layout = paneLayout(panes);
const stacked = seamOf(layout.seams, "pane:A:B");
- expect(stacked.axisFraction).toBe(0.5);
+ expect(stacked.axisFraction).toBe(1);
const next = dragSeam(evenWeights(), stacked, 100, 1000);
- const { boxes } = paneLayout(panes, 2, next);
- // 100 px of a 500 px band is a fifth, moved from B to A.
- expect(round(boxes[0].h / 0.5)).toBe(0.7);
+ const { boxes } = paneLayout(panes, next);
+ expect(round(boxes[0].h)).toBe(0.6);
+ expect(round(boxes[1].h)).toBe(0.4);
});
it("does nothing when the workspace has not been measured yet", () => {
@@ -173,7 +193,7 @@ describe("dragSeam", () => {
describe("evenSeam", () => {
it("makes two neighbours equal without disturbing the rest", () => {
const panes = [pane("A", 0), pane("B", 1), pane("C", 2)];
- const seams = paneLayout(panes, 10).seams;
+ const seams = paneLayout(panes).seams;
const lopsided: PaneWeights = { ...evenWeights(), columns: [3, 1, 4] };
const next = evenSeam(lopsided, seamOf(seams, "column:0:1"));
expect(next.columns).toEqual([2, 2, 4]);
@@ -186,8 +206,8 @@ describe("weightsAfterSplit", () => {
// every other pane on the line narrower.
const before = [pane("A", 0), pane("B", 1), pane("C", 2)];
const after = [pane("A", 0), pane("New", 1), pane("B", 2), pane("C", 3)];
- const next = weightsAfterSplit(evenWeights(), before, after, "A", "New", 10);
- const { boxes } = paneLayout(after, 10, next);
+ const next = weightsAfterSplit(evenWeights(), before, after, "A", "New");
+ const { boxes } = paneLayout(after, next);
// A held a third of the line; it and the pane split off it now hold a sixth
// each — the same third between them.
expect(round(boxes[0].w)).toBe(0.17);
@@ -201,15 +221,15 @@ describe("weightsAfterSplit", () => {
const before = [pane("A", 0), pane("B", 1)];
const after = [pane("A", 0), pane("New", 1), pane("B", 2)];
const wide: PaneWeights = { ...evenWeights(), columns: [3, 1] };
- const next = weightsAfterSplit(wide, before, after, "A", "New", 10);
+ const next = weightsAfterSplit(wide, before, after, "A", "New");
expect(next.columns).toEqual([1.5, 1.5, 1]);
});
it("halves the anchor's HEIGHT when the split went downwards", () => {
const before = [pane("A", 0), pane("B", 1)];
const after = [pane("A", 0), pane("New", 0, 1), pane("B", 1)];
- const next = weightsAfterSplit(evenWeights(), before, after, "A", "New", 10);
- const { boxes } = paneLayout(after, 10, next);
+ const next = weightsAfterSplit(evenWeights(), before, after, "A", "New");
+ const { boxes } = paneLayout(after, next);
expect(round(boxes[0].h)).toBe(0.5);
expect(round(boxes[1].h)).toBe(0.5);
// The pane beside them keeps its full height — that is what makes a split
@@ -220,22 +240,32 @@ describe("weightsAfterSplit", () => {
it("splits a stacked pane in half without resizing its neighbours", () => {
const before = [pane("A", 0), pane("B", 0, 1)];
const after = [pane("A", 0), pane("B", 0, 1), pane("New", 0, 2)];
- const next = weightsAfterSplit(evenWeights(), before, after, "B", "New", 10);
- const { boxes } = paneLayout(after, 10, next);
+ const next = weightsAfterSplit(evenWeights(), before, after, "B", "New");
+ const { boxes } = paneLayout(after, next);
expect(round(boxes[0].h)).toBe(0.5);
expect(round(boxes[1].h)).toBe(0.25);
expect(round(boxes[2].h)).toBe(0.25);
});
- it("leaves the anchor alone when the new column wrapped onto another band", () => {
- // Halving would be a lie there: the two are not sharing a line, so the
- // anchor would just end up oddly narrow beside columns it never split from.
- const before = [pane("A", 0), pane("B", 1)];
- const after = [pane("A", 0), pane("New", 1), pane("B", 2)];
- const next = weightsAfterSplit(evenWeights(), before, after, "A", "New", 2);
- const { boxes } = paneLayout(after, 2, next);
- expect(round(boxes[0].w)).toBe(0.5);
- expect(round(boxes[1].w)).toBe(0.5);
+ it("still halves the anchor on a workspace wider than its window", () => {
+ // This case used to be the exception: past the wrap the new column landed
+ // on another line, so halving would have left the anchor oddly narrow
+ // beside columns it never split from. Nothing wraps now — the new pane is
+ // always the anchor's neighbour — so the rule holds at every size.
+ const before = Array.from({ length: 8 }, (_, i) => pane(`T${i}`, i));
+ const after = [
+ pane("T0", 0),
+ pane("New", 1),
+ // The backend re-packs, so everything right of the split shifts up one.
+ ...Array.from({ length: 7 }, (_, i) => pane(`T${i + 1}`, i + 2)),
+ ];
+ const next = weightsAfterSplit(evenWeights(), before, after, "T0", "New");
+ const { boxes } = paneLayout(after, next);
+ expect(round(boxes[0].w)).toBe(round(boxes[1].w));
+ // Together they hold exactly the eighth of the line T0 had to itself.
+ expect(round(boxes[0].w + boxes[1].w)).toBe(round(1 / 8));
+ // ...and no other column moved.
+ expect(round(boxes[2].w)).toBe(round(1 / 8));
});
});
diff --git a/jarvis/ui/web/frontend/src/components/agentic/paneLayout.ts b/jarvis/ui/web/frontend/src/components/agentic/paneLayout.ts
index 3904deb9dd..8f87d01f2f 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/paneLayout.ts
+++ b/jarvis/ui/web/frontend/src/components/agentic/paneLayout.ts
@@ -25,25 +25,28 @@
* a laptop; a weight does, and it is also what makes "half" mean half at every
* window size.
*
- * Three families of weight, each attached to the most stable identity available:
+ * Two families of weight, each attached to the most stable identity available:
*
* * `columns` — by column index, because a column has no id of its own (the
* backend renumbers them on every open and close). `remapColumnWeights` carries
* them across such a renumber by matching on the panes each column holds.
- * * `bands` — by band index. A band is a line of columns, and which columns share
- * one depends on the window width, so there is nothing stabler to key on.
* * `panes` — by call-sign, which IS stable for a pane's whole life.
*
+ * There used to be a third, `bands`, for the height of each line of columns.
+ * The workspace does not wrap into lines any more (see the header of
+ * `./layout`), so there is exactly one line and nothing to divide between two
+ * of them.
+ *
* ## Fractions, not a CSS grid
*
* The layout is returned as fractional rectangles because one CSS grid cannot
- * express it: `grid-template-columns` is shared by every row, so two bands could
- * never have different column widths. Panes are therefore positioned absolutely
- * inside one container — which keeps the property the grid was chosen for in the
- * first place, that a pane is never re-parented and so never unmounts (see the
- * header of `./layout`).
+ * express it: `grid-template-columns` is shared by every row, so a column's
+ * width could never be dragged independently of the panes stacked below it.
+ * Panes are therefore positioned absolutely inside one container — which keeps
+ * the property the grid was chosen for in the first place, that a pane is never
+ * re-parented and so never unmounts (see the header of `./layout`).
*/
-import { paneColumns, type Positioned } from "./layout";
+import type { Positioned } from "./layout";
/** Smallest a pane may be dragged to, on either axis. */
export const MIN_SEAM_PANE_PX = 120;
@@ -65,15 +68,13 @@ export interface Sized extends Positioned {
export interface PaneWeights {
/** Width of each column, by column index (left to right). */
columns: number[];
- /** Height of each band, by band index (top to bottom). */
- bands: number[];
/** Height of each pane within its own column's stack, by call-sign. */
panes: Record<string, number>;
}
/** The even split — what a workspace looks like before anything is dragged. */
export function evenWeights(): PaneWeights {
- return { columns: [], bands: [], panes: {} };
+ return { columns: [], panes: {} };
}
/** A pane's rectangle, as fractions of the workspace on both axes. */
@@ -82,8 +83,6 @@ export interface PaneBox {
y: number;
w: number;
h: number;
- /** Which band it sits in, top to bottom. */
- band: number;
/** Its column's index among all columns, left to right. */
columnIndex: number;
/** Its place in that column's stack, top to bottom. */
@@ -91,7 +90,7 @@ export interface PaneBox {
}
/** Which boundary a seam is, and therefore which weights a drag changes. */
-export type SeamKind = "column" | "band" | "pane";
+export type SeamKind = "column" | "pane";
/**
* A draggable boundary between two neighbours.
@@ -110,16 +109,18 @@ export interface PaneSeam {
h: number;
/**
* The two neighbours, as keys into the matching weight family: column indexes
- * for `column`, band indexes for `band`, call-signs for `pane`.
+ * for `column`, call-signs for `pane`.
*/
before: string | number;
after: string | number;
/** Combined weight of every sibling the drag redistributes within. */
groupWeight: number;
/**
- * Fraction of the workspace axis those siblings span — 1 for columns (a band
- * is the full width) and bands (the full height), the band's own height for
- * panes stacked inside one column. Turns a pointer's pixels into weight.
+ * Fraction of the workspace axis those siblings span. Always 1 now that a
+ * workspace is one line of columns — the columns span its full width, and a
+ * column's stack its full height — but kept as a field because it is what
+ * turns a pointer's pixels into weight, and reading `deltaPx / (axisPx * f)`
+ * at the drag site is what makes that conversion checkable.
*/
axisFraction: number;
/** Plain-language name, used as the seam's tooltip and accessible label. */
@@ -131,12 +132,16 @@ export interface WorkspaceLayout {
/** One box per input pane, in input order. */
boxes: PaneBox[];
seams: PaneSeam[];
- /** Lines of columns the workspace wraps into. */
- bands: number;
+ /**
+ * Columns the workspace holds, left to right — also the width below which it
+ * stops shrinking and scrolls sideways instead, in multiples of one minimum
+ * pane width. See `MIN_PANE_WIDTH_PX` in `./layout` for why there is a floor.
+ */
+ columns: number;
/**
* Height below which panes stop shrinking and the workspace scrolls instead,
- * in multiples of one minimum pane height — the tallest stack of each band,
- * added up. See `MIN_PANE_HEIGHT_PX` in `./layout` for why there is a floor.
+ * in multiples of one minimum pane height — the tallest stack in the
+ * workspace. See `MIN_PANE_HEIGHT_PX` in `./layout` for why there is a floor.
*/
minHeightUnits: number;
}
@@ -154,17 +159,17 @@ function paneWeight(weights: PaneWeights, name: string): number {
/**
* Lay a workspace out.
*
- * `maxPerBand` is the width-derived cap from `bandCapacityFor` — the same number
- * the arrangement in `./layout` is computed from, so the two never disagree
- * about where a workspace wraps.
+ * Every column the panes name gets a place on ONE line, however many there are:
+ * the workspace never re-arranges itself to fit a window (see the header of
+ * `./layout`). `columns` comes back with the boxes so the caller can decide how
+ * wide to draw the canvas, which is where the readability floor is paid now.
*/
export function paneLayout<T extends Sized>(
panes: readonly T[],
- maxPerBand: number,
weights: PaneWeights = evenWeights(),
): WorkspaceLayout {
if (panes.length === 0) {
- return { boxes: [], seams: [], bands: 0, minHeightUnits: 0 };
+ return { boxes: [], seams: [], columns: 0, minHeightUnits: 0 };
}
// Columns in left-to-right order with gaps closed, exactly as `paneGrid` does
@@ -179,123 +184,78 @@ export function paneLayout<T extends Sized>(
});
for (const stack of stacks) stack.sort((a, b) => panes[a].slot - panes[b].slot);
- const perBand = Math.max(1, paneColumns(ordered.length, maxPerBand));
- const bandCount = Math.ceil(ordered.length / perBand);
-
- // ------------------------------------------------------------------ bands
- const bandWeights = Array.from({ length: bandCount }, (_, band) =>
- weightAt(weights.bands, band),
- );
- const bandTotal = bandWeights.reduce((sum, w) => sum + w, 0) || 1;
- const bandY: number[] = [];
- const bandH: number[] = [];
- let yCursor = 0;
- for (let band = 0; band < bandCount; band += 1) {
- const height = bandWeights[band] / bandTotal;
- bandY.push(yCursor);
- bandH.push(height);
- yCursor += height;
- }
+ const columnWeights = stacks.map((_, index) => weightAt(weights.columns, index));
+ const columnTotal = columnWeights.reduce((sum, w) => sum + w, 0) || 1;
const boxes: PaneBox[] = new Array(panes.length);
const seams: PaneSeam[] = [];
- let minHeightUnits = 0;
-
- for (let band = 0; band < bandCount; band += 1) {
- const first = band * perBand;
- const inBand = ordered.slice(first, first + perBand).map((_, i) => first + i);
- const columnWeights = inBand.map((index) => weightAt(weights.columns, index));
- const columnTotal = columnWeights.reduce((sum, w) => sum + w, 0) || 1;
-
- let tallest = 1;
- let xCursor = 0;
- inBand.forEach((index, position) => {
- const width = columnWeights[position] / columnTotal;
- const stack = stacks[index];
- tallest = Math.max(tallest, stack.length);
-
- // ------------------------------------------------- panes in this column
- const stackWeights = stack.map((pane) => paneWeight(weights, panes[pane].name));
- const stackTotal = stackWeights.reduce((sum, w) => sum + w, 0) || 1;
- let stackCursor = 0;
- stack.forEach((pane, slot) => {
- const share = stackWeights[slot] / stackTotal;
- boxes[pane] = {
- x: xCursor,
- y: bandY[band] + bandH[band] * stackCursor,
- w: width,
- h: bandH[band] * share,
- band,
- columnIndex: index,
- slotIndex: slot,
- };
- if (slot > 0) {
- seams.push({
- id: `pane:${panes[stack[slot - 1]].name}:${panes[pane].name}`,
- kind: "pane",
- orientation: "horizontal",
- x: xCursor,
- y: bandY[band] + bandH[band] * stackCursor,
- w: width,
- h: 0,
- before: panes[stack[slot - 1]].name,
- after: panes[pane].name,
- groupWeight: stackTotal,
- axisFraction: bandH[band],
- label: `Drag to resize ${panes[stack[slot - 1]].name} and ${panes[pane].name}`,
- });
- }
- stackCursor += share;
- });
-
- if (position > 0) {
+ let tallest = 1;
+ let xCursor = 0;
+
+ stacks.forEach((stack, index) => {
+ const width = columnWeights[index] / columnTotal;
+ tallest = Math.max(tallest, stack.length);
+
+ // --------------------------------------------------- panes in this column
+ const stackWeights = stack.map((pane) => paneWeight(weights, panes[pane].name));
+ const stackTotal = stackWeights.reduce((sum, w) => sum + w, 0) || 1;
+ let stackCursor = 0;
+ stack.forEach((pane, slot) => {
+ const share = stackWeights[slot] / stackTotal;
+ boxes[pane] = {
+ x: xCursor,
+ y: stackCursor,
+ w: width,
+ h: share,
+ columnIndex: index,
+ slotIndex: slot,
+ };
+ if (slot > 0) {
seams.push({
- id: `column:${inBand[position - 1]}:${index}`,
- kind: "column",
- orientation: "vertical",
+ id: `pane:${panes[stack[slot - 1]].name}:${panes[pane].name}`,
+ kind: "pane",
+ orientation: "horizontal",
x: xCursor,
- y: bandY[band],
- w: 0,
- h: bandH[band],
- before: inBand[position - 1],
- after: index,
- groupWeight: columnTotal,
+ y: stackCursor,
+ w: width,
+ h: 0,
+ before: panes[stack[slot - 1]].name,
+ after: panes[pane].name,
+ groupWeight: stackTotal,
axisFraction: 1,
- label: "Drag to resize these two columns of terminals",
+ label: `Drag to resize ${panes[stack[slot - 1]].name} and ${panes[pane].name}`,
});
}
- xCursor += width;
+ stackCursor += share;
});
- minHeightUnits += tallest;
-
- if (band > 0) {
+ if (index > 0) {
seams.push({
- id: `band:${band - 1}:${band}`,
- kind: "band",
- orientation: "horizontal",
- x: 0,
- y: bandY[band],
- w: 1,
- h: 0,
- before: band - 1,
- after: band,
- groupWeight: bandTotal,
+ id: `column:${index - 1}:${index}`,
+ kind: "column",
+ orientation: "vertical",
+ x: xCursor,
+ y: 0,
+ w: 0,
+ h: 1,
+ before: index - 1,
+ after: index,
+ groupWeight: columnTotal,
axisFraction: 1,
- label: "Drag to resize these two rows of terminals",
+ label: "Drag to resize these two columns of terminals",
});
}
- }
+ xCursor += width;
+ });
- return { boxes, seams, bands: bandCount, minHeightUnits };
+ return { boxes, seams, columns: stacks.length, minHeightUnits: tallest };
}
// ---------------------------------------------------------------- dragging
function readSide(weights: PaneWeights, seam: PaneSeam, side: string | number): number {
if (seam.kind === "pane") return paneWeight(weights, String(side));
- const list = seam.kind === "column" ? weights.columns : weights.bands;
- return weightAt(list, Number(side));
+ return weightAt(weights.columns, Number(side));
}
function writeSide(
@@ -307,15 +267,14 @@ function writeSide(
if (seam.kind === "pane") {
return { ...weights, panes: { ...weights.panes, [String(side)]: value } };
}
- const key = seam.kind === "column" ? "columns" : "bands";
- const list = [...weights[key]];
+ const list = [...weights.columns];
const index = Number(side);
// A weight nobody has dragged yet is absent, not zero — fill the gap with the
// default so writing index 5 of an empty list does not create four holes that
// read back as 0 and collapse their columns.
while (list.length <= index) list.push(1);
list[index] = value;
- return { ...weights, [key]: list };
+ return { ...weights, columns: list };
}
/**
@@ -479,7 +438,7 @@ export function remapColumnWeights<T extends Sized>(
const panes = Object.fromEntries(
Object.entries(weights.panes).filter(([name]) => live.has(name)),
);
- return { columns, bands: [...weights.bands], panes };
+ return { columns, panes };
}
/**
@@ -490,10 +449,9 @@ export function remapColumnWeights<T extends Sized>(
* lost width to make room for a new full-height column — and people reasonably
* expect the pane they clicked to be the only one that changes.
*
- * Halving is skipped in the one case where it would be a lie: when the new
- * column wrapped onto a different line than its anchor, the two are not sharing
- * anything, and shrinking the anchor to half of its band would leave it oddly
- * narrow next to neighbours it never split from.
+ * Halving now holds for every split, including the ones that used to land on
+ * another line: a workspace is one line of columns, so the new pane and its
+ * anchor are always neighbours sharing the room the anchor had.
*/
export function weightsAfterSplit<T extends Sized>(
weights: PaneWeights,
@@ -501,7 +459,6 @@ export function weightsAfterSplit<T extends Sized>(
after: readonly T[],
anchor: string,
added: string,
- maxPerBand: number,
): PaneWeights {
const carried = remapColumnWeights(weights, before, after);
const nowIn = columnIndexes(after);
@@ -519,11 +476,6 @@ export function weightsAfterSplit<T extends Sized>(
};
}
- const perBand = Math.max(1, paneColumns(columnCount(after), maxPerBand));
- if (Math.floor(anchorColumn / perBand) !== Math.floor(addedColumn / perBand)) {
- return carried;
- }
-
// Split right: the two halves together occupy the width the anchor had.
const half = weightAt(carried.columns, anchorColumn) / 2;
const columns = [...carried.columns];
diff --git a/jarvis/ui/web/frontend/src/components/agentic/usePaneWeights.ts b/jarvis/ui/web/frontend/src/components/agentic/usePaneWeights.ts
index c199fdca18..20dde9d9d7 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/usePaneWeights.ts
+++ b/jarvis/ui/web/frontend/src/components/agentic/usePaneWeights.ts
@@ -47,9 +47,11 @@ export function loadWeights(workspaceId: string): PaneWeights {
const raw = window.localStorage.getItem(storageKey(workspaceId));
if (!raw) return evenWeights();
const parsed = JSON.parse(raw) as Partial<PaneWeights>;
+ // Only the families that still exist are read back. Entries written by an
+ // older build carry a `bands` list too — the workspace no longer wraps into
+ // bands, so it is dropped here rather than kept as a number nothing means.
return {
columns: Array.isArray(parsed.columns) ? parsed.columns.map(Number) : [],
- bands: Array.isArray(parsed.bands) ? parsed.bands.map(Number) : [],
panes:
parsed.panes && typeof parsed.panes === "object"
? (parsed.panes as Record<string, number>)
diff --git a/jarvis/ui/web/frontend/src/views/AgenticIdeView.test.tsx b/jarvis/ui/web/frontend/src/views/AgenticIdeView.test.tsx
index 1bf4f09c07..97e96d0ec0 100644
--- a/jarvis/ui/web/frontend/src/views/AgenticIdeView.test.tsx
+++ b/jarvis/ui/web/frontend/src/views/AgenticIdeView.test.tsx
@@ -554,9 +554,17 @@ describe("Agentic IDE launcher", () => {
}
}
- /** Columns and bands the stage lays its panes out in. */
+ /** Columns and rows the stage lays its panes out in. */
const columnsOf = (stage: HTMLElement) => stage.style.gridTemplateColumns;
const rowsOf = (stage: HTMLElement) => stage.style.gridTemplateRows;
+ /**
+ * How much wider than its frame the stage draws the workspace.
+ *
+ * The frame is the WINDOW and the grid inside it is the workspace, so
+ * anything over 100 % is the part that will be a sideways scroll away — the
+ * preview's way of saying "this many fit, the rest are to the right".
+ */
+ const widthOf = (stage: HTMLElement) => stage.style.width;
/**
* A pixel width the way the readout writes it.
@@ -657,75 +665,83 @@ describe("Agentic IDE launcher", () => {
).toBe(true);
});
- it("previews 12 terminals as 6 and 6 when the window is wide enough", async () => {
- // 2328 px of workspace minus the grid's padding fits six 380 px panes, so
- // the twelve wrap into two even bands — the arrangement the user asked for.
+ it("previews 12 terminals as 12 columns, six of them on screen", async () => {
+ // 2328 px of workspace minus the grid's padding fits six 380 px panes. All
+ // twelve are still ONE line — the workspace is twice the window and scrolls
+ // — because a wrap would have paid for the new panes with the height of the
+ // ones already open (reported 2026-08-03).
const stage = await stageAt(2328, "12");
- expect(columnsOf(stage)).toBe("repeat(6, minmax(0, 1fr))");
- expect(rowsOf(stage)).toBe("repeat(2, minmax(0, 1fr))");
+ expect(columnsOf(stage)).toBe("repeat(12, minmax(0, 1fr))");
+ expect(rowsOf(stage)).toBe("repeat(1, minmax(0, 1fr))");
+ expect(widthOf(stage)).toBe("200%");
});
- it("previews the narrower arrangement a narrow window will really produce", async () => {
- // The same twelve in a 1314 px workspace: only three panes stay readable
- // per line, so the grid makes 3 × 4. The preview promised 6 + 6 here once,
- // which is the drift this test exists to catch.
+ it("previews the same twelve in a narrow window, fewer of them on screen", async () => {
+ // The arrangement does not depend on the window any more — only the view
+ // onto it does. A 1314 px workspace shows three of the twelve columns at
+ // the same readable width, and the rest are a scroll to the right.
const stage = await stageAt(1314, "12");
- expect(columnsOf(stage)).toBe("repeat(3, minmax(0, 1fr))");
- expect(rowsOf(stage)).toBe("repeat(4, minmax(0, 1fr))");
+ expect(columnsOf(stage)).toBe("repeat(12, minmax(0, 1fr))");
+ expect(rowsOf(stage)).toBe("repeat(1, minmax(0, 1fr))");
+ expect(widthOf(stage)).toBe("400%");
});
it("keeps a small workspace on one line at any usable width", async () => {
const stage = await stageAt(1314, "3");
expect(columnsOf(stage)).toBe("repeat(3, minmax(0, 1fr))");
expect(rowsOf(stage)).toBe("repeat(1, minmax(0, 1fr))");
+ // Nothing to scroll past, so the stage is an ordinary full-width grid.
+ expect(widthOf(stage)).toBe("100%");
});
it("previews four terminals side by side in a 2K workspace", async () => {
// An aspect-ratio rule used to fold these into 2 x 2. It re-dealt the
// running workspace on the fourth split (reported 2026-07-31), so rows are
- // the user's choice now and only width wraps — the preview says the same.
+ // the user's choice now — the preview says the same.
const stage = await stageAt(2048, "4", 1164);
expect(columnsOf(stage)).toBe("repeat(4, minmax(0, 1fr))");
expect(rowsOf(stage)).toBe("repeat(1, minmax(0, 1fr))");
+ expect(widthOf(stage)).toBe("100%");
});
- it("draws one pane per terminal and never more than the stage can hold", async () => {
+ it("draws one pane per terminal and never grows the box to fit them", async () => {
// The old dot preview sat in a fixed 40×40 px box with nothing bounding it,
// so a high count in a narrow window grew a tall column of dots straight out
- // through the card, over the buttons above and below. The stage divides a
- // FIXED height between its rows instead, so no count can overflow it — the
- // panes get thinner, the box does not grow.
+ // through the card, over the buttons above and below. The stage is a FIXED
+ // frame that clips instead — the panes past the window are drawn outside it
+ // and cut off at its edge, which is what the workspace itself does.
const stage = await stageAt(800, "12");
expect(stage.children.length).toBe(12);
- expect(columnsOf(stage)).toBe("repeat(2, minmax(0, 1fr))");
- expect(rowsOf(stage)).toBe("repeat(6, minmax(0, 1fr))");
+ expect(columnsOf(stage)).toBe("repeat(12, minmax(0, 1fr))");
+ expect(rowsOf(stage)).toBe("repeat(1, minmax(0, 1fr))");
+ expect(widthOf(stage)).toBe("600%");
});
- it("names the window width its arrangement depends on", async () => {
- // The reported bug: the preview said "2 across, 4 down" in a 1050 px window
- // and the workspace opened 4 × 2 once maximised. Both are right — what was
- // missing is that the arrangement has a condition at all.
+ it("names the window width at which nothing has to be scrolled to", async () => {
+ // The reported bug behind this readout: an arrangement stated without its
+ // condition. The condition changed on 2026-08-03 — the arrangement is fixed
+ // now and the window decides how much of it is visible — so the sentence
+ // has to say that instead.
await stageAt(1050, "8");
const readout = screen.getByTestId("workspace-stage-readout");
- expect(readout.textContent).toContain("2 across");
- expect(readout.textContent).toContain("4 down");
+ expect(readout.textContent).toContain("8 across");
+ expect(readout.textContent).toContain("2 of them on screen");
// 8 panes × the readable minimum + the grid's own padding — the width at
- // which they all fit on one line, stated so a maximise cannot turn the
- // preview into a broken promise. Computed rather than written out, because
- // tightening the grid's padding moves this number without changing
+ // which they are all visible at once. Computed rather than written out,
+ // because tightening the grid's padding moves this number without changing
// anything the test is actually about.
//
// `grouped` spells out the narrow no-break space the readout separates
// thousands with: an invisible literal here reads as a plain space,
// passes review, and fails the run.
- const oneBandWidth = 8 * MIN_PANE_WIDTH_PX + GRID_HORIZONTAL_PADDING_PX;
+ const allVisibleWidth = 8 * MIN_PANE_WIDTH_PX + GRID_HORIZONTAL_PADDING_PX;
expect(readout.textContent).toContain(
- grouped(String(oneBandWidth).replace(/\B(?=(\d{3})+(?!\d))/g, " ")),
+ grouped(String(allVisibleWidth).replace(/\B(?=(\d{3})+(?!\d))/g, " ")),
);
// 1 056, not 1 050: the view rounds the measured width to 16 px steps so a
// one-pixel drift cannot churn the layout, and the readout reports the width
- // the arrangement was actually decided from rather than a truer-looking one.
+ // it actually answered for rather than a truer-looking one.
expect(readout.textContent).toContain(grouped("1 056"));
});
@@ -734,8 +750,8 @@ describe("Agentic IDE launcher", () => {
const readout = screen.getByTestId("workspace-stage-readout");
expect(readout.textContent).toContain("8 across");
- expect(readout.textContent).toContain("1 down");
expect(readout.textContent).toMatch(/wide enough/i);
+ expect(readout.textContent).not.toMatch(/scroll/i);
});
it("says so plainly when the machine has no terminal backend", async () => {