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): remove a project's workspaces before deleting it and name a stale backend
rubenluetke10-beepc686daf083ec
diff --git a/jarvis/ui/web/frontend/src/components/agentic/IdeProjectTree.test.tsx b/jarvis/ui/web/frontend/src/components/agentic/IdeProjectTree.test.tsxindex 69ec8ed879..d9b7be738b 100644--- a/jarvis/ui/web/frontend/src/components/agentic/IdeProjectTree.test.tsx+++ b/jarvis/ui/web/frontend/src/components/agentic/IdeProjectTree.test.tsx@@ -2,7 +2,7 @@ import { act, cleanup, fireEvent, render, screen, waitFor } from "@testing-libraimport { afterEach, beforeEach, expect, it, vi } from "vitest";import { IdeProjectTree } from "./IdeProjectTree";import { useIdeProjectsStore } from "@/store/ideProjects";-import type { IdeProject } from "@/lib/agenticIdeApi";+import { IdeApiError, type IdeProject } from "@/lib/agenticIdeApi";import { ChatLibraryError } from "@/lib/chatLibraryApi";const patchProject = vi.hoisted(() => vi.fn());@@ -225,10 +225,24 @@ it("asks for confirmation before deleting a project with no open workspaces", asexpect(screen.getByTestId("ide-project-confirm-delete")).toBeDefined();expect(deleteProject).not.toHaveBeenCalled();fireEvent.click(screen.getByTestId("ide-project-confirm-delete-confirm"));+ // The closed workspace is forgotten too, or it would re-derive the project row.+ await waitFor(() => expect(removeWorkspace).toHaveBeenCalledWith("p1-w1"));await waitFor(() => expect(deleteProject).toHaveBeenCalledWith("p1"));});-it("closes open workspaces when a project is deleted", async () => {+it("says to restart when the backend predates workspace removal", async () => {+ const { useEventStore } = await import("@/store/events");+ const pushToast = vi.fn();+ useEventStore.setState({ pushToast } as never);+ removeWorkspace.mockRejectedValue(new IdeApiError("Not Found", 404));+ render(<IdeProjectTree />);+ fireEvent.contextMenu(screen.getByTestId("ide-workspace-row-p1-w1"));+ fireEvent.click(screen.getByTestId("ide-workspace-menu-close"));+ fireEvent.click(screen.getByTestId("ide-workspace-confirm-close-confirm"));+ await waitFor(() => expect(pushToast).toHaveBeenCalledWith("error", expect.stringContaining("restart the app")));+});++it("removes open workspaces when a project is deleted", async () => {render(<IdeProjectTree />);fireEvent.contextMenu(screen.getByTestId("ide-project-header-p1"));fireEvent.click(screen.getByTestId("ide-project-menu-delete"));@@ -236,7 +250,7 @@ it("closes open workspaces when a project is deleted", async () => {expect((confirm as HTMLButtonElement).disabled).toBe(false);expect(deleteProject).not.toHaveBeenCalled();fireEvent.click(confirm);- await waitFor(() => expect(closeWorkspace).toHaveBeenCalledWith("p1-w1"));+ await waitFor(() => expect(removeWorkspace).toHaveBeenCalledWith("p1-w1"));await waitFor(() => expect(deleteProject).toHaveBeenCalledWith("p1"));await waitFor(() => expect(useIdeProjectsStore.getState().refreshRequest?.nonce).toBe(1));});diff --git a/jarvis/ui/web/frontend/src/components/agentic/IdeProjectTree.tsx b/jarvis/ui/web/frontend/src/components/agentic/IdeProjectTree.tsxindex 76d47369e3..97bd9ecf0e 100644--- a/jarvis/ui/web/frontend/src/components/agentic/IdeProjectTree.tsx+++ b/jarvis/ui/web/frontend/src/components/agentic/IdeProjectTree.tsx@@ -2,7 +2,7 @@ import { useEffect, useLayoutEffect, useRef, useState, type KeyboardEvent as Reaimport { 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 { closeWorkspace, removeWorkspace, renameWorkspace, IdeApiError, reorderWorkspaces, type IdeProject, type ProjectWorkspace } from "@/lib/agenticIdeApi";+import { removeWorkspace, renameWorkspace, IdeApiError, reorderWorkspaces, type IdeProject, type ProjectWorkspace } from "@/lib/agenticIdeApi";import { useEventStore } from "@/store/events";import { useIdeProjectsStore } from "@/store/ideProjects";@@ -24,6 +24,18 @@ function reorderErrorMessage(error: unknown): string {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+ * that exact pair means a backend older than this view: restart it.+ */+function removalErrorMessage(error: unknown): string {+ if (error instanceof IdeApiError && (error.status === 405 || (error.status === 404 && error.message === "Not Found"))) {+ return REORDER_NEEDS_RESTART;+ }+ return error instanceof Error ? error.message : String(error);+}+function readExpansion(): Record<string, boolean> {try {const value: unknown = JSON.parse(localStorage.getItem(EXPANSION_KEY) ?? "{}");@@ -223,7 +235,7 @@ export function IdeProjectTree() {setContextMenu(null);requestRefresh();} catch (error) {- pushToast("error", (error as Error).message);+ pushToast("error", removalErrorMessage(error));} finally {setConfirmBusy(false);}@@ -238,12 +250,12 @@ export function IdeProjectTree() {}setConfirmBusy(true);try {- // A project with open workspaces would otherwise come straight back:- // the sidebar derives a project row from every running workspace, so- // deleting the library entry alone changes nothing on screen. The- // confirm dialog says so, and confirming stops the agents first.- for (const workspace of target.workspaces.filter((entry) => entry.status === "open")) {- await closeWorkspace(workspace.id);+ // A project with workspaces would otherwise come straight back: the+ // sidebar derives a project row from every open AND remembered+ // workspace, so deleting the library entry alone changes nothing on+ // screen. Removing each one stops its agents and forgets its record.+ for (const workspace of target.workspaces) {+ await removeWorkspace(workspace.id);}await deleteProject(target.id);setConfirmProject(null);@@ -251,7 +263,7 @@ export function IdeProjectTree() {setMenuId(null);requestRefresh();} catch (error) {- pushToast("error", (error as Error).message);+ pushToast("error", removalErrorMessage(error));} finally {setConfirmBusy(false);}diff --git a/jarvis/ui/web/frontend/src/lib/agenticIdeApi.ts b/jarvis/ui/web/frontend/src/lib/agenticIdeApi.tsindex 69f1e7e7fc..260b5d1896 100644--- a/jarvis/ui/web/frontend/src/lib/agenticIdeApi.ts+++ b/jarvis/ui/web/frontend/src/lib/agenticIdeApi.ts@@ -1339,7 +1339,9 @@ export async function removeWorkspace(id: string): Promise<IdeState> {`/api/agentic-ide/workspaces/${encodeURIComponent(id)}/record`,{ method: "DELETE" },);- if (!res.ok) throw new Error(await detail(res));+ // Carries the status: a bare "Not Found" means a backend older than this+ // route, which the sidebar explains as "restart the app".+ if (!res.ok) throw new IdeApiError(await detail(res), res.status);const body = (await res.json()) as { state: IdeState };return body.state;}