дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-04 17:21:13 +02:00
A remote daemon of another build refuses to retire while it has terminals, runs, agent sessions or unsaved changes. After an upgrade left such a daemon (its binary gone, so no build can reconnect to it), the project could not be opened and the error only asked to reconnect with the old build. The refusal now comes back as RemoteBackendBusy and the window asks whether to stop that backend. Agreeing reconnects with `openidea-server --attach <path> --replace`, which sends the old daemon SIGTERM (its own shutdown), kills it after the shutdown timeout if needed, and starts this build's daemon. Works for SSH hosts, WSL and dev containers, and for daemons of earlier builds (found by their --daemon command line). Fixes #6119
51 рядки
2.0 KiB
TypeScript
51 рядки
2.0 KiB
TypeScript
import { afterEach, expect, it, vi } from "vitest";
|
|
import { commands, type RemoteTarget } from "./ipc";
|
|
import { connectRemote, provideBackendBusyPrompt } from "./remote";
|
|
|
|
vi.mock("@tauri-apps/api/core", async (original) => ({
|
|
...(await original<typeof import("@tauri-apps/api/core")>()),
|
|
Channel: class {
|
|
onmessage: unknown = null;
|
|
},
|
|
}));
|
|
vi.mock("./ipc", async (original) => ({
|
|
...(await original<typeof import("./ipc")>()),
|
|
isTauri: () => true,
|
|
}));
|
|
|
|
const target: RemoteTarget = { kind: "ssh", config: "box" };
|
|
const busy = {
|
|
status: "error" as const,
|
|
error: { kind: "unavailable" as const, message: "busy", data: { type: "remoteBackendBusy" as const } },
|
|
};
|
|
const stop = { status: "error" as const, error: { kind: "unavailable" as const, message: "second attempt" } };
|
|
|
|
afterEach(() => vi.restoreAllMocks());
|
|
|
|
it("stops another build's backend once the user agrees, then connects again (#6119)", async () => {
|
|
const connect = vi.spyOn(commands, "remoteConnect").mockResolvedValueOnce(busy).mockResolvedValueOnce(stop);
|
|
const prompt = vi.fn(async () => true);
|
|
const dispose = provideBackendBusyPrompt(prompt);
|
|
await expect(connectRemote(target, "/srv/app")).rejects.toThrow("second attempt");
|
|
dispose();
|
|
expect(prompt).toHaveBeenCalledOnce();
|
|
expect(connect.mock.calls.map((c) => c[2])).toEqual([false, true]);
|
|
});
|
|
|
|
it("keeps the error when the user declines", async () => {
|
|
const connect = vi.spyOn(commands, "remoteConnect").mockResolvedValue(busy);
|
|
const dispose = provideBackendBusyPrompt(async () => false);
|
|
await expect(connectRemote(target, "/srv/app")).rejects.toThrow("busy");
|
|
dispose();
|
|
expect(connect).toHaveBeenCalledOnce();
|
|
});
|
|
|
|
it("doesn't ask about other connection errors", async () => {
|
|
vi.spyOn(commands, "remoteConnect").mockResolvedValue(stop);
|
|
const prompt = vi.fn(async () => true);
|
|
const dispose = provideBackendBusyPrompt(prompt);
|
|
await expect(connectRemote(target, "/srv/app")).rejects.toThrow("second attempt");
|
|
dispose();
|
|
expect(prompt).not.toHaveBeenCalled();
|
|
});
|