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): drag a stack of side-by-side seams as one line from a seam's ends

rubenluetke10-beep243c5c8010b8
diff --git a/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.tsx b/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.tsx
index f2fa09a6a1..3fa500661a 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.tsx
@@ -1273,6 +1273,26 @@ export function AgenticGrid({
return callback;
}, []);
+ /*
+ * The seams lit as "this moves too" while the pointer rests on another one.
+ *
+ * Held near its top or bottom end, a vertical seam drags every aligned seam
+ * of the panes stacked above and below it (see `stackedSeams`); this shows
+ * that line BEFORE the press. Written straight onto the elements rather
+ * than through state, because a hover must not re-render a wall of
+ * terminals each time the pointer crosses into an end zone.
+ */
+ const linkedSeams = useRef<readonly string[]>([]);
+ const markLinkedSeams = useCallback((ids: readonly string[]) => {
+ const previous = linkedSeams.current;
+ if (previous.length === ids.length && previous.every((id, index) => id === ids[index])) {
+ return;
+ }
+ for (const id of previous) seamNodes.current.get(id)?.removeAttribute("data-linked");
+ for (const id of ids) seamNodes.current.get(id)?.setAttribute("data-linked", "true");
+ linkedSeams.current = ids;
+ }, []);
+
/**
* Put every pane and seam where ``next`` says, without telling React.
*
@@ -2895,8 +2915,14 @@ export function AgenticGrid({
testId={`pane-seam-${seam.id}`}
orientation={seam.orientation}
title={seam.label}
- active={sizes.dragging === seam.id}
+ active={sizes.draggingSeams.includes(seam.id)}
onPointerDown={(event) => sizes.startDrag(seam, event)}
+ // Only the OTHER seams of a stack are marked: the held one is
+ // already lit by its own hover.
+ onPointerMove={(event) =>
+ markLinkedSeams(sizes.seamsAt(seam, event).filter((id) => id !== seam.id))
+ }
+ onPointerLeave={() => markLinkedSeams([])}
onDoubleClick={() => sizes.even(seam)}
// An arrow key moves the seam the way it points, which for the
// vertical axis is the opposite of `PaneResizer`'s own sign: its
diff --git a/jarvis/ui/web/frontend/src/components/agentic/treeLayout.test.ts b/jarvis/ui/web/frontend/src/components/agentic/treeLayout.test.ts
index df30f31609..5b8e10335b 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/treeLayout.test.ts
+++ b/jarvis/ui/web/frontend/src/components/agentic/treeLayout.test.ts
@@ -7,11 +7,15 @@ import { describe, expect, it } from "vitest";
import {
dragSeam,
+ dragSeams,
evenSeam,
evenedTree,
+ grabsSeamEnd,
isEvenTree,
+ stackedSeams,
treeLayout,
treeLeaves,
+ treeSeams,
type LayoutNode,
type LayoutSplit,
} from "./treeLayout";
@@ -266,3 +270,80 @@ describe("evening out", () => {
expect(levelled.weights[2]).toBeCloseTo(4 / 3);
});
});
+
+/** Two rows of two: the stack a sideways drag can move as one line. */
+const twoRows = (top = [1, 1], bottom = [1, 1]): LayoutSplit => ({
+ direction: "column",
+ children: [
+ { direction: "row", children: [{ pane: "t1" }, { pane: "t2" }], weights: top },
+ { direction: "row", children: [{ pane: "t3" }, { pane: "t4" }], weights: bottom },
+ ],
+ weights: [1, 1],
+});
+
+const rowWeights = (tree: LayoutNode, index: number) =>
+ ((tree as LayoutSplit).children[index] as LayoutSplit).weights;
+
+describe("stacked seam drags", () => {
+ it("grabs the whole stack only near a seam's top or bottom end", () => {
+ const rect = { top: 100, height: 300 };
+ expect(grabsSeamEnd(rect, 110)).toBe(true);
+ expect(grabsSeamEnd(rect, 250)).toBe(false);
+ expect(grabsSeamEnd(rect, 390)).toBe(true);
+ expect(grabsSeamEnd({ top: 0, height: 0 }, 0)).toBe(false);
+ });
+
+ it("links the aligned seams of panes stacked under each other", () => {
+ const seams = treeSeams(twoRows());
+ const top = seams.find((seam) => seam.id === "0:1")!;
+ const line = stackedSeams(seams, top, 1000);
+ expect(line.map((seam) => seam.id)).toEqual(["0:1", "1:1"]);
+ });
+
+ it("does not link seams that sit visibly apart, or a horizontal seam", () => {
+ const seams = treeSeams(twoRows([1, 1], [1, 3]));
+ const top = seams.find((seam) => seam.id === "0:1")!;
+ expect(stackedSeams(seams, top, 1000)).toEqual([top]);
+ const across = seams.find((seam) => seam.orientation === "horizontal")!;
+ expect(stackedSeams(seams, across, 1000)).toEqual([across]);
+ });
+
+ it("stops the line at a full-width pane in between", () => {
+ const tree: LayoutNode = {
+ direction: "column",
+ children: [
+ { direction: "row", children: [{ pane: "t1" }, { pane: "t2" }], weights: [1, 1] },
+ { pane: "t5" },
+ { direction: "row", children: [{ pane: "t3" }, { pane: "t4" }], weights: [1, 1] },
+ ],
+ weights: [1, 1, 1],
+ };
+ const seams = treeSeams(tree);
+ const top = seams.find((seam) => seam.id === "0:1")!;
+ expect(stackedSeams(seams, top, 1000)).toEqual([top]);
+ });
+
+ it("moves every seam of the line together", () => {
+ const tree = twoRows();
+ const seams = treeSeams(tree);
+ const lead = seams.find((seam) => seam.id === "0:1")!;
+ const next = dragSeams(tree, stackedSeams(seams, lead, 1000), lead, 100, 1000);
+ expect(rowWeights(next, 0)[0]).toBeCloseTo(1.2);
+ expect(rowWeights(next, 1)[0]).toBeCloseTo(1.2);
+ });
+
+ it("stops the whole line at the tightest pane's minimum", () => {
+ // The bottom seam already sits further right, so its right pane runs out
+ // of room first — the top seam must stop at the same x, not keep going.
+ const tree = twoRows([1, 1], [1.01, 0.99]);
+ const seams = treeSeams(tree);
+ const lead = seams.find((seam) => seam.id === "0:1")!;
+ const line = stackedSeams(seams, lead, 1000);
+ expect(line).toHaveLength(2);
+ const next = dragSeams(tree, line, lead, 1000, 1000);
+ expect(rowWeights(next, 0)[0]).toBeCloseTo(rowWeights(next, 1)[0]);
+ const { boxes } = treeLayout(next, panes("t1", "t2", "t3", "t4"));
+ expect(boxes[1]!.w * 1000).toBeGreaterThanOrEqual(119.999);
+ expect(boxes[3]!.w * 1000).toBeGreaterThanOrEqual(119.999);
+ });
+});
diff --git a/jarvis/ui/web/frontend/src/components/agentic/treeLayout.ts b/jarvis/ui/web/frontend/src/components/agentic/treeLayout.ts
index c8e0356f09..5deb2a8dd9 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/treeLayout.ts
+++ b/jarvis/ui/web/frontend/src/components/agentic/treeLayout.ts
@@ -293,6 +293,147 @@ export function dragSeam(
return withWeights(root, seam.path, weights);
}
+/** Every seam of ``root``, without the pane names only the labels need. */
+export function treeSeams(root: LayoutNode): PaneSeam[] {
+ return treeLayout(
+ root,
+ treeLeaves(root).map((key) => ({ key, name: key })),
+ ).seams;
+}
+
+/**
+ * How much of a vertical seam's length, at EACH end, grabs the whole stack.
+ *
+ * A sideways drag means two different things depending on where the seam is
+ * held (asked for 2026-10-02): held near the middle of a pane's height it
+ * moves that one boundary, held near its top or bottom it moves every aligned
+ * boundary of the panes stacked above and below as one line — the way a
+ * horizontal seam already moves a whole row of panes.
+ */
+export const SEAM_END_ZONE = 0.3;
+
+/** How far apart two stacked seams may be and still count as one line. */
+export const SEAM_LINK_TOLERANCE_PX = 8;
+
+/** Do two seam ends touch? Both come from the same cursor sums. */
+const EDGE_EPSILON = 1e-6;
+
+/** Is ``clientY`` in the top or bottom end zone of a seam drawn at ``rect``? */
+export function grabsSeamEnd(
+ rect: { top: number; height: number },
+ clientY: number,
+): boolean {
+ if (!(rect.height > 0)) return false;
+ const along = (clientY - rect.top) / rect.height;
+ return along < SEAM_END_ZONE || along > 1 - SEAM_END_ZONE;
+}
+
+/**
+ * The grabbed vertical seam plus every seam that continues it straight up or
+ * down: the boundaries of the panes stacked above and below it.
+ *
+ * A seam joins the line when it sits at (nearly) the same x AND touches the
+ * line's current top or bottom end, so a full-width pane in between breaks
+ * the line — the panes past it are not "under each other" any more. The
+ * grabbed seam always comes first. A horizontal seam is returned alone.
+ */
+export function stackedSeams(
+ seams: readonly PaneSeam[],
+ grabbed: PaneSeam,
+ widthPx: number,
+): PaneSeam[] {
+ if (grabbed.orientation !== "vertical" || !(widthPx > 0)) return [grabbed];
+ const tolerance = SEAM_LINK_TOLERANCE_PX / widthPx;
+ const candidates = seams.filter(
+ (seam) =>
+ seam.orientation === "vertical" &&
+ seam.id !== grabbed.id &&
+ Math.abs(seam.x - grabbed.x) <= tolerance,
+ );
+ const line = [grabbed];
+ let top = grabbed.y;
+ let bottom = grabbed.y + grabbed.h;
+ for (let grew = true; grew; ) {
+ grew = false;
+ for (const seam of candidates) {
+ if (line.includes(seam)) continue;
+ if (Math.abs(seam.y + seam.h - top) <= EDGE_EPSILON) {
+ top = seam.y;
+ } else if (Math.abs(seam.y - bottom) <= EDGE_EPSILON) {
+ bottom = seam.y + seam.h;
+ } else {
+ continue;
+ }
+ line.push(seam);
+ grew = true;
+ }
+ }
+ return line;
+}
+
+/**
+ * How far ``seam`` may travel, in px from where it is, before a neighbour
+ * drops below `MIN_SEAM_PANE_PX` — or null when `dragSeam` would not move it
+ * by the pointer at all (no room, a vanished container, or two panes already
+ * too small to share anything but an even split).
+ */
+function seamTravel(
+ root: LayoutNode,
+ seam: PaneSeam,
+ axisPx: number,
+): { lo: number; hi: number } | null {
+ const span = axisPx * seam.axisFraction;
+ if (!Number.isFinite(span) || span <= 0) return null;
+ const node = containerAt(root, seam.path);
+ if (!node || seam.boundary < 1 || seam.boundary >= node.children.length) return null;
+ const before = cleanWeight(node.weights[seam.boundary - 1]);
+ const total = before + cleanWeight(node.weights[seam.boundary]);
+ const perPx = seam.groupWeight / span;
+ const min = MIN_SEAM_PANE_PX * perPx;
+ if (total <= min * 2) return null;
+ return {
+ lo: Math.min(0, (min - before) / perPx),
+ hi: Math.max(0, (total - min - before) / perPx),
+ };
+}
+
+/**
+ * Move a whole line of seams (see `stackedSeams`) as one.
+ *
+ * Every seam lands on the LEAD seam's new position, so a line whose members
+ * sat a few pixels apart comes out straight. The position is held to the
+ * range every member can reach, so the line stops as one when its tightest
+ * pane hits the minimum instead of bending there; members that cannot agree
+ * on any range fall back to each clamping on its own.
+ */
+export function dragSeams(
+ root: LayoutNode,
+ seams: readonly PaneSeam[],
+ lead: PaneSeam,
+ deltaPx: number,
+ axisPx: number,
+): LayoutNode {
+ if (seams.length <= 1) return dragSeam(root, lead, deltaPx, axisPx);
+ const at = (seam: PaneSeam) =>
+ (seam.orientation === "vertical" ? seam.x : seam.y) * axisPx;
+ let target = at(lead) + deltaPx;
+ let lo = -Infinity;
+ let hi = Infinity;
+ for (const seam of seams) {
+ const travel = seamTravel(root, seam, axisPx);
+ if (!travel) continue;
+ lo = Math.max(lo, at(seam) + travel.lo);
+ hi = Math.min(hi, at(seam) + travel.hi);
+ }
+ if (lo <= hi) target = Math.min(hi, Math.max(lo, target));
+ // The members divide different containers, so each edit leaves the others'
+ // weights exactly as the drag started with them.
+ return seams.reduce(
+ (tree, seam) => dragSeam(tree, seam, target - at(seam), axisPx),
+ root,
+ );
+}
+
/**
* How many pane stripes a subtree lines up along ``direction``.
*
diff --git a/jarvis/ui/web/frontend/src/components/agentic/useTreeSizes.ts b/jarvis/ui/web/frontend/src/components/agentic/useTreeSizes.ts
index 1b310d7883..29d68ad8bc 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/useTreeSizes.ts
+++ b/jarvis/ui/web/frontend/src/components/agentic/useTreeSizes.ts
@@ -29,9 +29,13 @@ import { useCallback, useEffect, useRef, useState } from "react";
import { saveLayoutWeights } from "../../lib/agenticIdeApi";
import {
dragSeam,
+ dragSeams,
evenSeam,
evenedTree,
+ grabsSeamEnd,
sameShape,
+ stackedSeams,
+ treeSeams,
type LayoutNode,
type PaneSeam,
} from "./treeLayout";
@@ -39,6 +43,9 @@ import {
/** How far one arrow-key press moves a seam. Matches `PaneResizer`. */
const KEY_STEP_PX = 16;
+/** `draggingSeams` while nothing is held — one array, so it never re-renders. */
+const NO_SEAMS: readonly string[] = [];
+
/** How long after the last size edit the result is posted to the backend. */
const SAVE_DEBOUNCE_MS = 600;
@@ -53,8 +60,15 @@ export interface TreeSizeControls {
tree: LayoutNode | null;
/** Id of the seam being dragged right now, if any. */
dragging: string | null;
+ /** Every seam the drag moves: the held one, plus its stack when grabbed at an end. */
+ draggingSeams: readonly string[];
/** Begin a drag — wire to a seam's `onPointerDown`. */
startDrag: (seam: PaneSeam, event: React.PointerEvent) => void;
+ /**
+ * The seams a drag started at this pointer would move — wire to a seam's
+ * `onPointerMove` to show the stack before it is grabbed.
+ */
+ seamsAt: (seam: PaneSeam, event: React.PointerEvent) => readonly string[];
/** Move a seam by ``deltaPx`` — the keyboard equivalent of a drag. */
nudge: (seam: PaneSeam, deltaPx: number) => void;
/** Give a seam's two neighbours the same size — wire to `onDoubleClick`. */
@@ -95,7 +109,8 @@ export function useTreeSizes(
? override
: (serverTree ?? null);
- const [dragging, setDragging] = useState<string | null>(null);
+ /** The seams in the drag, the held one first; null when nothing is held. */
+ const [dragGroup, setDragGroup] = useState<readonly string[] | null>(null);
/*
* Saves are debounced and fire-and-forget: a run of arrow-key nudges is one
@@ -133,9 +148,12 @@ export function useTreeSizes(
// Drag anchors — refs so the move handler never reads a stale closure. The
// drag works from the tree it STARTED with, so a slow pointer cannot
// accumulate rounding drift over a hundred frames.
- const active = useRef<{ seam: PaneSeam; point: number; from: LayoutNode } | null>(
- null,
- );
+ const active = useRef<{
+ seam: PaneSeam;
+ group: PaneSeam[];
+ point: number;
+ from: LayoutNode;
+ } | null>(null);
const point = useRef(0);
const live = useRef<LayoutNode | null>(null);
@@ -146,6 +164,32 @@ export function useTreeSizes(
const previewRef = useRef(onPreview);
previewRef.current = onPreview;
+ /**
+ * The seams a pointer at ``event`` on ``seam`` moves, resolved against
+ * ``from``: the held seam alone, or — for a vertical seam held near its top
+ * or bottom end — the whole line of panes stacked under each other (see
+ * `stackedSeams`).
+ */
+ const groupFor = useCallback(
+ (from: LayoutNode, seam: PaneSeam, event: React.PointerEvent): PaneSeam[] => {
+ if (seam.orientation !== "vertical") return [seam];
+ const target = event.currentTarget as Element | null;
+ const rect = target?.getBoundingClientRect?.();
+ if (!rect || !grabsSeamEnd(rect, event.clientY)) return [seam];
+ return stackedSeams(treeSeams(from), seam, extentRef.current().width);
+ },
+ [],
+ );
+
+ const seamsAt = useCallback(
+ (seam: PaneSeam, event: React.PointerEvent): readonly string[] => {
+ const current = treeRef.current;
+ if (!current) return [seam.id];
+ return groupFor(current, seam, event).map((member) => member.id);
+ },
+ [groupFor],
+ );
+
/** Tears down the gesture in flight, if any; set while a drag runs. */
const stopDrag = useRef<(() => void) | null>(null);
@@ -163,10 +207,11 @@ export function useTreeSizes(
event.preventDefault();
stopDrag.current?.();
const at = seam.orientation === "vertical" ? event.clientX : event.clientY;
- active.current = { seam, point: at, from };
+ const group = groupFor(from, seam, event);
+ active.current = { seam, group, point: at, from };
point.current = at;
live.current = null;
- setDragging(seam.id);
+ setDragGroup(group.map((member) => member.id));
const axisPx = () => {
const size = extentRef.current();
@@ -180,7 +225,13 @@ export function useTreeSizes(
frame = undefined;
const drag = active.current;
if (!drag) return;
- const next = dragSeam(drag.from, drag.seam, point.current - drag.point, axisPx());
+ const next = dragSeams(
+ drag.from,
+ drag.group,
+ drag.seam,
+ point.current - drag.point,
+ axisPx(),
+ );
live.current = next;
if (previewRef.current) previewRef.current(next);
else commit(next);
@@ -224,7 +275,7 @@ export function useTreeSizes(
const settled = live.current;
active.current = null;
live.current = null;
- setDragging(null);
+ setDragGroup(null);
if (settled) commit(settled);
}
@@ -233,7 +284,7 @@ export function useTreeSizes(
window.addEventListener("pointercancel", settle);
stopDrag.current = detach;
},
- [commit],
+ [commit, groupFor],
);
// A grid unmounted mid-drag must not leave listeners or a locked cursor.
@@ -265,7 +316,17 @@ export function useTreeSizes(
commit(evenedTree(current));
}, [commit]);
- return { tree, dragging, startDrag, nudge, even, evenAll, liveTree: live };
+ return {
+ tree,
+ dragging: dragGroup?.[0] ?? null,
+ draggingSeams: dragGroup ?? NO_SEAMS,
+ startDrag,
+ seamsAt,
+ nudge,
+ even,
+ evenAll,
+ liveTree: live,
+ };
}
export { KEY_STEP_PX };
diff --git a/jarvis/ui/web/frontend/src/components/layout/PaneResizer.tsx b/jarvis/ui/web/frontend/src/components/layout/PaneResizer.tsx
index 6e4bfe4bc1..cba31a5581 100644
--- a/jarvis/ui/web/frontend/src/components/layout/PaneResizer.tsx
+++ b/jarvis/ui/web/frontend/src/components/layout/PaneResizer.tsx
@@ -26,6 +26,10 @@ export interface PaneResizerProps {
orientation?: PaneResizerOrientation;
/** Begin a drag — wire to `useResizablePane`'s ``startResize``. */
onPointerDown: (e: React.PointerEvent) => void;
+ /** Pointer travelling over the grip, for screens that preview what a drag moves. */
+ onPointerMove?: (e: React.PointerEvent) => void;
+ /** Pointer gone from the grip — the counterpart of `onPointerMove`. */
+ onPointerLeave?: (e: React.PointerEvent) => void;
/** Restore the default size — wire to ``reset``. */
onDoubleClick: () => void;
/** Keyboard equivalent of a drag, in px — wire to ``nudge``. */
@@ -77,6 +81,8 @@ export const PaneResizer = forwardRef<HTMLDivElement, PaneResizerProps>(function
{
orientation = "vertical",
onPointerDown,
+ onPointerMove,
+ onPointerLeave,
onDoubleClick,
onNudge,
valueNow,
@@ -122,6 +128,8 @@ export const PaneResizer = forwardRef<HTMLDivElement, PaneResizerProps>(function
tabIndex={0}
data-testid={testId ?? `pane-resizer-${orientation}`}
onPointerDown={onPointerDown}
+ onPointerMove={onPointerMove}
+ onPointerLeave={onPointerLeave}
onDoubleClick={onDoubleClick}
onKeyDown={onKeyDown}
style={style}
@@ -133,7 +141,9 @@ export const PaneResizer = forwardRef<HTMLDivElement, PaneResizerProps>(function
className,
)}
>
- {/* The visible line — it replaces the border it sits on top of. */}
+ {/* The visible line — it replaces the border it sits on top of. A screen
+ can set `data-linked="true"` on a seam that a drag held on ANOTHER
+ seam would move too, and it lights the way a hovered one does. */}
<span
aria-hidden
className={cn(
@@ -147,7 +157,7 @@ export const PaneResizer = forwardRef<HTMLDivElement, PaneResizerProps>(function
!showLine && "hidden",
active
? "bg-primary"
- : "bg-border group-hover:bg-border-strong group-focus-visible:bg-border-strong",
+ : "bg-border group-hover:bg-border-strong group-focus-visible:bg-border-strong group-data-[linked=true]:bg-border-strong",
)}
/>
{/* A short thicker stub in the middle: without it the seam reads as a
@@ -160,7 +170,7 @@ export const PaneResizer = forwardRef<HTMLDivElement, PaneResizerProps>(function
vertical ? "h-8 w-[3px]" : "h-[3px] w-8",
active
? "bg-primary"
- : "bg-border group-hover:bg-border-strong group-focus-visible:bg-border-strong",
+ : "bg-border group-hover:bg-border-strong group-focus-visible:bg-border-strong group-data-[linked=true]:bg-border-strong",
)}
/>
</div>