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(agentic-ide): closing a grid pane lets the pane below move up

rubenluetke10-beepe0aed202cdf0
diff --git a/jarvis/agentic_ide/layout_tree.py b/jarvis/agentic_ide/layout_tree.py
index 2f1a996646..b22be7932c 100644
--- a/jarvis/agentic_ide/layout_tree.py
+++ b/jarvis/agentic_ide/layout_tree.py
@@ -590,15 +590,18 @@ def remove_pane(root: LayoutNode | None, pane: str) -> LayoutNode | None:
through :func:`rows_outermost` — once, at the end, never per recursion
step.
"""
- return rows_outermost(_removed(root, pane))
+ return rows_outermost(_removed(root, pane, by_columns=True))
-def _removed(root: LayoutNode | None, pane: str) -> LayoutNode | None:
+def _removed(root: LayoutNode | None, pane: str, *, by_columns: bool = False) -> LayoutNode | None:
if root is None:
return None
if isinstance(root, Leaf):
return None if root.pane == pane else root
+ if by_columns:
+ # A close hands the room to the pane below, not beside (see there).
+ root = _columns_for_close(root, pane)
children: list[LayoutNode] = []
weights: list[float] = []
for index, child in enumerate(root.children):
@@ -606,7 +609,7 @@ def _removed(root: LayoutNode | None, pane: str) -> LayoutNode | None:
if isinstance(child, Leaf) and child.pane == pane:
continue
if isinstance(child, Split):
- slimmed = _removed(child, pane)
+ slimmed = _removed(child, pane, by_columns=by_columns)
if slimmed is None:
continue
children.append(slimmed)
@@ -624,6 +627,62 @@ def _removed(root: LayoutNode | None, pane: str) -> LayoutNode | None:
)
+def _columns_for_close(node: Split, pane: str) -> Split:
+ """A grid about to lose one of its cells, read as columns for the close.
+
+ A grid stands on its rows (:func:`rows_outermost`), so closing a cell
+ would hand its room to its ROW neighbour — close the top-right of a 2×2
+ and the top-left stretches across the full width. The maintainer asked
+ (2026-09-29) for the pane BELOW to move up instead: the closed pane's
+ column-mates share its room and every other column keeps its width.
+
+ So a ``column[row[...], row[...]]`` whose bands line up is transposed
+ into the equivalent ``row[column[...], ...]`` — same picture, nothing
+ moves — right before the cell is dropped. :func:`remove_pane` stands
+ whatever grid survives back on its rows afterwards.
+ """
+ if node.direction != "column" or len(node.children) < 2:
+ return node
+ bands: list[Split] = []
+ for child in node.children:
+ if not isinstance(child, Split) or child.direction != "row":
+ return node
+ bands.append(child)
+ width = len(bands[0].children)
+ if width < 2 or any(len(band.children) != width for band in bands):
+ return node
+ cells = [cell for band in bands for cell in band.children]
+ if not any(isinstance(cell, Leaf) and cell.pane == pane for cell in cells):
+ return node
+ first = _shares(bands[0])
+ if not all(
+ abs(share - first[index]) <= EVEN_EPSILON * first[index]
+ for band in bands[1:]
+ for index, share in enumerate(_shares(band))
+ ):
+ return node
+
+ heights = [
+ _clean_weight(node.weights[index] if index < len(node.weights) else 1.0)
+ for index in range(len(bands))
+ ]
+ columns: list[LayoutNode] = [
+ Split(
+ direction="column",
+ children=[band.children[column] for band in bands],
+ weights=list(heights),
+ pinned=node.pinned,
+ )
+ for column in range(width)
+ ]
+ return Split(
+ direction="row",
+ children=columns,
+ weights=list(bands[0].weights),
+ pinned=any(band.pinned for band in bands),
+ )
+
+
def swap_panes(root: LayoutNode | None, first: str, second: str) -> LayoutNode | None:
"""Exchange two panes' places; the tree's shape and every weight stay put."""
if root is None:
diff --git a/tests/unit/web/test_agentic_ide_layout_tree.py b/tests/unit/web/test_agentic_ide_layout_tree.py
index 428c3d87ae..9d26fa3f00 100644
--- a/tests/unit/web/test_agentic_ide_layout_tree.py
+++ b/tests/unit/web/test_agentic_ide_layout_tree.py
@@ -621,6 +621,37 @@ def test_removing_gives_the_room_to_the_siblings() -> None:
assert slimmed.weights == [2.0, 1.0] # 2:1 survives, the tail's share dissolves
+def test_closing_a_grid_cell_moves_the_pane_below_up() -> None:
+ """Close the top-right of a 2x2: the bottom-right rises, the left stays.
+
+ The grid stands on its rows, so the closed pane's row neighbour used to
+ stretch across the full width instead (maintainer report, 2026-09-29).
+ """
+ grid = lt.wizard_tree(["t1", "t2", "t3", "t4"], 2)
+ assert isinstance(grid, Split) and grid.direction == "column"
+
+ closed = lt.remove_pane(grid, "t2")
+ assert closed == Split(
+ direction="row",
+ children=[
+ Split(
+ direction="column",
+ children=[Leaf(pane="t1"), Leaf(pane="t3")],
+ weights=[0.5, 0.5],
+ ),
+ Leaf(pane="t4"),
+ ],
+ weights=[1.0, 1.0],
+ )
+ check_canonical(closed)
+
+ # A bottom cell folds the same way: its column-mate grows down.
+ lower = lt.remove_pane(grid, "t3")
+ assert isinstance(lower, Split) and lower.direction == "row"
+ assert lower.children[0] == Leaf(pane="t1")
+ check_canonical(lower)
+
+
def test_removing_the_last_pane_empties_the_tree() -> None:
assert lt.remove_pane(Leaf(pane="t1"), "t1") is None