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(ide): keep a pane's last frame when its agent does not repaint
rubenluetke10-beepd5d321c19e22
diff --git a/jarvis/agentic_ide/session.py b/jarvis/agentic_ide/session.pyindex efac1055b3..5aaa1d8b35 100644--- a/jarvis/agentic_ide/session.py+++ b/jarvis/agentic_ide/session.py@@ -3992,23 +3992,31 @@ class Registry:# grid; they follow the new one now, not at their next# unrelated window resize._announce_geometry(term, cols, rows, except_viewer=on_output)- needs_repaint = term.replay.truncated+ # A frame still owed since an earlier resize counts like a cut+ # tail: what is kept was drawn for another size, so a fresh paint+ # has to be asked for even though this viewer changes nothing.+ needs_repaint = term.replay.truncated or term.replay.awaiting_frameif geometry_changed and is_coding_agent(term.agent):# A cursor-addressed TUI stream is meaningful only at the size# that produced it. Replaying the old geometry after a grid# re-layout leaves status rows and command fragments behind- # the new paint. Keep the terminal modes, drop those drawing- # bytes, and let the live agent rebuild one clean screen below.+ # the new paint, so a new replay epoch starts here and the live+ # agent is asked to rebuild one clean screen below. An agent+ # that paints whole frames keeps its old one meanwhile: the+ # viewer waits for the new frame's erase, and shows the old one+ # rather than an empty pane if the agent never answers (see+ # ``ReplayBuffer.rebase_for_resize``).replay = term.replay.rebase_for_resize()needs_repaint = Trueelse:replay = term.replay.text()if replay:# Hand over either the stream that drew the current screen, or- # (after a geometry change) the terminal-mode prologue that a- # clean repaint must draw on. A coding agent's TUI is a painted- # surface, not a log: the viewer needs one of those two rebuild- # paths rather than an append to whatever it held before.+ # (after a geometry change) the old frame or the terminal-mode+ # prologue that a clean repaint must draw on. A coding agent's+ # TUI is a painted surface, not a log: the viewer needs one of+ # those rebuild paths rather than an append to whatever it held+ # before.## On the replay channel when the viewer offered one — see the# docstring for what appending it to a screen that already had@@ -5080,7 +5088,9 @@ class Registry:if is_coding_agent(term.agent):# Future viewers must not replay cursor moves produced for the old# grid into the new one. The live viewer already has its screen;- # this only starts a clean replay epoch for the next reconnect.+ # this only starts a clean replay epoch for the next reconnect —+ # one that still shows the old frame, and asks for a new one, when+ # the agent lets this resize pass unanswered.term.replay.rebase_for_resize()term.transcript.resize(cols, rows)return Truediff --git a/jarvis/agentic_ide/transcript.py b/jarvis/agentic_ide/transcript.pyindex 143c246444..446f0638e2 100644--- a/jarvis/agentic_ide/transcript.py+++ b/jarvis/agentic_ide/transcript.py@@ -241,6 +241,16 @@ class ReplayBuffer:clears: int = field(default=0, init=False)#: The last bytes of the preceding read, in case it split an erase._clear_scan_tail: str = field(default="", init=False)+ #: Does the kept drawing belong to a terminal size the agent has since+ #: left? Set by :meth:`rebase_for_resize` for an agent that paints whole+ #: frames, cleared by that agent's next whole-screen erase — the fresh+ #: frame that replaces the old one. A replay taken meanwhile still shows+ #: the old frame, and its viewer has to ask for the new one.+ awaiting_frame: bool = field(default=False, init=False)+ #: Has this process painted a whole frame — an erase while holding the+ #: screen? Per process, unlike ``clears``: a pane's next agent may repaint+ #: differently.+ _paints_frames: bool = field(default=False, init=False)def feed(self, chunk: str) -> None:if not chunk:@@ -248,8 +258,15 @@ class ReplayBuffer:self._note_modes(chunk)scanned = self._clear_scan_tail + chunk# The tail is shorter than the sequence, so no erase is counted twice.- self.clears += scanned.count(_FULL_CLEAR)+ erases = scanned.count(_FULL_CLEAR)+ self.clears += erasesself._clear_scan_tail = scanned[-(len(_FULL_CLEAR) - 1) :]+ if erases:+ # A fresh frame has started, even when the erase was split across+ # two reads and so cannot rebase the buffer below.+ self.awaiting_frame = False+ if self.holds_screen:+ self._paints_frames = Trueerase = chunk.rfind(_FULL_CLEAR) if self.holds_screen else -1if erase >= 0:# A full-screen agent just emptied its screen, so everything it@@ -327,19 +344,36 @@ class ReplayBuffer:return self._mode_prologue() + "\x1b[0m" + textdef rebase_for_resize(self) -> str:- """Forget drawing bytes tied to the old geometry, preserving modes.+ """Start a new replay epoch for a new terminal size; return the replay.Cursor-addressed TUI output only has meaning at the terminal size thatproduced it. Replaying that stream into a differently sized viewerleaves old status rows and fragments between the newly painted ones.- A resize therefore starts a new replay epoch: the caller sends this- returned prologue to a reset viewer, then asks the live TUI to repaint.+ A resize therefore starts a new replay epoch: the caller sends the+ returned replay to a reset viewer, then asks the live TUI to repaint.++ **An agent that paints whole frames keeps its old one until the new+ one arrives.** Claude Code answers a resize with a frame that opens+ with a whole-screen erase (measured on 2.1.284), so the old drawing+ cannot leave fragments behind it — the erase wipes it, and the viewer+ stays hidden until that erase lands. Dropping it instead left the+ replay with nothing to draw: when the agent was too busy or starved to+ answer, every pane of a workspace came back as an empty black+ rectangle and stayed one until the agent next repainted on its own,+ which for an agent waiting for input is never (reported 2026-09-30,+ with the machine short of memory and disk). The old frame is kept and+ ``awaiting_frame`` says a new one is owed. Only an agent that has+ already shown a whole-screen erase qualifies: Codex repaints with+ partial erases, so a kept frame would show through its new one.Private modes survive because most coding CLIs negotiate alternatescreen and mouse tracking only once, at process startup. Droppingthose together with the stale drawing would repair the text whilesilently breaking the pane's mouse and scrollbar."""+ if self.holds_screen and self._paints_frames:+ self.awaiting_frame = True+ return self.text()return self._rebase("")def _rebase(self, frame: str) -> str:@@ -348,6 +382,7 @@ class ReplayBuffer:self._chunks.clear()self.truncated = Falseself._open_escape = False+ self.awaiting_frame = Falseself._chunks.append(prologue)self._size = len(prologue)if frame:@@ -377,6 +412,8 @@ class ReplayBuffer:self._modes.clear()self._mode_scan_tail = ""self._clear_scan_tail = ""+ self.awaiting_frame = False+ self._paints_frames = False__all__ = [diff --git a/tests/unit/agentic_ide/test_replay_channel.py b/tests/unit/agentic_ide/test_replay_channel.pyindex dce17cef36..ee9ce7a88a 100644--- a/tests/unit/agentic_ide/test_replay_channel.py+++ b/tests/unit/agentic_ide/test_replay_channel.py@@ -148,6 +148,82 @@ async def test_a_replay_at_another_size_promises_a_repaint(assert back.repaint_flags == [True]+async def _whole_frame_pane(pool: FakePtyManager, folder: Path): # noqa: ANN202 - internal fixture+ """A pane whose agent paints whole frames, the way Claude Code does."""+ registry = ide.Registry(pty_manager=pool)+ session = await registry.start(str(folder), [{"agent": "claude"}])+ term = session.terminals[0]+ first = Viewer()+ await registry.attach(+ term.key,+ 80,+ 24,+ first.on_output,+ _gone,+ workspace_id=session.id,+ on_replay=first.on_replay,+ )+ await pool.emit(term.pty_id, "\x1b[?1049h\x1b[2J\x1b[H┌─ Claude Code ─┐\r\n")+ return registry, session, term, first+++async def test_a_replay_at_another_size_keeps_the_last_frame(+ pool: FakePtyManager, tmp_path: Path+) -> None:+ """An agent that does not answer the repaint must not leave the pane black.++ Every pane of a workspace came back as an empty rectangle while its agents+ were too starved to repaint (2026-09-30): the replay at the new size held+ only the terminal modes. It now holds the last frame; the viewer still+ waits for the repaint and shows that frame only if none arrives.+ """+ registry, session, term, _first = await _whole_frame_pane(pool, tmp_path)+ back = Viewer()++ await registry.attach(+ term.key,+ 100,+ 30,+ back.on_output,+ _gone,+ workspace_id=session.id,+ on_replay=back.on_replay,+ )++ assert "┌─ Claude Code ─┐" in "".join(back.replay)+ assert back.repaint_flags == [True]+++async def test_a_resize_left_unanswered_still_rejoins_with_a_picture(+ pool: FakePtyManager, tmp_path: Path+) -> None:+ """A resize the agent never answered must not empty the next replay.++ The pane is resized while its viewer is away; the agent lets it pass. The+ next viewer arrives at that same size, so nothing about its own geometry+ asks for a repaint — the owed frame has to, or it re-joins an empty screen+ with no nudge at all.+ """+ registry, session, term, first = await _whole_frame_pane(pool, tmp_path)+ assert registry.resize(term.key, 100, 30, session.id, viewer=first.on_output)+ pool.resizes.clear()+ back = Viewer()++ await registry.attach(+ term.key,+ 100,+ 30,+ back.on_output,+ _gone,+ workspace_id=session.id,+ on_replay=back.on_replay,+ )++ assert "┌─ Claude Code ─┐" in "".join(back.replay)+ assert back.repaint_flags == [True]+ assert pool.resizes, "and the agent is asked again for the frame it owes"++async def test_live_output_after_a_rejoin_is_still_output(pool: FakePtyManager, tmp_path: Path) -> None:diff --git a/tests/unit/agentic_ide/test_transcript.py b/tests/unit/agentic_ide/test_transcript.pyindex 13ac21d387..c8cf1ca250 100644--- a/tests/unit/agentic_ide/test_transcript.py+++ b/tests/unit/agentic_ide/test_transcript.py@@ -304,7 +304,11 @@ def test_an_untruncated_replay_is_still_verbatim() -> None:def test_rebasing_for_a_resize_drops_old_drawing_but_preserves_modes() -> None:- """A TUI stream is geometry-bound; its negotiated terminal state is not."""+ """A TUI stream is geometry-bound; its negotiated terminal state is not.++ For an agent that has never painted a whole frame (Codex repaints with+ partial erases), the old drawing would show through the new one.+ """buffer = ReplayBuffer()buffer.feed("\x1b[?1049h\x1b[?1006hOLD STATUS ROW")@@ -316,11 +320,75 @@ def test_rebasing_for_a_resize_drops_old_drawing_but_preserves_modes() -> None:assert "\x1b[?1006h" in prologueassert prologue.endswith("\x1b[0m")assert buffer.truncated is False+ assert buffer.awaiting_frame is Falsebuffer.feed("NEW SCREEN")assert buffer.text() == prologue + "NEW SCREEN"+def test_a_whole_frame_painter_keeps_its_last_frame_until_the_next_one() -> None:+ """Never trade the only picture of a pane for an empty one.++ Dropping the old frame on a resize left nothing to replay, and an agent too+ busy or too starved to answer the repaint request left every pane of a+ workspace an empty black rectangle (2026-09-30). Claude Code repaints a+ resize with a whole-screen erase, so the old frame cannot linger once the+ new one arrives.+ """+ buffer = ReplayBuffer()+ buffer.feed("\x1b[?1049h\x1b[?1006h\x1b[2J\x1b[HOLD FRAME")++ replay = buffer.rebase_for_resize()++ assert "OLD FRAME" in replay, "the replay still draws the last frame"+ assert replay == buffer.text()+ assert buffer.awaiting_frame is True, "and a new frame is owed"++ buffer.feed("\x1b[2J\x1b[HNEW FRAME")++ assert buffer.awaiting_frame is False+ assert "OLD FRAME" not in buffer.text()+ assert buffer.text().endswith("\x1b[2J\x1b[HNEW FRAME")+++def test_a_frame_owed_since_a_resize_survives_further_resizes() -> None:+ """A dragged seam resizes many times; the picture must survive all of them."""+ buffer = ReplayBuffer()+ buffer.feed("\x1b[?1049h\x1b[2J\x1b[HOLD FRAME")++ buffer.rebase_for_resize()+ buffer.feed("\x1b[5;1Hspinner")+ replay = buffer.rebase_for_resize()++ assert "OLD FRAME" in replay and replay.endswith("spinner")+ assert buffer.awaiting_frame is True+++def test_an_erase_split_across_reads_still_ends_the_wait() -> None:+ """A PTY read may cut the new frame's erase after any byte."""+ buffer = ReplayBuffer()+ buffer.feed("\x1b[?1049h\x1b[2J\x1b[HOLD FRAME")+ buffer.rebase_for_resize()++ buffer.feed("tail\x1b[")+ buffer.feed("2J\x1b[HNEW FRAME")++ assert buffer.awaiting_frame is False+++def test_a_new_process_does_not_inherit_whole_frame_painting() -> None:+ """The next agent in a pane is judged by its own repaints."""+ buffer = ReplayBuffer()+ buffer.feed("\x1b[?1049h\x1b[2J\x1b[Hclaude frame")+ buffer.clear()+ buffer.feed("\x1b[?1049hcodex screen")++ replay = buffer.rebase_for_resize()++ assert "codex screen" not in replay+ assert buffer.awaiting_frame is False++def test_a_replay_forgets_the_modes_when_it_is_cleared() -> None:buffer = ReplayBuffer(limit=32)buffer.feed("\x1b[?1049h" + "z" * 100)