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): hold transient narrow pane widths back from the agent (#891)

Ruben Lütke341f4858c75e
diff --git a/dodaios/ui/web/frontend/src/components/agentic/AgenticTerminal.test.tsx b/dodaios/ui/web/frontend/src/components/agentic/AgenticTerminal.test.tsx
index 6465f00d68..5709c2125f 100644
--- a/dodaios/ui/web/frontend/src/components/agentic/AgenticTerminal.test.tsx
+++ b/dodaios/ui/web/frontend/src/components/agentic/AgenticTerminal.test.tsx
@@ -10,6 +10,11 @@ const terminalHarness = vi.hoisted(() => ({
spacingAtOpen: [] as unknown[],
/** What the terminal reports after a fit — a test moves it to grow the pane. */
size: { cols: 80, rows: 24 },
+ /**
+ * The columns the grid HOLDS, when a test needs them apart from what the
+ * tile proposes (null: the grid always matches the staged size).
+ */
+ gridCols: null as number | null,
/** Every frame the pane hands its socket. Returns whether it went out. */
send: vi.fn<(payload: unknown) => boolean>(() => true),
/** Every explicit grid resize — how the pane pins itself below the floors. */
@@ -62,7 +67,7 @@ const terminalHarness = vi.hoisted(() => ({
vi.mock("@xterm/xterm", () => ({
Terminal: class {
get cols() {
- return terminalHarness.size.cols;
+ return terminalHarness.gridCols ?? terminalHarness.size.cols;
}
get rows() {
return terminalHarness.size.rows;
@@ -208,6 +213,7 @@ import {
AgenticTerminal,
CURTAIN_MAX_MS,
DRAG_REFIT_MS,
+ NARROW_SETTLE_MS,
REBUILD_QUIET_MS,
REBUILD_SETTLE_MAX_MS,
REPAINT_WAIT_MAX_MS,
@@ -1491,6 +1497,69 @@ describe("pane refit", () => {
Reflect.deleteProperty(HTMLElement.prototype, "clientHeight");
});
+ it("gives the agent a narrower width only once the tile has held it", () => {
+ // Recorded 2026-10-26: a layout switch squeezed every pane to 16 columns
+ // for about a second. Claude Code sized a running command's output for
+ // those 16 columns and kept that height, leaving 36 blank rows mid-pane.
+ terminalHarness.gridCols = 80;
+ terminalHarness.fit.mockImplementation(() => {
+ terminalHarness.gridCols = terminalHarness.size.cols;
+ });
+ try {
+ render(pane(false));
+ settle();
+ const sentCols = () =>
+ terminalHarness.send.mock.calls
+ .map(([frame]) => frame as { t?: string; cols?: number })
+ .filter((frame) => frame.t === "r" || frame.t === "claim")
+ .map((frame) => frame.cols);
+ terminalHarness.send.mockClear();
+
+ // A squeeze that is undone again never reaches the agent.
+ terminalHarness.size = { cols: 16, rows: 24 };
+ act(() => {
+ window.dispatchEvent(new Event("resize"));
+ });
+ settle();
+ terminalHarness.size = { cols: 80, rows: 24 };
+ act(() => {
+ window.dispatchEvent(new Event("resize"));
+ });
+ settle();
+ act(() => {
+ vi.advanceTimersByTime(NARROW_SETTLE_MS + 100);
+ });
+ expect(sentCols()).not.toContain(16);
+ expect(terminalHarness.gridCols).toBe(80);
+
+ // A narrowing that stays is applied once it has held.
+ terminalHarness.size = { cols: 40, rows: 24 };
+ act(() => {
+ window.dispatchEvent(new Event("resize"));
+ });
+ settle();
+ expect(sentCols()).not.toContain(40);
+ act(() => {
+ vi.advanceTimersByTime(NARROW_SETTLE_MS);
+ });
+ settle();
+ expect(sentCols()).toContain(40);
+ expect(terminalHarness.gridCols).toBe(40);
+
+ // Widening is not held.
+ terminalHarness.send.mockClear();
+ terminalHarness.size = { cols: 90, rows: 24 };
+ act(() => {
+ window.dispatchEvent(new Event("resize"));
+ });
+ settle();
+ expect(sentCols()).toContain(90);
+ } finally {
+ terminalHarness.gridCols = null;
+ terminalHarness.fit.mockReset();
+ }
+ });
+
it("follows a drag in throttled steps instead of freezing until release", () => {
// The reported jank (2026-08-11): while a seam moved, the text froze and
// the release re-wrapped it in one hard snap. Mid-drag the pane now takes
diff --git a/dodaios/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx b/dodaios/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx
index f2f82096d2..03c2cd0bfb 100644
--- a/dodaios/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx
+++ b/dodaios/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx
@@ -335,6 +335,22 @@ export const RESIZE_PARSE_WAIT_MS = 250;
*/
export const DRAG_REFIT_MS = 200;
+/**
+ * How long a NARROWER tile must hold before the pane and its agent take it.
+ *
+ * Switching a layout passes through widths nobody chose: every pane of a
+ * workspace was squeezed to 15-16 columns for about a second and then widened
+ * back to 46 (recorded 2026-10-26). Claude Code sizes the live output box of a
+ * running command for the width it sees and never shrinks that box while the
+ * command runs, so one such second left 36 blank rows in the middle of the pane
+ * until the command ended; finished blocks showed the same kind of gap. No
+ * resize afterwards brings the space back. A narrowing that is undone within
+ * this window therefore never reaches the agent; one that stays is applied
+ * after it. Widening is not held, and neither are the deliberate refits (drag
+ * release, a pane returning to the stage, a font change).
+ */
+export const NARROW_SETTLE_MS = 1_500;
+
/**
* How long a call-sign may be — the same cap the backend enforces
* (`MAX_TERMINAL_NAME`), so the field stops where the save would have failed
@@ -2336,6 +2352,54 @@ export function AgenticTerminal({
// to drop it when the pane goes away. See ./paneReflowQueue for why panes
// must not reflow in the same frame as each other.
const reflow = () => sendResize();
+ /** The narrower width this pane is waiting to see hold (NARROW_SETTLE_MS). */
+ let narrowCols: number | null = null;
+ let narrowTimer: number | undefined;
+ const clearNarrowHold = () => {
+ narrowCols = null;
+ if (narrowTimer !== undefined) window.clearTimeout(narrowTimer);
+ narrowTimer = undefined;
+ };
+ /**
+ * The observer's refit: a wider tile is taken at once, a narrower one only
+ * once it has held for NARROW_SETTLE_MS (see there for why).
+ */
+ const observedReflow = () => {
+ if (disposed) return;
+ let proposedCols: number | undefined;
+ // Only a pane that already gave its agent a size can hold one back; the
+ // first fit after mount is never a transient.
+ if (sentSize && measurable() && activeRef.current) {
+ try {
+ proposedCols = fit.proposeDimensions()?.cols;
+ } catch {
+ proposedCols = undefined;
+ }
+ }
+ const cols =
+ proposedCols !== undefined && Number.isFinite(proposedCols)
+ ? Math.max(proposedCols, MIN_REAL_COLS)
+ : undefined;
+ if (cols === undefined || cols >= term.cols) {
+ clearNarrowHold();
+ sendResize();
+ return;
+ }
+ if (cols === narrowCols) {
+ // Held for the whole window: the tile really is this narrow now.
+ if (narrowTimer === undefined) {
+ narrowCols = null;
+ sendResize();
+ }
+ return;
+ }
+ clearNarrowHold();
+ narrowCols = cols;
+ narrowTimer = window.setTimeout(() => {
+ narrowTimer = undefined;
+ queuePaneReflow(observedReflow);
+ }, NARROW_SETTLE_MS);
+ };
const scheduleResize = () => {
// While a seam or the prompt bar is being dragged the pane still
// follows, but on a leash: at most one refit per DRAG_REFIT_MS, so the
@@ -2356,7 +2420,7 @@ export function AgenticTerminal({
if (resizeTimer !== undefined) window.clearTimeout(resizeTimer);
resizeTimer = window.setTimeout(() => {
resizeTimer = undefined;
- queuePaneReflow(reflow);
+ queuePaneReflow(observedReflow);
}, 80);
};
@@ -2456,6 +2520,8 @@ export function AgenticTerminal({
// A queued reflow outlives the pane by up to a frame, and would then fit
// a disposed terminal inside a detached element.
cancelPaneReflow(reflow);
+ cancelPaneReflow(observedReflow);
+ clearNarrowHold();
window.removeEventListener("resize", scheduleResize);
window.removeEventListener("focus", claimResize);
window.removeEventListener("pointermove", reclaimOnGesture);