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): keep dragged pane widths with their panes across outside changes
Ruben Lütke56e4eba34acb
diff --git a/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.test.tsx b/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.test.tsxindex 5709a6ea6f..f9e029b1ae 100644--- a/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.test.tsx+++ b/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.test.tsx@@ -1582,6 +1582,84 @@ describe("resizing the workspace", () => {await waitFor(() => expect(stored().panes).toEqual({ Mika: 0.5, New: 0.5 }));});++ /*+ * The workspace changes WITHOUT this grid doing it.+ *+ * A terminal opened by voice, closed by another client, or rearranged by the+ * backend resuming after a restart arrives here as nothing but a new+ * `session` prop — no callback ran, so nothing remapped the index-keyed+ * column weights. This is how a closed pane's dragged width ended up on a+ * different pane's column (2026-07-31: one pane squeezed, its nearly empty+ * neighbour twice as wide).+ */+ it("keeps dragged widths with their panes when the workspace changes from outside", async () => {+ const restore = measured(1800, 600);+ try {+ const { rerender } = renderGrid(+ sessionWith([["Mika", 0], ["Nova", 1], ["Aria", 2]]),+ );+ // Drag the seam between Nova and Aria so Aria is the wide one.+ dragSeamBy("pane-seam-column:1:2", 1200, 900);+ expect(widthOf("Aria")).toBe(50);++ // Mika goes away without this grid being asked — every index shifts.+ rerender({ session: sessionWith([["Nova", 0], ["Aria", 1]]) });++ // Aria keeps the width it was dragged to; index-keyed weights would have+ // handed it to Nova and squeezed Aria instead.+ expect(widthOf("Aria")).toBe(75);+ expect(widthOf("Nova")).toBe(25);+ } finally {+ restore();+ }+ });++ it("carries dragged widths across a reload behind which the workspace changed", () => {+ // What an earlier session left behind: Aria dragged wide while Mika still+ // existed. The reload happens after Mika was closed elsewhere, so the+ // stored index-keyed widths no longer match the session being mounted.+ window.localStorage.setItem(+ WEIGHTS_KEY,+ JSON.stringify({ columns: [1, 0.5, 1.5], bands: [], panes: {} }),+ );+ window.localStorage.setItem(+ "jarvis.agenticIde.paneArrangement.v1.ide_test",+ JSON.stringify({ Mika: 0, Nova: 1, Aria: 2 }),+ );+ const restore = measured(1800, 600);+ try {+ renderGrid(sessionWith([["Nova", 0], ["Aria", 1]]));+ expect(widthOf("Aria")).toBe(75);+ expect(widthOf("Nova")).toBe(25);+ } finally {+ restore();+ }+ });++ it("does not read a rename as a rearrangement", async () => {+ vi.mocked(api.renameTerminal).mockResolvedValue(+ sessionWith([["Frontend", 0], ["Nova", 1]]),+ );+ const restore = measured(1000, 600);+ try {+ const { rerender } = renderGrid(sessionWith([["Mika", 0], ["Nova", 1]]));+ dragSeamBy("pane-seam-column:0:1", 500, 750);+ expect(widthOf("Mika")).toBe(75);++ fireEvent.click(screen.getByTestId("pane-rename-Mika"));+ await waitFor(() =>+ expect(api.renameTerminal).toHaveBeenCalledWith("Mika", "Frontend"),+ );+ rerender({ session: sessionWith([["Frontend", 0], ["Nova", 1]]) });++ // The renamed pane keeps the width that was dragged for it — a remap+ // here would have seen "Mika left, Frontend arrived" and reset it.+ expect(widthOf("Frontend")).toBe(75);+ } finally {+ restore();+ }+ });});describe("a workspace with far more panes than the window fits", () => {diff --git a/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.tsx b/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.tsxindex bd51f0434b..6e9f26b481 100644--- a/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.tsx+++ b/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.tsx@@ -59,14 +59,21 @@ import {MIN_PANE_HEIGHT_PX,} from "./layout";import {+ paneArrangement,paneLayout,+ panesFromArrangement,remapColumnWeights,+ sameArrangement,weightsAfterSplit,type PaneBox,type PaneSeam,type PaneWeights,} from "./paneLayout";-import { usePaneWeights } from "./usePaneWeights";+import {+ loadStoredArrangement,+ saveStoredArrangement,+ usePaneWeights,+} from "./usePaneWeights";import { ContinueInterrupted } from "./ContinueInterrupted";import { PaneNotifications } from "./PaneNotifications";import { PromptPreview } from "./PromptPreview";@@ -821,6 +828,62 @@ export function AgenticGrid({[session.terminals, perBand, sizes.weights],);+ /*+ * Which panes the current column weights are keyed to.+ *+ * Weights are stored by COLUMN INDEX (see `paneLayout`), and the backend+ * renumbers columns on every open and close. The grid's own actions remap+ * the weights in the same breath — but a workspace also changes from OUTSIDE+ * this grid: a terminal opened by voice, a second client, the backend+ * resuming after a restart. Those arrive as a new `session.terminals` with+ * nothing else said, and index-keyed widths then land on whichever pane+ * holds the index now (observed 2026-07-31: after a restart re-opened the+ * workspace, one pane inherited the width its closed neighbour had been+ * dragged to, and the pane that owned it was squeezed instead).+ *+ * So the arrangement the weights belong to is tracked in a ref — updated by+ * every action that already remaps — and persisted beside the weights. The+ * effect below answers any drift between it and the session with the same+ * remap the grid's own actions use, which also covers a fresh mount whose+ * stored weights were keyed to an arrangement that changed while no grid+ * was watching.+ */+ const weightsBasis = useRef<Record<string, number> | null>(null);+ const weightsBasisFor = useRef<string | null>(null);++ /** Declare the weights remapped: they are keyed to ``terminals`` now. */+ const rebaseWeights = useCallback(+ (terminals: readonly { name: string; column: number; slot: number }[]) => {+ const arrangement = paneArrangement(terminals);+ weightsBasis.current = arrangement;+ weightsBasisFor.current = session.id;+ saveStoredArrangement(session.id, arrangement);+ },+ [session.id],+ );++ useEffect(() => {+ // A workspace switch loads that workspace's weights (see `usePaneWeights`),+ // so the basis switches with it: its stored arrangement when one survives,+ // otherwise the session as it stands — never the outgoing workspace's.+ if (weightsBasisFor.current !== session.id) {+ weightsBasisFor.current = session.id;+ weightsBasis.current =+ loadStoredArrangement(session.id) ?? paneArrangement(session.terminals);+ }+ const basis = weightsBasis.current;+ const current = paneArrangement(session.terminals);+ if (basis && !sameArrangement(basis, current)) {+ // Runs AFTER the hook's own load effect in the same commit, so on a+ // workspace switch this updater already sees that workspace's weights.+ sizes.setWeights((weights) =>+ remapColumnWeights(weights, panesFromArrangement(basis), session.terminals),+ );+ }+ weightsBasis.current = current;+ saveStoredArrangement(session.id, current);+ }, [session.id, session.terminals, sizes.setWeights]);+/** Hold the dragged sizes against anything else that renders mid-gesture.*@@ -909,6 +972,7 @@ export function AgenticGrid({): remapColumnWeights(current, session.terminals, next.terminals),);+ rebaseWeights(next.terminals);// ...unless it is a plain terminal — that one is typed into by hand, and// stealing the target would silently redirect the next prompt into a pane// that refuses it.@@ -939,6 +1003,7 @@ export function AgenticGrid({sizes.setWeights((current) =>remapColumnWeights(current, session.terminals, next.terminals),);+ rebaseWeights(next.terminals);onSessionChanged?.(next);} catch (error) {pushToast("error", (error as Error).message);@@ -946,7 +1011,7 @@ export function AgenticGrid({setWorking(false);}},- [onSessionChanged, pushToast, session.terminals, sizes.setWeights],+ [onSessionChanged, pushToast, rebaseWeights, session.terminals, sizes.setWeights],);const arrange = usePaneArrange(@@ -1104,6 +1169,18 @@ export function AgenticGrid({setStatuses((current) => rekey(current, from, to));setRecaps((current) => rekey(current, from, to));setRestartTokens((current) => rekey(current, from, to));+ // The pane's dragged height is keyed by call-sign too, and the basis+ // map is what stops the remap effect from reading a rename as "one+ // pane left, another arrived" — which would put the lone column of a+ // renamed pane back at its default width.+ sizes.setWeights((current) => ({+ ...current,+ panes: rekey(current.panes, from, to),+ }));+ if (weightsBasis.current) {+ weightsBasis.current = rekey(weightsBasis.current, from, to);+ saveStoredArrangement(session.id, weightsBasis.current);+ }setTarget((current) => (current === from ? to : current));setMaximized((current) => (current === from ? to : current));setPendingClose((current) => (current === from ? to : current));@@ -1128,7 +1205,7 @@ export function AgenticGrid({setWorking(false);}},- [onSessionChanged, pushToast],+ [onSessionChanged, pushToast, session.id, sizes.setWeights],);/** Where the bell's "jump to pane" goes — here, or via the view for a tab. */@@ -1169,6 +1246,7 @@ export function AgenticGrid({sizes.setWeights((current) =>remapColumnWeights(current, session.terminals, next.terminals),);+ rebaseWeights(next.terminals);onSessionChanged?.(next);if (target === name) setTarget(next.terminals.find(takesPrompts)?.name ?? "");} catch (e) {@@ -1187,6 +1265,7 @@ export function AgenticGrid({sizes.setWeights((current) =>remapColumnWeights(current, session.terminals, result.session.terminals),);+ rebaseWeights(result.session.terminals);onSessionChanged?.(result.session);const remaining = new Set(result.session.terminals.map((term) => term.name));if (maximized && !remaining.has(maximized)) setMaximized(null);diff --git a/jarvis/ui/web/frontend/src/components/agentic/paneLayout.test.ts b/jarvis/ui/web/frontend/src/components/agentic/paneLayout.test.tsindex a9117bf36b..7da0cbd927 100644--- a/jarvis/ui/web/frontend/src/components/agentic/paneLayout.test.ts+++ b/jarvis/ui/web/frontend/src/components/agentic/paneLayout.test.ts@@ -4,8 +4,11 @@ import {evenSeam,evenWeights,MIN_SEAM_PANE_PX,+ paneArrangement,paneLayout,+ panesFromArrangement,remapColumnWeights,+ sameArrangement,weightsAfterSplit,type PaneSeam,type PaneWeights,@@ -260,3 +263,33 @@ describe("remapColumnWeights", () => {expect(remapColumnWeights(weights, before, after).panes).toEqual({ A: 2 });});});++describe("paneArrangement", () => {+ it("maps each pane to its column index with gaps closed", () => {+ // Backend column NUMBERS may have holes mid-close; the weights are keyed+ // by packed index, so the arrangement must speak the same language.+ const panes = [pane("A", 0), pane("B", 4), pane("C", 4, 1)];+ expect(paneArrangement(panes)).toEqual({ A: 0, B: 1, C: 1 });+ });++ it("round-trips through panesFromArrangement into remapColumnWeights", () => {+ // The restart story: only the arrangement survived (as stored JSON), the+ // pane objects did not — the synthesized list must carry a width the same+ // way the live list would have.+ const stored = paneArrangement([pane("A", 0), pane("B", 1), pane("C", 2)]);+ const wide: PaneWeights = { ...evenWeights(), columns: [1, 1, 4] };+ const after = [pane("B", 0), pane("C", 1)];+ expect(+ remapColumnWeights(wide, panesFromArrangement(stored), after).columns,+ ).toEqual([1, 4]);+ });+});++describe("sameArrangement", () => {+ it("accepts identical mappings and rejects moved or exchanged panes", () => {+ expect(sameArrangement({ A: 0, B: 1 }, { B: 1, A: 0 })).toBe(true);+ expect(sameArrangement({ A: 0, B: 1 }, { A: 0, B: 2 })).toBe(false);+ expect(sameArrangement({ A: 0 }, { A: 0, B: 1 })).toBe(false);+ expect(sameArrangement({ A: 0, B: 1 }, { A: 0, C: 1 })).toBe(false);+ });+});diff --git a/jarvis/ui/web/frontend/src/components/agentic/paneLayout.ts b/jarvis/ui/web/frontend/src/components/agentic/paneLayout.tsindex 2be799f156..3904deb9dd 100644--- a/jarvis/ui/web/frontend/src/components/agentic/paneLayout.ts+++ b/jarvis/ui/web/frontend/src/components/agentic/paneLayout.ts@@ -384,6 +384,48 @@ function columnCount<T extends Sized>(panes: readonly T[]): number {return new Set(panes.map((p) => p.column)).size;}+/**+ * Which column each pane sits in, by call-sign, gaps closed.+ *+ * This is the ARRANGEMENT the column weights are keyed to: the weights store+ * only "column 2 is wide", so they mean anything at all only together with the+ * mapping from panes to those indexes. The grid keeps the arrangement its+ * weights belong to and compares it against every new session — that is how it+ * notices the backend renumbered columns underneath index-keyed widths, which+ * happens on every open and close the grid itself did not perform (a terminal+ * opened by voice, a second client, the backend resuming after a restart).+ */+export function paneArrangement<T extends Sized>(+ panes: readonly T[],+): Record<string, number> {+ return Object.fromEntries(columnIndexes(panes));+}++/** Do two arrangements place exactly the same panes in the same columns? */+export function sameArrangement(+ a: Record<string, number>,+ b: Record<string, number>,+): boolean {+ const names = Object.keys(a);+ if (names.length !== Object.keys(b).length) return false;+ return names.every((name) => b[name] === a[name]);+}++/**+ * The pane list an arrangement describes — enough for `remapColumnWeights`.+ *+ * Column matching only reads names and columns, so every pane is slot 0.+ */+export function panesFromArrangement(+ arrangement: Record<string, number>,+): Sized[] {+ return Object.entries(arrangement).map(([name, column]) => ({+ name,+ column,+ slot: 0,+ }));+}+/*** Carry column widths across a renumber.*diff --git a/jarvis/ui/web/frontend/src/components/agentic/usePaneWeights.ts b/jarvis/ui/web/frontend/src/components/agentic/usePaneWeights.tsindex f7931a13cf..c199fdca18 100644--- a/jarvis/ui/web/frontend/src/components/agentic/usePaneWeights.ts+++ b/jarvis/ui/web/frontend/src/components/agentic/usePaneWeights.ts@@ -22,6 +22,18 @@ import {const STORAGE_PREFIX = "jarvis.agenticIde.paneWeights.v1.";+/**+ * Where each workspace's pane→column arrangement is remembered.+ *+ * Stored beside the weights because the two are one fact: column weights are+ * keyed by column INDEX, so they only mean anything together with the mapping+ * from panes to those indexes. A workspace reopened after the backend+ * rearranged it (a restart, a voice-opened terminal, another client) reads+ * this to carry every dragged width over to the pane that owned it, instead of+ * letting index-keyed widths land on whichever pane holds that index now.+ */+const ARRANGEMENT_PREFIX = "jarvis.agenticIde.paneArrangement.v1.";+/** How far one arrow-key press moves a seam. Matches `PaneResizer`. */const KEY_STEP_PX = 16;@@ -58,6 +70,42 @@ function saveWeights(workspaceId: string, weights: PaneWeights): void {}}+/** The pane→column arrangement the stored weights are keyed to, if one was saved. */+export function loadStoredArrangement(+ workspaceId: string,+): Record<string, number> | null {+ try {+ const raw = window.localStorage.getItem(ARRANGEMENT_PREFIX + workspaceId);+ if (!raw) return null;+ const parsed = JSON.parse(raw) as Record<string, unknown>;+ const entries = Object.entries(parsed).filter(+ (entry): entry is [string, number] =>+ Number.isFinite(entry[1]) && (entry[1] as number) >= 0,+ );+ return entries.length > 0 ? Object.fromEntries(entries) : null;+ } catch {+ // Corrupt entry, private mode, storage disabled — without a remembered+ // arrangement the weights are simply trusted as they are, which is the+ // exact behaviour every workspace had before arrangements were stored.+ return null;+ }+}++/** Remember which panes the currently stored weights belong to. */+export function saveStoredArrangement(+ workspaceId: string,+ arrangement: Record<string, number>,+): void {+ try {+ window.localStorage.setItem(+ ARRANGEMENT_PREFIX + workspaceId,+ JSON.stringify(arrangement),+ );+ } catch {+ /* quota / private mode — the arrangement will not survive this session */+ }+}+/** How big the workspace currently is, in px, along each axis. */export interface WorkspaceExtent {width: number;