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(ide): choose where a moved terminal lands in the target grid

rubenluetke10-beepb9a7da11debe
diff --git a/docs/jarvis-cli-reference.md b/docs/jarvis-cli-reference.md
index 30787c607e..79938bd07d 100644
--- a/docs/jarvis-cli-reference.md
+++ b/docs/jarvis-cli-reference.md
@@ -110,7 +110,7 @@ _Generated from the curated command tree by `scripts/ci/gen_cli_reference.py`
- `jarvis ide archive-terminal <name> --restore --workspace --dry-run` — Hide a coding session from the chat list, or restore it.
- `jarvis ide close-terminals <names> --yes --dry-run` — Stop several coding agents and close their terminal panes.
-- `jarvis ide move-terminal <name> <target_workspace> --workspace --dry-run` — Move a terminal pane into another open workspace.
+- `jarvis ide move-terminal <name> <target_workspace> --workspace --beside --side --dry-run` — Move a terminal pane into another open workspace.
- `jarvis ide rename-terminal <name> <new_name> --dry-run` — Rename a running terminal pane without restarting its agent.
## local-models
diff --git a/jarvis/agentic_ide/session.py b/jarvis/agentic_ide/session.py
index 663657a4bf..7780b19303 100644
--- a/jarvis/agentic_ide/session.py
+++ b/jarvis/agentic_ide/session.py
@@ -312,6 +312,9 @@ MIN_VIEWER_ROWS = 4
# the same placements the split buttons already express — the difference is that
# these move a pane that exists instead of opening one.
MOVE_POSITIONS = ("swap", "left", "right", "above", "below")
+# Where a pane moved in from another workspace may sit beside a pane there.
+# No swap: the pane it would trade places with has nowhere to go.
+TRANSFER_SIDES = ("left", "right", "above", "below")
# Transport ceiling for one injected prompt. Raised from 4000 once composed
# prompts became structured briefs that describe the code they point at: at
# 4000 the cap, not the writer, was deciding where a brief ended. Bracketed
@@ -6078,7 +6081,13 @@ class Registry:
return moved
async def transfer_terminal(
- self, wanted: str, *, workspace_id: str | None, target_workspace_id: str
+ self,
+ wanted: str,
+ *,
+ workspace_id: str | None,
+ target_workspace_id: str,
+ anchor: str | None = None,
+ side: str = "right",
) -> tuple[Session, Session, Terminal]:
"""Move pane ``wanted`` out of its workspace into another OPEN one.
@@ -6100,6 +6109,12 @@ class Registry:
same conversation in the same place instead of an empty chat in the
new folder. Moved back home, the field empties again.
+ ``anchor`` names a pane of the TARGET tab to put the moved one beside,
+ on ``side`` (``left``/``right``/``above``/``below``): the two then
+ share that pane's rectangle and nothing else moves — the meaning a
+ split has. A side with no room left in the grid is refused before
+ anything changes. Without an anchor the pane joins the workspace edge.
+
Returns ``(source, target, terminal)``. Moving a pane into the tab it is
already in is a no-op, not an error — a drop the user took back.
"""
@@ -6131,8 +6146,23 @@ class Registry:
f"{term.name} is still being set up on its computer. "
"Move it once it has started there."
)
+ if anchor is not None and side not in TRANSFER_SIDES:
+ allowed = ", ".join(f"'{item}'" for item in TRANSFER_SIDES)
+ raise SessionError(f"Side must be one of {allowed}.")
old_key, old_name = term.key, term.name
+ # Its call-sign, key and place in the new tab are all settled
+ # BEFORE anything changes: a place with no room refuses the move
+ # rather than leaving the pane half-way between two tabs.
+ new_name = _unique_name(old_name, {normalize(t.name) for t in target.terminals})
+ keys = {t.key for t in target.terminals}
+ new_key = old_key if old_key not in keys else (normalize(new_name) or "t")
+ stem, suffix = new_key, 2
+ while new_key in keys:
+ new_key = f"{stem}{suffix}"
+ suffix += 1
+ placed = self._placed_beside(target, new_key, anchor, side)
+
cwd = term.cwd(source.folder)
term.folder = "" if _same_folder(cwd, target.folder) else cwd
@@ -6174,21 +6204,20 @@ class Registry:
term.prompt_viewers.clear()
# Into the new one with a call-sign and key that are free there.
- term.name = _unique_name(old_name, {normalize(t.name) for t in target.terminals})
- keys = {t.key for t in target.terminals}
- key = old_key if old_key not in keys else (normalize(term.name) or "t")
- stem, suffix = key, 2
- while key in keys:
- key = f"{stem}{suffix}"
- suffix += 1
- term.key = key
+ term.name, term.key = new_name, new_key
target.terminals.append(term)
- # It joins the workspace edge like an anchor-less add: no pane was
- # chosen to sit beside, and every pane then gets an even share.
- target.layout = layout_tree.append_pane(target.layout, term.key)
- columns, rows = layout_tree.grid_span(target.layout)
- if columns > MAX_GRID_COLUMNS or rows > MAX_GRID_ROWS:
- self._row_major_grid(target)
+ if placed is not None:
+ # Beside the pane the user picked: the two share that pane's
+ # room, the same local meaning a split has.
+ target.layout = placed
+ else:
+ # It joins the workspace edge like an anchor-less add: no
+ # pane was chosen to sit beside.
+ target.layout = layout_tree.append_pane(target.layout, term.key)
+ columns, rows = layout_tree.grid_span(target.layout)
+ if columns > MAX_GRID_COLUMNS or rows > MAX_GRID_ROWS:
+ self._row_major_grid(target)
+ # Every pane then gets an even share, as after any add.
target.layout = layout_tree.evened(target.layout)
self._renumber(target)
await self._persist()
@@ -6201,6 +6230,36 @@ class Registry:
)
return source, target, term
+ @staticmethod
+ def _placed_beside(
+ target: Session, key: str, anchor: str | None, side: str
+ ) -> layout_tree.LayoutNode | None:
+ """``target``'s tree with pane ``key`` split off ``anchor`` — or None.
+
+ None means no place was asked for. A named pane that is not there, or
+ a side that would push the grid past its largest shape, is refused:
+ quietly re-dealing the grid would put the pane somewhere the user did
+ not choose.
+ """
+ if anchor is None:
+ return None
+ beside = target.find(anchor)
+ if beside is None:
+ known = ", ".join(t.name for t in target.terminals) or "none"
+ raise SessionError(f"No terminal called {anchor!r} in {target.name}. Running: {known}.")
+ tree = target.layout or layout_tree.from_grid(
+ (t.key, t.column, t.slot) for t in target.terminals
+ )
+ placed = layout_tree.split_pane(tree, beside.key, key, cast("Any", side))
+ columns, rows = layout_tree.grid_span(placed)
+ if columns > MAX_GRID_COLUMNS or rows > MAX_GRID_ROWS:
+ where = {"left": "left of", "right": "right of"}.get(side, side)
+ raise SessionError(
+ f"No room {where} {beside.name}: a workspace holds at most "
+ f"{MAX_GRID_COLUMNS} columns and {MAX_GRID_ROWS} rows."
+ )
+ return placed
+
async def refold(self, depth: int) -> Session:
"""Re-deal every pane into columns ``depth`` deep, in reading order.
diff --git a/jarvis/cli_ctl/commands/ide.py b/jarvis/cli_ctl/commands/ide.py
index 85108fbc28..a31c512590 100644
--- a/jarvis/cli_ctl/commands/ide.py
+++ b/jarvis/cli_ctl/commands/ide.py
@@ -66,16 +66,29 @@ def move_terminal(
str | None,
typer.Option("--workspace", help="Workspace id the terminal is in now."),
] = None,
+ beside: Annotated[
+ str | None,
+ typer.Option("--beside", help="Pane of the target workspace to place it next to."),
+ ] = None,
+ side: Annotated[
+ str,
+ typer.Option("--side", help="left, right, above or below the --beside pane."),
+ ] = "right",
dry_run: bool = options.dry_opt(),
) -> None:
"""Move a terminal pane into another open workspace.
Its agent keeps running. The pane may get another call-sign when the
target workspace already has one by that name; the answer says which.
+ With --beside it shares that pane's place in the grid; without, it joins
+ the right edge.
"""
body: dict[str, object] = {"target_workspace_id": target_workspace}
if workspace:
body["workspace_id"] = workspace
+ if beside:
+ body["anchor"] = beside
+ body["side"] = side
invoke.run(
"POST",
f"/api/agentic-ide/terminals/{quote(name, safe='')}/transfer",
diff --git a/jarvis/ui/web/agentic_ide_routes.py b/jarvis/ui/web/agentic_ide_routes.py
index f12c61e0ac..5d5cd417d2 100644
--- a/jarvis/ui/web/agentic_ide_routes.py
+++ b/jarvis/ui/web/agentic_ide_routes.py
@@ -85,6 +85,7 @@ from jarvis.agentic_ide import (
drop_analysis,
drops,
git_changes,
+ layout_tree,
native_picker,
notifications,
prompt_attachments,
@@ -409,6 +410,17 @@ class TransferTerminalRequest(BaseModel):
min_length=1,
description="Open workspace to move the pane into.",
)
+ anchor: str | None = Field(
+ default=None,
+ description=(
+ "A pane of the target workspace to put the moved one beside "
+ "(call-sign or 'pane:<history_id>'). Omitted, it joins the edge."
+ ),
+ )
+ side: Literal["left", "right", "above", "below"] = Field(
+ default="right",
+ description="Which side of the anchor pane it goes on; ignored without one.",
+ )
class RefoldRequest(BaseModel):
@@ -2928,6 +2940,38 @@ async def move_terminal(name: str, req: MoveTerminalRequest) -> dict:
}
+ "/workspaces/{workspace_id}/layout",
+ summary="Where every pane of one open workspace sits",
+)
+def get_workspace_layout(workspace_id: str) -> dict:
+ """The split tree and the panes of ``workspace_id``, without anything else.
+
+ ``/state`` draws only the workspace on screen. Placing a pane INTO another
+ tab needs that tab's shape, and its full state (transcripts, recaps,
+ prompt statistics per pane) is the wrong price for a small map.
+ """
+ session = get_registry().get(workspace_id)
+ if session is None:
+ raise HTTPException(status_code=404, detail="That workspace is not open.")
+ return {
+ "id": session.id,
+ "name": session.name,
+ "layout": layout_tree.to_dict(session.layout) if session.layout else None,
+ "terminals": [
+ {
+ "key": t.key,
+ "name": t.name,
+ "agent": t.agent,
+ "display_name": t.display_name,
+ "history_id": t.history_id,
+ }
+ for t in session.terminals
+ ],
+ "max_terminals": MAX_TERMINALS,
+ }
+
+
@router.post(
"/terminals/{name}/transfer",
summary="Move a terminal into another open workspace",
@@ -2944,7 +2988,11 @@ async def transfer_terminal(request: Request, name: str, req: TransferTerminalRe
registry = get_registry()
try:
source, target, term = await registry.transfer_terminal(
- name, workspace_id=req.workspace_id, target_workspace_id=req.target_workspace_id
+ name,
+ workspace_id=req.workspace_id,
+ target_workspace_id=req.target_workspace_id,
+ anchor=req.anchor,
+ side=req.side,
)
except SessionError as exc:
# A pane or workspace that is not there is not found; a full or busy
diff --git a/jarvis/ui/web/frontend/src/components/agentic/MovePaneDialog.test.tsx b/jarvis/ui/web/frontend/src/components/agentic/MovePaneDialog.test.tsx
new file mode 100644
index 0000000000..13debaf03b
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/components/agentic/MovePaneDialog.test.tsx
@@ -0,0 +1,74 @@
+/**
+ * The place picker for a pane moving into another workspace.
+ *
+ * Its promise is that nothing it offers is refused later: a side that would
+ * push the target grid past its largest shape is disabled, a full workspace
+ * cannot be confirmed, and what is sent names the target pane by identity.
+ */
+import { afterEach, beforeEach, expect, it, vi } from "vitest";
+import { cleanup, fireEvent, render, screen } from "@testing-library/react";
+const api = vi.hoisted(() => ({ layout: vi.fn() }));
+vi.mock("@/lib/agenticIdeApi", () => ({ fetchWorkspaceLayout: api.layout }));
+import { MovePaneDialog, type MovePaneRequest } from "./MovePaneDialog";
+import { balancedLayout } from "./workspaceDocking";
+
+const pane = (name: string) => ({ key: name.toLowerCase(), name, agent: "codex", display_name: "Codex", history_id: `h-${name}` });
+const workspace = (names: string[], layout = balancedLayout(names.map((name) => name.toLowerCase())), max = 16) =>
+ ({ id: "w2", name: "Blog", layout, max_terminals: max, terminals: names.map(pane) });
+const request: MovePaneRequest = { pane: { name: "T9", agent: "claude", displayName: "Claude Code" }, target: { id: "w2", name: "Blog" } };
+
+beforeEach(() => { vi.clearAllMocks(); });
+afterEach(cleanup);
+
+it("defaults to automatic and confirms without a place", async () => {
+ api.layout.mockResolvedValue(workspace(["T1", "T2"]));
+ const onConfirm = vi.fn();
+ render(<MovePaneDialog request={request} busy={false} onCancel={() => {}} onConfirm={onConfirm} />);
+
+ await screen.findByRole("button", { name: "Place T9 below T1" });
+ expect(screen.getByTestId("move-pane-auto").getAttribute("aria-checked")).toBe("true");
+ expect(screen.getByRole("status").textContent).toContain("joins the right edge");
+ fireEvent.click(screen.getByTestId("move-pane-confirm"));
+
+ expect(api.layout).toHaveBeenCalledWith("w2");
+ expect(onConfirm).toHaveBeenCalledExactlyOnceWith(null);
+});
+
+it("sends the picked pane by identity and the side", async () => {
+ api.layout.mockResolvedValue(workspace(["T1", "T2"]));
+ const onConfirm = vi.fn();
+ render(<MovePaneDialog request={request} busy={false} onCancel={() => {}} onConfirm={onConfirm} />);
+
+ fireEvent.click(await screen.findByRole("button", { name: "Place T9 left of T2" }));
+ expect(screen.getByRole("status").textContent).toBe("T9 goes left of T2 and shares its space.");
+ fireEvent.click(screen.getByTestId("move-pane-confirm"));
+
+ expect(onConfirm).toHaveBeenCalledExactlyOnceWith({ anchor: "pane:h-T2", side: "left" });
+});
+
+it("disables a side the grid has no room for", async () => {
+ const row = ["T1", "T2", "T3", "T4"];
+ api.layout.mockResolvedValue(workspace(row, { direction: "row", children: row.map((name) => ({ pane: name.toLowerCase() })), weights: [1, 1, 1, 1] }));
+ render(<MovePaneDialog request={request} busy={false} onCancel={() => {}} onConfirm={() => {}} />);
+
+ // Four columns already: a fifth beside any of them does not fit, a second row does.
+ expect((await screen.findByRole("button", { name: "Place T9 right of T1" }) as HTMLButtonElement).disabled).toBe(true);
+ expect((screen.getByRole("button", { name: "Place T9 below T1" }) as HTMLButtonElement).disabled).toBe(false);
+});
+
+it("cannot confirm into a full workspace", async () => {
+ api.layout.mockResolvedValue(workspace(["T1", "T2"], undefined, 2));
+ render(<MovePaneDialog request={request} busy={false} onCancel={() => {}} onConfirm={() => {}} />);
+
+ await screen.findByRole("button", { name: "Place T9 below T1" });
+ expect((screen.getByTestId("move-pane-confirm") as HTMLButtonElement).disabled).toBe(true);
+ expect(screen.getByRole("status").textContent).toContain("is full");
+});
+
+it("says an empty workspace is simply filled", async () => {
+ api.layout.mockResolvedValue(workspace([], null));
+ render(<MovePaneDialog request={request} busy={false} onCancel={() => {}} onConfirm={() => {}} />);
+
+ expect(await screen.findByText("No terminals open here yet.")).toBeTruthy();
+ expect(screen.getByRole("status").textContent).toBe("Blog is empty, so T9 fills it.");
+});
diff --git a/jarvis/ui/web/frontend/src/components/agentic/MovePaneDialog.tsx b/jarvis/ui/web/frontend/src/components/agentic/MovePaneDialog.tsx
new file mode 100644
index 0000000000..f68122c8af
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/components/agentic/MovePaneDialog.tsx
@@ -0,0 +1,182 @@
+import { useEffect, useState, type ComponentType } from "react";
+import * as Dialog from "@radix-ui/react-dialog";
+import { ArrowDown, ArrowLeft, ArrowRight, ArrowUp, FolderInput, Loader2, Wand2 } from "lucide-react";
+import { AgentMark } from "./AgentMark";
+import { treeLayout } from "./treeLayout";
+import { GRID_LIMIT_HINT, fitsWorkspace, previewSplit, workspaceLayout } from "./workspaceDocking";
+import { fetchWorkspaceLayout, type TransferPlacement, type TransferSide, type WorkspaceLayoutView } from "@/lib/agenticIdeApi";
+import { cn } from "@/lib/utils";
+
+/** The pane being moved and the open workspace it goes to. */
+export interface MovePaneRequest {
+ pane: { name: string; agent: string; displayName: string };
+ target: { id: string; name: string };
+}
+
+interface Props {
+ request: MovePaneRequest | null;
+ busy: boolean;
+ onCancel: () => void;
+ /** `null` places the pane automatically at the right edge of the grid. */
+ onConfirm: (placement: TransferPlacement | null) => void;
+}
+
+const SIDES: { side: TransferSide; words: string; Icon: ComponentType<{ className?: string }>; at: string }[] = [
+ { side: "left", words: "left of", Icon: ArrowLeft, at: "left-1 top-1/2 -translate-y-1/2" },
+ { side: "right", words: "right of", Icon: ArrowRight, at: "right-1 top-1/2 -translate-y-1/2" },
+ { side: "above", words: "above", Icon: ArrowUp, at: "left-1/2 top-1 -translate-x-1/2" },
+ { side: "below", words: "below", Icon: ArrowDown, at: "bottom-1 left-1/2 -translate-x-1/2" },
+];
+
+/** The half of the anchor's tile the moved pane will take. */
+const HALF: Record<TransferSide, string> = {
+ left: "inset-y-0 left-0 w-1/2",
+ right: "inset-y-0 right-0 w-1/2",
+ above: "inset-x-0 top-0 h-1/2",
+ below: "inset-x-0 bottom-0 h-1/2",
+};
+
+const SPLIT_DIRECTION = { left: "left", right: "right", above: "above", below: "down" } as const;
+const INCOMING = "__incoming__";
+
+/**
+ * Choose where a pane lands in another workspace's grid.
+ *
+ * The target grid is drawn as a small map. Each of its panes offers four
+ * arrows; picking one puts the moved pane on that side of it, sharing that
+ * pane's room the way a split does. A side that would push the grid past its
+ * largest shape is disabled rather than offered and then refused. "Automatic"
+ * — the default, so Enter alone keeps the quick path — joins the right edge.
+ */
+export function MovePaneDialog({ request, busy, onCancel, onConfirm }: Props) {
+ const [view, setView] = useState<WorkspaceLayoutView | null>(null);
+ const [loadError, setLoadError] = useState("");
+ const [choice, setChoice] = useState<TransferPlacement | null>(null);
+ const [hover, setHover] = useState<TransferPlacement | null>(null);
+ const targetId = request?.target.id;
+
+ useEffect(() => {
+ setView(null);
+ setLoadError("");
+ setChoice(null);
+ setHover(null);
+ if (!targetId) return;
+ let live = true;
+ fetchWorkspaceLayout(targetId)
+ .then((next) => { if (live) setView(next); })
+ .catch((error: unknown) => { if (live) setLoadError(error instanceof Error ? error.message : String(error)); });
+ return () => { live = false; };
+ }, [targetId]);
+
+ const terminals = view?.terminals ?? [];
+ const current = view ? workspaceLayout(view.layout, terminals) : null;
+ const boxes = treeLayout(current, terminals).boxes;
+ const full = view !== null && terminals.length >= view.max_terminals;
+ const anchorOf = (terminal: (typeof terminals)[number]) => terminal.history_id ? `pane:${terminal.history_id}` : terminal.name;
+ const fits = (key: string, side: TransferSide) =>
+ !full && current !== null && fitsWorkspace(previewSplit(current, key, INCOMING, SPLIT_DIRECTION[side]));
+ const shown = hover ?? choice;
+ const chosen = choice ? terminals.find((terminal) => anchorOf(terminal) === choice.anchor) : null;
+ const paneName = request?.pane.name ?? "";
+ const summary = full
+ ? `${request?.target.name} is full: a workspace holds ${view?.max_terminals} terminals.`
+ : chosen && choice
+ ? `${paneName} goes ${SIDES.find((entry) => entry.side === choice.side)?.words} ${chosen.name} and shares its space.`
+ : terminals.length
+ ? `${paneName} joins the right edge, and every pane gets an even share.`
+ : `${request?.target.name} is empty, so ${paneName} fills it.`;
+ const submit = () => { if (!busy && !full && view) onConfirm(choice); };
+
+ return <Dialog.Root open={request !== null} onOpenChange={(open) => { if (!open && !busy) onCancel(); }}>
+ <Dialog.Portal>
+ <Dialog.Overlay className="fixed inset-0 z-[80] bg-background/70 backdrop-blur-sm data-[state=open]:animate-in data-[state=open]:fade-in-0" />
+ <Dialog.Content data-testid="move-pane-dialog"
+ className="fixed left-1/2 top-1/2 z-[90] w-[min(560px,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 rounded-2xl border border-border bg-popover p-6 text-popover-foreground shadow-2xl data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95">
+ <form onSubmit={(event) => { event.preventDefault(); submit(); }}>
+ <div className="flex items-start gap-4">
+ <div className="flex h-10 w-10 shrink-0 items-center justify-center rounded-xl bg-primary/10 text-primary">
+ <FolderInput className="h-[18px] w-[18px]" aria-hidden />
+ </div>
+ <div className="min-w-0 flex-1">
+ <Dialog.Title className="truncate text-base font-semibold">Move {paneName} to {request?.target.name}</Dialog.Title>
+ <Dialog.Description className="mt-1.5 text-sm leading-relaxed text-muted-foreground">
+ Pick where it goes in that grid. The agent keeps running.
+ </Dialog.Description>
+ </div>
+ </div>
+
+ <button type="button" role="radio" aria-checked={choice === null} data-testid="move-pane-auto"
+ disabled={busy} onClick={() => setChoice(null)}
+ className={cn(
+ "mt-4 flex w-full items-center gap-3 rounded-xl border px-3 py-2.5 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50",
+ choice === null ? "border-primary bg-primary/5" : "border-border hover:bg-muted/60",
+ )}>
+ <Wand2 className={cn("h-4 w-4 shrink-0", choice === null ? "text-primary" : "text-muted-foreground")} aria-hidden />
+ <span className="min-w-0">
+ <span className="block text-sm font-medium">Automatic</span>
+ <span className="block text-xs text-muted-foreground">At the right edge, every pane evened out</span>
+ </span>
+ </button>
+
+ <div className="mt-3 rounded-xl border border-border bg-muted/30 p-1.5">
+ <div data-testid="move-pane-map" className="relative aspect-[16/9] w-full" onMouseLeave={() => setHover(null)}>
+ {!view && !loadError && <div className="flex h-full items-center justify-center gap-2 text-xs text-muted-foreground">
+ <Loader2 className="h-3.5 w-3.5 animate-spin" aria-hidden />Loading {request?.target.name}…</div>}
+ {view && terminals.length === 0 && <div className="flex h-full items-center justify-center text-xs text-muted-foreground">
+ No terminals open here yet.</div>}
+ {terminals.map((terminal, index) => {
+ const box = boxes[index];
+ if (!box) return null;
+ const anchor = anchorOf(terminal);
+ const lit = shown?.anchor === anchor ? shown.side : null;
+ return <div key={terminal.key} data-testid={`move-pane-tile-${terminal.name}`}
+ className="absolute p-0.5" style={{ left: `${box.x * 100}%`, top: `${box.y * 100}%`, width: `${box.w * 100}%`, height: `${box.h * 100}%` }}>
+ <div className="relative flex h-full w-full items-center justify-center overflow-hidden rounded-lg border border-border bg-card">
+ {lit && <div aria-hidden className={cn("absolute flex items-center justify-center rounded-md border-2 border-primary bg-primary/15 text-xs font-semibold text-primary", HALF[lit])}>
+ {paneName}</div>}
+ <span className={cn("flex min-w-0 items-center gap-1.5 px-7 text-xs font-medium", lit && "invisible")}>
+ <AgentMark agent={terminal.agent} label={terminal.display_name} variant="plain" size="sm" />
+ <span className="truncate">{terminal.name}</span>
+ </span>
+ {SIDES.map(({ side, words, Icon, at }) => {
+ const allowed = fits(terminal.key, side);
+ const selected = choice?.anchor === anchor && choice.side === side;
+ return <button key={side} type="button" aria-pressed={selected} disabled={busy || !allowed}
+ data-testid={`move-pane-${terminal.name}-${side}`}
+ aria-label={`Place ${paneName} ${words} ${terminal.name}`}
+ title={allowed ? `${words[0].toUpperCase()}${words.slice(1)} ${terminal.name}` : `No room here. ${GRID_LIMIT_HINT}`}
+ onClick={() => setChoice({ anchor, side })}
+ onMouseEnter={() => { if (allowed) setHover({ anchor, side }); }}
+ onFocus={() => { if (allowed) setHover({ anchor, side }); }}
+ onBlur={() => setHover(null)}
+ className={cn(
+ "absolute z-10 flex h-6 w-6 items-center justify-center rounded-md border transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-30",
+ at,
+ selected ? "border-primary bg-primary text-primary-foreground" : "border-border bg-popover text-muted-foreground hover:border-primary hover:text-primary",
+ )}>
+ <Icon className="h-3.5 w-3.5" aria-hidden />
+ </button>;
+ })}
+ </div>
+ </div>;
+ })}
+ </div>
+ </div>
+
+ <p role="status" className="mt-3 text-xs leading-relaxed text-muted-foreground">{view ? summary : ""}</p>
+ {loadError && <p role="alert" className="mt-2 text-xs text-destructive">{loadError}</p>}
+
+ <div className="mt-5 flex justify-end gap-2">
+ <button type="button" disabled={busy} onClick={onCancel}
+ className="rounded-lg border border-border px-3.5 py-2 text-sm font-medium hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-40">
+ Cancel</button>
+ <button type="submit" data-testid="move-pane-confirm" disabled={busy || full || !view}
+ className="flex items-center gap-1.5 rounded-lg bg-primary px-3.5 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-popover disabled:opacity-50">
+ {busy && <Loader2 className="h-3.5 w-3.5 animate-spin" aria-hidden />}
+ Move to {request?.target.name}</button>
+ </div>
+ </form>
+ </Dialog.Content>
+ </Dialog.Portal>
+ </Dialog.Root>;
+}
diff --git a/jarvis/ui/web/frontend/src/components/agentic/WorkspaceTerminalGrid.transfer.test.tsx b/jarvis/ui/web/frontend/src/components/agentic/WorkspaceTerminalGrid.transfer.test.tsx
index 102039dd43..88af21ceb9 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/WorkspaceTerminalGrid.transfer.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/WorkspaceTerminalGrid.transfer.test.tsx
@@ -1,6 +1,7 @@
/**
* Moving a pane into another open workspace, from its menu or by dropping it
- * on that workspace's row in the sidebar.
+ * on that workspace's row in the sidebar. Both ask where in that grid it goes
+ * (MovePaneDialog) before anything moves.
*
* The agent keeps running; only the tab that lists it changes. What the grid
* owes is to send the pane's stable identity (never a call-sign another tab
@@ -10,8 +11,8 @@
import { afterEach, beforeEach, expect, it, vi } from "vitest";
import { cleanup, fireEvent, render, screen, waitFor } from "@testing-library/react";
import type { SessionState } from "@/lib/agenticIdeApi";
-const api = vi.hoisted(() => ({ transfer: vi.fn(), move: vi.fn(), toast: vi.fn() }));
-vi.mock("@/lib/agenticIdeApi", () => ({ transferTerminal: api.transfer, moveTerminal: api.move }));
+const api = vi.hoisted(() => ({ transfer: vi.fn(), move: vi.fn(), toast: vi.fn(), layout: vi.fn() }));
+vi.mock("@/lib/agenticIdeApi", () => ({ transferTerminal: api.transfer, moveTerminal: api.move, fetchWorkspaceLayout: api.layout }));
vi.mock("@/store/events", () => ({ useEventStore: (select: (state: unknown) => unknown) => select({ pushToast: api.toast }) }));
vi.mock("./AgenticTerminal", () => ({ AgenticTerminal: (props: {
name: string;
@@ -51,19 +52,28 @@ function sidebarRow(id: string, name: string): HTMLElement {
return row;
}
-beforeEach(() => { vi.clearAllMocks(); });
+/** Blog, as the move dialog's map draws it: one Claude pane. */
+const blog = { id: "w2", name: "Blog", layout: { pane: "t1" }, max_terminals: 16,
+ terminals: [{ key: "t1", name: "T1", agent: "claude", display_name: "Claude Code", history_id: "b-T1" }] };
+
+beforeEach(() => { vi.clearAllMocks(); api.layout.mockResolvedValue(blog); });
afterEach(() => { cleanup(); document.body.innerHTML = ""; });
-it("offers every other open workspace and moves the pane by its identity", async () => {
+it("offers every other open workspace and moves the pane to the place picked", async () => {
api.transfer.mockResolvedValue({ terminal: { name: "T3" }, state: { session: makeSession(["T1"]) } });
const onChanged = vi.fn();
render(<WorkspaceTerminalGrid {...props} session={makeSession()} onChanged={onChanged} />);
- expect(screen.queryByRole("button", { name: "T2: Move to Personal Jarvis" })).toBeNull();
- expect(screen.getByRole("button", { name: "T2: Move to VMs" })).toBeTruthy();
- fireEvent.click(screen.getByRole("button", { name: "T2: Move to Blog" }));
+ expect(screen.queryByRole("button", { name: "T2: Move to Personal Jarvis…" })).toBeNull();
+ expect(screen.getByRole("button", { name: "T2: Move to VMs…" })).toBeTruthy();
+ fireEvent.click(screen.getByRole("button", { name: "T2: Move to Blog…" }));
+
+ // Nothing moves until a place is confirmed.
+ fireEvent.click(await screen.findByRole("button", { name: "Place T2 below T1" }));
+ expect(api.transfer).not.toHaveBeenCalled();
+ fireEvent.click(screen.getByTestId("move-pane-confirm"));
- await waitFor(() => expect(api.transfer).toHaveBeenCalledExactlyOnceWith("pane:h-T2", "w1", "w2"));
+ await waitFor(() => expect(api.transfer).toHaveBeenCalledExactlyOnceWith("pane:h-T2", "w1", "w2", { anchor: "pane:b-T1", side: "below" }));
await waitFor(() => expect(onChanged).toHaveBeenCalledOnce());
expect(onChanged.mock.calls[0][0].terminals.map((t: { name: string }) => t.name)).toEqual(["T1"]);
// It arrived under another call-sign; the user is told which.
@@ -75,14 +85,18 @@ it("says why a move was refused and keeps the pane", async () => {
const onChanged = vi.fn(), onMutationEnd = vi.fn();
render(<WorkspaceTerminalGrid {...props} session={makeSession()} onChanged={onChanged} onMutationEnd={onMutationEnd} />);
- fireEvent.click(screen.getByRole("button", { name: "T1: Move to Blog" }));
+ fireEvent.click(screen.getByRole("button", { name: "T1: Move to Blog…" }));
+ await screen.findByRole("button", { name: "Place T1 below T1" });
+ fireEvent.click(screen.getByTestId("move-pane-confirm"));
await waitFor(() => expect(api.toast).toHaveBeenCalledWith("error", "Blog already has the maximum of 12 terminals."));
expect(onChanged).not.toHaveBeenCalled();
expect(onMutationEnd).toHaveBeenCalledOnce();
+ // Still open: another place can be picked.
+ expect(screen.getByTestId("move-pane-dialog")).toBeTruthy();
});
-it("moves a pane dropped on a workspace in the sidebar, lighting the row while it hovers", async () => {
+it("asks where a pane dropped on a workspace in the sidebar goes, lighting the row while it hovers", async () => {
api.transfer.mockResolvedValue({ terminal: { name: "T1" }, state: { session: makeSession(["T2"]) } });
const row = sidebarRow("w2", "Blog");
render(<WorkspaceTerminalGrid {...props} session={makeSession()} />);
@@ -94,7 +108,12 @@ it("moves a pane dropped on a workspace in the sidebar, lighting the row while i
fireEvent.pointerUp(window, { pointerId: 1, clientX: 1200, clientY: 40 });
expect(row.hasAttribute("data-pane-drop-active")).toBe(false);
- await waitFor(() => expect(api.transfer).toHaveBeenCalledExactlyOnceWith("pane:h-T1", "w1", "w2"));
+ expect(await screen.findByText("Move T1 to Blog")).toBeTruthy();
+ expect(api.transfer).not.toHaveBeenCalled();
+ await screen.findByRole("button", { name: "Place T1 below T1" });
+ fireEvent.click(screen.getByTestId("move-pane-confirm"));
+ // "Automatic" is the default: no place named.
+ await waitFor(() => expect(api.transfer).toHaveBeenCalledExactlyOnceWith("pane:h-T1", "w1", "w2", null));
expect(api.move).not.toHaveBeenCalled();
});
diff --git a/jarvis/ui/web/frontend/src/components/agentic/WorkspaceTerminalGrid.tsx b/jarvis/ui/web/frontend/src/components/agentic/WorkspaceTerminalGrid.tsx
index cec851fbb3..c52c574e32 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/WorkspaceTerminalGrid.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/WorkspaceTerminalGrid.tsx
@@ -2,9 +2,10 @@ import { useCallback, useEffect, useLayoutEffect, useRef, useState } from "react
import { AgenticTerminal } from "./AgenticTerminal";
import { AgentMark } from "./AgentMark";
import { ForkPaneDialog, type ForkMode, type ForkSource } from "./ForkPaneDialog";
+import { MovePaneDialog, type MovePaneRequest } from "./MovePaneDialog";
import type { PaneSplitDirection } from "./WorkspaceTerminalHeader";
import type { SessionState, TerminalState } from "@/lib/agenticIdeApi";
-import { forkTerminal, moveTerminal, placeTerminal, renameTerminal, transferTerminal, type PaneMovePosition } from "@/lib/agenticIdeApi";
+import { forkTerminal, moveTerminal, placeTerminal, renameTerminal, transferTerminal, type PaneMovePosition, type TransferPlacement } from "@/lib/agenticIdeApi";
import { useComputerChoices } from "@/hooks/useComputers";
import { useThemeValue } from "@/hooks/useTheme";
import { useEventStore } from "@/store/events";
@@ -195,11 +196,18 @@ export function WorkspaceTerminalGrid({ session, onChanged, onAdd, onClose, onSe
}
}, [pushToast]);
- // "Move to <workspace>", from the pane menu or by dropping the pane on a
- // workspace in the sidebar: the pane leaves this grid and joins that tab
- // with its agent still running, and that tab's grid re-joins it.
+ // "Move to <workspace>…", from the pane menu or by dropping the pane on a
+ // workspace in the sidebar: a dialog asks where in that grid it goes, then
+ // the pane leaves this grid and joins that tab with its agent still
+ // running, and that tab's grid re-joins it.
const [transferring, setTransferring] = useState<string | null>(null);
- const transfer = useCallback(async (sourceId: string, target: WorkspaceChoice) => {
+ const [moving, setMoving] = useState<{ id: string; request: MovePaneRequest } | null>(null);
+ const askWhere = useCallback((sourceId: string, target: WorkspaceChoice) => {
+ const terminal = latest.current.session.terminals.find((entry) => idOf(entry) === sourceId);
+ if (!terminal || target.id === latest.current.session.id) return;
+ setMoving({ id: sourceId, request: { pane: { name: terminal.name, agent: terminal.agent, displayName: terminal.display_name }, target } });
+ }, []);
+ const transfer = useCallback(async (sourceId: string, target: WorkspaceChoice, placement: TransferPlacement | null = null) => {
const owner = latest.current.session;
const terminal = owner.terminals.find((entry) => idOf(entry) === sourceId);
if (!terminal || target.id === owner.id || saveInFlight.current || latest.current.disabled) return;
@@ -207,14 +215,16 @@ export function WorkspaceTerminalGrid({ session, onChanged, onAdd, onClose, onSe
latest.current.onMutationStart?.();
setTransferring(sourceId);
try {
- const result = await transferTerminal(terminal.history_id ? `pane:${terminal.history_id}` : terminal.name, owner.id, target.id);
+ const result = await transferTerminal(terminal.history_id ? `pane:${terminal.history_id}` : terminal.name, owner.id, target.id, placement);
if (!mounted.current) return;
+ setMoving(null);
const next = result.state.session;
if (next && latest.current.session === owner && next.id === owner.id) latest.current.onChanged(next);
const renamed = result.terminal.name !== terminal.name ? ` as ${result.terminal.name}` : "";
pushToast("success", `${terminal.name} moved to ${target.name}${renamed}. Its agent keeps running.`);
setAnnouncement(`${terminal.name} moved to ${target.name}${renamed}.`);
} catch (error) {
+ // The dialog stays open, so another place can be picked.
if (mounted.current) pushToast("error", (error as Error).message);
} finally {
saveInFlight.current = false;
@@ -290,7 +300,7 @@ export function WorkspaceTerminalGrid({ session, onChanged, onAdd, onClose, onSe
const workspace = armed ? workspaceAt(release.clientX, release.clientY) : null;
const target = workspace ? null : targetAt(release.clientX, release.clientY);
cleanup();
- if (armed && workspace) void transfer(id, workspace);
+ if (armed && workspace) askWhere(id, workspace);
else if (armed && target?.allowed) void move(id, target.id, target.position);
};
dragCleanup.current = cleanup;
@@ -299,7 +309,7 @@ export function WorkspaceTerminalGrid({ session, onChanged, onAdd, onClose, onSe
window.addEventListener("pointercancel", onCancel, true);
window.addEventListener("blur", cleanup);
window.addEventListener("keydown", onKey, true);
- }, [move, transfer]);
+ }, [move, askWhere]);
const rename = async (terminal: TerminalState, name: string) => {
const owner = latest.current.session;
@@ -451,7 +461,7 @@ export function WorkspaceTerminalGrid({ session, onChanged, onAdd, onClose, onSe
branch={terminal.branch || undefined}
computerName={computerName(terminal)} placementItems={placementItems(terminal)}
workspaceItems={transferring || saving || disabled ? [] : workspaces.filter((workspace) => workspace.id !== session.id)
- .map((workspace) => ({ label: `Move to ${workspace.name}`, run: () => void transfer(id, workspace) }))}
+ .map((workspace) => ({ label: `Move to ${workspace.name}…`, run: () => askWhere(id, workspace) }))}
onFork={terminal.accepts_prompts === false ? undefined : () => setForking({ name: terminal.name, agent: terminal.agent, displayName: terminal.display_name, workspaceId: session.id })} />
{drag?.target?.id === id && <div aria-hidden="true" data-testid="dock-preview" data-position={drag.target.position}
className={cn("pointer-events-none absolute z-20 flex items-center justify-center border-2 p-2", minimal ? "rounded-none" : "rounded-xl", drag.target.allowed ? "border-ring/70 bg-accent/[0.15]" : "border-destructive bg-background/80",
@@ -488,5 +498,7 @@ export function WorkspaceTerminalGrid({ session, onChanged, onAdd, onClose, onSe
</div>}
<span className="sr-only" role="status">{announcement}</span>
<ForkPaneDialog source={forking} busy={forkBusy} onCancel={() => setForking(null)} onConfirm={(choice) => void fork(choice)} />
+ <MovePaneDialog request={moving?.request ?? null} busy={transferring !== null} onCancel={() => setMoving(null)}
+ onConfirm={(placement) => { if (moving) void transfer(moving.id, moving.request.target, placement); }} />
</div>;
}
diff --git a/jarvis/ui/web/frontend/src/lib/agenticIdeApi.transfer.test.ts b/jarvis/ui/web/frontend/src/lib/agenticIdeApi.transfer.test.ts
index eff5f5921c..1ebdb4d864 100644
--- a/jarvis/ui/web/frontend/src/lib/agenticIdeApi.transfer.test.ts
+++ b/jarvis/ui/web/frontend/src/lib/agenticIdeApi.transfer.test.ts
@@ -5,7 +5,7 @@
* the pane menu already offers a move the server cannot do yet.
*/
import { afterEach, expect, it, vi } from "vitest";
-import { transferTerminal } from "./agenticIdeApi";
+import { fetchWorkspaceLayout, transferTerminal } from "./agenticIdeApi";
function answer(status: number, body: unknown) {
vi.stubGlobal("fetch", vi.fn(async () => new Response(JSON.stringify(body), { status })));
@@ -33,3 +33,21 @@ it("asks for a restart when the backend predates the route", async () => {
answer(404, { detail: "Not Found" });
await expect(transferTerminal("T1", "w1", "w2")).rejects.toThrow("restart the app");
});
+
+it("names the chosen place in the target grid", async () => {
+ answer(200, { terminal: { name: "T2" }, state: {} });
+
+ await transferTerminal("T1", "w1", "w2", { anchor: "pane:b1", side: "below" });
+
+ const [, init] = (fetch as unknown as ReturnType<typeof vi.fn>).mock.calls[0];
+ expect(JSON.parse(init.body)).toEqual({ workspace_id: "w1", target_workspace_id: "w2", anchor: "pane:b1", side: "below" });
+});
+
+it("reads another workspace's shape from its own route", async () => {
+ answer(200, { id: "w2", name: "Blog", layout: null, terminals: [], max_terminals: 16 });
+
+ const view = await fetchWorkspaceLayout("w2");
+
+ expect((fetch as unknown as ReturnType<typeof vi.fn>).mock.calls[0][0]).toBe("/api/agentic-ide/workspaces/w2/layout");
+ expect(view.name).toBe("Blog");
+});
diff --git a/jarvis/ui/web/frontend/src/lib/agenticIdeApi.ts b/jarvis/ui/web/frontend/src/lib/agenticIdeApi.ts
index c7beb3c9d2..0df7241895 100644
--- a/jarvis/ui/web/frontend/src/lib/agenticIdeApi.ts
+++ b/jarvis/ui/web/frontend/src/lib/agenticIdeApi.ts
@@ -1494,6 +1494,30 @@ export async function moveTerminal(
return body.state.session;
}
+/** Which side of a pane in the target workspace a moved pane goes on. */
+export type TransferSide = "left" | "right" | "above" | "below";
+
+/** Where in the target grid a moved pane lands: beside `anchor`, on `side`. */
+export interface TransferPlacement {
+ /** A pane of the TARGET workspace: its call-sign or `pane:<history_id>`. */
+ anchor: string;
+ side: TransferSide;
+}
+
+/** One open workspace's shape: what a placement map draws. */
+export interface WorkspaceLayoutView {
+ id: string;
+ name: string;
+ layout: LayoutNode | null;
+ terminals: Pick<TerminalState, "key" | "name" | "agent" | "display_name" | "history_id">[];
+ max_terminals: number;
+}
+
+/** The split tree and panes of an open workspace that may not be on screen. */
+export async function fetchWorkspaceLayout(workspaceId: string): Promise<WorkspaceLayoutView> {
+ return getJson<WorkspaceLayoutView>(`/api/agentic-ide/workspaces/${encodeURIComponent(workspaceId)}/layout`);
+}
+
/** What moving a pane into another workspace answers with. */
export interface TerminalTransfer {
/** The pane as it is now — its call-sign may have changed in the new tab. */
@@ -1509,19 +1533,25 @@ export interface TerminalTransfer {
* The agent is not restarted: its process, conversation and folder stay as
* they are, and only the tab that lists and draws it changes. The pane keeps
* its call-sign unless the target tab already has one by that name — the
- * answer's `terminal.name` is the one it answers to now.
+ * answer's `terminal.name` is the one it answers to now. With a `placement`
+ * it shares that pane's room in the target grid; without, it joins the edge.
*/
export async function transferTerminal(
name: string,
workspaceId: string,
targetWorkspaceId: string,
+ placement?: TransferPlacement | null,
): Promise<TerminalTransfer> {
const res = await fetch(
`/api/agentic-ide/terminals/${encodeURIComponent(name)}/transfer`,
{
method: "POST",
headers: { "Content-Type": "application/json" },
- body: JSON.stringify({ workspace_id: workspaceId, target_workspace_id: targetWorkspaceId }),
+ body: JSON.stringify({
+ workspace_id: workspaceId,
+ target_workspace_id: targetWorkspaceId,
+ ...(placement ? { anchor: placement.anchor, side: placement.side } : {}),
+ }),
},
);
if (!res.ok) {
diff --git a/tests/unit/agentic_ide/test_pane_transfer.py b/tests/unit/agentic_ide/test_pane_transfer.py
index ce929bfa8d..ecb2769840 100644
--- a/tests/unit/agentic_ide/test_pane_transfer.py
+++ b/tests/unit/agentic_ide/test_pane_transfer.py
@@ -273,3 +273,89 @@ async def test_the_route_tells_a_missing_pane_from_a_missing_tab(
assert missing_pane.value.status_code == 404
assert missing_tab.value.status_code == 409
+
+
+# ------------------------------------------------------------------ placement
+async def test_a_chosen_place_shares_that_panes_room(registry: Registry, tmp_path: Path) -> None:
+ """Beside the pane the user picked, the way a split carves it."""
+ source = await registry.start(str(tmp_path), [{"agent": "claude"}], name="Jarvis")
+ target = await registry.start(str(tmp_path), [{"agent": "claude"}], name="Blog")
+ await registry.add_terminal(workspace_id=target.id, direction="right") # Blog: T1 | T2
+
+ _, _, moved = await registry.transfer_terminal(
+ "T1", workspace_id=source.id, target_workspace_id=target.id, anchor="T1", side="below"
+ )
+
+ assert moved.name == "T3"
+ assert [(t.name, t.column, t.slot) for t in target.terminals] == [
+ ("T1", 0, 0),
+ ("T3", 0, 1),
+ ("T2", 1, 0),
+ ]
+
+
+async def test_left_of_a_pane_puts_it_first_in_the_row(
+ registry: Registry, tmp_path: Path
+) -> None:
+ source, target = await _two_tabs(registry, tmp_path, first=1, second=1)
+
+ await registry.transfer_terminal(
+ "T1", workspace_id=source.id, target_workspace_id=target.id, anchor="T1", side="left"
+ )
+
+ assert [t.name for t in target.terminals] == ["T2", "T1"]
+
+
+async def test_a_place_without_room_changes_nothing(registry: Registry, tmp_path: Path) -> None:
+ """Refused before the pane leaves its tab — never half-way between two."""
+ source = await registry.start(str(tmp_path), [{"agent": "claude"}], name="Jarvis")
+ target = await registry.start(str(tmp_path), [{"agent": "claude"}], name="Blog")
+ for _ in range(session_mod.MAX_GRID_COLUMNS - 1):
+ await registry.add_terminal(workspace_id=target.id, direction="right")
+ before = [t.name for t in target.terminals]
+
+ with pytest.raises(SessionError, match="No room"):
+ await registry.transfer_terminal(
+ "T1", workspace_id=source.id, target_workspace_id=target.id, anchor="T1", side="right"
+ )
+
+ assert [t.name for t in source.terminals] == ["T1"]
+ assert [t.name for t in target.terminals] == before
+
+
+async def test_an_unknown_anchor_is_refused(registry: Registry, tmp_path: Path) -> None:
+ source, target = await _two_tabs(registry, tmp_path)
+
+ with pytest.raises(SessionError, match="No terminal called 'Mika' in Blog"):
+ await registry.transfer_terminal(
+ "T1", workspace_id=source.id, target_workspace_id=target.id, anchor="Mika"
+ )
+ assert len(source.terminals) == 2
+
+
+async def test_the_layout_route_describes_another_tab(registry: Registry, tmp_path: Path) -> None:
+ """The map the move dialog draws: shape and panes, nothing heavier."""
+ _, target = await _two_tabs(registry, tmp_path)
+
+ body = routes.get_workspace_layout(target.id)
+
+ assert body["name"] == "Blog"
+ assert [t["name"] for t in body["terminals"]] == ["T1", "T2"]
+ assert body["layout"] is not None
+ with pytest.raises(HTTPException) as missing:
+ routes.get_workspace_layout("ide_missing")
+ assert missing.value.status_code == 404
+
+
+async def test_the_route_passes_the_chosen_place(registry: Registry, tmp_path: Path) -> None:
+ source, target = await _two_tabs(registry, tmp_path, first=1, second=1)
+
+ await routes.transfer_terminal(
+ _request(),
+ "T1",
+ routes.TransferTerminalRequest(
+ workspace_id=source.id, target_workspace_id=target.id, anchor="T1", side="above"
+ ),
+ )
+
+ assert [(t.name, t.slot) for t in target.terminals] == [("T2", 0), ("T1", 1)]
diff --git a/tests/unit/cli_ctl/test_commands_ide.py b/tests/unit/cli_ctl/test_commands_ide.py
index 80c5791856..10fbaa9349 100644
--- a/tests/unit/cli_ctl/test_commands_ide.py
+++ b/tests/unit/cli_ctl/test_commands_ide.py
@@ -90,3 +90,16 @@ def test_move_terminal_names_both_workspaces(capture_api) -> None:
assert call["method"] == "POST"
assert call["path"] == "/api/agentic-ide/terminals/T2/transfer"
assert call["body"] == {"target_workspace_id": "ide_blog", "workspace_id": "ide_jarvis"}
+
+
+def test_move_terminal_can_name_its_place(capture_api) -> None:
+ result = runner.invoke(
+ app, ["ide", "move-terminal", "T2", "ide_blog", "--beside", "T1", "--side", "below"]
+ )
+
+ assert result.exit_code == 0
+ assert capture_api["calls"][-1]["body"] == {
+ "target_workspace_id": "ide_blog",
+ "anchor": "T1",
+ "side": "below",
+ }