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): keep terminal and agent the same size across layout switches

rubenluetke10-beep42abaf00131d
diff --git a/jarvis/agentic_ide/session.py b/jarvis/agentic_ide/session.py
index 6372a59d0c..a6b7ac42e7 100644
--- a/jarvis/agentic_ide/session.py
+++ b/jarvis/agentic_ide/session.py
@@ -5155,9 +5155,15 @@ class Registry:
term.name,
)
return False
- # The replayed screen has to follow the real one; otherwise the
- # transcript keeps wrapping at the old width.
- if (term.transcript.cols, term.transcript.rows) == (cols, rows):
+ # Already the PTY's size: nothing to resize. Compared against the PTY,
+ # not the transcript — the transcript is a display mirror that can
+ # drift (see `Terminal.pty_cols`), and a request matching only the
+ # mirror was answered "granted" while the agent stayed in another size.
+ if (term.pty_cols, term.pty_rows) == (cols, rows):
+ # The replayed screen has to follow the real one; otherwise the
+ # transcript keeps wrapping at the old width.
+ if (term.transcript.cols, term.transcript.rows) != (cols, rows):
+ term.transcript.resize(cols, rows)
return True
clears_before = term.replay.clears
if not self._pool(term).resize(term.pty_id, cols, rows):
diff --git a/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.test.tsx b/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.test.tsx
index 57d42d6fef..6465f00d68 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.test.tsx
@@ -1602,6 +1602,48 @@ describe("pane refit", () => {
expect(frames.slice(shorter + 1)).toContainEqual({ t: "claim", cols: 80, rows: 24 });
});
+ /*
+ * Reported 2026-10-06: back from the thread layout, a pane that had followed
+ * another geometry while hidden kept that grid, and the return nudge then
+ * put the agent on the tile's size — lines wrapped into word fragments down
+ * the pane's edge. Coming back on stage is a change made in this window, so
+ * it takes the size back whatever `document.hasFocus()` answers.
+ */
+ it("takes the size back when a displaced pane returns to the stage without window focus", () => {
+ const view = render(pane(false, {}, true));
+ settle();
+ view.rerender(pane(false, {}, false));
+ settle();
+ displacedBy(30, 10);
+ vi.spyOn(document, "hasFocus").mockReturnValue(false);
+
+ view.rerender(pane(false, {}, true));
+ act(() => {
+ vi.advanceTimersByTime(RETURN_REPAINT_NUDGE_MS + 10);
+ });
+
+ expect(terminalHarness.send).toHaveBeenCalledWith({ t: "claim", cols: 80, rows: 24 });
+ expect(terminalHarness.send).not.toHaveBeenCalledWith(expect.objectContaining({ t: "r" }));
+ });
+
+ it("never sizes the agent while the pane is off the stage", () => {
+ // The grid behind the maximized side panel is invisible but still laid
+ // out in a narrowed tile; fitting there squeezed every agent to a strip.
+ const view = render(pane(false, {}, true));
+ settle();
+ view.rerender(pane(false, {}, false));
+ settle();
+ terminalHarness.send.mockClear();
+
+ terminalHarness.size = { cols: 37, rows: 24 };
+ act(() => {
+ window.dispatchEvent(new Event("resize"));
+ vi.advanceTimersByTime(600);
+ });
+
+ expect(terminalHarness.send).not.toHaveBeenCalled();
+ });
+
it("does not nudge a pane taking the stage for the first time", () => {
const view = render(pane(false, {}, false));
settle();
diff --git a/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx b/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx
index 10a14fe5e3..f8eea93c15 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx
@@ -742,6 +742,8 @@ export function AgenticTerminal({
// process together) without reaching into the connect effect's socket.
const resizeRef = useRef<(() => void) | null>(null);
const claimResizeRef = useRef<(() => void) | null>(null);
+ /** The refit a pane makes on coming back on stage — see `returnResize`. */
+ const returnResizeRef = useRef<(() => void) | null>(null);
/** Asks the agent to paint its whole screen again — see RETURN_REPAINT_NUDGE_MS. */
const repaintOnReturnRef = useRef<(() => void) | null>(null);
/** Was this pane parked off the stage since it last took it? */
@@ -1719,6 +1721,12 @@ export function AgenticTerminal({
// well as at the gate: a deferred fit runs a moment later, and the tile it
// was asked for may be gone by then.
if (disposed || !measurable()) return;
+ // A pane off the stage never sizes its agent. A grid covered by the
+ // maximized side panel is invisible but still laid out, in a tile the
+ // panel narrowed: fitting there squeezed every agent behind it to a strip
+ // (37 columns, measured) and its output stayed wrapped at that width in
+ // the scrollback. Coming back on stage refits (the `active` effect).
+ if (!activeRef.current) return;
// The pane draws at the READER'S text size, never one it picked itself.
// An auto-shrink that walked this size down until the floor grid fit the
// tile shipped and was rejected within hours (2026-08-11): it silently
@@ -1920,24 +1928,48 @@ export function AgenticTerminal({
* tile is deliberately silent (see `applyResize`).
*/
const repaintOnReturn = () => {
- const size = sentSize;
+ // The grid this pane HOLDS, never the size it last asked for. The two
+ // differ while the pane follows a geometry the server chose (see
+ // `onGeometry`), and a nudge carrying the old request was granted
+ // silently: the agent went back to the tile's width while xterm stayed
+ // at the followed one, so every line it drew wrapped into word
+ // fragments down the pane's edge (reported 2026-10-06, after switching
+ // from the thread layout back to the grid).
+ const size = sentSize ? { cols: term.cols, rows: term.rows } : null;
if (disposed || !size || !socket) return;
- const claimOwner = viewerMayOwn();
+ // Coming back on stage is a change made in THIS window (see `returnResize`).
+ const claimOwner = activeRef.current && mayLead();
const kind = claimOwner ? "claim" : "r";
const shorter = Math.max(MIN_REAL_ROWS, size.rows - 1);
if (shorter === size.rows) return;
if (!socket.send({ t: kind, cols: size.cols, rows: shorter })) return;
window.setTimeout(() => {
if (disposed) return;
- // A refit may have landed during the wait; give back the newest size.
- const back = sentSize ?? size;
- if (socket?.send({ t: kind, cols: back.cols, rows: back.rows }) && claimOwner) {
+ // A refit may have landed during the wait; give back the grid as it is now.
+ const back = { cols: term.cols, rows: term.rows };
+ if (!socket?.send({ t: kind, cols: back.cols, rows: back.rows })) return;
+ // What the agent was last asked for, so the next refit of the tile is
+ // compared against it and not against an older request.
+ sentSize = back;
+ if (claimOwner) {
owned = true;
displaced = false;
}
}, RETURN_REPAINT_NUDGE_MS);
};
repaintOnReturnRef.current = repaintOnReturn;
+ /**
+ * Refit a pane that comes back on stage, taking the size if this window may.
+ *
+ * A layout switch, a workspace switch or leaving the Verse is something the
+ * user did in this window, so it claims like a gesture in the pane does —
+ * without asking `document.hasFocus()`, whose answer the desktop shell lets
+ * lag (see `viewerMayOwn`). Only asking left a pane that had followed
+ * another geometry while it was hidden at that geometry: `applyResize`
+ * stays silent for a tile it already requested.
+ */
+ const returnResize = () => sendResize(activeRef.current && mayLead());
+ returnResizeRef.current = returnResize;
/**
* The same, on the strength of a gesture INSIDE this pane.
*
@@ -2408,6 +2440,7 @@ export function AgenticTerminal({
resizeRef.current = null;
claimResizeRef.current = null;
repaintOnReturnRef.current = null;
+ returnResizeRef.current = null;
takeOwnershipRef.current = null;
if (visibilityRef.current === visibility) visibilityRef.current = null;
};
@@ -2460,7 +2493,7 @@ export function AgenticTerminal({
const returningViewport = preservedViewportRef.current;
const restoreViewport = () => {
resizeRef.current?.();
- claimResizeRef.current?.();
+ (returning ? returnResizeRef : claimResizeRef).current?.();
restoreTerminalViewport(termRef.current, returningViewport);
};
// Measure the now-mounted stage before parsing held output. Once xterm has
diff --git a/jarvis/ui/web/frontend/src/views/AgenticIdeView.tsx b/jarvis/ui/web/frontend/src/views/AgenticIdeView.tsx
index 327e8b9b86..6cd2e64625 100644
--- a/jarvis/ui/web/frontend/src/views/AgenticIdeView.tsx
+++ b/jarvis/ui/web/frontend/src/views/AgenticIdeView.tsx
@@ -27,6 +27,7 @@ import { BrandedSelect } from "@/components/ui/select";
import { useEventStore } from "@/store/events";
import { useIdeChatStore } from "@/store/ideChat";
import { useIdeProjectsStore } from "@/store/ideProjects";
+import { useIdeSidePanelStore } from "@/store/ideSidePanel";
import { useIdeSkillsStore } from "@/store/ideSkills";
import { useIdeThreadsStore } from "@/store/ideThreads";
import { ThreadView } from "@/components/agentic/threads/ThreadView";
@@ -89,6 +90,10 @@ export function AgenticIdeView({ onScreen = true }: AgenticIdeViewProps) {
const ideWorkspace = useIdeChatStore((state) => state.workspace);
const stagedPane = useIdeChatStore((state) => state.stagedPane);
const editorShown = useCodeEditorStore((state) => state.visible && state.tabs.some((tab) => tab.workspaceId === ideWorkspace?.id));
+ // A maximized side panel (the Verse) covers the grid, which only turns invisible
+ // and keeps a narrowed tile. Its panes leave the stage so they neither paint
+ // nor size their agents to a strip nobody is reading.
+ const panelCoversGrid = useIdeSidePanelStore((state) => state.open && state.maximized);
const [state, setState] = useState<IdeState | null>(null);
const [projects, setProjects] = useState<IdeProject[]>([]);
const [agents, setAgents] = useState<AgentStatus[]>([]);
@@ -577,7 +582,7 @@ export function AgenticIdeView({ onScreen = true }: AgenticIdeViewProps) {
{/* The grid stays mounted behind the threads: its terminals keep running
and come back exactly as they were when the layout switches back. */}
<div hidden={threads} className="h-full min-h-0">
- {session ? <RetainedWorkspaceGrid session={session} onScreen={onScreen && !threads && !editorShown} workspaceIds={state.workspaces?.map((workspace) => workspace.id)} onChanged={(next) => setState((current) => current?.session?.id === next.id ? { ...current, session: next } : current)}
+ {session ? <RetainedWorkspaceGrid session={session} onScreen={onScreen && !threads && !editorShown && !panelCoversGrid} workspaceIds={state.workspaces?.map((workspace) => workspace.id)} onChanged={(next) => setState((current) => current?.session?.id === next.id ? { ...current, session: next } : current)}
onAdd={openAgentPicker} onClose={closeAgent} onSelect={setSelected} selected={selected} fontSize={fontSize} appearance={appearance} disabled={busy}
onMutationStart={beginGridMutation} onMutationEnd={endGridMutation} paneStyle={paneStyle} workspaces={state.workspaces ?? []} />
: <div className="flex h-full flex-col items-center justify-center gap-3 px-6 text-center">