Stop local daemon when removing localhost (#1297)

* fix(app): stop local daemon when removing localhost

* fix(app): handle daemon removal rollback

* fix(app): return listen address in desktop e2e mock

* fix(app): refresh daemon status after registration failure

* fix(app): unslop daemon status error coverage

* fix(app): preserve daemon toggle error context

---------

Co-authored-by: Mohamed Boudra <boudra.moha@gmail.com>
This commit is contained in:
Matt Cowger
2026-06-04 07:30:40 -07:00
committed by GitHub
parent 9e2c75a8a3
commit b5192e577a
9 changed files with 341 additions and 61 deletions

View File

@@ -1,5 +1,5 @@
import { describe, expect, it, vi } from "vitest";
import { DaemonStartService } from "./daemon-start-service";
import { DaemonStartService, upsertDesktopDaemonConnection } from "./daemon-start-service";
import type { HostRuntimeStore } from "./host-runtime";
import type { DesktopDaemonStatus } from "@/desktop/daemon/desktop-daemon";
@@ -223,3 +223,50 @@ describe("DaemonStartService", () => {
expect(notifications).toBe(countAfterFirst);
});
});
describe("upsertDesktopDaemonConnection", () => {
it("upserts a valid desktop daemon status", async () => {
const fake = createFakeStore();
const result = await upsertDesktopDaemonConnection(fake.store, makeStatus());
expect(result).toEqual({ ok: true });
expect(fake.upserts).toEqual([
{ listenAddress: "127.0.0.1:6767", serverId: "srv_desktop", hostname: "desktop" },
]);
});
it("rejects a missing listen address without upserting", async () => {
const fake = createFakeStore();
const result = await upsertDesktopDaemonConnection(fake.store, makeStatus({ listen: null }));
expect(result).toEqual({
ok: false,
error: "Desktop daemon did not return a listen address.",
});
expect(fake.upserts).toEqual([]);
});
it("rejects a missing server id without upserting", async () => {
const fake = createFakeStore();
const result = await upsertDesktopDaemonConnection(fake.store, makeStatus({ serverId: "" }));
expect(result).toEqual({
ok: false,
error: "Desktop daemon did not return a server id.",
});
expect(fake.upserts).toEqual([]);
});
it("rejects an unsupported listen address without upserting", async () => {
const fake = createFakeStore();
const result = await upsertDesktopDaemonConnection(fake.store, makeStatus({ listen: "???" }));
expect(result.ok).toBe(false);
expect(result.ok ? "" : result.error).toContain("unsupported listen address");
expect(fake.upserts).toEqual([]);
});
});