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.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
fix(agentic-ide): commit the pane-layout module the grid imports
Ruben Lütkeee2d0f2864ee
diff --git a/jarvis/ui/web/frontend/src/components/agentic/layout.test.ts b/jarvis/ui/web/frontend/src/components/agentic/layout.test.tsnew file mode 100644index 0000000000..d1e565c067--- /dev/null+++ b/jarvis/ui/web/frontend/src/components/agentic/layout.test.ts@@ -0,0 +1,83 @@+import { describe, expect, it } from "vitest";+import { MAX_PANES_PER_BAND, paneColumns, paneLines, paneRows } from "./layout";++describe("paneColumns", () => {+ it("keeps a small workspace on one line", () => {+ // What the grid actually does today for every one of these: one row,+ // panes 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 panes on one line leaves each of them too narrow to read, so they+ // break into two even lines: 6 above, 6 below.+ expect(paneColumns(11)).toBe(6);+ expect(paneColumns(12)).toBe(6);+ });++ it("keeps the lines even rather than filling the first one up", () => {+ // 21 panes could be 10 + 10 + 1; an almost empty last line next to two+ // full ones looks broken, so every line gets the same width.+ expect(paneColumns(21)).toBe(7);+ expect(paneColumns(20)).toBe(10);+ });++ 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 line while the row fits", () => {+ expect(paneLines(1)).toBe(1);+ expect(paneLines(10)).toBe(1);+ });++ it("grows with the wrap, so a wrapped row gets the height for it", () => {+ expect(paneLines(11)).toBe(2);+ expect(paneLines(12)).toBe(2);+ expect(paneLines(21)).toBe(3);+ });++ it("is nothing for an empty workspace", () => {+ expect(paneLines(0)).toBe(0);+ });+});++describe("paneRows", () => {+ const term = (name: string, row: number) => ({ name, row });++ it("groups the panes by the row the backend gave them", () => {+ const panes = [term("Mika", 0), term("Nova", 0), term("Aria", 1)];+ expect(paneRows(panes).map((r) => r.map((p) => p.name))).toEqual([+ ["Mika", "Nova"],+ ["Aria"],+ ]);+ });++ it("keeps an over-wide row whole — the grid wraps it, not this", () => {+ // Splitting it here would move panes into a new parent element on every+ // wrap, which unmounts them and kills the agents behind them.+ const panes = Array.from({ length: 12 }, (_, i) => term(`T${i + 1}`, 0));+ const rows = paneRows(panes);+ expect(rows).toHaveLength(1);+ expect(rows[0]).toHaveLength(12);+ });++ it("skips rows the backend left empty", () => {+ // close_terminal() re-packs rows, but a session read mid-change can still+ // carry a gap — an empty row would render as a blank stripe.+ const panes = [term("Mika", 0), term("Nova", 3)];+ expect(paneRows(panes).map((r) => r.length)).toEqual([1, 1]);+ });++ it("handles an empty workspace", () => {+ expect(paneRows([])).toEqual([]);+ });+});diff --git a/jarvis/ui/web/frontend/src/components/agentic/layout.ts b/jarvis/ui/web/frontend/src/components/agentic/layout.tsnew file mode 100644index 0000000000..16ddd2e966--- /dev/null+++ b/jarvis/ui/web/frontend/src/components/agentic/layout.ts@@ -0,0 +1,82 @@+/**+ * How N agent panes are laid out in the workspace — the ONE answer, shared by+ * the grid that renders them and the wizard that previews them.+ *+ * It used to be two answers. The grid put every pane of a row side by side+ * (the backend starts a session with all panes in row 0), while the wizard's+ * dot preview had its own formula that stacked them 3-per-line — so picking+ * "4 terminals" showed 3 above and 1 below and then opened 4 side by side. A+ * preview that contradicts the thing it previews is worse than no preview, and+ * the only durable fix is that both call the same function.+ *+ * The rule: panes stay on one line for as long as they stay readable, and wrap+ * into EVEN lines once they don't. Even, because filling the first line to the+ * cap and leaving a remainder (12 → 10 + 2) reads as a broken layout, whereas+ * 6 + 6 reads as a grid. Below the cap nothing wraps, so the common two-,+ * four-, and eight-pane workspaces keep the single row they have today.+ *+ * Note what this returns: a WIDTH, not a list of lines. The grid renders one+ * row's panes as siblings in a CSS grid and lets the browser wrap them, which+ * matters because every pane has to stay mounted — moving a pane into a new+ * parent element would tear down its WebSocket and kill the agent behind it.+ */++/**+ * Most panes that may share one line.+ *+ * Past this, panes get too narrow for their terminal content to survive — an+ * agent's output wraps into an unreadable column and the pane is there in name+ * only. Wrapping keeps every pane wide enough to actually read.+ */+export const MAX_PANES_PER_BAND = 10;++/** Anything with a grid row — the pane fields this module actually needs. */+interface Positioned {+ row: number;+}++/**+ * Panes per line for a row of ``count`` panes: the row's width in the grid.+ *+ * Also the wizard's preview width, which is the point — the dots the user sees+ * before starting are the arrangement they get.+ */+export function paneColumns(count: number, maxPerBand: number = MAX_PANES_PER_BAND): number {+ if (count <= 0) return 0;+ const cap = Math.max(1, maxPerBand);+ const bands = Math.ceil(count / cap);+ return Math.ceil(count / bands);+}++/**+ * Lines a row of ``count`` panes occupies once wrapped.+ *+ * The grid gives a wrapped row proportionally more height, so a row of 12+ * (two lines) does not get squeezed into the same band as a row of 1.+ */+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);+}++/**+ * The workspace's rows, in render order, with empty ones dropped.+ *+ * Rows come from the backend and carry the user's own splits ("split down"+ * opens a row). A gap in the row numbers — possible while a close is still+ * being packed away — must not render as a blank stripe.+ */+export function paneRows<T extends Positioned>(panes: readonly T[]): T[][] {+ const rows: T[][] = [];+ const byRow = new Map<number, T[]>();+ for (const pane of panes) {+ let row = byRow.get(pane.row);+ if (!row) {+ row = [];+ byRow.set(pane.row, row);+ rows.push(row);+ }+ row.push(pane);+ }+ return rows;+}