Skip to content

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.

fix(ide): ask for a restart when a terminal move meets an older backend

rubenluetke10-beepc1362c169207
diff --git a/jarvis/ui/web/frontend/src/lib/agenticIdeApi.transfer.test.ts b/jarvis/ui/web/frontend/src/lib/agenticIdeApi.transfer.test.ts
new file mode 100644
index 0000000000..eff5f5921c
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/lib/agenticIdeApi.transfer.test.ts
@@ -0,0 +1,35 @@
+/**
+ * `transferTerminal` against a backend that knows the route and one that
+ * predates it. The second is the normal state right after an update: the
+ * bundle reloads on its own, the Python backend only on the next restart, so
+ * the pane menu already offers a move the server cannot do yet.
+ */
+import { afterEach, expect, it, vi } from "vitest";
+import { transferTerminal } from "./agenticIdeApi";
+
+function answer(status: number, body: unknown) {
+ vi.stubGlobal("fetch", vi.fn(async () => new Response(JSON.stringify(body), { status })));
+}
+
+afterEach(() => { vi.unstubAllGlobals(); });
+
+it("posts both workspaces and returns the moved pane", async () => {
+ answer(200, { terminal: { name: "T3" }, source_workspace_id: "w1", target_workspace_id: "w2", state: {} });
+
+ const result = await transferTerminal("pane:h1", "w1", "w2");
+
+ const [url, init] = (fetch as unknown as ReturnType<typeof vi.fn>).mock.calls[0];
+ expect(url).toBe("/api/agentic-ide/terminals/pane%3Ah1/transfer");
+ expect(JSON.parse(init.body)).toEqual({ workspace_id: "w1", target_workspace_id: "w2" });
+ expect(result.terminal.name).toBe("T3");
+});
+
+it("passes on the server's own reason", async () => {
+ answer(409, { detail: "Blog already has the maximum of 12 terminals." });
+ await expect(transferTerminal("T1", "w1", "w2")).rejects.toThrow("Blog already has the maximum of 12 terminals.");
+});
+
+it("asks for a restart when the backend predates the route", async () => {
+ answer(404, { detail: "Not Found" });
+ await expect(transferTerminal("T1", "w1", "w2")).rejects.toThrow("restart the app");
+});
diff --git a/jarvis/ui/web/frontend/src/lib/agenticIdeApi.ts b/jarvis/ui/web/frontend/src/lib/agenticIdeApi.ts
index 0a986f520d..c7beb3c9d2 100644
--- a/jarvis/ui/web/frontend/src/lib/agenticIdeApi.ts
+++ b/jarvis/ui/web/frontend/src/lib/agenticIdeApi.ts
@@ -1524,7 +1524,15 @@ export async function transferTerminal(
body: JSON.stringify({ workspace_id: workspaceId, target_workspace_id: targetWorkspaceId }),
},
);
- if (!res.ok) throw new Error(await detail(res));
+ if (!res.ok) {
+ const message = await detail(res);
+ // The route's own 404 names the missing pane; a bare "Not Found" (or a
+ // 405) means the backend serving this view predates the route.
+ if (res.status === 405 || (res.status === 404 && message === "Not Found")) {
+ throw new Error("This view is newer than the backend — restart the app and try again.");
+ }
+ throw new Error(message);
+ }
return (await res.json()) as TerminalTransfer;
}