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(ide): a repaint nudge restores the size the pane has now, not the old one

rubenluetke10-beepd015f2dd975b
diff --git a/jarvis/agentic_ide/session.py b/jarvis/agentic_ide/session.py
index 5a9cc4d977..5892c3567b 100644
--- a/jarvis/agentic_ide/session.py
+++ b/jarvis/agentic_ide/session.py
@@ -4739,10 +4739,27 @@ class Registry:
)
async def _resize_there_and_back(self, term: Terminal, cols: int, rows: int) -> bool:
- """One nudge: the height one row short, then back. False if it failed."""
+ """One nudge: the height one row short, then back. False if it failed.
+
+ "Back" means the size the pane holds WHEN the nudge ends, not the one
+ passed in. The sleep between the two resizes yields the loop, and a
+ viewer's resize landing inside it (a dragged seam, the IDE view shown
+ again after a tab switch) has already moved the PTY to the new size.
+ Restoring the captured size then put the agent back on the OLD grid
+ while ``pty_cols``, the transcript and every viewer's xterm said the
+ new one — and nothing ever corrected it, because each side believed
+ the sizes agreed. The agent kept formatting for a width nobody showed:
+ rows drawn over rows, word tails left behind (reported 2026-09-29).
+ """
pty_id = term.pty_id
if not pty_id:
return False
+ # The same holds for the start: a nudge only ever varies the height of
+ # the size the agent already has. A re-joining viewer that does not own
+ # the pane passes ITS size, and nudging to that width would reflow the
+ # agent for a window that was never granted the pane.
+ cols = term.pty_cols or cols
+ rows = term.pty_rows or rows
manager = self._pool(term)
try:
# The whole point of the nudge is a full repaint — which must read
@@ -4755,7 +4772,10 @@ class Registry:
# into a single row and never recover the frame.
manager.resize(pty_id, cols, max(rows - 1, 2))
await asyncio.sleep(REPAINT_NUDGE_S)
- manager.resize(pty_id, cols, rows)
+ if term.pty_id != pty_id:
+ # A new process owns the pane now and was sized on its own.
+ return False
+ manager.resize(pty_id, term.pty_cols or cols, term.pty_rows or rows)
term.last_resize_at = time.time()
except Exception as exc: # noqa: BLE001 - a stale screen beats a failed reconnect
logger.debug("Agentic IDE: could not nudge {} into a repaint: {}", term.name, exc)
diff --git a/tests/unit/agentic_ide/test_session.py b/tests/unit/agentic_ide/test_session.py
index e746ba989e..e157f7b22b 100644
--- a/tests/unit/agentic_ide/test_session.py
+++ b/tests/unit/agentic_ide/test_session.py
@@ -460,6 +460,56 @@ async def test_a_viewer_resize_the_agent_ignored_is_nudged_again(
assert not registry._repaint_check_by_pane
+async def test_a_resize_during_a_nudge_is_not_undone_by_its_restore(
+ registry: Registry,
+ fake_pty: FakePtyManager,
+ tmp_path: Path,
+ monkeypatch: pytest.MonkeyPatch,
+) -> None:
+ """A nudge puts back the size the pane has NOW, not the one it started at.
+
+ Its restore used to write the captured size after the sleep, so a viewer
+ resize landing in between (a tab switch back, a dragged seam) left the agent
+ drawing for the old width while every xterm showed the new one: rows drawn
+ over rows, word tails left behind (2026-09-29).
+ """
+ monkeypatch.setattr(session_mod, "REPAINT_NUDGE_S", 0.05)
+ await _open(registry, tmp_path, [{"agent": "claude"}])
+ await registry.attach("T1", 80, 24, _noop_output, _noop_exit)
+ term = registry.session.terminals[0]
+ pty = term.pty_id
+ fake_pty.resizes.clear()
+
+ nudge = asyncio.create_task(registry._resize_there_and_back(term, 80, 24))
+ await asyncio.sleep(0.01)
+ # A viewer resizes while the nudge holds the pane a row short.
+ assert registry.resize(term.key, 120, 40) is True
+ assert await nudge
+
+ sizes = [(cols, rows) for tid, cols, rows in fake_pty.resizes if tid == pty]
+ assert sizes[0] == (80, 23)
+ assert sizes[-1] == (120, 40), "the nudge put the agent back on the old grid"
+ assert (term.pty_cols, term.pty_rows) == (120, 40)
+
+
+async def test_a_nudge_never_changes_the_width_the_agent_has(
+ registry: Registry,
+ fake_pty: FakePtyManager,
+ tmp_path: Path,
+) -> None:
+ """A re-joining viewer's own size must not reach the agent through a nudge."""
+ await _open(registry, tmp_path, [{"agent": "claude"}])
+ await registry.attach("T1", 80, 24, _noop_output, _noop_exit)
+ term = registry.session.terminals[0]
+ pty = term.pty_id
+ fake_pty.resizes.clear()
+
+ assert await registry._resize_there_and_back(term, 132, 50)
+
+ sizes = [(cols, rows) for tid, cols, rows in fake_pty.resizes if tid == pty]
+ assert sizes == [(80, 23), (80, 24)]
+
+
async def test_a_line_mode_agent_is_nudged_once(
registry: Registry, fake_pty: FakePtyManager, tmp_path: Path
) -> None: