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.

feat(agentic-ide): every opened terminal evens the whole wall

rubenluetke10-beep9fa2a4ead55e
diff --git a/jarvis/agentic_ide/layout_tree.py b/jarvis/agentic_ide/layout_tree.py
index c8554c1e25..fcab848569 100644
--- a/jarvis/agentic_ide/layout_tree.py
+++ b/jarvis/agentic_ide/layout_tree.py
@@ -42,6 +42,11 @@ Every function returns a tree in canonical form:
* **A close gives the freed room to the siblings, proportionally.** The
closed pane's weight is simply dropped; the remaining weights renormalise
against each other, so a 2:1:1 stack losing its tail becomes 2:1.
+* **The session evens the wall after every open.** The halving above decides
+ the SHAPE; the weights it leaves are then replaced by ``evened`` — every
+ terminal at the same share, exactly what the grid's "even out" button does
+ — because a new terminal carved from a pane that had been dragged small
+ arrived as a sliver nobody asked for (maintainer request, 2026-08-22).
"""
from __future__ import annotations
@@ -294,6 +299,51 @@ def append_pane(root: LayoutNode | None, added: str) -> LayoutNode:
return Split(direction="row", children=[root, Leaf(pane=added)], weights=[1.0, 1.0])
+def axis_span(node: LayoutNode, direction: Direction) -> int:
+ """How many TERMINALS wide (``row``) or tall (``column``) ``node`` is.
+
+ The yardstick "even" is measured with. A container that runs in
+ ``direction`` is as many stripes as its children together; one running the
+ other way is only as wide as its widest member. Without this a workspace
+ like ``row[pane, stack-of-two, pane]`` would "even" to quarters and the
+ stacked terminals come out half as wide as their neighbours — the same
+ arithmetic the frontend's ``axisSpan`` (``treeLayout.ts``) uses, and the
+ two must agree or the grid's "already even" button state lies.
+ """
+ if isinstance(node, Leaf):
+ return 1
+ spans = [axis_span(child, direction) for child in node.children]
+ if not spans:
+ return 1
+ return sum(spans) if node.direction == direction else max(spans)
+
+
+def evened(root: LayoutNode | None) -> LayoutNode | None:
+ """The same tree with every TERMINAL back at an equal share of the room.
+
+ The backend half of the grid's "even out" button: the arrangement — which
+ pane sits where — is never touched, only how the boundaries fall. Weights
+ are stripe counts rather than a flat 1, so a nested group is given as much
+ room as the terminals it lines up (see ``axis_span``). Applied after every
+ pane the session OPENS (``Registry.add_terminal``), so a fresh terminal
+ never arrives as a sliver carved from a pane that had already been dragged
+ small, and the wall reads as one even grid however it was assembled.
+ """
+ if root is None:
+ return None
+ return _evened(root)
+
+
+def _evened(node: LayoutNode) -> LayoutNode:
+ if isinstance(node, Leaf):
+ return node
+ return Split(
+ direction=node.direction,
+ children=[_evened(child) for child in node.children],
+ weights=[float(axis_span(child, node.direction)) for child in node.children],
+ )
+
+
def remove_pane(root: LayoutNode | None, pane: str) -> LayoutNode | None:
"""The tree without ``pane``; ``None`` when it held nothing else.
diff --git a/jarvis/agentic_ide/session.py b/jarvis/agentic_ide/session.py
index 28ea4430e0..ff47421d06 100644
--- a/jarvis/agentic_ide/session.py
+++ b/jarvis/agentic_ide/session.py
@@ -3891,10 +3891,10 @@ class Registry:
session.terminals.append(term)
# Where it goes is the tree's business, and the distinction is the
# whole feature: a NAMED anchor is a split — the new pane carves
- # the clicked pane's own rectangle and nothing else moves — while
- # an anchor-less add ("open five more", the empty grid's button)
- # joins the workspace edge as a full-height column, because no
- # pane was chosen to give up half its room.
+ # the clicked pane's own rectangle and no other pane changes its
+ # PLACE — while an anchor-less add ("open five more", the empty
+ # grid's button) joins the workspace edge as a full-height column,
+ # because no pane was chosen to sit beside.
if anchor and base is not None:
session.layout = layout_tree.split_pane(
session.layout,
@@ -3904,6 +3904,16 @@ class Registry:
)
else:
session.layout = layout_tree.append_pane(session.layout, term.key)
+ # Then every terminal back to an equal share — the same act as the
+ # grid's "even out" button, run for the user on every open. The
+ # split decided the SHAPE; its halved weights are not kept, because
+ # a pane split off one that had been dragged small arrived as a
+ # sliver, and the maintainer asked (2026-08-22) that a new
+ # terminal always land in an evenly shared wall. Doing it here
+ # rather than in the grid covers every way a terminal opens —
+ # split button, batch, voice, CLI — and the persisted layout
+ # agrees with the screen.
+ session.layout = layout_tree.evened(session.layout)
self._renumber(session)
await self._persist()
logger.info(
diff --git a/tests/unit/web/test_agentic_ide_grid.py b/tests/unit/web/test_agentic_ide_grid.py
index 3d85924dff..6213016740 100644
--- a/tests/unit/web/test_agentic_ide_grid.py
+++ b/tests/unit/web/test_agentic_ide_grid.py
@@ -7,6 +7,7 @@ are the coarse hints `_renumber` projects from that tree — for the flat
columns-of-stacks shapes most of this file builds, the projection is exact,
which is why the assertions written against the old flat grid still hold.
"""
+
from __future__ import annotations
import pytest
@@ -196,6 +197,60 @@ async def test_dragged_sizes_from_a_reshaped_workspace_are_declined(tmp_path) ->
assert all(weight == 1.0 for weight in session.layout.weights)
+async def test_opening_a_terminal_evens_the_whole_wall(tmp_path) -> None:
+ """Every open is also the "even out" button (maintainer request, 2026-08-22).
+
+ Two panes dragged to 3:1, then a split off the SMALL one. Halving alone
+ would leave the newcomer at an eighth of the width — a sliver. The session
+ keeps the split's shape (the new pane sits beside its anchor) but deals
+ every terminal the same share, and the persisted tree says so too.
+ """
+ registry = await _workspace(tmp_path, 1)
+ session = registry.session
+ assert session is not None
+ first = session.terminals[0]
+ second = await registry.add_terminal(anchor=first.name, direction="right")
+ dragged = layout_tree.to_dict(session.layout)
+ dragged["weights"] = [3.0, 1.0]
+ await registry.set_layout_weights(dragged)
+ assert isinstance(session.layout, layout_tree.Split)
+ assert session.layout.weights == [3.0, 1.0]
+
+ third = await registry.add_terminal(anchor=second.name, direction="right")
+
+ layout = session.layout
+ assert isinstance(layout, layout_tree.Split) and layout.direction == "row"
+ # Shape: the newcomer landed beside the pane that was split.
+ assert layout_tree.leaves(layout) == [first.key, second.key, third.key]
+ # Sizes: the drag is gone, every terminal holds the same share.
+ assert layout.weights == [1.0, 1.0, 1.0]
+ assert session.to_dict()["layout"]["weights"] == [1.0, 1.0, 1.0]
+
+
+async def test_opening_into_a_nested_group_evens_by_terminal_count(tmp_path) -> None:
+ """The stacked half of a split is as wide as the terminals it lines up."""
+ registry = await _workspace(tmp_path, 1)
+ session = registry.session
+ assert session is not None
+ first = session.terminals[0]
+ second = await registry.add_terminal(anchor=first.name, direction="right")
+ # Stack a third under the second: row[t1, column[t2, t3]].
+ await registry.add_terminal(anchor=second.name, direction="down")
+ dragged = layout_tree.to_dict(session.layout)
+ dragged["weights"] = [3.0, 1.0]
+ await registry.set_layout_weights(dragged)
+
+ # Split the first rightwards: row[t1, t4, column[t2, t3]] — the stack is
+ # one terminal wide, so the row deals three equal shares.
+ await registry.add_terminal(anchor=first.name, direction="right")
+
+ layout = session.layout
+ assert isinstance(layout, layout_tree.Split) and layout.direction == "row"
+ assert layout.weights == [1.0, 1.0, 1.0]
+ stack = layout.children[2]
+ assert isinstance(stack, layout_tree.Split) and stack.weights == [1.0, 1.0]
+
+
async def test_unreadable_dragged_sizes_are_refused_out_loud(tmp_path) -> None:
registry = await _workspace(tmp_path, 2)
with pytest.raises(SessionError):
diff --git a/tests/unit/web/test_agentic_ide_layout_tree.py b/tests/unit/web/test_agentic_ide_layout_tree.py
index b1a17e4cdf..e8633fa839 100644
--- a/tests/unit/web/test_agentic_ide_layout_tree.py
+++ b/tests/unit/web/test_agentic_ide_layout_tree.py
@@ -159,6 +159,79 @@ def test_appending_takes_an_even_share_of_a_dragged_row() -> None:
assert tree.weights == [3.0, 1.0, 2.0]
+# ------------------------------------------------------------- evening out
+
+
+def test_evened_levels_a_dragged_row() -> None:
+ row = Split(
+ direction="row",
+ children=[Leaf(pane="t1"), Leaf(pane="t2"), Leaf(pane="t3")],
+ weights=[3.0, 1.0, 2.0],
+ )
+ tree = lt.evened(row)
+ assert isinstance(tree, Split)
+ assert tree.weights == [1.0, 1.0, 1.0]
+ # Only the boundaries moved — the arrangement is untouched.
+ assert lt.leaves(tree) == ["t1", "t2", "t3"]
+ check_canonical(tree)
+
+
+def test_evened_counts_terminals_not_tree_nodes() -> None:
+ """A nested stack is as many stripes as the terminals it lines up.
+
+ ``row[pane, stack-of-two, pane]`` evened to a flat 1:1:1 would hand the
+ stack a quarter of the width and draw its two terminals half as wide as
+ their neighbours (reported 2026-08-12 on the grid's button). Stripe
+ counts are the yardstick the frontend's ``evenedTree`` uses, and the
+ backend must deal the same shares or the button reads "already even"
+ over a workspace the server just left uneven.
+ """
+ stack = Split(
+ direction="row",
+ children=[Leaf(pane="t2"), Leaf(pane="t3")],
+ weights=[5.0, 1.0],
+ )
+ tree = lt.evened(
+ Split(
+ direction="column",
+ children=[Leaf(pane="t1"), stack, Leaf(pane="t4")],
+ weights=[4.0, 1.0, 1.0],
+ )
+ )
+ assert isinstance(tree, Split)
+ # A row inside a column is only ONE terminal tall — plain shares.
+ assert tree.weights == [1.0, 1.0, 1.0]
+ inner = tree.children[1]
+ assert isinstance(inner, Split) and inner.weights == [1.0, 1.0]
+
+ wide = lt.evened(
+ Split(
+ direction="row",
+ children=[Leaf(pane="t1"), stack, Leaf(pane="t4")],
+ weights=[4.0, 1.0, 1.0],
+ )
+ )
+ assert isinstance(wide, Split)
+ # A row inside a row is TWO terminals wide and is dealt two shares.
+ assert wide.weights == [1.0, 2.0, 1.0]
+
+
+def test_evened_leaves_the_trivial_trees_alone() -> None:
+ assert lt.evened(None) is None
+ assert lt.evened(Leaf(pane="t1")) == Leaf(pane="t1")
+
+
+def test_axis_span_is_the_widest_member_across_the_grain() -> None:
+ stack = Split(
+ direction="column",
+ children=[Leaf(pane="t1"), Leaf(pane="t2"), Leaf(pane="t3")],
+ weights=[1.0, 1.0, 1.0],
+ )
+ assert lt.axis_span(stack, "column") == 3
+ assert lt.axis_span(stack, "row") == 1
+ assert lt.axis_span(Leaf(pane="t9"), "row") == 1
+
+
# ---------------------------------------------------------------- closing