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): persist dragged pane sizes through the layout-weights route

rubenluetke10-beepa637307a1ee7
diff --git a/jarvis/ui/web/agentic_ide_routes.py b/jarvis/ui/web/agentic_ide_routes.py
index 90328a4090..5f53a8978b 100644
--- a/jarvis/ui/web/agentic_ide_routes.py
+++ b/jarvis/ui/web/agentic_ide_routes.py
@@ -289,9 +289,9 @@ class MoveTerminalRequest(BaseModel):
position: str = Field(
default="swap",
description=(
- "'swap' exchanges the two panes and keeps the grid's shape; "
- "'left'/'right' give the moved pane its own column beside the "
- "target; 'above'/'below' put it in the target's own column."
+ "'swap' exchanges the two panes and keeps the workspace's shape; "
+ "'left'/'right'/'above'/'below' put the moved pane on that side "
+ "OF THE TARGET, splitting the target's own rectangle in half."
),
)
@@ -310,6 +310,18 @@ class RefoldRequest(BaseModel):
)
+class LayoutWeightsRequest(BaseModel):
+ """The workspace tree as the dragging client saw it, weights included."""
+
+ layout: dict = Field(
+ description=(
+ "The whole split tree in its wire form (the session state's "
+ "'layout' field), carrying the dragged weights. Only the weights "
+ "are adopted; the structure stays the server's."
+ ),
+ )
+
+
class CloseTerminalsRequest(BaseModel):
"""The terminal panes one destructive batch action should stop."""
@@ -2364,10 +2376,10 @@ async def move_terminal(name: str, req: MoveTerminalRequest) -> dict:
Nothing is started or stopped — this only changes where a running pane is
drawn, which is what makes rearranging safe on a grid full of working
- agents. ``position="swap"`` exchanges the two panes and leaves the grid's
- shape untouched; ``"left"``/``"right"`` give the moved pane a column of its
- own beside the target; ``"above"``/``"below"`` put it into the target's own
- column, moving only that stack.
+ agents. ``position="swap"`` exchanges the two panes and leaves the
+ workspace's shape untouched; the four sides put the moved pane on that
+ side OF THE TARGET, carving the target's own rectangle in half — the same
+ local meaning the split buttons have.
Dropping a pane onto itself succeeds and changes nothing.
"""
@@ -2395,6 +2407,25 @@ async def move_terminal(name: str, req: MoveTerminalRequest) -> dict:
}
[email protected]("/layout/weights", summary="Apply dragged pane sizes to the workspace")
+async def set_layout_weights(req: LayoutWeightsRequest) -> dict:
+ """Persist the pane sizes a seam drag produced.
+
+ The client sends back the whole tree it was looking at; the server adopts
+ the WEIGHTS when the shape still matches its own and quietly declines when
+ the workspace was reshaped mid-drag (a voice-opened pane, another client)
+ — the returned state carries the authoritative tree either way, so the
+ caller redraws from the answer rather than guessing.
+ """
+ try:
+ await get_registry().set_layout_weights(req.layout)
+ except SessionError as exc:
+ message = str(exc)
+ status = 409 if "No Agentic-IDE session" in message else 422
+ raise HTTPException(status_code=status, detail=message) from exc
+ return {"ok": True, "state": get_registry().state()}
+
+
@router.delete(
"/terminals/agent/{agent}",
summary="Close every terminal of one coding agent",
diff --git a/tests/unit/web/test_agentic_ide_grid.py b/tests/unit/web/test_agentic_ide_grid.py
index 4417bb96e1..3d85924dff 100644
--- a/tests/unit/web/test_agentic_ide_grid.py
+++ b/tests/unit/web/test_agentic_ide_grid.py
@@ -1,17 +1,19 @@
"""Grid geometry of the Agentic-IDE workspace: where a split puts a pane.
-The workspace is a left-to-right list of columns, each a top-to-bottom stack.
-The distinction these tests defend is that "split down" affects the anchor's
-column ONLY. The earlier one-axis model could not express that — a downward
-split opened a window-wide row, so splitting one pane halved the height of
-every other pane in the workspace.
+The workspace is a split TREE (see ``layout_tree``): every split carves the
+clicked pane's own rectangle and leaves every other pane alone, in both
+directions and at any depth. The ``(column, slot)`` tuples these tests read
+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
+from jarvis.agentic_ide import layout_tree
from jarvis.agentic_ide import session as session_mod
-from jarvis.agentic_ide.session import Registry
+from jarvis.agentic_ide.session import Registry, SessionError
@pytest.fixture(autouse=True)
@@ -140,6 +142,66 @@ async def test_terminals_stay_in_reading_order(tmp_path) -> None:
assert [t.index for t in registry.session.terminals] == [0, 1, 2, 3]
+async def test_split_right_in_a_stack_keeps_the_other_pane_full_width(tmp_path) -> None:
+ """THE reported bug (2026-08-12), end to end through the registry.
+
+ Two panes stacked; "split right" on the TOP one. The old flat grid could
+ only answer with a full-height column — the new pane arrived beside BOTH
+ 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)
+ session = registry.session
+ assert session is not None
+ top, bottom = session.terminals[0], session.terminals[1]
+ added = await registry.add_terminal(anchor=top.name, direction="right")
+
+ layout = session.layout
+ assert isinstance(layout, layout_tree.Split) and layout.direction == "column"
+ upper, lower = layout.children
+ assert isinstance(upper, layout_tree.Split) and upper.direction == "row"
+ assert layout_tree.leaves(upper) == [top.key, added.key]
+ # The bottom pane is a direct child of the stack: full width, untouched.
+ assert lower == layout_tree.Leaf(pane=bottom.key)
+ # And the wire state carries the tree for the grid to draw from.
+ assert session.to_dict()["layout"] == layout_tree.to_dict(layout)
+
+
+async def test_dragged_sizes_are_adopted_when_the_shape_matches(tmp_path) -> None:
+ registry = await _workspace(tmp_path, 2)
+ session = registry.session
+ assert session is not None and session.layout is not None
+ 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]
+
+
+async def test_dragged_sizes_from_a_reshaped_workspace_are_declined(tmp_path) -> None:
+ """A drag races a voice-opened pane: the drag loses, the workspace wins."""
+ registry = await _workspace(tmp_path, 2)
+ session = registry.session
+ assert session is not None and session.layout is not None
+ stale = layout_tree.to_dict(session.layout)
+ stale["weights"] = [3.0, 1.0]
+ await registry.add_terminal(direction="right") # reshapes the tree
+
+ await registry.set_layout_weights(stale)
+
+ assert isinstance(session.layout, layout_tree.Split)
+ # Every weight still even — the stale drag was quietly declined.
+ assert all(weight == 1.0 for weight in session.layout.weights)
+
+
+async def test_unreadable_dragged_sizes_are_refused_out_loud(tmp_path) -> None:
+ registry = await _workspace(tmp_path, 2)
+ with pytest.raises(SessionError):
+ await registry.set_layout_weights({"direction": "diagonal", "children": []})
+
+
async def test_split_may_name_a_different_agent(tmp_path) -> None:
"""The pane the UI's CLI picker opens: same split, other coding agent."""
registry = await _workspace(tmp_path, 1)