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): a pane follows the size its agent really got
Personal Jarvis Maintainer58228169cb7b
diff --git a/docs/BUGS.md b/docs/BUGS.mdindex 30282254c7..b79724d067 100644--- a/docs/BUGS.md+++ b/docs/BUGS.md@@ -8822,3 +8822,56 @@ wake path) verifies via a transcript too and has NO equivalentbefore-the-phrase isolation gate — the identical false-wake class isplausibly still open there whenever that engine is active. Port the sameword-agnostic lead-in check to its match site, calibrated on real windows.++## BUG-128: a narrow pane's agent draws two screens into one grid — the "mirrored" terminal on macOS (HIGH, FIXED 2026-08-11)++**Symptoms (2026-08-11).** In the Agentic IDE the maintainer's macOS panes+showed doubled, character-by-character text: output interleaved with itself so+the pane read as corrupted rather than as merely narrow. The same build on+Windows looked perfect, which made it read as a macOS renderer or WebView fault.+It was neither. The distinguishing variable was never the platform: the Windows+window was maximized and the Mac window was not, and only a pane below the+viewer floor triggers it. Restarting a pane cleared it — a fresh PTY is spawned+at the size the pane currently measures, so the two grids agree again until the+next refused resize.++**Root.** A resize is a REQUEST. `Registry.resize` is allowed to turn one down+(a tile under `MIN_VIEWER_COLS`/`MIN_VIEWER_ROWS` keeps the working geometry, a+viewer that no longer holds the pane is ignored) and to clamp one (a pane stuck+below the floor is lifted onto it). The pane, meanwhile, reflows its own xterm+the instant it measures the tile — before anything has agreed to that size — and+the wire had no frame for "not granted". So a refusal left the viewer's grid and+the agent's PTY permanently different widths, with neither side able to notice.+A TUI addresses rows by RELATIVE cursor moves, so from that point the agent's+repaints finished into rows holding other text. Two screens, one grid.++The handshake had the same hole: `attach` may refuse the size a re-joining pane+asks for, and a pane re-joining a running agent is the likeliest place of all to+inherit a geometry it never requested.++**Fix.** `Terminal.pty_cols`/`pty_rows` record the geometry actually handed to+`setwinsize` — the transcript is a display mirror and drifts from the PTY in both+directions, so it cannot answer "what size is the agent drawing in?".+`Registry.pty_geometry` exposes it; `report_geometry` in `agentic_pty` sends+`{t:"size",cols,rows}` whenever the granted size differs from the requested one,+on the handshake and on every later resize. Sent ONLY on disagreement, so a+dragged seam adds no chatter and a client that does not know the frame is no+worse off than before. The pane follows it via `onGeometry` → `term.resize`,+deliberately without updating `sentSize`: that records what was ASKED, which is+what stops a refused pane from oscillating — it asks once, then stays quiet.+Following the agent also repairs what is already on screen, because that content+was drawn for the agent's geometry all along.++The below-the-floor rescue was reading the transcript too, and now reads the PTY.++**Guards:** `tests/unit/agentic_ide/test_refused_geometry.py` (a refused resize+reports, a granted one stays silent, a lifted pane reports where it was lifted+to) · `paneSocket.test.ts` "geometry reconciliation" (the frame reaches+`onGeometry`, a malformed one is ignored, an older client survives it) ·+`test_session.py::test_a_pane_under_the_crash_guard_is_lifted_off_it` now stages+"under the guard" on the PTY, where the fact lives.++**Lesson.** A viewer that reflows itself on a request it has not had granted is+holding an assumption, not a measurement. Any wire that lets one side clamp or+refuse needs a path back, or the two sides drift silently and the damage surfaces+somewhere that looks unrelated — here, as a rendering fault on one OS.diff --git a/jarvis/agentic_ide/session.py b/jarvis/agentic_ide/session.pyindex 58f168cf9e..10753a54d2 100644--- a/jarvis/agentic_ide/session.py+++ b/jarvis/agentic_ide/session.py@@ -880,6 +880,22 @@ class Terminal:account: str | None = Nonestatus: Status = "pending"pty_id: str | None = None+ # The geometry the PTY ACTUALLY holds, as last handed to `setwinsize`.+ #+ # Not derivable from anything else that was already here, which is why it+ # exists. `transcript.cols` looks like the same number and is not: it is the+ # DISPLAY mirror, and it drifts from the PTY in both directions. `resize`+ # floors a request before recording it there, so the transcript can hold a+ # size the child was never given; and `Transcript.resize` stores whatever it+ # is handed while its own `ScreenBuffer` clamps to `screen.MIN_COLS` (20), so+ # `transcript.cols` can equally hold a size the replayed grid is not in.+ # Two things were reading it as the real geometry — the reattach fallback and+ # the below-the-floor rescue — and only the PTY's own numbers can answer the+ # question both are really asking: what size is the AGENT drawing in?+ #+ # Zero until the first spawn, meaning "no process has been sized yet".+ pty_cols: int = 0+ pty_rows: int = 0# Set just before this pane's agent is killed on purpose (viewer gone, pane# closed, workspace closed). A killed process reports a failure exit exactly# like a crashed one, so without this the resume self-healing in `attach`@@ -2631,8 +2647,13 @@ class Registry:# its own, and handing it back here would reconnect the agent to# the very strip it stopped drawing in. Reattaching is the moment# such a pane can be put right.- cols = max(term.transcript.cols, MIN_VIEWER_COLS)- rows = max(term.transcript.rows, MIN_VIEWER_ROWS)+ #+ # From the PTY's own geometry rather than the transcript's, which+ # only agrees with it above `screen.MIN_COLS` (see `pty_cols`). A+ # pane that has never spawned has no PTY geometry, and there the+ # transcript's default is exactly the right answer.+ cols = max(term.pty_cols or term.transcript.cols, MIN_VIEWER_COLS)+ rows = max(term.pty_rows or term.transcript.rows, MIN_VIEWER_ROWS)if appearance in THEME_COLOURS:term.queries.appearance = appearance@@ -2662,6 +2683,7 @@ class Registry:if geometry_changed:geometry_changed = manager.resize(term.pty_id, cols, rows)if geometry_changed:+ term.pty_cols, term.pty_rows = cols, rowsterm.transcript.resize(cols, rows)# The TUI is about to redraw itself for the new geometry;# that redraw must not read as the agent working.@@ -2933,6 +2955,9 @@ class Registry:agent_start_gate.release()term.pty_id = pty_session.terminal_id+ # The size the child was actually born with — `spawn` was handed these+ # two numbers directly above, so this is the geometry, not a guess.+ term.pty_cols, term.pty_rows = cols, rowsterm.status = "live"term.error = ""term.exit_code = None@@ -3422,6 +3447,31 @@ class Registry:viewer=claimed.output,)+ def pty_geometry(+ self, key: str, workspace_id: str | None = None+ ) -> tuple[int, int] | None:+ """The size this pane's agent is really drawing in, or ``None``.++ The answer a viewer needs to keep its own grid honest. ``resize`` is+ allowed to refuse (a tile under the floor, a viewer that no longer holds+ the pane) and to clamp, and until this existed a viewer had no way to+ learn that its request had not been granted — it had already reflowed+ its own xterm and would then hold a grid the agent was never told about.+ A TUI addresses rows by RELATIVE moves, so at that point its repaints+ finish into rows holding something else, and the pane reads as corrupted+ rather than as merely narrow (reported 2026-08-11).++ ``None`` while no process has been sized: a pane that has not spawned has+ no geometry to disagree with.+ """+ found = self._locate(key, workspace_id)+ if found is None:+ return None+ term = found[1]+ if not term.pty_cols or not term.pty_rows:+ return None+ return term.pty_cols, term.pty_rows+def resize(self,key: str,@@ -3469,9 +3519,19 @@ class Registry:# the floor rather than left there. It is the one place a clamp is# right: no window is showing a workable frame anyway, so there is# no honest geometry left to preserve.- current = found[1].transcript if found is not None else None+ # The PTY's own geometry, NOT the transcript's. The question here is+ # whether the AGENT is stuck in a terminal it cannot draw in, and only+ # the size last handed to `setwinsize` answers it; the transcript is a+ # display mirror that drifts from the PTY in both directions. See+ # `Terminal.pty_cols`.+ term_found = found[1] if found is not None else None+ current = (+ (term_found.pty_cols, term_found.pty_rows)+ if term_found is not None and term_found.pty_cols+ else None+ )if current is None or (- current.cols >= MIN_VIEWER_COLS and current.rows >= MIN_VIEWER_ROWS+ current[0] >= MIN_VIEWER_COLS and current[1] >= MIN_VIEWER_ROWS):logger.debug("Agentic IDE: kept {}'s working geometry instead of a {}x{} tile",@@ -3483,8 +3543,8 @@ class Registry:logger.info("Agentic IDE: lifting {} off a {}x{} terminal its agent cannot draw in",key,- current.cols,- current.rows,+ current[0],+ current[1],)cols = max(cols, MIN_VIEWER_COLS)rows = max(rows, MIN_VIEWER_ROWS)@@ -3526,6 +3586,7 @@ class Registry:return Trueif not self._manager().resize(term.pty_id, cols, rows):return False+ term.pty_cols, term.pty_rows = cols, rows# The TUI answers the new size with a full redraw — shadow it so a# finished pane does not read as "working" every time the grid# re-lays itself out (chat view toggle, maximize, a dragged seam).diff --git a/jarvis/ui/web/agentic_ide_routes.py b/jarvis/ui/web/agentic_ide_routes.pyindex 41f5fa644e..dedba66ba4 100644--- a/jarvis/ui/web/agentic_ide_routes.py+++ b/jarvis/ui/web/agentic_ide_routes.py@@ -3547,7 +3547,9 @@ async def agentic_pty(ws: WebSocket, name: str) -> None:Wire protocol (JSON both ways) — client: ``{t:"i",d}`` input,``{t:"r",cols,rows}`` resize, ``{t:"claim",cols,rows}`` foregroundownership; server: ``{t:"o",d}`` output, ``{t:"ready"}``,- ``{t:"exit",code}``, ``{t:"error",message}``.+ ``{t:"exit",code}``, ``{t:"error",message}``, ``{t:"size",cols,rows}``+ the geometry a REFUSED or clamped resize actually left the agent in (see+ ``report_geometry`` — a resize is a request, not an instruction).The optional ``workspace`` query parameter names the workspace this panebelongs to. It matters because several can be open and the front one changes@@ -3623,6 +3625,38 @@ async def agentic_pty(ws: WebSocket, name: str) -> None:except Exception: # noqa: BLE001, S110 - viewer gonepass+ async def report_geometry(requested: tuple[int, int]) -> None:+ """Tell the viewer the size its agent really got — but only if it lost.++ A resize is a REQUEST, and ``SessionRegistry.resize`` is allowed to turn+ it down: a tile under the viewer floor keeps the working geometry, a+ viewer that no longer holds the pane is ignored outright, and a pane+ stuck below the floor is lifted to it. The pane meanwhile reflowed its+ own xterm the moment it measured its tile, so a refusal used to leave the+ two grids permanently disagreeing — and a TUI addresses rows relatively,+ so its next repaint finishes into rows holding something else. That is+ the doubled, character-by-character text a narrow pane was showing+ (reported 2026-08-11); it looks like a rendering fault and is really two+ different screens in one grid.++ Sent ONLY when the granted size differs from the requested one. The+ normal path — the overwhelming majority of resizes — stays silent, so+ this adds no chatter to a dragged seam, and a viewer that never hears+ back can go on believing it was granted what it asked for, because it+ was. A client that does not know this frame ignores it and is no worse+ off than before.+ """+ granted = registry.pty_geometry(term.key, pane_workspace)+ if granted is None or granted == requested:+ return+ async with send_lock:+ try:+ await ws.send_json(+ {"t": "size", "cols": granted[0], "rows": granted[1]}+ )+ except Exception: # noqa: BLE001, S110 - viewer gone+ pass+async def on_prompt(notice: dict) -> None:"""This pane was just handed a prompt — tell the viewer outright.@@ -3758,6 +3792,14 @@ async def agentic_pty(ws: WebSocket, name: str) -> None:})+ # The handshake carries a size too, and ``attach`` is allowed to turn that+ # one down for the same reasons a later resize can be. Reported through the+ # same channel rather than as extra fields on ``ready``: a pane re-joining a+ # running agent is the MOST likely place to inherit a geometry it did not+ # ask for, and one reconciliation path is the only way the handshake and+ # every later resize cannot drift apart.+ await report_geometry((cols, rows))+# Register only once the handshake is out. A notice arriving before the# pane knows its own name would be dropped by the client as belonging to# nothing, and the state read that follows would then be its first hint.@@ -3799,21 +3841,21 @@ async def agentic_pty(ws: WebSocket, name: str) -> None:# from the viewer that no longer holds the pane would set the# agent's screen to a window nobody is reading — and the viewer# that IS being read has no way to notice or correct it.- registry.resize(- term.key,+ want = (_safe_int(msg.get("cols"), cols),_safe_int(msg.get("rows"), rows),- pane_workspace,- viewer=on_output,)+ registry.resize(term.key, *want, pane_workspace, viewer=on_output)+ await report_geometry(want)elif kind == "claim":- registry.claim_viewer(- term.key,+ want = (_safe_int(msg.get("cols"), cols),_safe_int(msg.get("rows"), rows),- pane_workspace,- viewer=on_output,)+ registry.claim_viewer(+ term.key, *want, pane_workspace, viewer=on_output+ )+ await report_geometry(want)finally:# The viewer went away — switched tab, reloaded, closed the browser.# None of those mean "stop working", so the agent keeps running anddiff --git a/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx b/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsxindex e227acadcc..7ae9cf34d5 100644--- a/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx+++ b/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx@@ -1501,6 +1501,35 @@ export function AgenticTerminal({},onOutput: (text) => writeToPane(text),onReplay: (text) => replayToPane(text),+ /**+ * The agent is in a different size than this pane asked for — follow it.+ *+ * `applyResize` reflows xterm the instant it measures the tile, before+ * anything has agreed to that size, and the server is allowed to say no+ * (a tile under the floor keeps the working geometry, a displaced viewer+ * is ignored). Nothing used to reconcile the two afterwards — the wire+ * had no way to say "not granted" — so a refusal left this grid and the+ * agent's permanently different widths, and the agent's relative cursor+ * moves then finished its repaints into rows holding other text. That is+ * the doubled, character-by-character text a narrow pane showed+ * (2026-08-11): not a renderer fault, two screens in one grid.+ *+ * `sentSize` is deliberately NOT updated. It records what was ASKED,+ * and that is what stops this from oscillating: the same tile measured+ * again matches it and is never re-sent, so a pane whose size is refused+ * asks once and then stays quiet — while a tile that really changes+ * still speaks up. Following the agent also repairs what is already on+ * screen, because that content was drawn for this geometry all along.+ */+ onGeometry: ({ cols, rows }) => {+ if (disposed) return;+ if (term.cols === cols && term.rows === rows) return;+ try {+ term.resize(cols, rows);+ } catch {+ /* the terminal is being torn down — nothing left to reconcile */+ }+ },/*** A prompt just landed in this pane — make that impossible to miss.*diff --git a/jarvis/ui/web/frontend/src/components/agentic/paneSocket.test.ts b/jarvis/ui/web/frontend/src/components/agentic/paneSocket.test.tsindex dcb4a96393..be7afc7bb2 100644--- a/jarvis/ui/web/frontend/src/components/agentic/paneSocket.test.ts+++ b/jarvis/ui/web/frontend/src/components/agentic/paneSocket.test.ts@@ -556,3 +556,73 @@ describe("openPaneSocket delivery receipts", () => {socket.close();});});++describe("openPaneSocket geometry reconciliation", () => {+ const originalWs = globalThis.WebSocket;++ beforeEach(() => {+ (globalThis as unknown as { WebSocket: unknown }).WebSocket = MockWebSocket;+ (globalThis as unknown as { window: unknown }).window = globalThis;+ (window as unknown as { location: unknown }).location = {+ protocol: "http:",+ host: "localhost:5173",+ };+ MockWebSocket.last = null;+ MockWebSocket.opened = [];+ vi.useFakeTimers();+ });++ afterEach(() => {+ vi.useRealTimers();+ (globalThis as unknown as { WebSocket: unknown }).WebSocket = originalWs;+ });++ it("passes on the size the agent really got when a resize was refused", () => {+ // The pane already reflowed its own xterm to the tile it measured. If the+ // server turned that size down and the pane never hears so, the two grids+ // disagree for good — and a TUI moving its cursor RELATIVELY then finishes+ // its repaints into rows holding other text. That is the doubled,+ // character-by-character output a narrow pane showed (2026-08-11).+ const onGeometry = vi.fn();+ const socket = openPaneSocket(+ { name: "Mika", cols: 24, rows: 8 },+ { ...handlers(), onGeometry },+ );+ MockWebSocket.last!.fire("open");++ MockWebSocket.last!.deliver({ t: "size", cols: 96, rows: 30 });++ expect(onGeometry).toHaveBeenCalledWith({ cols: 96, rows: 30 });+ socket.close();+ });++ it("ignores a size frame that cannot be a real geometry", () => {+ // A grid of zero columns wrecks a TUI's drawing permanently, so a malformed+ // frame must not be able to do what the floors elsewhere exist to prevent.+ const onGeometry = vi.fn();+ const socket = openPaneSocket(+ { name: "Mika", cols: 80, rows: 24 },+ { ...handlers(), onGeometry },+ );+ MockWebSocket.last!.fire("open");++ MockWebSocket.last!.deliver({ t: "size", cols: 0, rows: 24 });+ MockWebSocket.last!.deliver({ t: "size", cols: 80 });+ MockWebSocket.last!.deliver({ t: "size", cols: "80", rows: "24" });++ expect(onGeometry).not.toHaveBeenCalled();+ socket.close();+ });++ it("survives a client that registered no geometry handler", () => {+ // Every older viewer is one of these: the frame is new, and a pane that+ // ignores it is no worse off than it was before the frame existed.+ const socket = openPaneSocket({ name: "Mika", cols: 80, rows: 24 }, handlers());+ MockWebSocket.last!.fire("open");++ expect(() =>+ MockWebSocket.last!.deliver({ t: "size", cols: 96, rows: 30 }),+ ).not.toThrow();+ socket.close();+ });+});diff --git a/jarvis/ui/web/frontend/src/components/agentic/paneSocket.ts b/jarvis/ui/web/frontend/src/components/agentic/paneSocket.tsindex bf028936b1..e06cf540b1 100644--- a/jarvis/ui/web/frontend/src/components/agentic/paneSocket.ts+++ b/jarvis/ui/web/frontend/src/components/agentic/paneSocket.ts@@ -218,6 +218,22 @@ export interface PaneSocketHandlers {}) => void;/** This pane was handed a prompt just now. */onPrompt?: (delivery: PromptDelivery) => void;+ /**+ * The agent is in a DIFFERENT size than this pane asked for.+ *+ * A resize is a request. The server turns one down when the tile is under the+ * viewer floor or when this socket no longer holds the pane, and it lifts a+ * pane that is stuck below the floor — so what a pane asked for and what its+ * agent got are not always the same number. Only the disagreements arrive+ * here; being granted what you asked for stays silent.+ *+ * Acting on it is not optional. The pane reflowed its own xterm the moment it+ * measured its tile, and a grid that disagrees with the agent's is worse than+ * a grid that is too small: a TUI moves its cursor RELATIVELY, so its next+ * repaint lands on rows holding other text and the two screens interleave+ * character by character.+ */+ onGeometry?: (size: { cols: number; rows: number }) => void;/** The agent itself finished. Final: nothing reconnects after this. */onExit: (code: number) => void;/**@@ -453,6 +469,8 @@ export function openPaneSocket(last_prompt_at?: number | null;last_prompt_chars?: number;last_prompt_preview?: string;+ cols?: number;+ rows?: number;};try {msg = JSON.parse((ev as MessageEvent).data as string);@@ -494,6 +512,21 @@ export function openPaneSocket(submitted: msg.submitted ?? null,prompts_sent: msg.prompts_sent ?? 0,});+ } else if (msg.t === "size") {+ // The size this pane's agent is really in, sent only when it differs+ // from what this pane asked for. Guarded rather than trusted: a grid of+ // zero columns wrecks a TUI's drawing permanently, so a malformed frame+ // must not be able to do what the floors elsewhere exist to prevent.+ if (+ typeof msg.cols === "number" &&+ typeof msg.rows === "number" &&+ Number.isFinite(msg.cols) &&+ Number.isFinite(msg.rows) &&+ msg.cols > 0 &&+ msg.rows > 0+ ) {+ handlers.onGeometry?.({ cols: msg.cols, rows: msg.rows });+ }} else if (msg.t === "exit") {agentExited = true;handlers.onExit(msg.code ?? 0);diff --git a/tests/unit/agentic_ide/test_refused_geometry.py b/tests/unit/agentic_ide/test_refused_geometry.pynew file mode 100644index 0000000000..0bc02c4950--- /dev/null+++ b/tests/unit/agentic_ide/test_refused_geometry.py@@ -0,0 +1,158 @@+"""A viewer must learn the size its agent is REALLY in, or the pane corrupts.++A resize is a request, not an instruction. ``Registry.resize`` turns one down+when the tile is under the viewer floor, ignores one from a viewer that no+longer holds the pane, and lifts a pane stuck below the floor back onto it. The+pane meanwhile reflowed its own xterm the moment it measured the tile — so a+refusal used to leave the two grids permanently disagreeing.++That is not a cosmetic drift. A TUI addresses rows by RELATIVE cursor moves, so+once the two grids disagree the agent's next repaint finishes into rows holding+other text and the screens interleave character by character. Reported on macOS+2026-08-11 as "the content is mirrored": it reads as a renderer fault and is+really two different screens in one grid. A Windows window wide enough that no+resize is ever refused never shows it, which is what made it look platform-+specific.++So: the server reports the granted geometry whenever it differs from the+requested one, and stays silent when the request was honoured — the normal case,+and the reason a dragged seam adds no chatter to the wire.++Driven through ``client.portal`` for the reason spelled out in+``test_stale_workspace_socket``: the registry's locks and the PTY callbacks live+on the SERVER loop.+"""++from __future__ import annotations++from collections.abc import Iterator+from pathlib import Path++import pytest+from fastapi import FastAPI+from fastapi.testclient import TestClient++from jarvis.agentic_ide import session as session_mod+from jarvis.agentic_ide.session import (+ MIN_VIEWER_COLS,+ MIN_VIEWER_ROWS,+ Registry,+)+from tests.fakes.fake_pty_manager import FakePtyManager++[email protected](autouse=True)+def _isolated_recents(+ tmp_path_factory: pytest.TempPathFactory, monkeypatch: pytest.MonkeyPatch+) -> None:+ from jarvis.agentic_ide import recents++ store = tmp_path_factory.mktemp("recents") / "recents.json"+ monkeypatch.setattr(recents, "_store_path", lambda: store)+++def registry(monkeypatch: pytest.MonkeyPatch) -> Registry:+ monkeypatch.setattr(session_mod, "agent_argv", lambda name: (f"/usr/bin/{name}",))+ reg = Registry(pty_manager=FakePtyManager())+ monkeypatch.setattr(session_mod, "get_registry", lambda: reg)+ from jarvis.ui.web import agentic_ide_routes++ monkeypatch.setattr(agentic_ide_routes, "get_registry", lambda: reg)+ monkeypatch.setattr(agentic_ide_routes, "credentials_valid", lambda _scope: True)+ return reg+++def client(registry: Registry) -> Iterator[TestClient]:+ from jarvis.ui.web.agentic_ide_routes import router++ app = FastAPI()+ app.include_router(router)+ with TestClient(app) as ready:+ yield ready+++def _open(client: TestClient, registry: Registry, folder: Path) -> None:+ folder.mkdir(parents=True, exist_ok=True)+ client.portal.call(registry.start, str(folder), [{"agent": "claude"}])+++def _next_size(socket, limit: int = 12) -> dict | None:+ """The next ``size`` frame, or ``None`` if the pane says other things first.++ Output and state frames share this socket, so a size report is looked for+ among them rather than assumed to be next in line.+ """+ for _ in range(limit):+ frame = socket.receive_json()+ if frame.get("t") == "size":+ return frame+ return None+++def test_a_refused_resize_tells_the_viewer_what_the_agent_really_got(+ client: TestClient, registry: Registry, tmp_path: Path+) -> None:+ """The failure this exists for: a tile under the floor is turned down."""+ _open(client, registry, tmp_path / "ws")++ with client.websocket_connect("/api/agentic-ide/pty/T1?cols=120&rows=40") as socket:+ assert socket.receive_json()["t"] == "ready"+ # Under MIN_VIEWER_COLS: the PTY keeps the geometry it is working in,+ # and the pane has already reflowed itself to the narrow tile.+ socket.send_json({"t": "r", "cols": 4, "rows": 2})+ reported = _next_size(socket)++ assert reported is not None, (+ "a refused resize left the viewer believing it had been granted — that "+ "is the disagreement that interleaves two screens in one grid"+ )+ assert (reported["cols"], reported["rows"]) == (120, 40)+++def test_a_granted_resize_says_nothing(+ client: TestClient, registry: Registry, tmp_path: Path+) -> None:+ """Silence is the contract for the normal path, not an accident.++ Proven without waiting on a frame that must never come: a granted resize is+ followed by a refused one, and the first size report to arrive describes the+ REFUSED size. Had the granted resize also reported, that frame would be+ sitting in front of it.+ """+ _open(client, registry, tmp_path / "ws")++ with client.websocket_connect("/api/agentic-ide/pty/T1?cols=120&rows=40") as socket:+ assert socket.receive_json()["t"] == "ready"+ socket.send_json({"t": "r", "cols": 90, "rows": 30})+ # Small but POSITIVE: `_safe_int` reads anything <= 0 as "unset" and+ # substitutes the handshake size, so a literal zero never reaches the+ # registry over this wire and would be granted rather than refused.+ socket.send_json({"t": "r", "cols": 4, "rows": 2})+ reported = _next_size(socket)++ assert reported is not None+ assert (reported["cols"], reported["rows"]) == (90, 30), (+ "the granted 90x30 announced itself; only disagreements belong on the wire"+ )+++def test_a_pane_lifted_off_the_floor_reports_the_size_it_was_lifted_to(+ client: TestClient, registry: Registry, tmp_path: Path+) -> None:+ """A clamp is a disagreement too — the viewer asked for less than it got."""+ _open(client, registry, tmp_path / "ws")+ assert registry.session is not None+ term = registry.session.terminals[0]++ with client.websocket_connect("/api/agentic-ide/pty/T1?cols=120&rows=40") as socket:+ assert socket.receive_json()["t"] == "ready"+ # However it got there (an older client, a session predating the guard),+ # this pane's agent is in a terminal it cannot draw in.+ term.pty_cols, term.pty_rows = 3, 2+ socket.send_json({"t": "r", "cols": 4, "rows": 2})+ reported = _next_size(socket)++ assert reported is not None, "a lifted pane must say where it was lifted to"+ assert (reported["cols"], reported["rows"]) == (MIN_VIEWER_COLS, MIN_VIEWER_ROWS)diff --git a/tests/unit/agentic_ide/test_session.py b/tests/unit/agentic_ide/test_session.pyindex f3c020a47f..0613c5e403 100644--- a/tests/unit/agentic_ide/test_session.py+++ b/tests/unit/agentic_ide/test_session.py@@ -405,11 +405,17 @@ async def test_a_pane_under_the_crash_guard_is_lifted_off_it("the last honest geometry", which here is a broken one. The pane would staysilent and the status badge would go on reading that silence as a finishedjob (:mod:`jarvis.agentic_ide.activity`).++ "Under the guard" is a fact about the PTY, so it is staged on the PTY's own+ geometry. Staging it on the transcript instead would prove nothing: that is+ the display mirror, and the rescue deliberately does not ask it (see+ `Terminal.pty_cols`)."""session = await _open(registry, tmp_path, [{"agent": "claude"}])term = session.terminals[0]await registry.attach(term.name, 120, 40, _noop_output, _noop_exit)pty = term.pty_id+ term.pty_cols, term.pty_rows = 3, 2term.transcript.resize(3, 2)fake_pty.resizes.clear()