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 folders in the sidebar
rubenluetke10-beep80c3d2b99a70
diff --git a/jarvis/ui/web/frontend/src/components/agentic/IdeProjectTree.project-reorder.test.tsx b/jarvis/ui/web/frontend/src/components/agentic/IdeProjectTree.project-reorder.test.tsxnew file mode 100644index 0000000000..f6fdc05aac--- /dev/null+++ b/jarvis/ui/web/frontend/src/components/agentic/IdeProjectTree.project-reorder.test.tsx@@ -0,0 +1,138 @@+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 reorderProjects = vi.hoisted(() => vi.fn());+const reorderWorkspaces = vi.hoisted(() => vi.fn());+vi.mock("@/lib/chatLibraryApi", () => ({+ patchProject: vi.fn(async () => ({})),+ openProject: vi.fn(async () => ({ id: "p1" })),+ reorderProjects,+ ChatLibraryError: class extends Error {+ constructor(message: string, readonly status: number) {+ super(message);+ }+ },+}));+vi.mock("@/lib/agenticIdeApi", () => ({ reorderWorkspaces }));++function folder(id: string, name: string, pinned = false): IdeProject {+ return {+ id,+ path: `/${id}`,+ name,+ color: null,+ pinned,+ archived: false,+ scratch: false,+ created_at: 0,+ last_opened_at: 0,+ exists: true,+ chats: 0,+ workspaces: [],+ } as IdeProject;+}++beforeEach(() => {+ localStorage.clear();+ reorderProjects.mockReset().mockResolvedValue([]);+ reorderWorkspaces.mockReset().mockResolvedValue({});+ useIdeProjectsStore.setState({+ projects: [folder("p1", "AiGrokAgents"), folder("p2", "Personal Jarvis"), folder("p3", "workspace")],+ activeWorkspaceId: null,+ pendingWorkspaceId: null,+ refreshRequest: null,+ action: null,+ });+});+afterEach(cleanup);++it("marks folder headers draggable with a reorder hint", () => {+ render(<IdeProjectTree />);+ const header = screen.getByTestId("ide-project-header-p1");+ expect(header.getAttribute("draggable")).toBe("true");+ expect(screen.getByRole("button", { name: "Collapse AiGrokAgents" }).getAttribute("title")).toContain(+ "drag to reorder",+ );+});++it("moves a folder with Alt plus arrow keys", async () => {+ render(<IdeProjectTree />);+ fireEvent.keyDown(screen.getByRole("button", { name: "Collapse AiGrokAgents" }), {+ key: "ArrowDown",+ altKey: true,+ });+ await waitFor(() => expect(reorderProjects).toHaveBeenCalledWith(["p2", "p1", "p3"]));+ await waitFor(() => expect(useIdeProjectsStore.getState().refreshRequest?.nonce).toBe(1));+});++it("ignores Alt plus arrow keys at the folder list edges", () => {+ render(<IdeProjectTree />);+ fireEvent.keyDown(screen.getByRole("button", { name: "Collapse AiGrokAgents" }), {+ key: "ArrowUp",+ altKey: true,+ });+ fireEvent.keyDown(screen.getByRole("button", { name: "Expand workspace" }), {+ key: "ArrowDown",+ altKey: true,+ });+ expect(reorderProjects).not.toHaveBeenCalled();+});++it("drags a folder below its neighbour", async () => {+ render(<IdeProjectTree />);+ const source = screen.getByTestId("ide-project-header-p1");+ const target = screen.getByTestId("ide-project-header-p2");+ const data = new Map<string, string>();+ const dataTransfer = {+ types: ["application/x-jarvis-project-id"],+ effectAllowed: "",+ dropEffect: "",+ setData: (kind: string, value: string) => void data.set(kind, value),+ getData: (kind: string) => data.get(kind) ?? "",+ };+ fireEvent.dragStart(source, { dataTransfer });+ target.getBoundingClientRect = () => ({ top: 0, height: 44, left: 0, width: 300 } as DOMRect);+ fireEvent.dragOver(target, { dataTransfer, clientY: 40 });+ fireEvent.drop(target, { dataTransfer, clientY: 40 });+ await waitFor(() => expect(reorderProjects).toHaveBeenCalledWith(["p2", "p1", "p3"]));+});++it("keeps a pinned folder inside its own section", () => {+ useIdeProjectsStore.setState({+ projects: [folder("p1", "AiGrokAgents", true), folder("p2", "Personal Jarvis")],+ });+ render(<IdeProjectTree />);+ const source = screen.getByTestId("ide-project-header-p1");+ const target = screen.getByTestId("ide-project-header-p2");+ const data = new Map<string, string>();+ const dataTransfer = {+ types: ["application/x-jarvis-project-id"],+ effectAllowed: "",+ dropEffect: "",+ setData: (kind: string, value: string) => void data.set(kind, value),+ getData: (kind: string) => data.get(kind) ?? "",+ };+ fireEvent.dragStart(source, { dataTransfer });+ target.getBoundingClientRect = () => ({ top: 0, height: 44, left: 0, width: 300 } as DOMRect);+ fireEvent.dragOver(target, { dataTransfer, clientY: 40 });+ fireEvent.drop(target, { dataTransfer, clientY: 40 });+ expect(reorderProjects).not.toHaveBeenCalled();+});++it("shows a toast instead of reordering when the backend rejects", async () => {+ reorderProjects.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.getByRole("button", { name: "Collapse AiGrokAgents" }), {+ key: "ArrowDown",+ altKey: true,+ });+ });+ await waitFor(() => expect(pushToast).toHaveBeenCalledWith("error", "stale list"));+});diff --git a/jarvis/ui/web/frontend/src/lib/chatLibraryApi.ts b/jarvis/ui/web/frontend/src/lib/chatLibraryApi.tsindex 21a4f60b4f..af63195651 100644--- a/jarvis/ui/web/frontend/src/lib/chatLibraryApi.ts+++ b/jarvis/ui/web/frontend/src/lib/chatLibraryApi.ts@@ -18,6 +18,8 @@ export interface ChatProject {name: string;color: string | null;pinned: boolean;+ /** Manual sidebar position, set by drag and drop. Absent on an older backend. */+ position?: number;archived: boolean;created_at: number;last_opened_at: number;@@ -136,6 +138,21 @@ export async function deleteProject(projectId: string): Promise<boolean> {return body.removed;}+/**+ * Persist a drag-and-drop folder order in the sidebar.+ *+ * `projectIds` carries the visible projects front to back. Pinning still+ * groups first: within each section the given order wins, and a folder never+ * leaves its section by being dragged.+ */+export async function reorderProjects(projectIds: string[]): Promise<ChatProject[]> {+ const body = await request<{ projects: ChatProject[] }>("/projects/order", {+ method: "PUT",+ body: JSON.stringify({ project_ids: projectIds }),+ });+ return body.projects;+}+/** One project's chats. Called when a project is opened, never on mount. */export async function fetchChats(projectId: string,