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): settle panes resized while loading, and say how many panes fit

rubenluetke10-beep813d0c00f3fb
diff --git a/jarvis/agentic_ide/session.py b/jarvis/agentic_ide/session.py
index 288e196ec6..2a2b5950b8 100644
--- a/jarvis/agentic_ide/session.py
+++ b/jarvis/agentic_ide/session.py
@@ -1086,6 +1086,11 @@ class Terminal:
# Movement in the shadow of this stamp is the pane being redrawn, not the
# agent working — see `activity._resize_shadowed`.
last_resize_at: float | None = None
+ # Resized while its agent was still loading, before it had taken the whole
+ # screen — so no repaint check could run for that size, and a CLI that was
+ # not listening yet may still be drawing for the size it was born with.
+ # Settled once the input line appears (see `_prompt_ready_then_settle`).
+ resized_while_booting: bool = False
prompts_sent: int = 0
last_prompt: str = ""
# The current process's records are kept as a fallback if the local history
@@ -1904,6 +1909,16 @@ class SessionError(RuntimeError):
"""A request the registry refuses, with a user-facing English message."""
+class WorkspaceFull(SessionError):
+ """The refusal is the pane cap (``MAX_TERMINALS``), not anything else.
+
+ Its own type because callers answer it differently from every other
+ refusal — the voice path says "the workspace is full" in the turn's
+ language instead of reading the English sentence out — and matching on
+ the message's wording broke the moment a message was reworded.
+ """
+
+
class SessionNotReady(SessionError):
"""The addressed workspace is not open — not "not here", but "not yet".
@@ -3664,6 +3679,35 @@ class Registry:
)
return term.name in ready
+ async def _prompt_ready_then_settle(self, session: Session, term: Terminal) -> bool:
+ """Wait for the input line, then repaint a pane resized while it loaded.
+
+ A fresh pane is spawned at the size its tile measured on mount, and the
+ grid settles a moment later — so its real size reaches the PTY while the
+ CLI is still booting. A CLI that is not listening for size changes yet
+ keeps drawing for the size it was born with: an interface narrower or
+ shorter than its pane, the input box floating mid-pane (reported
+ 2026-09-29, four panes opened together). The repaint check cannot catch
+ this, because it only runs once the agent has taken the whole screen.
+ One nudge after the input line appears — when the CLI certainly listens
+ — makes it lay out for the size the pane really has.
+ """
+ generation = term.process_generation
+ ready = await self._prompt_ready(session, term)
+ if (
+ ready
+ and term.process_generation == generation
+ and term.resized_while_booting
+ and term.replay.holds_screen
+ and term.pty_cols
+ and term.pty_rows
+ ):
+ term.resized_while_booting = False
+ # Shielded: the slot's ceiling may cancel this wait, and a nudge
+ # cut between its two resizes leaves the PTY a row short.
+ await asyncio.shield(self._nudge_repaint(term, term.pty_cols, term.pty_rows))
+ return ready
+
async def _acquire_agent_cold_start(self, term: Terminal) -> asyncio.Semaphore | None:
"""Take this CLI/account's boot slot when its registry entry needs one.
@@ -4060,6 +4104,7 @@ class Registry:
# can inherit the previous PTY's settled-screen evidence.
term.process_generation += 1
term.idle_seen = False
+ term.resized_while_booting = False
term.transcript.resize(cols, rows)
# Readiness belongs to this process. Keeping the dead process's screen
# here leaves old prompt sigils visible to the readiness probe and makes
@@ -4238,7 +4283,9 @@ class Registry:
try:
# One of a few starts at a time (see COLD_START_LIMIT), and the
# slot stays taken until this pane's input line appears.
- async with self._cold_start_slot(ready=lambda: self._prompt_ready(session, term)):
+ async with self._cold_start_slot(
+ ready=lambda: self._prompt_ready_then_settle(session, term)
+ ):
try:
identity = "pane:" + term.history_id
if term.stopping or self._locate(identity, session.id) != (session, term):
@@ -4691,10 +4738,14 @@ class Registry:
test, a script) simply goes unchecked.
"""
if not term.replay.holds_screen:
+ # Either a line-mode CLI, or a full-screen one still loading. The
+ # second cannot be checked yet, so it is settled after boot.
+ term.resized_while_booting = True
return
try:
loop = asyncio.get_running_loop()
except RuntimeError:
+ # No event loop (shutdown or sync caller): skip the repaint check.
return
# One check per pane: a dragged seam resizes many times a second, and
# only the newest size's repaint is worth waiting for. An older check is
@@ -5138,7 +5189,7 @@ class Registry:
if session is None:
raise SessionError("No Agentic-IDE session is running.")
if len(session.terminals) >= MAX_TERMINALS:
- raise SessionError(
+ raise WorkspaceFull(
f"This workspace already has the maximum of {MAX_TERMINALS} terminals."
)
if direction not in ("right", "down", "left", "up", "above", "below"):
@@ -5502,7 +5553,7 @@ class Registry:
# Checked before a worktree is created, so a full workspace does not
# leave an orphaned branch behind.
if len(session.terminals) >= MAX_TERMINALS:
- raise SessionError(
+ raise WorkspaceFull(
f"This workspace already has the maximum of {MAX_TERMINALS} terminals."
)
folder = ""
@@ -5569,7 +5620,7 @@ class Registry:
raise SessionError("No Agentic-IDE session is running.")
wanted = max(1, int(count))
if len(selected.terminals) + wanted > MAX_TERMINALS:
- raise SessionError(f"A workspace can contain at most {MAX_TERMINALS} terminals.")
+ raise WorkspaceFull(f"A workspace can contain at most {MAX_TERMINALS} terminals.")
created: list[Terminal] = []
for _ in range(wanted):
try:
@@ -6772,6 +6823,7 @@ __all__ = [
"SessionError",
"SessionNotReady",
"Terminal",
+ "WorkspaceFull",
"accepts_prompts",
"agent_argv",
"agent_display",
diff --git a/jarvis/brain/manager.py b/jarvis/brain/manager.py
index dd59ce6379..de9f69b1c1 100644
--- a/jarvis/brain/manager.py
+++ b/jarvis/brain/manager.py
@@ -6800,10 +6800,12 @@ class BrainManager:
try:
window = int(getattr(brain, "context_window", 0) or 0)
except (TypeError, ValueError):
+ # A malformed context window means 'unknown'; no trimming then.
window = 0
try:
max_tools = int(getattr(brain, "max_tools", 0) or 0)
except (TypeError, ValueError):
+ # A malformed tool limit means 'unknown'; no trimming then.
max_tools = 0
if window <= 0 and max_tools <= 0:
return tools
@@ -8199,6 +8201,7 @@ class BrainManager:
from jarvis.agentic_ide.session import (
MAX_TERMINALS,
SessionError,
+ WorkspaceFull,
get_registry,
terminals_added_event,
)
@@ -8317,12 +8320,29 @@ class BrainManager:
# is attempted on its own and what could not be opened is
# named at the end, so a mixed fleet degrades pane by pane
# instead of all at once.
+ # The registry refuses a batch that does not fit as a
+ # whole, but a spoken "open five more" with room for three
+ # opens three and says so (``ide_terminals_spawned_capped``):
+ # the user hears the shortfall instead of a flat refusal.
+ current = registry.session
+ room = (
+ MAX_TERMINALS - len(current.terminals)
+ if current is not None
+ else group.count
+ )
+ if room <= 0:
+ if created:
+ break
+ raise WorkspaceFull(
+ f"A workspace can contain at most {MAX_TERMINALS} terminals."
+ )
+ wanted = min(group.count, room)
try:
opened, _capped = await registry.add_terminals(
- group.count, agent=group.agent
+ wanted, agent=group.agent
)
except SessionError as exc:
- if "maximum" in str(exc).lower():
+ if isinstance(exc, WorkspaceFull):
raise
log.info(
"Agentic IDE spawn: %s group refused: %s",
@@ -8332,7 +8352,7 @@ class BrainManager:
refused.append(str(exc))
continue
created.extend(opened)
- if _capped:
+ if _capped or wanted < group.count:
# The workspace filled up mid-fleet. Stop rather than
# asking for the next group and getting the same
# refusal — the readback already reports the shortfall.
@@ -8342,7 +8362,7 @@ class BrainManager:
# these already carries a user-facing English sentence, and speaking
# it is more useful than a generic failure.
log.info("Agentic IDE spawn fast-path refused: %s", exc)
- if "maximum" in str(exc).lower():
+ if isinstance(exc, WorkspaceFull):
return action_phrase(
"ide_terminals_full", out_lang, max=MAX_TERMINALS
)
diff --git a/tests/unit/agentic_ide/test_library.py b/tests/unit/agentic_ide/test_library.py
index 8b11ed199c..0f5bc717db 100644
--- a/tests/unit/agentic_ide/test_library.py
+++ b/tests/unit/agentic_ide/test_library.py
@@ -44,22 +44,20 @@ def test_reopening_a_project_keeps_its_name(tmp_path: Path) -> None:
assert reopened.name == "The good one"
-def test_projects_list_pinned_first_then_most_recent(tmp_path: Path) -> None:
+def test_projects_list_pinned_first_then_in_the_users_order(tmp_path: Path) -> None:
"""The order IS the sidebar's order, so it is asserted rather than assumed."""
for name in ("alpha", "beta", "gamma"):
(tmp_path / name).mkdir()
- alpha = library.ensure_project(tmp_path / "alpha")
+ library.ensure_project(tmp_path / "alpha")
library.ensure_project(tmp_path / "beta")
gamma = library.ensure_project(tmp_path / "gamma")
- library.update_project(alpha.id, pinned=True)
+ library.update_project(gamma.id, pinned=True)
listed = [p.name for p in library.list_projects()]
- # Pinned wins outright; the rest fall in most-recently-opened order, and
- # gamma was opened last.
- assert listed[0] == "alpha"
- assert listed[1] == "gamma"
- assert gamma.id in {p.id for p in library.list_projects()}
+ # Pinned wins outright; the rest keep the drag-and-drop order, where a
+ # project nobody arranged goes behind every arranged one.
+ assert listed == ["gamma", "alpha", "beta"]
def test_archived_projects_are_hidden_but_not_gone(tmp_path: Path) -> None:
diff --git a/tests/unit/agentic_ide/test_session.py b/tests/unit/agentic_ide/test_session.py
index e157f7b22b..65dcf42cf3 100644
--- a/tests/unit/agentic_ide/test_session.py
+++ b/tests/unit/agentic_ide/test_session.py
@@ -427,6 +427,63 @@ async def test_repaint_nudges_stop_at_the_bound_and_leave_the_real_size(
assert sizes[-1] == (80, 24), "the pane must be left at the size it really is"
+async def _ready_now(_session: object, _term: object) -> bool:
+ return True
+
+
+async def test_a_pane_resized_while_its_agent_loaded_is_repainted_once_ready(
+ registry: Registry,
+ fake_pty: FakePtyManager,
+ tmp_path: Path,
+ monkeypatch: pytest.MonkeyPatch,
+) -> None:
+ """The grid settles while the CLI boots; its real size must be drawn for.
+
+ Four panes opened together were spawned at the mount-time size and resized
+ a moment later, before Claude Code listened for size changes — so it kept
+ laying out for the old size (2026-09-29). No repaint check can run before
+ the agent takes the whole screen, so the pane is nudged once it is ready.
+ """
+ monkeypatch.setattr(session_mod, "REPAINT_CONFIRM_S", 0.02)
+ monkeypatch.setattr(session_mod, "REPAINT_POLL_S", 0.005)
+ monkeypatch.setattr(registry, "_prompt_ready", _ready_now)
+ session = await _open(registry, tmp_path, [{"agent": "claude"}])
+ term = session.terminals[0]
+ await registry.attach(term.name, 114, 30, _noop_output, _noop_exit)
+ pty = term.pty_id
+ # Still loading: nothing has taken the screen yet.
+ assert registry.resize(term.key, 104, 30, session.id)
+ assert term.resized_while_booting
+ await fake_pty.emit(pty, "\x1b[?1049h\x1b[2J\x1b[Hdrawn for 114 columns")
+ fake_pty.resizes.clear()
+
+ assert await registry._prompt_ready_then_settle(session, term)
+
+ sizes = [(cols, rows) for tid, cols, rows in fake_pty.resizes if tid == pty]
+ assert sizes[:2] == [(104, 29), (104, 30)]
+ assert not term.resized_while_booting
+ await asyncio.gather(*registry._repaint_checks)
+ assert fake_pty.resizes[-1][1:] == (104, 30)
+
+
+async def test_a_pane_never_resized_while_loading_is_not_nudged(
+ registry: Registry,
+ fake_pty: FakePtyManager,
+ tmp_path: Path,
+ monkeypatch: pytest.MonkeyPatch,
+) -> None:
+ monkeypatch.setattr(registry, "_prompt_ready", _ready_now)
+ session = await _open(registry, tmp_path, [{"agent": "claude"}])
+ term = session.terminals[0]
+ await registry.attach(term.name, 104, 30, _noop_output, _noop_exit)
+ await fake_pty.emit(term.pty_id, "\x1b[?1049h\x1b[2J\x1b[Hdrawn for 104 columns")
+ fake_pty.resizes.clear()
+
+ assert await registry._prompt_ready_then_settle(session, term)
+
+ assert fake_pty.resizes == []
+
+
async def test_a_viewer_resize_the_agent_ignored_is_nudged_again(
registry: Registry,
fake_pty: FakePtyManager,
diff --git a/tests/unit/brain/test_agentic_ide_clarify_fast_path.py b/tests/unit/brain/test_agentic_ide_clarify_fast_path.py
index 88b7cb92e5..b104fbc511 100644
--- a/tests/unit/brain/test_agentic_ide_clarify_fast_path.py
+++ b/tests/unit/brain/test_agentic_ide_clarify_fast_path.py
@@ -56,6 +56,13 @@ def _clean_window() -> None:
@pytest.fixture
def registry(monkeypatch: pytest.MonkeyPatch) -> Registry:
monkeypatch.setattr(session_mod, "agent_argv", lambda name: (f"/usr/bin/{name}",))
+ # Every pane here is attached, and a fake PTY never draws an input line, so
+ # the cold-start gate would hold each slot for its full ceiling: five panes
+ # queued behind a limit of two spent ~15 s per test, and the file outgrew
+ # CI's per-file timeout. The gate itself is covered in
+ # tests/unit/agentic_ide/test_cold_start_gate.py; here it only has to let go.
+ monkeypatch.setattr(session_mod, "COLD_START_SETTLE_S", 0.0)
+ monkeypatch.setattr(session_mod, "COLD_START_HOLD_MAX_S", 0.0)
reg = Registry(pty_manager=FakePtyManager())
monkeypatch.setattr(session_mod, "get_registry", lambda: reg)
return reg
diff --git a/tests/unit/web/test_agentic_ide_grid.py b/tests/unit/web/test_agentic_ide_grid.py
index 4cab02e298..7db549bcb3 100644
--- a/tests/unit/web/test_agentic_ide_grid.py
+++ b/tests/unit/web/test_agentic_ide_grid.py
@@ -58,23 +58,28 @@ def grid(registry: Registry) -> list[tuple[str, int, int]]:
return [(t.name, t.column, t.slot) for t in session.terminals]
-async def test_wizard_opens_columns_of_two(tmp_path) -> None:
- """Four terminals are two columns of two, not four columns of one.
+async def test_wizard_opens_an_even_grid_in_reading_order(tmp_path) -> None:
+ """Four terminals are a 2 x 2, not four columns of one.
The workspace is one screenful, so a row of columns divides the window
between every pane: six terminals left each about 410 px on the
maintainer's display, under the width their agent needs to draw in, so
every pane was clipped at its tile edge and the six read as overlapping
- one another (2026-08-11). Filling columns two deep halves the column count
- and so doubles each pane's width.
+ one another (2026-08-11). The opening grid is dealt row by row
+ (``balanced_columns``), so T1 and T2 share the top band.
"""
registry = await _workspace(tmp_path, 4)
- assert [(c, s) for _, c, s in grid(registry)] == [(0, 0), (0, 1), (1, 0), (1, 1)]
+ assert [(c, s) for _, c, s in grid(registry)] == [(0, 0), (1, 0), (0, 1), (1, 1)]
-async def test_wizard_stands_an_odd_pane_in_a_column_of_its_own(tmp_path) -> None:
+async def test_wizard_opens_two_panes_side_by_side(tmp_path) -> None:
+ registry = await _workspace(tmp_path, 2)
+ assert [(c, s) for _, c, s in grid(registry)] == [(0, 0), (1, 0)]
+
+
+async def test_wizard_puts_an_odd_pane_in_the_second_row(tmp_path) -> None:
registry = await _workspace(tmp_path, 3)
- assert [(c, s) for _, c, s in grid(registry)] == [(0, 0), (0, 1), (1, 0)]
+ assert [(c, s) for _, c, s in grid(registry)] == [(0, 0), (1, 0), (0, 1)]
async def test_split_down_stacks_inside_the_anchors_own_column(tmp_path) -> None:
@@ -153,9 +158,12 @@ async def test_split_right_in_a_stack_keeps_the_other_pane_full_width(tmp_path)
panes and everything was squeezed. The tree answers locally: the top half
holds two panes side by side, the bottom pane keeps the full width.
"""
- registry = await _workspace(tmp_path, 2)
+ # Two panes OPEN side by side (``balanced_columns``), so the stack is
+ # built the way a user builds one: split the first pane downwards.
+ registry = await _workspace(tmp_path, 1)
session = registry.session
assert session is not None
+ await registry.add_terminal(anchor=session.terminals[0].name, direction="down")
top, bottom = session.terminals[0], session.terminals[1]
added = await registry.add_terminal(anchor=top.name, direction="right")
diff --git a/tests/unit/web/test_agentic_ide_recents.py b/tests/unit/web/test_agentic_ide_recents.py
index 11c517fe00..465f19c0d1 100644
--- a/tests/unit/web/test_agentic_ide_recents.py
+++ b/tests/unit/web/test_agentic_ide_recents.py
@@ -24,7 +24,14 @@ async def test_open_route_remembers_the_user_selected_folder(
)
class FakeRegistry:
- async def start(self, folder: str, terminals: list[dict]) -> object:
+ async def start(
+ self,
+ folder: str,
+ terminals: list[dict],
+ *,
+ project_id: str | None = None,
+ name: str | None = None,
+ ) -> object:
assert folder == str(tmp_path)
assert len(terminals) == 3
return session