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
fix(ide): only move terminals between workspaces on the same folder
rubenluetke10-beep6d061682519b
diff --git a/jarvis/agentic_ide/session.py b/jarvis/agentic_ide/session.pyindex 7780b19303..4dddf5a55a 100644--- a/jarvis/agentic_ide/session.py+++ b/jarvis/agentic_ide/session.py@@ -6098,16 +6098,16 @@ class Registry:already relies on — the new workspace's grid attaches a viewer andre-joins the running agent.- What does change is only what is scoped to ONE workspace:+ Only between workspaces on the SAME folder. An agent belongs to the+ folder it works in, and a pane listed under another project while it+ edits this one is a trap, not an organisation (maintainer decision,+ 2026-10-01). A target on another folder is refused before anything+ changes.- * the call-sign and key, which are unique per tab — a "T2" moving into- a tab that already has a T2 takes the lowest free number there, a- custom name keeps itself unless it is taken (``_unique_name``);- * the folder. The agent keeps working where it was started; a pane- moved into a workspace on ANOTHER folder records that folder as its- own (the field a worktree fork uses), so a later restart resumes the- same conversation in the same place instead of an empty chat in the- new folder. Moved back home, the field empties again.+ What does change is only what is scoped to ONE workspace: the+ call-sign and key, which are unique per tab — a "T2" moving into a tab+ that already has a T2 takes the lowest free number there, a custom+ name keeps itself unless it is taken (``_unique_name``).``anchor`` names a pane of the TARGET tab to put the moved one beside,on ``side`` (``left``/``right``/``above``/``below``): the two then@@ -6137,6 +6137,11 @@ class Registry:)if target.id == source.id:return source, target, term+ if not _same_folder(source.folder, target.folder):+ raise SessionError(+ f"{term.name} can only move to a workspace on the same folder; "+ f"{target.name} works in another one."+ )if len(target.terminals) >= MAX_TERMINALS:raise SessionError(f"{target.name} already has the maximum of {MAX_TERMINALS} terminals."@@ -6163,9 +6168,6 @@ class Registry:suffix += 1placed = self._placed_beside(target, new_key, anchor, side)- cwd = term.cwd(source.folder)- term.folder = "" if _same_folder(cwd, target.folder) else cwd-# Out of the old workspace the way a close takes a pane out, minus# the kill: its rectangle folds away and its bell entries go (they# are "jump to this pane" buttons keyed by the old tab and key).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.tsxindex 14ae8a4649..4d5e1b47cf 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@@ -6,7 +6,8 @@* 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* also has), to drop the pane from its own screen with the answer, and to say- * when the pane arrived under another name.+ * when the pane arrived under another name. And only workspaces on the same+ * folder are offered at all: a pane never moves to another project's folder.*/import { afterEach, beforeEach, expect, it, vi } from "vitest";import { cleanup, fireEvent, render, screen, waitFor } from "@testing-library/react";@@ -35,9 +36,16 @@ vi.stubGlobal("ResizeObserver", ResizeObserverStub);vi.stubGlobal("PointerEvent", PointerEventStub);const makeSession = (names = ["T1", "T2"]) => ({- id: "w1", layout: balancedLayout(names), terminals: names.map((name) => ({ name, key: name.toLowerCase(), history_id: `h-${name}`, display_name: "Claude Code", agent: "claude" })),+ id: "w1", folder: "C:/work/jarvis", layout: balancedLayout(names), terminals: names.map((name) => ({ name, key: name.toLowerCase(), history_id: `h-${name}`, display_name: "Claude Code", agent: "claude" })),}) as SessionState;-const workspaces = [{ id: "w1", name: "Personal Jarvis" }, { id: "w2", name: "Blog" }, { id: "w3", name: "VMs" }];+// Blog and VMs share this folder (spelled differently, as Windows allows);+// Website is another project.+const workspaces = [+ { id: "w1", name: "Personal Jarvis", folder: "C:/work/jarvis" },+ { id: "w2", name: "Blog", folder: "c:\\work\\Jarvis\\" },+ { id: "w3", name: "VMs", folder: "C:/work/jarvis" },+ { id: "w4", name: "Website", folder: "C:/work/site" },+];const props = { onChanged: vi.fn(), onAdd: vi.fn(), onClose: vi.fn(), onSelect: vi.fn(), selected: "", fontSize: 13, appearance: null, workspaces };/** A sidebar row as IdeProjectTree draws it, and a pointer that finds it right of x=1000. */@@ -59,12 +67,13 @@ const blog = { id: "w2", name: "Blog", layout: { pane: "t1" }, max_terminals: 16beforeEach(() => { vi.clearAllMocks(); api.layout.mockResolvedValue(blog); });afterEach(() => { cleanup(); document.body.innerHTML = ""; });-it("offers every other open workspace and moves the pane to the place picked", async () => {+it("offers the other workspaces on this folder 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.queryByRole("button", { name: "T2: Move to Website…" })).toBeNull();expect(screen.getByRole("button", { name: "T2: Move to VMs…" })).toBeTruthy();fireEvent.click(screen.getByRole("button", { name: "T2: Move to Blog…" }));@@ -128,3 +137,17 @@ it("ignores the row of the workspace the pane is already in", () => {expect(api.transfer).not.toHaveBeenCalled();});++it("does not take a pane into a workspace on another folder, and says why", () => {+ const row = sidebarRow("w4", "Website");+ render(<WorkspaceTerminalGrid {...props} session={makeSession()} />);++ fireEvent.pointerDown(screen.getByRole("button", { name: "Move T1" }), { button: 0, pointerId: 1, clientX: 15, clientY: 15 });+ fireEvent.pointerMove(window, { pointerId: 1, clientX: 1200, clientY: 40 });+ expect(row.hasAttribute("data-pane-drop-active")).toBe(false);+ expect(screen.getByText("Not into Website: another folder")).toBeTruthy();+ fireEvent.pointerUp(window, { pointerId: 1, clientX: 1200, clientY: 40 });++ expect(screen.queryByTestId("move-pane-dialog")).toBeNull();+ expect(api.transfer).not.toHaveBeenCalled();+});diff --git a/jarvis/ui/web/frontend/src/components/agentic/WorkspaceTerminalGrid.tsx b/jarvis/ui/web/frontend/src/components/agentic/WorkspaceTerminalGrid.tsxindex c52c574e32..4c3cff8b09 100644--- a/jarvis/ui/web/frontend/src/components/agentic/WorkspaceTerminalGrid.tsx+++ b/jarvis/ui/web/frontend/src/components/agentic/WorkspaceTerminalGrid.tsx@@ -62,13 +62,25 @@ interface Props {workspaces?: readonly WorkspaceChoice[];}-interface WorkspaceChoice { id: string; name: string }+interface WorkspaceChoice { id: string; name: string; folder?: string }interface DropTarget { id: string; position: PaneMovePosition; allowed: boolean }-interface DragFeedback { id: string; target: DropTarget | null; x: number; y: number; workspace?: WorkspaceChoice | null }+interface DragFeedback { id: string; target: DropTarget | null; x: number; y: number; workspace?: WorkspaceChoice | null; blocked?: string | null }/** The attribute a sidebar row carries when a dragged pane may be dropped on it. */const WORKSPACE_DROP = "data-pane-drop-workspace";+/**+ * One folder, however the path is spelled. Panes only move between+ * workspaces on the same folder (the server refuses anything else); Windows+ * paths compare case-blind, like the filesystem under them.+ */+function sameFolder(left: string | undefined, right: string | undefined): boolean {+ if (!left || !right) return false;+ const clean = (path: string) => path.replace(/\\/g, "/").replace(/\/+$/, "");+ const [a, b] = [clean(left), clean(right)];+ return /^[a-z]:\//i.test(a) ? a.toLowerCase() === b.toLowerCase() : a === b;+}+export function WorkspaceTerminalGrid({ session, onChanged, onAdd, onClose, onSelect, selected, maxPanes = MAX_WORKSPACE_PANES, fontSize, appearance, disabled = false, onMutationStart, onMutationEnd, paneStyle: look = "classic", workspaces = [] }: Props) {const theme = useThemeValue();const pushToast = useEventStore((state) => state.pushToast);@@ -202,9 +214,14 @@ export function WorkspaceTerminalGrid({ session, onChanged, onAdd, onClose, onSe// running, and that tab's grid re-joins it.const [transferring, setTransferring] = useState<string | null>(null);const [moving, setMoving] = useState<{ id: string; request: MovePaneRequest } | null>(null);+ // Only the other workspaces on this one's folder: a pane never moves to+ // another project's folder.+ const movable = workspaces.filter((workspace) => workspace.id !== session.id && sameFolder(workspace.folder, session.folder));+ const movableRef = useRef(movable);+ movableRef.current = movable;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;+ if (!terminal || !movableRef.current.some((entry) => entry.id === target.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) => {@@ -260,26 +277,30 @@ export function WorkspaceTerminalGrid({ session, onChanged, onAdd, onClose, onSe};// A workspace row in the sidebar under the pointer. It is lit straight on// the DOM: the sidebar is another component, and this is one attribute- // for the length of a drag, not state it needs to own.+ // for the length of a drag, not state it needs to own. A row on another+ // folder stays dark and is named as `blocked`, so the drag can say why.let litRow: HTMLElement | null = null;- const workspaceAt = (x: number, y: number): WorkspaceChoice | null => {+ const workspaceAt = (x: number, y: number): { workspace: WorkspaceChoice | null; blocked: string | null } => {const row = document.elementFromPoint?.(x, y)?.closest<HTMLElement>(`[${WORKSPACE_DROP}]`) ?? null;const targetId = row?.getAttribute(WORKSPACE_DROP) ?? "";- const hit = row && targetId && targetId !== latest.current.session.id ? row : null;+ const workspace = targetId ? movableRef.current.find((entry) => entry.id === targetId) ?? null : null;+ const hit = workspace ? row : null;if (hit !== litRow) {litRow?.removeAttribute("data-pane-drop-active");hit?.setAttribute("data-pane-drop-active", "true");litRow = hit;}- return hit ? { id: targetId, name: hit.getAttribute("data-pane-drop-name") || "that workspace" } : null;+ const blocked = row && targetId && !workspace && targetId !== latest.current.session.id+ ? row.getAttribute("data-pane-drop-name") || "that workspace" : null;+ return { workspace, blocked };};const onMove = (motion: PointerEvent) => {if (motion.pointerId !== pointer) return;if (!armed && Math.hypot(motion.clientX - initialX, motion.clientY - initialY) <= 5) return;armed = true;motion.preventDefault();- const workspace = workspaceAt(motion.clientX, motion.clientY);- setDrag({ id, target: workspace ? null : targetAt(motion.clientX, motion.clientY), workspace, x: motion.clientX, y: motion.clientY });+ const { workspace, blocked } = workspaceAt(motion.clientX, motion.clientY);+ setDrag({ id, target: workspace || blocked ? null : targetAt(motion.clientX, motion.clientY), workspace, blocked, x: motion.clientX, y: motion.clientY });};const cleanup = () => {litRow?.removeAttribute("data-pane-drop-active");@@ -297,7 +318,7 @@ export function WorkspaceTerminalGrid({ session, onChanged, onAdd, onClose, onSeconst onKey = (key: KeyboardEvent) => { if (key.key === "Escape") { key.preventDefault(); key.stopPropagation(); cleanup(); } };const onUp = (release: PointerEvent) => {if (release.pointerId !== pointer) return;- const workspace = armed ? workspaceAt(release.clientX, release.clientY) : null;+ const workspace = armed ? workspaceAt(release.clientX, release.clientY).workspace : null;const target = workspace ? null : targetAt(release.clientX, release.clientY);cleanup();if (armed && workspace) askWhere(id, workspace);@@ -460,7 +481,7 @@ export function WorkspaceTerminalGrid({ session, onChanged, onAdd, onClose, onSesplitDisabled={tiles.length >= maxPanes} onSplit={(direction) => onAdd(terminal.name, direction)}branch={terminal.branch || undefined}computerName={computerName(terminal)} placementItems={placementItems(terminal)}- workspaceItems={transferring || saving || disabled ? [] : workspaces.filter((workspace) => workspace.id !== session.id)+ workspaceItems={transferring || saving || disabled ? [] : movable.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}@@ -495,6 +516,7 @@ export function WorkspaceTerminalGrid({ session, onChanged, onAdd, onClose, onSestyle={{ left: drag.x + 14, top: drag.y + 14 }}><AgentMark agent={dragged.agent} label={dragged.display_name} variant="plain" />{dragged.name}{drag.workspace && <span className="font-normal text-muted-foreground">Move to {drag.workspace.name}</span>}+ {drag.blocked && <span className="font-normal text-destructive">Not into {drag.blocked}: another folder</span>}</div>}<span className="sr-only" role="status">{announcement}</span><ForkPaneDialog source={forking} busy={forkBusy} onCancel={() => setForking(null)} onConfirm={(choice) => void fork(choice)} />diff --git a/tests/unit/agentic_ide/test_pane_transfer.py b/tests/unit/agentic_ide/test_pane_transfer.pyindex f1af3a19ff..391f303b21 100644--- a/tests/unit/agentic_ide/test_pane_transfer.py+++ b/tests/unit/agentic_ide/test_pane_transfer.py@@ -5,7 +5,8 @@ or stopped. The agent's process, conversation and history belong to the pane,so moving it only changes which tab lists and draws it. What a tab owns on itsown — the call-sign, the key, the folder — is what these tests pin, becauseevery failure there is silent on screen: two panes answering to one name, or a-pane whose next restart opens an empty chat in the wrong folder.+pane that ends up listed under another project's folder. Moving is only+allowed between workspaces on the same folder."""from __future__ import annotations@@ -153,26 +154,44 @@ async def test_its_key_never_collides_with_a_renamed_pane(assert target.find("T1") is moved-async def test_another_folder_is_remembered_and_forgotten_on_the_way_home(- registry: Registry, tmp_path: Path+async def test_a_workspace_on_another_folder_is_refused(+ registry: Registry, fake_pty: FakePtyManager, tmp_path: Path) -> None:- """The agent keeps working where it started, and a restart resumes there."""+ """A pane never moves to another project's folder — and nothing changes."""jarvis_dir, blog_dir = tmp_path / "jarvis", tmp_path / "blog"jarvis_dir.mkdir()blog_dir.mkdir()source = await registry.start(str(jarvis_dir), [{"agent": "claude"}] * 2, name="Jarvis")target = await registry.start(str(blog_dir), [{"agent": "claude"}], name="Blog")+ await registry.attach("T2", 80, 24, _noop, _noop_exit, workspace_id=source.id)- _, _, moved = await registry.transfer_terminal(- "T2", workspace_id=source.id, target_workspace_id=target.id- )- assert moved.cwd(target.folder) == source.folder+ with pytest.raises(SessionError, match="same folder"):+ await registry.transfer_terminal(+ "T2", workspace_id=source.id, target_workspace_id=target.id+ )- _, _, back = await registry.transfer_terminal(- moved.name, workspace_id=target.id, target_workspace_id=source.id- )- assert back.folder == ""- assert back.cwd(source.folder) == source.folder+ assert [t.name for t in source.terminals] == ["T1", "T2"]+ assert [t.name for t in target.terminals] == ["T1"]+ assert fake_pty.closed == []+++async def test_the_route_refuses_another_folder_as_a_conflict(+ registry: Registry, tmp_path: Path+) -> None:+ jarvis_dir, blog_dir = tmp_path / "jarvis", tmp_path / "blog"+ jarvis_dir.mkdir()+ blog_dir.mkdir()+ source = await registry.start(str(jarvis_dir), [{"agent": "claude"}], name="Jarvis")+ target = await registry.start(str(blog_dir), [{"agent": "claude"}], name="Blog")++ with pytest.raises(HTTPException) as refused:+ await routes.transfer_terminal(+ _request(),+ "T1",+ routes.TransferTerminalRequest(workspace_id=source.id, target_workspace_id=target.id),+ )++ assert refused.value.status_code == 409async def test_the_same_folder_needs_no_folder_of_its_own(