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
feat(ide): drag and drop to reorder workspaces
rubenluetke10-beep8cc9d505c630
diff --git a/jarvis/agentic_ide/session.py b/jarvis/agentic_ide/session.pyindex a4e3775956..d1f70ca241 100644--- a/jarvis/agentic_ide/session.py+++ b/jarvis/agentic_ide/session.py@@ -2355,6 +2355,19 @@ class Registry:await self._persist()return session+ async def reorder_workspaces(self, workspace_ids: list[str]) -> list[Session]:+ """Persist tab order without starting, stopping or renaming anything."""+ async with self._lock:+ if len(workspace_ids) != len(self._sessions) or set(workspace_ids) != set(+ self._sessions+ ):+ raise SessionError(+ "Workspace order must contain every open workspace exactly once."+ )+ self._sessions = {wid: self._sessions[wid] for wid in workspace_ids}+ await self._persist()+ return list(self._sessions.values())+async def reorder_terminals(self, workspace_id: str, terminal_ids: list[str]) -> Session:"""Persist row-major order without restarting or renaming an agent."""async with self._lock:diff --git a/jarvis/ui/web/agentic_ide_routes.py b/jarvis/ui/web/agentic_ide_routes.pyindex 9f056b44c6..d55f5099fe 100644--- a/jarvis/ui/web/agentic_ide_routes.py+++ b/jarvis/ui/web/agentic_ide_routes.py@@ -14,6 +14,7 @@ Endpoints (prefix ``/api/agentic-ide``):* ``POST /folders/create`` → make one new folder inside an existing one* ``POST /terminal-target/open`` → open a path printed by one terminal* ``GET /workspaces`` → every open workspace, in tab order+* ``PUT /workspaces/order`` → reorder workspace tabs via drag and drop* ``GET /workspaces/{id}/files`` → browse that workspace's file tree* ``GET /workspaces/{id}/file`` → stream one workspace file in-app* ``GET /workspaces/{id}/file-preview`` → readable text or a binary preview@@ -538,6 +539,12 @@ class TerminalOrderRequest(BaseModel):)+class WorkspaceOrderRequest(BaseModel):+ workspace_ids: list[str] = Field(+ description="Every open workspace id exactly once, in left-to-right tab order.",+ )++class SpawnGroupRequest(BaseModel):"""One "N panes running agent X" part of a fleet request."""@@ -1929,6 +1936,18 @@ def get_project_workspaces() -> dict:return workspace_catalog.project_graph(get_registry())[email protected]("/workspaces/order", summary="Reorder workspace tabs")+async def reorder_workspaces(request: Request, req: WorkspaceOrderRequest) -> dict:+ """Persist a drag-and-drop tab order without touching panes or agents."""+ registry = get_registry()+ try:+ await registry.reorder_workspaces(req.workspace_ids)+ except SessionError as exc:+ raise HTTPException(status_code=422, detail=str(exc)) from exc+ await _announce_workspace(request, registry.session, "reordered")+ return {"ok": True, "state": registry.state()}++@router.put("/workspaces/{workspace_id}/terminal-order", summary="Reorder workspace terminals")async def reorder_workspace_terminals(request: Request,diff --git a/jarvis/ui/web/frontend/src/components/agentic/IdeProjectTree.reorder.test.tsx b/jarvis/ui/web/frontend/src/components/agentic/IdeProjectTree.reorder.test.tsxnew file mode 100644index 0000000000..7d59e4e415--- /dev/null+++ b/jarvis/ui/web/frontend/src/components/agentic/IdeProjectTree.reorder.test.tsx@@ -0,0 +1,103 @@+import { act, cleanup, fireEvent, render, screen, waitFor } from "@testing-library/react";+import { afterEach, beforeEach, expect, it, vi } from "vitest";+import { IdeProjectTree } from "./IdeProjectTree";+import { useIdeProjectsStore } from "@/store/ideProjects";+import type { IdeProject } from "@/lib/agenticIdeApi";++const reorderWorkspaces = vi.hoisted(() => vi.fn());+vi.mock("@/lib/agenticIdeApi", () => ({ reorderWorkspaces }));+vi.mock("@/lib/chatLibraryApi", () => ({+ patchProject: vi.fn(async () => ({})),+ openProject: vi.fn(async () => ({ id: "p1" })),+ ChatLibraryError: class extends Error {+ constructor(message: string, readonly status: number) {+ super(message);+ }+ },+}));++function workspace(id: string, name: string) {+ return { id, name, status: "open", live_terminals: 1, terminals: 1, restorable: true };+}++function projectWithThree(): IdeProject {+ return {+ id: "p1",+ path: "/p1",+ name: "App",+ color: null,+ pinned: false,+ archived: false,+ scratch: false,+ created_at: 0,+ last_opened_at: 0,+ exists: true,+ chats: 0,+ workspaces: [workspace("w1", "First"), workspace("w2", "Second"), workspace("w3", "Third")],+ } as IdeProject;+}++beforeEach(() => {+ localStorage.clear();+ reorderWorkspaces.mockReset().mockResolvedValue({});+ useIdeProjectsStore.setState({+ projects: [projectWithThree()],+ activeWorkspaceId: "w1",+ pendingWorkspaceId: null,+ refreshRequest: null,+ action: null,+ });+});+afterEach(cleanup);++it("marks open workspaces draggable with a reorder hint", () => {+ render(<IdeProjectTree />);+ const row = screen.getByTestId("ide-workspace-row-w1");+ expect(row.getAttribute("draggable")).toBe("true");+ expect(screen.getByTestId("ide-workspace-w1").getAttribute("title")).toContain("drag to reorder");+});++it("moves a workspace with Alt plus arrow keys", async () => {+ render(<IdeProjectTree />);+ fireEvent.keyDown(screen.getByTestId("ide-workspace-w1"), { key: "ArrowDown", altKey: true });+ await waitFor(() => expect(reorderWorkspaces).toHaveBeenCalledWith(["w2", "w1", "w3"]));+ await waitFor(() => expect(useIdeProjectsStore.getState().refreshRequest?.nonce).toBe(1));+});++it("ignores Alt plus arrow keys at the list edges", () => {+ render(<IdeProjectTree />);+ fireEvent.keyDown(screen.getByTestId("ide-workspace-w1"), { key: "ArrowUp", altKey: true });+ fireEvent.keyDown(screen.getByTestId("ide-workspace-w3"), { key: "ArrowDown", altKey: true });+ expect(reorderWorkspaces).not.toHaveBeenCalled();+});++it("drags a workspace below its neighbour", async () => {+ render(<IdeProjectTree />);+ const row = screen.getByTestId("ide-workspace-row-w1");+ const target = screen.getByTestId("ide-workspace-row-w2");+ const data = new Map<string, string>();+ const dataTransfer = {+ types: ["application/x-jarvis-workspace-id"],+ effectAllowed: "",+ dropEffect: "",+ setData: (kind: string, value: string) => void data.set(kind, value),+ getData: (kind: string) => data.get(kind) ?? "",+ };+ fireEvent.dragStart(row, { dataTransfer });+ target.getBoundingClientRect = () => ({ top: 0, height: 40, left: 0, width: 200 } as DOMRect);+ fireEvent.dragOver(target, { dataTransfer, clientY: 35 });+ fireEvent.drop(target, { dataTransfer, clientY: 35 });+ await waitFor(() => expect(reorderWorkspaces).toHaveBeenCalledWith(["w2", "w1", "w3"]));+});++it("shows a toast instead of reordering when the backend rejects", async () => {+ reorderWorkspaces.mockRejectedValueOnce(new Error("stale list"));+ const { useEventStore } = await import("@/store/events");+ const pushToast = vi.fn();+ useEventStore.setState({ pushToast } as never);+ render(<IdeProjectTree />);+ act(() => {+ fireEvent.keyDown(screen.getByTestId("ide-workspace-w1"), { key: "ArrowDown", altKey: true });+ });+ await waitFor(() => expect(pushToast).toHaveBeenCalledWith("error", "stale list"));+});diff --git a/jarvis/ui/web/frontend/src/components/agentic/IdeProjectTree.tsx b/jarvis/ui/web/frontend/src/components/agentic/IdeProjectTree.tsxindex a5d7b317ae..444361af7d 100644--- a/jarvis/ui/web/frontend/src/components/agentic/IdeProjectTree.tsx+++ b/jarvis/ui/web/frontend/src/components/agentic/IdeProjectTree.tsx@@ -1,11 +1,12 @@import { useEffect, useRef, useState } from "react";import { Check, ChevronDown, ChevronRight, Folder, Loader2, Mic, MoreHorizontal, Pin, Plus, X } from "lucide-react";import { ChatLibraryError, openProject, patchProject } from "@/lib/chatLibraryApi";-import type { IdeProject, ProjectWorkspace } from "@/lib/agenticIdeApi";+import { reorderWorkspaces, type IdeProject, type ProjectWorkspace } from "@/lib/agenticIdeApi";import { useEventStore } from "@/store/events";import { useIdeProjectsStore } from "@/store/ideProjects";const EXPANSION_KEY = "jarvis.ide.projectExpansion.v1";+const WORKSPACE_DRAG_MIME = "application/x-jarvis-workspace-id";function readExpansion(): Record<string, boolean> {try {@@ -37,6 +38,9 @@ export function IdeProjectTree() {const [renamingId, setRenamingId] = useState<string | null>(null);const [draftName, setDraftName] = useState("");const [mutatingId, setMutatingId] = useState<string | null>(null);+ const [draggedId, setDraggedId] = useState<string | null>(null);+ const [dropTarget, setDropTarget] = useState<{ id: string; before: boolean } | null>(null);+ const [reordering, setReordering] = useState(false);const sawProjectSnapshot = useRef(false);const lastActiveId = useRef<string | null>(null);const lastPendingId = useRef<string | null>(null);@@ -113,6 +117,31 @@ export function IdeProjectTree() {finally { mutatingProjects.current.delete(project.id); setMutatingId(null); }};+ const moveWorkspace = async (sourceId: string, targetId: string, before: boolean) => {+ if (reordering || sourceId === targetId) return;+ const globalOrder = visible+ .flatMap((project) => project.workspaces)+ .filter((workspace) => workspace.status === "open")+ .map((workspace) => workspace.id);+ const sourceProject = visible.find((project) => project.workspaces.some((workspace) => workspace.id === sourceId));+ const targetProject = visible.find((project) => project.workspaces.some((workspace) => workspace.id === targetId));+ if (!sourceProject || !targetProject || sourceProject.id !== targetProject.id) return;+ const without = globalOrder.filter((id) => id !== sourceId);+ const targetIndex = without.indexOf(targetId);+ if (targetIndex < 0) return;+ const insertAt = before ? targetIndex : targetIndex + 1;+ const next = [...without.slice(0, insertAt), sourceId, ...without.slice(insertAt)];+ if (next.join("\u0000") === globalOrder.join("\u0000")) return;+ setReordering(true);+ try {+ await reorderWorkspaces(next);+ requestRefresh();+ } catch (error) { pushToast("error", (error as Error).message); }+ finally { setReordering(false); setDraggedId(null); setDropTarget(null); }+ };++ const clearDragState = () => { setDraggedId(null); setDropTarget(null); };+const projectRow = (project: IdeProject) => {const open = expansion[project.id] ?? (project.id === activeProject?.id || (!activeWorkspaceId && visible[0]?.id === project.id));const active = project.id === activeProject?.id;@@ -159,13 +188,61 @@ export function IdeProjectTree() {{project.workspaces.map((workspace: ProjectWorkspace) => {const pending = workspace.id === pendingWorkspaceId;const selected = workspace.id === activeWorkspaceId;- return <div key={workspace.id} className={`group/space flex min-h-10 items-center rounded-xl border border-transparent transition-colors hover:bg-muted/70 ${selected ? "border-border/50 bg-muted text-foreground" : ""} ${pending ? "bg-muted/80 text-foreground" : ""}`}>+ const draggable = workspace.status === "open" && !pending && !reordering;+ const isDragged = draggedId === workspace.id;+ const isDropBefore = dropTarget?.id === workspace.id && dropTarget.before;+ const isDropAfter = dropTarget?.id === workspace.id && !dropTarget.before;+ return <div key={workspace.id}+ data-testid={`ide-workspace-row-${workspace.id}`}+ draggable={draggable}+ onDragStart={(event) => {+ if (!draggable) { event.preventDefault(); return; }+ event.dataTransfer.setData(WORKSPACE_DRAG_MIME, workspace.id);+ event.dataTransfer.setData("text/plain", workspace.id);+ event.dataTransfer.effectAllowed = "move";+ setDraggedId(workspace.id);+ }}+ onDragEnd={clearDragState}+ onDragOver={(event) => {+ if (!draggedId || draggedId === workspace.id || workspace.status !== "open") return;+ if (!event.dataTransfer.types.includes(WORKSPACE_DRAG_MIME) && !event.dataTransfer.types.includes("text/plain")) return;+ event.preventDefault();+ event.dataTransfer.dropEffect = "move";+ const rect = event.currentTarget.getBoundingClientRect();+ const before = (event.clientY - rect.top) < rect.height / 2;+ setDropTarget((current) => current?.id === workspace.id && current.before === before ? current : { id: workspace.id, before });+ }}+ onDragLeave={(event) => {+ const next = event.relatedTarget as Node | null;+ if (next && event.currentTarget.contains(next)) return;+ setDropTarget((current) => current?.id === workspace.id ? null : current);+ }}+ onDrop={(event) => {+ if (!draggedId) return;+ event.preventDefault();+ const sourceId = event.dataTransfer.getData(WORKSPACE_DRAG_MIME) || draggedId;+ const rect = event.currentTarget.getBoundingClientRect();+ const before = (event.clientY - rect.top) < rect.height / 2;+ clearDragState();+ void moveWorkspace(sourceId, workspace.id, before);+ }}+ className={`group/space relative flex min-h-10 items-center rounded-xl border border-transparent transition-colors hover:bg-muted/70 ${selected ? "border-border/50 bg-muted text-foreground" : ""} ${pending ? "bg-muted/80 text-foreground" : ""} ${isDragged ? "opacity-40" : ""} ${isDropBefore ? "before:absolute before:-top-0.5 before:left-2 before:right-2 before:h-0.5 before:rounded-full before:bg-primary" : ""} ${isDropAfter ? "after:absolute after:-bottom-0.5 after:left-2 after:right-2 after:h-0.5 after:rounded-full after:bg-primary" : ""}`}><button type="button" data-testid={`ide-workspace-${workspace.id}`}aria-current={selected ? "page" : undefined} aria-busy={pending || undefined}- title={workspace.status === "closed" && !workspace.restorable ? "This workspace cannot be restored on this machine" : undefined}+ title={workspace.status === "closed" && !workspace.restorable ? "This workspace cannot be restored on this machine" : workspace.status === "open" ? `${workspace.name} — drag to reorder, or press Alt plus arrow keys to move` : undefined}disabled={workspace.status === "closed" && !workspace.restorable}onClick={() => activateWorkspace(workspace.id)}- className={`flex min-h-10 min-w-0 flex-1 items-center gap-2.5 rounded-xl px-2.5 text-left text-[15px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-45 ${selected || pending ? "text-foreground" : "text-muted-foreground"}`}>+ onKeyDown={(event) => {+ if (!event.altKey || workspace.status !== "open") return;+ if (event.key !== "ArrowUp" && event.key !== "ArrowDown") return;+ event.preventDefault();+ const openInProject = project.workspaces.filter((entry) => entry.status === "open");+ const index = openInProject.findIndex((entry) => entry.id === workspace.id);+ const neighbour = event.key === "ArrowUp" ? openInProject[index - 1] : openInProject[index + 1];+ if (!neighbour) return;+ void moveWorkspace(workspace.id, neighbour.id, event.key === "ArrowUp");+ }}+ className={`flex min-h-10 min-w-0 flex-1 items-center gap-2.5 rounded-xl px-2.5 text-left text-[15px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-45 ${selected || pending ? "text-foreground" : "text-muted-foreground"} ${draggable ? "cursor-grab active:cursor-grabbing" : ""}`}>{pending ? <Loader2 aria-hidden className="h-3.5 w-3.5 shrink-0 animate-spin" />: <span aria-hidden className={`h-2 w-2 shrink-0 rounded-full ${workspace.status === "open" && workspace.live_terminals > 0 ? "bg-emerald-500" : "bg-muted-foreground/40"}`} />}<span className="min-w-0 flex-1 truncate">{workspace.name}</span>diff --git a/jarvis/ui/web/frontend/src/components/agentic/WorkspaceBar.reorder.test.tsx b/jarvis/ui/web/frontend/src/components/agentic/WorkspaceBar.reorder.test.tsxnew file mode 100644index 0000000000..a2bcf39a49--- /dev/null+++ b/jarvis/ui/web/frontend/src/components/agentic/WorkspaceBar.reorder.test.tsx@@ -0,0 +1,94 @@+import { fireEvent, render, screen } from "@testing-library/react";+import { describe, expect, it, vi } from "vitest";+import { WorkspaceBar } from "./WorkspaceBar";+import type { WorkspaceCard } from "@/lib/agenticIdeApi";++function card(id: string, name: string): WorkspaceCard {+ return {+ id,+ folder: `C:/work/${name}`,+ name,+ branch: "main",+ terminals: 1,+ live_terminals: 1,+ focus_mode: false,+ created_at: 0,+ last_active_at: 0,+ active: false,+ };+}++const base = {+ workspaces: [card("w1", "First"), card("w2", "Second"), card("w3", "Third")],+ activeId: "w1",+ addingNew: false,+ maxWorkspaces: null,+ onSelect: () => {},+ onAdd: () => {},+ onRename: async () => true,+ onClose: () => {},+};++describe("WorkspaceBar tab reorder", () => {+ it("leaves tabs static when no reorder handler is wired", () => {+ render(<WorkspaceBar {...base} />);+ expect(screen.getByTestId("workspace-tab-drop-w1").getAttribute("draggable")).toBeNull();+ });++ it("makes tabs draggable when reordering is supported", () => {+ render(<WorkspaceBar {...base} onReorder={vi.fn()} />);+ expect(screen.getByTestId("workspace-tab-drop-w1").getAttribute("draggable")).toBe("true");+ });++ it("moves a tab with Alt plus arrow keys", () => {+ const onReorder = vi.fn();+ render(<WorkspaceBar {...base} onReorder={onReorder} />);+ fireEvent.keyDown(screen.getByTestId("workspace-tab-w1"), { key: "ArrowRight", altKey: true });+ expect(onReorder).toHaveBeenCalledWith(["w2", "w1", "w3"]);+ });++ it("ignores Alt plus arrow keys at the bar edges", () => {+ const onReorder = vi.fn();+ render(<WorkspaceBar {...base} onReorder={onReorder} />);+ fireEvent.keyDown(screen.getByTestId("workspace-tab-w1"), { key: "ArrowLeft", altKey: true });+ fireEvent.keyDown(screen.getByTestId("workspace-tab-w3"), { key: "ArrowRight", altKey: true });+ expect(onReorder).not.toHaveBeenCalled();+ });++ it("drags a tab after its neighbour", () => {+ const onReorder = vi.fn();+ render(<WorkspaceBar {...base} onReorder={onReorder} />);+ const source = screen.getByTestId("workspace-tab-drop-w1");+ const target = screen.getByTestId("workspace-tab-drop-w2");+ const data = new Map<string, string>();+ const dataTransfer = {+ types: ["application/x-jarvis-workspace-tab"],+ effectAllowed: "",+ dropEffect: "",+ setData: (kind: string, value: string) => void data.set(kind, value),+ getData: (kind: string) => data.get(kind) ?? "",+ };+ fireEvent.dragStart(source, { dataTransfer });+ target.getBoundingClientRect = () => ({ left: 0, width: 200, top: 0, height: 32 } as DOMRect);+ fireEvent.dragOver(target, { dataTransfer, clientX: 180 });+ fireEvent.drop(target, { dataTransfer, clientX: 180 });+ expect(onReorder).toHaveBeenCalledWith(["w2", "w1", "w3"]);+ });++ it("never treats a file drag as a tab reorder", () => {+ const onReorder = vi.fn();+ const onDropFiles = vi.fn();+ render(<WorkspaceBar {...base} onReorder={onReorder} onDropFiles={onDropFiles} />);+ const target = screen.getByTestId("workspace-tab-drop-w2");+ fireEvent.drop(target, {+ dataTransfer: {+ types: ["Files"],+ files: [],+ items: [],+ dropEffect: "none",+ getData: () => "",+ },+ });+ expect(onReorder).not.toHaveBeenCalled();+ });+});diff --git a/jarvis/ui/web/frontend/src/components/agentic/WorkspaceBar.tsx b/jarvis/ui/web/frontend/src/components/agentic/WorkspaceBar.tsxindex 024b561020..1a0f751be3 100644--- a/jarvis/ui/web/frontend/src/components/agentic/WorkspaceBar.tsx+++ b/jarvis/ui/web/frontend/src/components/agentic/WorkspaceBar.tsx@@ -73,6 +73,12 @@ interface WorkspaceBarProps {onAdd: () => void;onRename: (id: string, name: string) => Promise<boolean>;onClose: (id: string) => void;+ /**+ * Persist a drag-and-drop tab order. Absent, tabs are not draggable.+ *+ * Receives every open workspace id exactly once, in left-to-right order.+ */+ onReorder?: (workspaceIds: string[]) => void | Promise<void>;/*** A file was dropped on a workspace TAB. Left out, the tabs refuse drags and* the cursor says so rather than accepting a file nothing would do anything@@ -106,11 +112,13 @@ export function WorkspaceBar({onAdd,onRename,onClose,+ onReorder,onDropFiles,busy = false,actions,embedded = false,}: WorkspaceBarProps) {+ const WORKSPACE_TAB_MIME = "application/x-jarvis-workspace-tab";const t = useT();const barRef = useRef<HTMLDivElement>(null);// Which tab has its close button armed. One at a time, and cleared on every@@ -121,6 +129,8 @@ export function WorkspaceBar({// Which tab a file drag is currently over. One at a time — a drag has one// position — so this is an id rather than a set.const [dropTarget, setDropTarget] = useState<string | null>(null);+ const [draggedTab, setDraggedTab] = useState<string | null>(null);+ const [tabDropTarget, setTabDropTarget] = useState<{ id: string; before: boolean } | null>(null);const [barWidth, setBarWidth] = useState<number | null>(null);const [rovingFocusId, setRovingFocusId] = useState(addingNew ? ADD_TAB_FOCUS_ID : (activeId ?? workspaces[0]?.id ?? ADD_TAB_FOCUS_ID),@@ -136,6 +146,62 @@ export function WorkspaceBar({const clearDropTarget = useCallback(() => setDropTarget(null), []);useDragSessionEnd(dropTarget !== null, clearDropTarget);+ const clearTabDrag = useCallback(() => { setDraggedTab(null); setTabDropTarget(null); }, []);+ useDragSessionEnd(draggedTab !== null, clearTabDrag);++ const moveTab = (sourceId: string, targetId: string, before: boolean) => {+ if (!onReorder || sourceId === targetId) return;+ const order = workspaces.map((workspace) => workspace.id);+ const without = order.filter((id) => id !== sourceId);+ const targetIndex = without.indexOf(targetId);+ if (targetIndex < 0) return;+ const insertAt = before ? targetIndex : targetIndex + 1;+ const next = [...without.slice(0, insertAt), sourceId, ...without.slice(insertAt)];+ if (next.join("\u0000") === order.join("\u0000")) return;+ void onReorder(next);+ };++ /** Tab-reorder handlers. Empty when the owner does not persist an order. */+ const tabDragHandlersFor = (workspace: WorkspaceCard) => {+ if (!onReorder) return {};+ const draggable = !busy && editing !== workspace.id;+ return {+ draggable,+ onDragStart: (event: React.DragEvent) => {+ if (!draggable) { event.preventDefault(); return; }+ event.dataTransfer.setData(WORKSPACE_TAB_MIME, workspace.id);+ event.dataTransfer.setData("text/plain", workspace.id);+ event.dataTransfer.effectAllowed = "move";+ setDraggedTab(workspace.id);+ },+ onDragEnd: clearTabDrag,+ onDragOver: (event: React.DragEvent) => {+ if (!draggedTab || draggedTab === workspace.id) return;+ if (!event.dataTransfer.types.includes(WORKSPACE_TAB_MIME) && !event.dataTransfer.types.includes("text/plain")) return;+ if (dragCarriesFiles(event.dataTransfer)) return;+ event.preventDefault();+ event.dataTransfer.dropEffect = "move";+ const rect = event.currentTarget.getBoundingClientRect();+ const before = (event.clientX - rect.left) < rect.width / 2;+ setTabDropTarget((current) => current?.id === workspace.id && current.before === before ? current : { id: workspace.id, before });+ },+ onDragLeave: (event: React.DragEvent) => {+ const next = event.relatedTarget as Node | null;+ if (next && event.currentTarget.contains(next)) return;+ setTabDropTarget((current) => current?.id === workspace.id ? null : current);+ },+ onDrop: (event: React.DragEvent) => {+ if (!draggedTab || dragCarriesFiles(event.dataTransfer)) return;+ event.preventDefault();+ const sourceId = event.dataTransfer.getData(WORKSPACE_TAB_MIME) || draggedTab;+ const rect = event.currentTarget.getBoundingClientRect();+ const before = (event.clientX - rect.left) < rect.width / 2;+ clearTabDrag();+ moveTab(sourceId, workspace.id, before);+ },+ };+ };+/** Drag-drop handlers for one tab. Empty when the owner takes no drops. */const dropHandlersFor = (workspace: WorkspaceCard) => {if (!onDropFiles) return {};@@ -296,6 +362,9 @@ export function WorkspaceBar({const armed = confirming === workspace.id;const renaming = editing === workspace.id;const dropping = dropTarget === workspace.id;+ const tabDragging = draggedTab === workspace.id;+ const tabDropBefore = tabDropTarget?.id === workspace.id && tabDropTarget.before;+ const tabDropAfter = tabDropTarget?.id === workspace.id && !tabDropTarget.before;const summary = t(workspace.terminals === 1? "workspace_bar.workspace_summary_one"@@ -327,10 +396,13 @@ export function WorkspaceBar({key={workspace.id}data-testid={`workspace-tab-drop-${workspace.id}`}{...dropHandlersFor(workspace)}+ {...tabDragHandlersFor(workspace)}title={onDropFiles? `${workspace.folder} — drop a screenshot or document here to send it to this workspace`- : workspace.folder+ : onReorder+ ? `${workspace.folder} — drag to reorder`+ : workspace.folder}/** The selected tab is a RAISED tab, marked once.@@ -357,6 +429,10 @@ export function WorkspaceBar({: selected? "border-border bg-secondary": "border-transparent hover:bg-secondary",+ tabDragging && "opacity-40",+ tabDropBefore && "before:absolute before:-left-0.5 before:bottom-1 before:top-1 before:w-0.5 before:rounded-full before:bg-primary",+ tabDropAfter && "after:absolute after:-right-0.5 after:bottom-1 after:top-1 after:w-0.5 after:rounded-full after:bg-primary",+ onReorder && !busy && "cursor-grab active:cursor-grabbing",)}>{renaming ? (@@ -425,6 +501,14 @@ export function WorkspaceBar({if (!selected) onSelect(workspace.id);}}onFocus={() => setRovingFocusId(workspace.id)}+ onKeyDown={(event) => {+ if (!onReorder || !event.altKey) return;+ if (event.key !== "ArrowLeft" && event.key !== "ArrowRight") return;+ event.preventDefault();+ const neighbour = event.key === "ArrowLeft" ? workspaces[index - 1] : workspaces[index + 1];+ if (!neighbour) return;+ moveTab(workspace.id, neighbour.id, event.key === "ArrowLeft");+ }}className={cn("flex min-w-0 items-center text-left disabled:cursor-not-allowed disabled:opacity-60",compact ? "flex-1 justify-center gap-1" : "gap-2",diff --git a/jarvis/ui/web/frontend/src/lib/agenticIdeApi.ts b/jarvis/ui/web/frontend/src/lib/agenticIdeApi.tsindex 0d97c80ec9..6f8d13a5cb 100644--- a/jarvis/ui/web/frontend/src/lib/agenticIdeApi.ts+++ b/jarvis/ui/web/frontend/src/lib/agenticIdeApi.ts@@ -429,6 +429,23 @@ export async function reorderIdeTerminals(id: string, terminalIds: string[]): Prreturn ((await res.json()) as { state: IdeState }).state;}+/**+ * Persist a drag-and-drop workspace tab order.+ *+ * `workspaceIds` must contain every open workspace exactly once, in+ * left-to-right order. Nothing starts, stops or restarts — only the tab+ * positions move, and the order survives restarts via the resume snapshot.+ */+export async function reorderWorkspaces(workspaceIds: string[]): Promise<IdeState> {+ const res = await fetch("/api/agentic-ide/workspaces/order", {+ method: "PUT",+ headers: { "Content-Type": "application/json" },+ body: JSON.stringify({ workspace_ids: workspaceIds }),+ });+ if (!res.ok) throw new Error(await detail(res));+ return ((await res.json()) as { state: IdeState }).state;+}+/*** Which subscription new terminals of one coding CLI open on.*diff --git a/tests/unit/agentic_ide/test_workspace_graph.py b/tests/unit/agentic_ide/test_workspace_graph.pyindex c1be17137c..73d5903c69 100644--- a/tests/unit/agentic_ide/test_workspace_graph.py+++ b/tests/unit/agentic_ide/test_workspace_graph.py@@ -285,3 +285,41 @@ async def test_initial_grid_order_survives_restore_at_every_supported_size(assert [term.history_id for term in restored.terminals] == idsassert max(term.column for term in restored.terminals) <= 3assert max(term.slot for term in restored.terminals) <= 1+++async def test_workspace_tab_order_moves_without_touching_panes(registry, tmp_path):+ first = await registry.start(str(tmp_path), [{"agent": "claude"}], name="First")+ second = await registry.start(str(tmp_path), [{"agent": "claude"}], name="Second")+ third = await registry.start(str(tmp_path), [{"agent": "claude"}], name="Third")+ assert [space.id for space in registry.sessions] == [first.id, second.id, third.id]+ result = await routes.reorder_workspaces(+ request(),+ routes.WorkspaceOrderRequest(workspace_ids=[third.id, first.id, second.id]),+ )+ assert [space.id for space in registry.sessions] == [third.id, first.id, second.id]+ assert [card["id"] for card in result["state"]["workspaces"]] == [+ third.id,+ first.id,+ second.id,+ ]+ # Active workspace stays on screen; only the tab positions move.+ assert result["state"]["active_id"] == third.id+ assert first.terminals[0].history_id != second.terminals[0].history_id+ graph = workspace_catalog.project_graph(registry)+ names = [card["name"] for card in graph["projects"][0]["workspaces"]]+ assert names == ["Third", "First", "Second"]++[email protected]("invalid", [[], ["unknown"], ["duplicate", "duplicate"]])+async def test_invalid_workspace_order_is_rejected_without_mutation(registry, tmp_path, invalid):+ first = await registry.start(str(tmp_path), [{"agent": "claude"}], name="First")+ second = await registry.start(str(tmp_path), [{"agent": "claude"}], name="Second")+ before = [space.id for space in registry.sessions]+ with pytest.raises(HTTPException) as caught:+ await routes.reorder_workspaces(+ request(),+ routes.WorkspaceOrderRequest(workspace_ids=invalid),+ )+ assert caught.value.status_code == 422+ assert [space.id for space in registry.sessions] == before+ assert {space.id for space in registry.sessions} == {first.id, second.id}