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): explain stale backend when reorder is rejected
rubenluetke10-beep1ba827f420d5
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.tsxindex f6fdc05aac..457cea311a 100644--- 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.tsx@@ -4,19 +4,38 @@ import { IdeProjectTree } from "./IdeProjectTree";import { useIdeProjectsStore } from "@/store/ideProjects";import type { IdeProject } from "@/lib/agenticIdeApi";+import { ChatLibraryError } from "@/lib/chatLibraryApi";+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) {+vi.mock("@/lib/chatLibraryApi", () => {+ class MockChatLibraryError extends Error {+ constructor(+ message: string,+ readonly status: number,+ ) {+ super(message);+ }+ }+ return {+ patchProject: vi.fn(async () => ({})),+ openProject: vi.fn(async () => ({ id: "p1" })),+ reorderProjects,+ ChatLibraryError: MockChatLibraryError,+ };+});+vi.mock("@/lib/agenticIdeApi", () => {+ class MockIdeApiError extends Error {+ constructor(+ message: string,+ readonly status: number,+ ) {super(message);+ this.name = "IdeApiError";}- },-}));-vi.mock("@/lib/agenticIdeApi", () => ({ reorderWorkspaces }));+ }+ return { reorderWorkspaces, IdeApiError: MockIdeApiError };+});function folder(id: string, name: string, pinned = false): IdeProject {return {@@ -136,3 +155,23 @@ it("shows a toast instead of reordering when the backend rejects", async () => {});await waitFor(() => expect(pushToast).toHaveBeenCalledWith("error", "stale list"));});++it("names the restart when the backend predates the reorder endpoint", async () => {+ reorderProjects.mockRejectedValueOnce(new ChatLibraryError("Method Not Allowed", 405));+ 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",+ "This view is newer than the backend — restart the app and try again.",+ ),+ );+});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.tsxindex 7d59e4e415..9307a0f64e 100644--- a/jarvis/ui/web/frontend/src/components/agentic/IdeProjectTree.reorder.test.tsx+++ b/jarvis/ui/web/frontend/src/components/agentic/IdeProjectTree.reorder.test.tsx@@ -2,10 +2,21 @@ 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";const reorderWorkspaces = vi.hoisted(() => vi.fn());-vi.mock("@/lib/agenticIdeApi", () => ({ reorderWorkspaces }));+vi.mock("@/lib/agenticIdeApi", () => {+ class MockIdeApiError extends Error {+ constructor(+ message: string,+ readonly status: number,+ ) {+ super(message);+ this.name = "IdeApiError";+ }+ }+ return { reorderWorkspaces, IdeApiError: MockIdeApiError };+});vi.mock("@/lib/chatLibraryApi", () => ({patchProject: vi.fn(async () => ({})),openProject: vi.fn(async () => ({ id: "p1" })),@@ -101,3 +112,20 @@ it("shows a toast instead of reordering when the backend rejects", async () => {});await waitFor(() => expect(pushToast).toHaveBeenCalledWith("error", "stale list"));});++it("names the restart when the backend predates the reorder endpoint", async () => {+ reorderWorkspaces.mockRejectedValueOnce(new IdeApiError("Method Not Allowed", 405));+ 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",+ "This view is newer than the backend — restart the app and try again.",+ ),+ );+});diff --git a/jarvis/ui/web/frontend/src/lib/agenticIdeApi.ts b/jarvis/ui/web/frontend/src/lib/agenticIdeApi.tsindex 6f8d13a5cb..628bce43c2 100644--- a/jarvis/ui/web/frontend/src/lib/agenticIdeApi.ts+++ b/jarvis/ui/web/frontend/src/lib/agenticIdeApi.ts@@ -435,6 +435,10 @@ export async function reorderIdeTerminals(id: string, terminalIds: string[]): Pr* `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.+ *+ * Throws {@link IdeApiError} carrying the HTTP status, so callers can tell+ * "the backend refused" apart from "the backend is too old to know this+ * endpoint" (405).*/export async function reorderWorkspaces(workspaceIds: string[]): Promise<IdeState> {const res = await fetch("/api/agentic-ide/workspaces/order", {@@ -442,10 +446,21 @@ export async function reorderWorkspaces(workspaceIds: string[]): Promise<IdeStatheaders: { "Content-Type": "application/json" },body: JSON.stringify({ workspace_ids: workspaceIds }),});- if (!res.ok) throw new Error(await detail(res));+ if (!res.ok) throw new IdeApiError(await detail(res), res.status);return ((await res.json()) as { state: IdeState }).state;}+/** An IDE API failure with its HTTP status attached. */+export class IdeApiError extends Error {+ constructor(+ message: string,+ readonly status: number,+ ) {+ super(message);+ this.name = "IdeApiError";+ }+}+/*** Which subscription new terminals of one coding CLI open on.*