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
feat(agentic-ide): hand-sized pane boundaries survive the next open
rubenluetke10-beepe5c3d7bf0577
diff --git a/jarvis/agentic_ide/layout_tree.py b/jarvis/agentic_ide/layout_tree.pyindex fcab848569..42cc6082f5 100644--- a/jarvis/agentic_ide/layout_tree.py+++ b/jarvis/agentic_ide/layout_tree.py@@ -42,11 +42,14 @@ Every function returns a tree in canonical form:* **A close gives the freed room to the siblings, proportionally.** Theclosed pane's weight is simply dropped; the remaining weights renormaliseagainst 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).+* **The session evens the wall after every open — except by hand-sized+ boundaries.** The halving above decides the SHAPE; the weights it leaves+ are then replaced by ``evened`` — every terminal at the same share, 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. A+ container whose boundaries the user dragged (``Split.pinned``, decided+ from the weights at save time) keeps them: a size chosen on purpose is+ not undone by the next open (maintainer request, 2026-08-22)."""from __future__ import annotations@@ -81,6 +84,13 @@ class Split:direction: Directionchildren: list[LayoutNode] = field(default_factory=list)weights: list[float] = field(default_factory=list)+ #: The user dragged THIS container's boundaries by hand (its weights were+ #: uneven the last time a client saved sizes). A pinned container keeps+ #: its weights through the evening that follows every open; every other+ #: container is dealt equal shares again. Cleared the moment the user+ #: evens it back out — by hand or with the grid's button — so "manual"+ #: is exactly "still uneven", never a sticky mode.+ pinned: bool = FalseLayoutNode = Leaf | Split@@ -112,6 +122,7 @@ def normalize(node: LayoutNode) -> LayoutNode:children: list[LayoutNode] = []weights: list[float] = []+ pinned = node.pinnedraw_weights = list(node.weights)for index, child in enumerate(node.children):cleaned = normalize(child)@@ -120,7 +131,9 @@ def normalize(node: LayoutNode) -> LayoutNode:# A row inside a row: inline the grandchildren, scaling their# weights so together they still occupy exactly the room the# child had. Nothing moves on screen — only the bookkeeping- # flattens.+ # flattens. Hand-sized boundaries stay hand-sized: the merged+ # container is pinned if either of the two was.+ pinned = pinned or cleaned.pinnedtotal = sum(cleaned.weights) or 1.0for grandchild, sub in zip(cleaned.children, cleaned.weights, strict=True):children.append(grandchild)@@ -131,7 +144,7 @@ def normalize(node: LayoutNode) -> LayoutNode:if len(children) == 1:return children[0]- return Split(direction=node.direction, children=children, weights=weights)+ return Split(direction=node.direction, children=children, weights=weights, pinned=pinned)def leaves(node: LayoutNode | None) -> list[str]:@@ -318,16 +331,55 @@ def axis_span(node: LayoutNode, direction: Direction) -> int:return sum(spans) if node.direction == direction else max(spans)+#: How far apart two sibling shares may be and still count as the same size.+#: Relative, because weights are multipliers: 7 and 7.0000001 are the same+#: pane on any screen. The frontend's ``EVEN_EPSILON`` (``treeLayout.ts``).+EVEN_EPSILON = 1e-4+++def is_even(node: LayoutNode | None) -> bool:+ """Is every TERMINAL under ``node`` at the share ``evened`` would give it?++ Judged per stripe, the way ``evened`` deals weights out (``axis_span``),+ so equal container weights over a nested group do NOT read as even while+ one terminal draws twice the size of another.+ """+ if node is None or isinstance(node, Leaf):+ return True+ return _even_weights(node) and all(is_even(child) for child in node.children)+++def _even_weights(node: Split) -> bool:+ """``node``'s own boundaries only — children not inspected."""+ shares = [+ _clean_weight(node.weights[index] if index < len(node.weights) else 1.0)+ / axis_span(child, node.direction)+ for index, child in enumerate(node.children)+ ]+ if not shares:+ return True+ first = shares[0]+ return all(abs(share - first) <= EVEN_EPSILON * first for share in shares)++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.+ """Every TERMINAL back at an equal share — except where a hand set them.++ The backend half of the grid's "even out" button, run for the user 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. 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``).++ A ``pinned`` container — one whose boundaries the user dragged by hand —+ keeps its weights: the maintainer asked (2026-08-22) that a size chosen+ on purpose survives the next open, while everything NOT chosen comes out+ even. Its children are still evened individually, so a split inside a+ hand-sized column shares that column evenly without moving the column.+ Unlike the button, which evens everything, this one is the quiet default+ and must not undo a choice."""if root is None:return None@@ -337,11 +389,15 @@ def evened(root: LayoutNode | None) -> LayoutNode | None: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],- )+ children = [_evened(child) for child in node.children]+ if node.pinned:+ weights = [+ _clean_weight(node.weights[index] if index < len(node.weights) else 1.0)+ for index in range(len(children))+ ]+ else:+ weights = [float(axis_span(child, node.direction)) for child in node.children]+ return Split(direction=node.direction, children=children, weights=weights, pinned=node.pinned)def remove_pane(root: LayoutNode | None, pane: str) -> LayoutNode | None:@@ -377,7 +433,9 @@ def remove_pane(root: LayoutNode | None, pane: str) -> LayoutNode | None:return Noneif len(children) == 1:return normalize(children[0])- return normalize(Split(direction=root.direction, children=children, weights=weights))+ return normalize(+ Split(direction=root.direction, children=children, weights=weights, pinned=root.pinned)+ )def swap_panes(root: LayoutNode | None, first: str, second: str) -> LayoutNode | None:@@ -441,6 +499,7 @@ def to_dict(node: LayoutNode) -> dict[str, Any]:"direction": node.direction,"children": [to_dict(child) for child in node.children],"weights": [_clean_weight(weight) for weight in node.weights],+ "pinned": bool(node.pinned),}@@ -474,6 +533,11 @@ def from_dict(data: Any) -> LayoutNode:for index in range(len(parsed))]node = Split(direction=direction, children=parsed, weights=weights)+ # A snapshot written before containers carried the flag: a container that+ # is uneven was dragged by a hand that is no longer there to say so, and+ # its sizes must survive the next open the same way they did until now.+ raw_pinned = data.get("pinned")+ node.pinned = bool(raw_pinned) if isinstance(raw_pinned, bool) else not _even_weights(node)seen: set[str] = set()for pane in leaves(node):if pane in seen:@@ -505,10 +569,18 @@ def adopt_weights(current: LayoutNode, proposed: LayoutNode) -> LayoutNode:Callers check :func:`same_shape` first; this keeps the session's own treeauthoritative for STRUCTURE while letting a client persist the one thing aseam drag changes.++ This is also where ``pinned`` is decided, from the weights alone: a+ container the save leaves uneven was sized by hand and holds that size+ through later opens; one the save leaves even — dragged back, a seam+ double-clicked, the "even out" button — is released. The client's own+ ``pinned`` value, if it sends one, is not consulted: the flag is a fact+ about the weights, and deriving it here is what keeps the two from+ disagreeing."""if isinstance(current, Leaf) or isinstance(proposed, Leaf):return current- return Split(+ adopted = Split(direction=current.direction,children=[adopt_weights(mine, theirs)@@ -517,6 +589,8 @@ def adopt_weights(current: LayoutNode, proposed: LayoutNode) -> LayoutNode:weights=[_clean_weight(weight) for weight in proposed.weights[: len(current.children)]]+ [1.0] * max(0, len(current.children) - len(proposed.weights)),)+ adopted.pinned = not _even_weights(adopted)+ return adopteddef grid_hints(root: LayoutNode | None) -> dict[str, tuple[int, int]]:diff --git a/jarvis/agentic_ide/session.py b/jarvis/agentic_ide/session.pyindex ff47421d06..aa7d642a19 100644--- a/jarvis/agentic_ide/session.py+++ b/jarvis/agentic_ide/session.py@@ -3905,14 +3905,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.+ # grid's "even out" button, run for the user on every open — EXCEPT+ # inside a container whose boundaries were dragged by hand+ # (`Split.pinned`): a size chosen on purpose survives the next+ # open, everything not chosen comes out even. The split decided+ # the SHAPE; its halved weights are not kept where nobody chose+ # them, because a pane split off one that had been dragged small+ # arrived as a sliver (maintainer request, 2026-08-22). 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()diff --git a/tests/unit/web/test_agentic_ide_grid.py b/tests/unit/web/test_agentic_ide_grid.pyindex 6213016740..a53d11ea76 100644--- a/tests/unit/web/test_agentic_ide_grid.py+++ b/tests/unit/web/test_agentic_ide_grid.py@@ -197,13 +197,43 @@ 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:+async def test_opening_a_terminal_evens_the_untouched_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.+ A column of two; a third split off its lower pane. Halving alone would+ leave the newcomer at a quarter of the column — a sliver. Nobody dragged+ anything here, so the session keeps the split's shape (the new pane sits+ under 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")+ third = await registry.add_terminal(anchor=second.name, direction="down")+ fourth = await registry.add_terminal(anchor=third.name, direction="down")++ layout = session.layout+ assert isinstance(layout, layout_tree.Split) and layout.direction == "row"+ assert layout.weights == [1.0, 1.0]+ column = layout.children[1]+ assert isinstance(column, layout_tree.Split) and column.direction == "column"+ # Shape: the newcomer landed under the pane that was split ...+ assert layout_tree.leaves(column) == [second.key, third.key, fourth.key]+ # ... sizes: not 1 : ½ : ½ but three equal shares, on the wire as well.+ assert column.weights == [1.0, 1.0, 1.0]+ assert session.to_dict()["layout"]["children"][1]["weights"] == [1.0, 1.0, 1.0]+++async def test_hand_sized_boundaries_survive_an_open(tmp_path) -> None:+ """A size the user chose is not undone by the next terminal.++ Two panes dragged to 3:1. Opening more must leave THAT boundary where the+ hand put it while everything the hand never touched still comes out even+ — a split inside the narrow column shares the column evenly, the column+ itself stays a quarter of the width, and an anchor-less add joins the row+ at an even share without disturbing the 3:1."""registry = await _workspace(tmp_path, 1)session = registry.session@@ -214,41 +244,49 @@ async def test_opening_a_terminal_evens_the_whole_wall(tmp_path) -> None: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]+ assert session.layout.pinned is True- third = await registry.add_terminal(anchor=second.name, direction="right")+ third = await registry.add_terminal(anchor=second.name, direction="down")+ await registry.add_terminal(anchor=third.name, direction="down")layout = session.layoutassert 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]+ # The dragged boundary holds ...+ assert layout.weights == [3.0, 1.0]+ assert layout.pinned is True+ column = layout.children[1]+ assert isinstance(column, layout_tree.Split)+ # ... and the boundaries nobody dragged are even.+ assert column.weights == [1.0, 1.0, 1.0]+ assert column.pinned is False++ # An anchor-less add takes an even share of the row and leaves the 3:1.+ await registry.add_terminal(direction="right")+ layout = session.layout+ assert isinstance(layout, layout_tree.Split)+ assert layout.weights == [3.0, 1.0, 2.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."""+async def test_evening_by_hand_releases_the_boundaries(tmp_path) -> None:+ """The "even out" button — or a drag back to even — ends the pin."""registry = await _workspace(tmp_path, 1)session = registry.sessionassert session is not Nonefirst = 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")+ 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)+ evened = layout_tree.to_dict(session.layout)+ evened["weights"] = [1.0, 1.0]+ await registry.set_layout_weights(evened)+ assert isinstance(session.layout, layout_tree.Split)+ assert session.layout.pinned is False- # 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]+ await registry.add_terminal(direction="right")+ # Back on the default path: every open evens the wall.+ assert isinstance(session.layout, layout_tree.Split)+ assert session.layout.weights == [1.0, 1.0, 1.0]async def test_unreadable_dragged_sizes_are_refused_out_loud(tmp_path) -> None:diff --git a/tests/unit/web/test_agentic_ide_layout_tree.py b/tests/unit/web/test_agentic_ide_layout_tree.pyindex e8633fa839..5993cd7066 100644--- a/tests/unit/web/test_agentic_ide_layout_tree.py+++ b/tests/unit/web/test_agentic_ide_layout_tree.py@@ -221,6 +221,102 @@ def test_evened_leaves_the_trivial_trees_alone() -> None:assert lt.evened(Leaf(pane="t1")) == Leaf(pane="t1")+def test_evened_keeps_hand_sized_boundaries_and_evens_the_rest() -> None:+ """A pinned container holds its weights; its children still even out."""+ column = Split(+ direction="column",+ children=[Leaf(pane="t2"), Leaf(pane="t3"), Leaf(pane="t4")],+ weights=[1.0, 0.5, 0.5], # a split's halving, nobody's choice+ )+ tree = lt.evened(+ Split(+ direction="row",+ children=[Leaf(pane="t1"), column],+ weights=[3.0, 1.0],+ pinned=True,+ )+ )+ assert isinstance(tree, Split)+ assert tree.weights == [3.0, 1.0] and tree.pinned is True+ inner = tree.children[1]+ assert isinstance(inner, Split)+ assert inner.weights == [1.0, 1.0, 1.0] and inner.pinned is False+++def test_adopting_weights_decides_pinned_from_the_weights() -> None:+ mine = lt.wizard_tree(["t1", "t2", "t3"], 2)+ theirs = lt.wizard_tree(["t1", "t2", "t3"], 2)+ assert isinstance(mine, Split) and isinstance(theirs, Split)++ theirs.weights = [3.0, 1.0]+ dragged = lt.adopt_weights(mine, theirs)+ assert isinstance(dragged, Split) and dragged.pinned is True+ # The inner stack was not touched and stays free.+ assert isinstance(dragged.children[0], Split) and dragged.children[0].pinned is False++ theirs.weights = [1.0, 1.0]+ # A client may echo `pinned` back; the flag is a fact about the weights+ # and the echo is not consulted.+ theirs.pinned = True+ released = lt.adopt_weights(dragged, theirs)+ assert isinstance(released, Split) and released.pinned is False+++def test_is_even_measures_terminals_not_nodes() -> None:+ stack = Split(direction="row", children=[Leaf(pane="t2"), Leaf(pane="t3")], weights=[1.0, 1.0])+ quarters = Split(+ direction="row",+ children=[Leaf(pane="t1"), stack, Leaf(pane="t4")],+ weights=[1.0, 1.0, 1.0],+ )+ # Equal container weights over a two-wide group: NOT even.+ assert not lt.is_even(quarters)+ assert lt.is_even(lt.evened(quarters))+ assert lt.is_even(None) and lt.is_even(Leaf(pane="t1"))+++def test_pinned_survives_the_dict_form_and_legacy_snapshots() -> None:+ tree = Split(direction="row", children=[Leaf(pane="t1"), Leaf(pane="t2")], weights=[3.0, 1.0])+ tree.pinned = True+ assert lt.to_dict(tree)["pinned"] is True+ assert lt.from_dict(lt.to_dict(tree)) == tree+ assert lt.from_dict(lt.to_dict(lt.evened(tree))).pinned is True # explicit flag wins++ # A snapshot from before the flag: an uneven container was dragged by a+ # hand that is no longer there to say so, and keeps its sizes.+ legacy = {"direction": "row", "children": [{"pane": "a"}, {"pane": "b"}], "weights": [3, 1]}+ assert lt.from_dict(legacy).pinned is True+ legacy["weights"] = [1, 1]+ assert lt.from_dict(legacy).pinned is False+++def test_structural_edits_carry_the_pin() -> None:+ row = Split(+ direction="row",+ children=[Leaf(pane="t1"), Leaf(pane="t2"), Leaf(pane="t3")],+ weights=[2.0, 1.0, 1.0],+ pinned=True,+ )+ slimmed = lt.remove_pane(row, "t3")+ assert isinstance(slimmed, Split) and slimmed.pinned is True+ split = lt.split_pane(row, "t2", "t4", "right")+ assert isinstance(split, Split) and split.pinned is True+ # A split running the other way opens a fresh, free container.+ stacked = lt.split_pane(row, "t2", "t5", "down")+ assert isinstance(stacked, Split) and stacked.pinned is True+ inner = stacked.children[1]+ assert isinstance(inner, Split) and inner.pinned is False+ # Merging a pinned row into its parent row keeps the pin.+ nested = Split(+ direction="row",+ children=[Leaf(pane="t0"), row],+ weights=[1.0, 1.0],+ )+ flat = lt.normalize(nested)+ assert isinstance(flat, Split) and flat.pinned is True+ check_canonical(flat)++def test_axis_span_is_the_widest_member_across_the_grain() -> None:stack = Split(direction="column",