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): richer project and workspace menus in the sidebar
rubenluetke10-beep1826b92677c0
diff --git a/jarvis/ui/web/chat_library_routes.py b/jarvis/ui/web/chat_library_routes.pyindex ab3f4dd1be..5cb719b99f 100644--- a/jarvis/ui/web/chat_library_routes.py+++ b/jarvis/ui/web/chat_library_routes.py@@ -37,7 +37,7 @@ from __future__ import annotationsfrom pathlib import Pathfrom typing import Any-from fastapi import APIRouter, HTTPException+from fastapi import APIRouter, HTTPException, Requestfrom pydantic import BaseModel, Fieldfrom jarvis.agentic_ide import library, resume_store@@ -272,6 +272,52 @@ def delete_project(project_id: str) -> RemovedOut:return RemovedOut(removed=removed or forgotten > 0)+class RevealedOut(BaseModel):+ opened: bool+++def _project_folder(project_id: str) -> str | None:+ """The folder of a project, including one known only from its workspaces.++ Older installs derive a project row from a remembered workspace without a+ library entry, and the sidebar offers the same actions on both kinds.+ """+ project = library.get_project(project_id)+ if project is not None:+ return project.path+ from jarvis.agentic_ide import workspace_catalog+ from jarvis.agentic_ide.session import get_registry++ for entry in workspace_catalog.project_graph(get_registry())["projects"]:+ if entry["id"] == project_id:+ return str(entry["path"])+ return None+++ "/projects/{project_id}/reveal",+ response_model=RevealedOut,+ summary="Open a project's folder in the file manager",+)+def reveal_project(request: Request, project_id: str) -> RevealedOut:+ """Open the project's folder in Explorer, Finder or the Linux file manager.++ Desktop-only: on a headless host the folder is on the server, not in front+ of the user, so the route 404s there like the other native file actions.+ The path comes from the stored project, never from the client.+ """+ if not bool(getattr(request.app.state, "native_file_actions", False)):+ raise HTTPException(status_code=404, detail="native-file-actions-disabled")+ folder = _project_folder(project_id)+ if folder is None:+ raise HTTPException(status_code=404, detail="No such project")+ if not _folder_exists(folder):+ raise HTTPException(status_code=404, detail="The project folder is not reachable.")+ from jarvis.platform.open_path import open_file++ return RevealedOut(opened=open_file(Path(folder)))++# --------------------------------------------------------------------------- ## chats# --------------------------------------------------------------------------- #diff --git a/jarvis/ui/web/frontend/src/components/agentic/IdeProjectTree.test.tsx b/jarvis/ui/web/frontend/src/components/agentic/IdeProjectTree.test.tsxindex d9b7be738b..375be8d895 100644--- a/jarvis/ui/web/frontend/src/components/agentic/IdeProjectTree.test.tsx+++ b/jarvis/ui/web/frontend/src/components/agentic/IdeProjectTree.test.tsx@@ -9,7 +9,10 @@ const patchProject = vi.hoisted(() => vi.fn());const openProject = vi.hoisted(() => vi.fn());const deleteProject = vi.hoisted(() => vi.fn());const reorderProjects = vi.hoisted(() => vi.fn());-vi.mock("@/lib/chatLibraryApi", () => ({ patchProject, openProject, deleteProject, reorderProjects,+const revealProject = vi.hoisted(() => vi.fn());+const robustCopy = vi.hoisted(() => vi.fn());+vi.mock("@/lib/clipboard", () => ({ robustCopy }));+vi.mock("@/lib/chatLibraryApi", () => ({ patchProject, openProject, deleteProject, reorderProjects, revealProject,ChatLibraryError: class extends Error { constructor(message: string, readonly status: number) { super(message); } },}));@@ -32,6 +35,8 @@ beforeEach(() => {openProject.mockReset().mockResolvedValue({ id: "p1" });deleteProject.mockReset().mockResolvedValue(true);reorderProjects.mockReset().mockResolvedValue([]);+ revealProject.mockReset().mockResolvedValue(true);+ robustCopy.mockReset().mockResolvedValue(true);renameWorkspace.mockReset().mockResolvedValue({});closeWorkspace.mockReset().mockResolvedValue({});removeWorkspace.mockReset().mockResolvedValue({});@@ -102,13 +107,19 @@ it("marks a queued workspace before the active workspace changes", () => {expect(row.textContent).toContain("Switching workspace");});-it("offers workspace options only on the active row and dispatches Jarvis Live", () => {- const second = { ...project("p2"), workspaces: [{ ...project("p2").workspaces[0], name: "Other" }] };- useIdeProjectsStore.setState({ projects: [project(), second] });+it("gives every workspace row a ⋯ menu and dispatches Jarvis Live", () => {+ const base = project();+ useIdeProjectsStore.setState({ projects: [{ ...base, workspaces: [...base.workspaces, { ...base.workspaces[0], id: "p1-w2", name: "Other" }] }] });render(<IdeProjectTree />);- fireEvent.click(screen.getByRole("button", { name: "Workspace options for Work" }));+ // Not only the active row: a background workspace has actions too.+ fireEvent.click(screen.getByRole("button", { name: "Workspace actions for Other" }));+ expect(screen.getByRole("menu", { name: "Workspace actions for Other" })).toBeDefined();+ fireEvent.click(screen.getByRole("button", { name: "Workspace actions for Other" }));+ expect(screen.queryByRole("menu")).toBeNull();+ fireEvent.click(screen.getByRole("button", { name: "Workspace actions for Work" }));+ fireEvent.click(screen.getByRole("menuitem", { name: "Workspace options…" }));expect(useIdeProjectsStore.getState().action).toMatchObject({ kind: "workspace-options", workspaceId: "p1-w1" });- expect(screen.queryByRole("button", { name: "Workspace options for Other" })).toBeNull();+ expect(screen.queryByRole("menu")).toBeNull();fireEvent.click(screen.getByRole("button", { name: "Jarvis Live" }));expect(useIdeProjectsStore.getState().action?.kind).toBe("toggle-voice");});@@ -116,11 +127,11 @@ it("offers workspace options only on the active row and dispatches Jarvis Live",it("pins and renames via the project API, then requests a guarded refresh", async () => {render(<IdeProjectTree />);fireEvent.click(screen.getByRole("button", { name: "Project actions for App" }));- fireEvent.click(screen.getByRole("button", { name: "Pin project" }));+ fireEvent.click(screen.getByRole("menuitem", { name: "Pin project" }));await waitFor(() => expect(patchProject).toHaveBeenCalledWith("p1", { pinned: true }));await waitFor(() => expect(useIdeProjectsStore.getState().refreshRequest?.nonce).toBe(1));fireEvent.click(screen.getByRole("button", { name: "Project actions for App" }));- fireEvent.click(screen.getByRole("button", { name: "Rename project" }));+ fireEvent.click(screen.getByRole("menuitem", { name: "Rename project" }));fireEvent.change(screen.getByRole("textbox", { name: "Rename App" }), { target: { value: "Better App" } });fireEvent.click(screen.getByRole("button", { name: "Save App" }));await waitFor(() => expect(patchProject).toHaveBeenCalledWith("p1", { name: "Better App" }));@@ -131,7 +142,7 @@ it("registers a legacy derived project only after PATCH 404, then retries once",patchProject.mockRejectedValueOnce(new ChatLibraryError("missing", 404)).mockResolvedValueOnce({});render(<IdeProjectTree />);fireEvent.click(screen.getByRole("button", { name: "Project actions for App" }));- fireEvent.click(screen.getByRole("button", { name: "Pin project" }));+ fireEvent.click(screen.getByRole("menuitem", { name: "Pin project" }));await waitFor(() => expect(patchProject).toHaveBeenCalledTimes(2));expect(openProject).toHaveBeenCalledTimes(1);expect(openProject).toHaveBeenCalledWith("/p1");@@ -143,7 +154,7 @@ it("does not register or retry on non-404 metadata errors", async () => {patchProject.mockRejectedValueOnce(new ChatLibraryError("denied", 403));render(<IdeProjectTree />);fireEvent.click(screen.getByRole("button", { name: "Project actions for App" }));- fireEvent.click(screen.getByRole("button", { name: "Pin project" }));+ fireEvent.click(screen.getByRole("menuitem", { name: "Pin project" }));await waitFor(() => expect(patchProject).toHaveBeenCalledTimes(1));expect(openProject).not.toHaveBeenCalled();expect(useIdeProjectsStore.getState().refreshRequest).toBeNull();@@ -154,8 +165,11 @@ it("submits only one metadata mutation when a project action is pressed twice",patchProject.mockImplementation(() => new Promise((resolve) => { finish = resolve; }));render(<IdeProjectTree />);fireEvent.click(screen.getByRole("button", { name: "Project actions for App" }));- const pin = screen.getByRole("button", { name: "Pin project" });- act(() => { fireEvent.click(pin); fireEvent.click(pin); });+ fireEvent.click(screen.getByRole("menuitem", { name: "Pin project" }));+ // The menu closes on the first press; reopening and pressing again while the+ // first request is still in flight must not send a second one.+ fireEvent.click(screen.getByRole("button", { name: "Project actions for App" }));+ act(() => { fireEvent.click(screen.getByRole("menuitem", { name: "Pin project" })); });expect(patchProject).toHaveBeenCalledTimes(1);act(() => finish({}));await waitFor(() => expect(useIdeProjectsStore.getState().refreshRequest?.nonce).toBe(1));@@ -254,3 +268,43 @@ it("removes open workspaces when a project is deleted", async () => {await waitFor(() => expect(deleteProject).toHaveBeenCalledWith("p1"));await waitFor(() => expect(useIdeProjectsStore.getState().refreshRequest?.nonce).toBe(1));});++it("groups project actions and runs folder actions", async () => {+ render(<IdeProjectTree />);+ fireEvent.click(screen.getByRole("button", { name: "Project actions for App" }));+ const menu = screen.getByRole("menu", { name: "Project actions for App" });+ expect(menu.querySelectorAll('[role="group"]').length).toBe(3);+ expect(Array.from(menu.querySelectorAll('[role="menuitem"]')).map((item) => item.textContent)).toEqual([+ "New workspace", "Open folder", "Copy folder path", "Rename project", "Pin project", "Delete project",+ ]);+ fireEvent.click(screen.getByRole("menuitem", { name: "Open folder" }));+ await waitFor(() => expect(revealProject).toHaveBeenCalledWith("p1"));+ fireEvent.click(screen.getByRole("button", { name: "Project actions for App" }));+ fireEvent.click(screen.getByRole("menuitem", { name: "Copy folder path" }));+ await waitFor(() => expect(robustCopy).toHaveBeenCalledWith("/p1"));+});++it("closes an open workspace but keeps it, separately from removing it", async () => {+ render(<IdeProjectTree />);+ fireEvent.click(screen.getByRole("button", { name: "Workspace actions for Work" }));+ fireEvent.click(screen.getByTestId("ide-workspace-menu-stop"));+ expect(screen.getByRole("dialog", { name: "Close Work?" })).toBeDefined();+ fireEvent.click(screen.getByTestId("ide-workspace-confirm-close-confirm"));+ await waitFor(() => expect(closeWorkspace).toHaveBeenCalledWith("p1-w1"));+ expect(removeWorkspace).not.toHaveBeenCalled();+});++it("offers no close or rename on a closed workspace", () => {+ useIdeProjectsStore.setState({+ projects: [{+ ...project(),+ workspaces: [{ ...project().workspaces[0], status: "closed", live_terminals: 0 } as IdeProject["workspaces"][number]],+ }],+ activeWorkspaceId: null,+ });+ render(<IdeProjectTree />);+ fireEvent.contextMenu(screen.getByTestId("ide-workspace-row-p1-w1"));+ expect(screen.queryByTestId("ide-workspace-menu-stop")).toBeNull();+ expect((screen.getByRole("menuitem", { name: /Rename workspace/ }) as HTMLButtonElement).disabled).toBe(true);+ expect(screen.getByRole("menuitem", { name: "Reopen workspace" })).toBeDefined();+});diff --git a/jarvis/ui/web/frontend/src/components/agentic/IdeProjectTree.tsx b/jarvis/ui/web/frontend/src/components/agentic/IdeProjectTree.tsxindex 97bd9ecf0e..981384bd01 100644--- a/jarvis/ui/web/frontend/src/components/agentic/IdeProjectTree.tsx+++ b/jarvis/ui/web/frontend/src/components/agentic/IdeProjectTree.tsx@@ -1,8 +1,9 @@import { useEffect, useLayoutEffect, useRef, useState, type KeyboardEvent as ReactKeyboardEvent } from "react";import { createPortal } from "react-dom";-import { Check, ChevronDown, ChevronRight, Folder, FolderPlus, Loader2, Mic, MoreHorizontal, Pencil, Pin, Plus, Trash2, X } from "lucide-react";-import { ChatLibraryError, deleteProject, openProject, patchProject, reorderProjects } from "@/lib/chatLibraryApi";-import { removeWorkspace, renameWorkspace, IdeApiError, reorderWorkspaces, type IdeProject, type ProjectWorkspace } from "@/lib/agenticIdeApi";+import { ArrowUpRight, Check, ChevronDown, ChevronRight, Copy, Folder, FolderOpen, FolderPlus, Loader2, Mic, MoreHorizontal, Pencil, Pin, PinOff, Plus, Power, SlidersHorizontal, Trash2, X, type LucideIcon } from "lucide-react";+import { ChatLibraryError, deleteProject, openProject, patchProject, reorderProjects, revealProject } from "@/lib/chatLibraryApi";+import { robustCopy } from "@/lib/clipboard";+import { closeWorkspace, removeWorkspace, renameWorkspace, IdeApiError, reorderWorkspaces, type IdeProject, type ProjectWorkspace } from "@/lib/agenticIdeApi";import { useEventStore } from "@/store/events";import { useIdeProjectsStore } from "@/store/ideProjects";@@ -24,6 +25,17 @@ function reorderErrorMessage(error: unknown): string {return error instanceof Error ? error.message : String(error);}+/** Why opening a folder failed, in the user's terms. */+function revealErrorMessage(error: unknown): string {+ if (error instanceof ChatLibraryError && error.message === "native-file-actions-disabled") {+ return "Opening folders works in the desktop app only.";+ }+ if (error instanceof ChatLibraryError && (error.status === 405 || (error.status === 404 && error.message === "Not Found"))) {+ return REORDER_NEEDS_RESTART;+ }+ return error instanceof Error ? error.message : String(error);+}+/*** A removal failure in the user's terms. FastAPI answers an unknown route with* a bare "Not Found" (the route's own 404 says which workspace is missing), so@@ -62,7 +74,6 @@ export function IdeProjectTree() {const requestRefresh = useIdeProjectsStore((state) => state.requestRefresh);const pushToast = useEventStore((state) => state.pushToast);const [expansion, setExpansion] = useState(readExpansion);- const [menuId, setMenuId] = useState<string | null>(null);const [renamingId, setRenamingId] = useState<string | null>(null);const [draftName, setDraftName] = useState("");const [mutatingId, setMutatingId] = useState<string | null>(null);@@ -78,7 +89,8 @@ export function IdeProjectTree() {>(null);const [renamingWorkspaceId, setRenamingWorkspaceId] = useState<string | null>(null);const [draftWorkspaceName, setDraftWorkspaceName] = useState("");- const [confirmWorkspace, setConfirmWorkspace] = useState<{ projectId: string; workspaceId: string } | null>(null);+ // "close" keeps a restorable row; "remove" makes the row go away for good.+ const [confirmWorkspace, setConfirmWorkspace] = useState<{ projectId: string; workspaceId: string; mode: "close" | "remove" } | null>(null);const [confirmProject, setConfirmProject] = useState<string | null>(null);const [confirmBusy, setConfirmBusy] = useState(false);const sawProjectSnapshot = useRef(false);@@ -124,17 +136,6 @@ export function IdeProjectTree() {if (ids.size > 0) knownProjectIds.current = ids;}, [projects]);- useEffect(() => {- if (!menuId) return;- const dismiss = (event: PointerEvent) => {- if (!(event.target instanceof Element) || event.target.closest("[data-project-menu]")?.getAttribute("data-project-menu") !== menuId) setMenuId(null);- };- const onKey = (event: KeyboardEvent) => { if (event.key === "Escape") setMenuId(null); };- document.addEventListener("pointerdown", dismiss);- document.addEventListener("keydown", onKey);- return () => { document.removeEventListener("pointerdown", dismiss); document.removeEventListener("keydown", onKey); };- }, [menuId]);-const mutate = async (project: IdeProject, changes: { pinned?: boolean; name?: string }) => {if (mutatingProjects.current.has(project.id)) return;mutatingProjects.current.add(project.id);@@ -150,7 +151,6 @@ export function IdeProjectTree() {await openProject(project.path);await patchProject(project.id, changes);}- setMenuId(null);setRenamingId(null);requestRefresh();} catch (error) { pushToast("error", (error as Error).message); }@@ -188,17 +188,38 @@ export function IdeProjectTree() {// here so a project row offers project actions instead of text editing.event.preventDefault();event.stopPropagation();- setMenuId(null);setContextMenu({ kind: "project", projectId, x: event.clientX, y: event.clientY });};const openWorkspaceMenu = (event: React.MouseEvent, projectId: string, workspaceId: string) => {event.preventDefault();event.stopPropagation();- setMenuId(null);setContextMenu({ kind: "workspace", projectId, workspaceId, x: event.clientX, y: event.clientY });};+ /** Open (or close again) the same menu as right-click, hanging under a ⋯ button. */+ const toggleAnchoredMenu = (+ event: React.MouseEvent<HTMLElement>,+ target: { kind: "project"; projectId: string } | { kind: "workspace"; projectId: string; workspaceId: string },+ ) => {+ event.stopPropagation();+ const same = contextMenu !== null && contextMenu.kind === target.kind && contextMenu.projectId === target.projectId+ && (target.kind === "project" || (contextMenu.kind === "workspace" && contextMenu.workspaceId === target.workspaceId));+ if (same) { setContextMenu(null); return; }+ const rect = event.currentTarget.getBoundingClientRect();+ setContextMenu({ ...target, x: rect.right - TREE_MENU_WIDTH, y: rect.bottom + 4 });+ };++ const copyPath = async (path: string) => {+ const copied = await robustCopy(path);+ pushToast(copied ? "success" : "error", copied ? "Folder path copied" : "Could not copy the folder path");+ };++ const revealFolder = async (projectId: string) => {+ try { await revealProject(projectId); }+ catch (error) { pushToast("error", revealErrorMessage(error)); }+ };+const submitWorkspaceRename = async (workspace: ProjectWorkspace) => {const name = draftWorkspaceName.trim();if (!name || name === workspace.name) {@@ -230,7 +251,8 @@ export function IdeProjectTree() {}setConfirmBusy(true);try {- await removeWorkspace(target.workspace.id);+ if (confirmWorkspace.mode === "close") await closeWorkspace(target.workspace.id);+ else await removeWorkspace(target.workspace.id);setConfirmWorkspace(null);setContextMenu(null);requestRefresh();@@ -260,7 +282,6 @@ export function IdeProjectTree() {await deleteProject(target.id);setConfirmProject(null);setContextMenu(null);- setMenuId(null);requestRefresh();} catch (error) {pushToast("error", removalErrorMessage(error));@@ -308,6 +329,7 @@ export function IdeProjectTree() {const isProjectDragged = draggedProjectId === project.id;const isProjectDropBefore = projectDropTarget?.id === project.id && projectDropTarget.before;const isProjectDropAfter = projectDropTarget?.id === project.id && !projectDropTarget.before;+ const projectMenuOpen = contextMenu?.kind === "project" && contextMenu.projectId === project.id;return <div key={project.id} className="mb-0.5" data-testid={`ide-project-${project.id}`}><div draggable={projectDraggable}data-testid={`ide-project-header-${project.id}`}@@ -371,22 +393,17 @@ export function IdeProjectTree() {<span className="min-w-0 flex-1 truncate">{project.name}</span>{count > 0 && <span className="rounded-md bg-background/50 px-1.5 py-0.5 text-xs tabular-nums text-muted-foreground" aria-label={`${count} agent ${count === 1 ? "session" : "sessions"}`}>{count}</span>}</button>- <div className={`absolute right-1 top-1/2 flex -translate-y-1/2 items-center transition-opacity ${menuId === project.id ? "opacity-100" : "pointer-events-none opacity-0 group-hover:pointer-events-auto group-hover:opacity-100 group-focus-within:pointer-events-auto group-focus-within:opacity-100 [@media(hover:none)]:pointer-events-auto [@media(hover:none)]:opacity-100"}`} data-project-menu={project.id}>- <button type="button" aria-label={`Project actions for ${project.name}`} title="Project actions" aria-expanded={menuId === project.id}- onClick={() => setMenuId((current) => current === project.id ? null : project.id)}- className="rounded p-1.5 text-muted-foreground/70 hover:bg-background/70 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring">+ <div className={`absolute right-1 top-1/2 flex -translate-y-1/2 items-center transition-opacity ${projectMenuOpen ? "opacity-100" : "pointer-events-none opacity-0 group-hover:pointer-events-auto group-hover:opacity-100 group-focus-within:pointer-events-auto group-focus-within:opacity-100 [@media(hover:none)]:pointer-events-auto [@media(hover:none)]:opacity-100"}`} data-project-menu={project.id}>+ <button type="button" aria-label={`Project actions for ${project.name}`} title="Project actions" aria-haspopup="menu" aria-expanded={projectMenuOpen}+ data-tree-menu-anchor+ onClick={(event) => toggleAnchoredMenu(event, { kind: "project", projectId: project.id })}+ className={`rounded p-1.5 hover:bg-background/70 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring ${projectMenuOpen ? "bg-background/70 text-foreground" : "text-muted-foreground/70"}`}>{working ? <Loader2 className="h-3.5 w-3.5 animate-spin" /> : <MoreHorizontal className="h-3.5 w-3.5" />}</button><button type="button" aria-label={`New workspace in ${project.name}`} title="New workspace" onClick={() => newWorkspace(project.id)}className="rounded p-1.5 text-muted-foreground/70 hover:bg-background/70 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"><Plus className="h-3.5 w-3.5" /></button>- {menuId === project.id && <div className="absolute right-0 top-full z-30 mt-1 min-w-40 rounded-lg border border-border bg-popover p-1 text-popover-foreground shadow-lg">- <button type="button" disabled={working} onClick={() => void mutate(project, { pinned: !project.pinned })}- className="flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-xs hover:bg-muted disabled:opacity-50"><Pin className="h-3.5 w-3.5" />{project.pinned ? "Unpin project" : "Pin project"}</button>- <button type="button" disabled={working} onClick={() => { setMenuId(null); setDraftName(project.name); setRenamingId(project.id); }}- className="block w-full rounded px-2 py-1.5 text-left text-xs hover:bg-muted disabled:opacity-50">Rename project</button>- </div>}</div></>}</div>@@ -498,11 +515,15 @@ export function IdeProjectTree() {<span className="text-xs tabular-nums opacity-70">{workspace.terminals}</span>{pending && <span className="sr-only">Switching workspace</span>}</button>- {selected && <button type="button" aria-label={`Workspace options for ${workspace.name}`} title="Workspace options"- onClick={() => openWorkspaceOptions(workspace.id)}- className="mr-1 rounded-md p-1.5 text-muted-foreground opacity-0 transition-opacity hover:bg-background/70 hover:text-foreground focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring group-hover/space:opacity-100 group-focus-within/space:opacity-100 [@media(hover:none)]:opacity-100">- <MoreHorizontal className="h-4 w-4" />- </button>}+ {(() => {+ const spaceMenuOpen = contextMenu?.kind === "workspace" && contextMenu.workspaceId === workspace.id;+ return <button type="button" aria-label={`Workspace actions for ${workspace.name}`} title="Workspace actions"+ aria-haspopup="menu" aria-expanded={spaceMenuOpen} data-tree-menu-anchor+ onClick={(event) => toggleAnchoredMenu(event, { kind: "workspace", projectId: project.id, workspaceId: workspace.id })}+ className={`mr-1 rounded-md p-1.5 text-muted-foreground transition-opacity hover:bg-background/70 hover:text-foreground focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring group-hover/space:opacity-100 group-focus-within/space:opacity-100 [@media(hover:none)]:opacity-100 ${spaceMenuOpen ? "bg-background/70 text-foreground opacity-100" : "opacity-0"}`}>+ <MoreHorizontal className="h-4 w-4" />+ </button>;+ })()}</>)}</div>;@@ -512,6 +533,49 @@ export function IdeProjectTree() {</div>;};+ const run = (action: () => void) => () => { setContextMenu(null); action(); };++ const projectMenuSections = (project: IdeProject): TreeMenuItem[][] => [+ [+ { id: "new", label: "New workspace", icon: FolderPlus, testId: "ide-project-menu-new", onSelect: run(() => newWorkspace(project.id)) },+ { id: "reveal", label: "Open folder", icon: FolderOpen, testId: "ide-project-menu-reveal", disabled: project.exists === false, onSelect: run(() => void revealFolder(project.id)) },+ { id: "copy", label: "Copy folder path", icon: Copy, testId: "ide-project-menu-copy", onSelect: run(() => void copyPath(project.path)) },+ ],+ [+ { id: "rename", label: "Rename project", icon: Pencil, testId: "ide-project-menu-rename", onSelect: run(() => { setDraftName(project.name); setRenamingId(project.id); }) },+ { id: "pin", label: project.pinned ? "Unpin project" : "Pin project", icon: project.pinned ? PinOff : Pin, testId: "ide-project-menu-pin", onSelect: run(() => void mutate(project, { pinned: !project.pinned })) },+ ],+ [+ { id: "delete", label: "Delete project", icon: Trash2, testId: "ide-project-menu-delete", destructive: true, onSelect: run(() => setConfirmProject(project.id)) },+ ],+ ];++ const workspaceMenuSections = (project: IdeProject, workspace: ProjectWorkspace): TreeMenuItem[][] => {+ const isOpen = workspace.status === "open";+ const isActive = workspace.id === activeWorkspaceId;+ const unavailable = !isOpen && !workspace.restorable;+ return [+ [+ { id: "open", label: isActive ? "Current workspace" : isOpen ? "Switch to workspace" : "Reopen workspace", icon: ArrowUpRight, testId: "ide-workspace-menu-open",+ disabled: isActive || unavailable, onSelect: run(() => { activateWorkspace(workspace.id); setProjectOpen(project.id, true); }) },+ { id: "rename", label: "Rename workspace", icon: Pencil, testId: "ide-workspace-menu-rename", disabled: !isOpen,+ hint: isOpen ? undefined : "Reopen it to rename",+ onSelect: run(() => { setDraftWorkspaceName(workspace.name); setRenamingWorkspaceId(workspace.id); setProjectOpen(project.id, true); }) },+ ...(isOpen ? [{ id: "options", label: "Workspace options…", icon: SlidersHorizontal, testId: "ide-workspace-menu-options", onSelect: run(() => openWorkspaceOptions(workspace.id)) }] : []),+ ],+ [+ { id: "reveal", label: "Open folder", icon: FolderOpen, testId: "ide-workspace-menu-reveal", onSelect: run(() => void revealFolder(project.id)) },+ { id: "copy", label: "Copy folder path", icon: Copy, testId: "ide-workspace-menu-copy", onSelect: run(() => void copyPath(workspace.folder || project.path)) },+ ],+ [+ ...(isOpen ? [{ id: "close", label: "Close workspace", icon: Power, testId: "ide-workspace-menu-stop", hint: "Stops its agents, keeps the row",+ onSelect: run(() => setConfirmWorkspace({ projectId: project.id, workspaceId: workspace.id, mode: "close" })) }] : []),+ { id: "remove", label: "Remove workspace", icon: Trash2, testId: "ide-workspace-menu-close", destructive: true,+ onSelect: run(() => setConfirmWorkspace({ projectId: project.id, workspaceId: workspace.id, mode: "remove" })) },+ ],+ ];+ };+const menuProject = contextMenu ? visible.find((project) => project.id === contextMenu.projectId) ?? null : null;const menuWorkspace =contextMenu?.kind === "workspace" && menuProject@@ -548,67 +612,26 @@ export function IdeProjectTree() {onDismiss={() => setContextMenu(null)}label={contextMenu.kind === "workspace" && menuWorkspace ? menuWorkspace.name : menuProject.name}kind={contextMenu.kind}- isOpen={contextMenu.kind === "workspace" ? menuWorkspace?.status === "open" : undefined}- isActive={contextMenu.kind === "workspace" ? menuWorkspace?.id === activeWorkspaceId : menuProject.id === activeProject?.id}- isExpanded={contextMenu.kind === "project" ? (expansion[menuProject.id] ?? menuProject.id === activeProject?.id) : undefined}- isPinned={menuProject.pinned}busy={mutatingId !== null || reordering || confirmBusy}- onOpen={contextMenu.kind === "workspace" && menuWorkspace ? () => {- const id = menuWorkspace.id;- setContextMenu(null);- activateWorkspace(id);- setProjectOpen(menuProject.id, true);- } : undefined}- onToggleExpand={contextMenu.kind === "project" ? () => {- setProjectOpen(menuProject.id, !(expansion[menuProject.id] ?? menuProject.id === activeProject?.id));- setContextMenu(null);- } : undefined}- onNewWorkspace={() => {- setContextMenu(null);- newWorkspace(menuProject.id);- }}- onPin={() => {- const target = menuProject;- setContextMenu(null);- void mutate(target, { pinned: !target.pinned });- }}- onRenameProject={contextMenu.kind === "project" ? () => {- setContextMenu(null);- setMenuId(null);- setDraftName(menuProject.name);- setRenamingId(menuProject.id);- setProjectOpen(menuProject.id, true);- } : undefined}- onRenameWorkspace={contextMenu.kind === "workspace" && menuWorkspace ? () => {- setContextMenu(null);- setDraftWorkspaceName(menuWorkspace.name);- setRenamingWorkspaceId(menuWorkspace.id);- setProjectOpen(menuProject.id, true);- } : undefined}- onWorkspaceOptions={contextMenu.kind === "workspace" && menuWorkspace ? () => {- const id = menuWorkspace.id;- setContextMenu(null);- openWorkspaceOptions(id);- } : undefined}- onCloseWorkspace={contextMenu.kind === "workspace" && menuWorkspace ? () => {- setContextMenu(null);- setConfirmWorkspace({ projectId: menuProject.id, workspaceId: menuWorkspace.id });- } : undefined}- onDeleteProject={contextMenu.kind === "project" ? () => {- setContextMenu(null);- setConfirmProject(menuProject.id);- } : undefined}+ sections={contextMenu.kind === "workspace" && menuWorkspace+ ? workspaceMenuSections(menuProject, menuWorkspace)+ : projectMenuSections(menuProject)}/>)}{confirmWorkspaceTarget && (<ConfirmTreeAction- title={`Remove ${confirmWorkspaceTarget.workspace.name}?`}- body={- confirmWorkspaceTarget.workspace.status === "open"- ? `Its ${confirmWorkspaceTarget.workspace.terminals} coding ${confirmWorkspaceTarget.workspace.terminals === 1 ? "agent" : "agents"} will stop and the workspace leaves the sidebar. The folder on disk and its chats stay untouched.`- : "The workspace leaves the sidebar. The folder on disk and its chats stay untouched."- }- confirmLabel={confirmBusy ? "Removing…" : `Remove ${confirmWorkspaceTarget.workspace.name}`}+ title={`${confirmWorkspace?.mode === "close" ? "Close" : "Remove"} ${confirmWorkspaceTarget.workspace.name}?`}+ body={(() => {+ const { workspace } = confirmWorkspaceTarget;+ const agents = `${workspace.terminals} coding ${workspace.terminals === 1 ? "agent" : "agents"}`;+ if (confirmWorkspace?.mode === "close") return `Its ${agents} will stop. The workspace stays in the sidebar, so you can reopen it later.`;+ return workspace.status === "open"+ ? `Its ${agents} will stop and the workspace leaves the sidebar. The folder on disk and its chats stay untouched.`+ : "The workspace leaves the sidebar. The folder on disk and its chats stay untouched.";+ })()}+ confirmLabel={confirmWorkspace?.mode === "close"+ ? (confirmBusy ? "Closing…" : `Close ${confirmWorkspaceTarget.workspace.name}`)+ : (confirmBusy ? "Removing…" : `Remove ${confirmWorkspaceTarget.workspace.name}`)}busy={confirmBusy}testId="ide-workspace-confirm-close"onCancel={() => {@@ -643,46 +666,40 @@ export function IdeProjectTree() {const TREE_MENU_WIDTH = 230;const TREE_MENU_MARGIN = 8;+/** One row of the sidebar's action menu. */+interface TreeMenuItem {+ id: string;+ label: string;+ icon: LucideIcon;+ testId: string;+ onSelect: () => void;+ disabled?: boolean;+ destructive?: boolean;+ /** A short second line: why an item is disabled, or what it keeps. */+ hint?: string;+}++/**+ * The one action menu for projects and workspaces, opened by right-click or+ * by a row's ⋯ button. Portalled to the body so no row's stacking context or+ * the sidebar's scroll clipping can cover it.+ */function TreeContextMenu({x,y,onDismiss,label,kind,- isOpen,- isActive,- isExpanded,- isPinned,busy,- onOpen,- onToggleExpand,- onNewWorkspace,- onPin,- onRenameProject,- onRenameWorkspace,- onWorkspaceOptions,- onCloseWorkspace,- onDeleteProject,+ sections,}: {x: number;y: number;onDismiss: () => void;label: string;kind: "project" | "workspace";- isOpen?: boolean;- isActive?: boolean;- isExpanded?: boolean;- isPinned?: boolean;busy: boolean;- onOpen?: () => void;- onToggleExpand?: () => void;- onNewWorkspace: () => void;- onPin: () => void;- onRenameProject?: () => void;- onRenameWorkspace?: () => void;- onWorkspaceOptions?: () => void;- onCloseWorkspace?: () => void;- onDeleteProject?: () => void;+ sections: TreeMenuItem[][];}) {const menuRef = useRef<HTMLDivElement | null>(null);@@ -694,7 +711,12 @@ function TreeContextMenu({}};const onPointerDown = (event: PointerEvent) => {- if (!menuRef.current?.contains(event.target as Node)) onDismiss();+ const target = event.target as Node;+ if (menuRef.current?.contains(target)) return;+ // A ⋯ button toggles the menu itself; dismissing here first would make+ // its click reopen the menu instead of closing it.+ if (target instanceof Element && target.closest("[data-tree-menu-anchor]")) return;+ onDismiss();};window.addEventListener("keydown", onKeyDown, true);window.addEventListener("pointerdown", onPointerDown, true);@@ -735,6 +757,8 @@ function TreeContextMenu({items[next]?.focus();};+ const visibleSections = sections.filter((section) => section.length > 0);+return createPortal(<divref={menuRef}@@ -743,103 +767,40 @@ function TreeContextMenu({data-testid={kind === "workspace" ? "ide-workspace-menu" : "ide-project-menu"}onKeyDown={onMenuKeyDown}style={{ width: TREE_MENU_WIDTH, visibility: "hidden" }}- className="fixed z-[100] overflow-hidden rounded-md border border-border bg-background py-1 shadow-lg"+ className="fixed z-[100] overflow-hidden rounded-xl border border-border bg-popover p-1 text-popover-foreground shadow-float">- {kind === "workspace" && onOpen && (- <button- type="button"- role="menuitem"- disabled={busy || isActive}- onClick={onOpen}- data-testid="ide-workspace-menu-open"- className="block w-full px-3 py-1.5 text-left text-xs text-foreground transition-colors hover:bg-muted disabled:opacity-50"- >- {isActive ? "Current workspace" : "Open workspace"}- </button>- )}- {kind === "project" && onToggleExpand && (- <button- type="button"- role="menuitem"- disabled={busy}- onClick={onToggleExpand}- className="block w-full px-3 py-1.5 text-left text-xs text-foreground transition-colors hover:bg-muted disabled:opacity-50"- >- {isExpanded ? "Collapse project" : "Expand project"}- </button>- )}- <button- type="button"- role="menuitem"- disabled={busy}- onClick={onNewWorkspace}- data-testid={kind === "workspace" ? "ide-workspace-menu-new" : "ide-project-menu-new"}- className="flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs text-foreground transition-colors hover:bg-muted disabled:opacity-50"- >- <FolderPlus aria-hidden className="h-3.5 w-3.5 shrink-0 text-muted-foreground" />- New workspace- </button>- <button- type="button"- role="menuitem"- disabled={busy}- onClick={onPin}- className="flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs text-foreground transition-colors hover:bg-muted disabled:opacity-50"- >- <Pin aria-hidden className="h-3.5 w-3.5 shrink-0 text-muted-foreground" />- {isPinned ? "Unpin project" : "Pin project"}- </button>- {(onRenameWorkspace ?? onRenameProject) && (- <button- type="button"- role="menuitem"- disabled={busy}- onClick={onRenameWorkspace ?? onRenameProject}- data-testid={kind === "workspace" ? "ide-workspace-menu-rename" : "ide-project-menu-rename"}- className="flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs text-foreground transition-colors hover:bg-muted disabled:opacity-50"- >- <Pencil aria-hidden className="h-3.5 w-3.5 shrink-0 text-muted-foreground" />- {kind === "workspace" ? "Rename workspace" : "Rename project"}- </button>- )}- {kind === "workspace" && onWorkspaceOptions && isOpen && (- <button- type="button"- role="menuitem"- disabled={busy}- onClick={onWorkspaceOptions}- data-testid="ide-workspace-menu-options"- className="block w-full px-3 py-1.5 text-left text-xs text-foreground transition-colors hover:bg-muted disabled:opacity-50"- >- Workspace options…- </button>- )}- {kind === "workspace" && onCloseWorkspace && (- <button- type="button"- role="menuitem"- disabled={busy}- onClick={onCloseWorkspace}- data-testid="ide-workspace-menu-close"- className="flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs text-destructive transition-colors hover:bg-destructive/10 disabled:opacity-50"- >- <Trash2 aria-hidden className="h-3.5 w-3.5 shrink-0" />- Remove workspace- </button>- )}- {kind === "project" && onDeleteProject && (- <button- type="button"- role="menuitem"- disabled={busy}- onClick={onDeleteProject}- data-testid="ide-project-menu-delete"- className="flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs text-destructive transition-colors hover:bg-destructive/10 disabled:opacity-50"- >- <Trash2 aria-hidden className="h-3.5 w-3.5 shrink-0" />- Delete project- </button>- )}+ <div className="flex items-center gap-2 px-2.5 pb-1.5 pt-1 text-[11px] font-medium text-muted-foreground">+ {kind === "workspace" ? <span aria-hidden className="h-1.5 w-1.5 shrink-0 rounded-full bg-muted-foreground/60" /> : <Folder aria-hidden className="h-3 w-3 shrink-0" />}+ <span className="min-w-0 truncate">{label}</span>+ </div>+ {visibleSections.map((section, index) => (+ <div key={section[0]?.id ?? index} role="group" className={index > 0 ? "mt-1 border-t border-border/70 pt-1" : ""}>+ {section.map((item) => {+ const Icon = item.icon;+ return (+ <button+ key={item.id}+ type="button"+ role="menuitem"+ disabled={busy || item.disabled}+ onClick={item.onSelect}+ data-testid={item.testId}+ className={`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-left text-[13px] transition-colors focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-45 ${+ item.destructive+ ? "text-destructive hover:bg-destructive/10 focus-visible:bg-destructive/10"+ : "text-foreground hover:bg-muted focus-visible:bg-muted"+ }`}+ >+ <Icon aria-hidden className={`h-4 w-4 shrink-0 ${item.destructive ? "" : "text-muted-foreground"}`} />+ <span className="flex min-w-0 flex-1 flex-col">+ <span className="truncate">{item.label}</span>+ {item.hint && <span className="truncate text-[11px] text-muted-foreground">{item.hint}</span>}+ </span>+ </button>+ );+ })}+ </div>+ ))}</div>,document.body,);diff --git a/jarvis/ui/web/frontend/src/lib/chatLibraryApi.ts b/jarvis/ui/web/frontend/src/lib/chatLibraryApi.tsindex af63195651..115129eaf1 100644--- a/jarvis/ui/web/frontend/src/lib/chatLibraryApi.ts+++ b/jarvis/ui/web/frontend/src/lib/chatLibraryApi.ts@@ -138,6 +138,18 @@ export async function deleteProject(projectId: string): Promise<boolean> {return body.removed;}+/**+ * Open the project's folder in the OS file manager. Desktop-only: a headless+ * backend answers 404, which surfaces as a ChatLibraryError.+ */+export async function revealProject(projectId: string): Promise<boolean> {+ const body = await request<{ opened: boolean }>(+ `/projects/${encodeURIComponent(projectId)}/reveal`,+ { method: "POST" },+ );+ return body.opened;+}+/*** Persist a drag-and-drop folder order in the sidebar.*diff --git a/tests/unit/agentic_ide/test_chat_library_routes.py b/tests/unit/agentic_ide/test_chat_library_routes.pyindex ff0cfc4f7b..f958e42bee 100644--- a/tests/unit/agentic_ide/test_chat_library_routes.py+++ b/tests/unit/agentic_ide/test_chat_library_routes.py@@ -260,3 +260,29 @@ def test_invalid_project_order_is_rejected_without_mutation(== 422)assert client.get("/api/chat-library/projects").json() == before+++# --------------------------------------------------------------- reveal folder+def test_reveal_opens_the_stored_project_folder(+ client: TestClient, tmp_path: Path, monkeypatch: pytest.MonkeyPatch+) -> None:+ from jarvis.platform import open_path++ opened: list[Path] = []+ monkeypatch.setattr(open_path, "open_file", lambda path: opened.append(path) or True)+ client.app.state.native_file_actions = True+ project = library.ensure_project(tmp_path, name="Reveal me")+ response = client.post(f"/api/chat-library/projects/{project.id}/reveal")+ assert response.status_code == 200+ assert response.json() == {"opened": True}+ assert opened == [Path(project.path)]+++def test_reveal_is_desktop_only(client: TestClient, tmp_path: Path) -> None:+ project = library.ensure_project(tmp_path)+ assert client.post(f"/api/chat-library/projects/{project.id}/reveal").status_code == 404+++def test_reveal_refuses_an_unknown_project(client: TestClient) -> None:+ client.app.state.native_file_actions = True+ assert client.post("/api/chat-library/projects/nope/reveal").status_code == 404