The desktop embedded runtime auto-registered its runtime root (the user's HOME directory) as a project on first launch, and bare `fusion` / `fn` / `fn dashboard` / `fusion dashboard` auto-registered the CWD as a project. Both silently created a "cwd-mode" project the operator never chose and dropped them onto a board for it. - Desktop: replace ensureDesktopRuntimeProject (which registered home) with resolveDesktopRuntimePrimaryProject, which only PICKS an already-registered project as the primary engine target and registers nothing. With no projects the server starts engine-less (createServer's engine is optional) and the dashboard shows its onboarding empty state. Applied to both the primary (local-runtime) and legacy (local-server) desktop server paths. - CLI dashboard command: ensureCwdProjectRegistered now runs with autoRegister:false, so it uses the CWD project only if already registered, else starts with none and the dashboard onboards. (serve/daemon keep their existing --no-auto-register flag; the CLI `desktop` launcher unchanged.) Verified: with zero projects the embedded server starts, /api/health -> 200, /api/projects -> [], / serves the client. Unit test asserts resolveDesktopRuntimePrimaryProject registers nothing. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
41 lines
1.5 KiB
TypeScript
41 lines
1.5 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { resolveDesktopRuntimePrimaryProject } from "../engine-runtime";
|
|
|
|
/*
|
|
* The desktop embedded runtime must NEVER auto-register a project (e.g. the home directory).
|
|
* resolveDesktopRuntimePrimaryProject only picks an already-registered project as the primary
|
|
* engine target, and registers nothing.
|
|
*/
|
|
describe("resolveDesktopRuntimePrimaryProject", () => {
|
|
it("returns null when no projects are registered (never auto-registers)", async () => {
|
|
let registerCalled = false;
|
|
const central = {
|
|
listProjects: async () => [],
|
|
registerProject: async () => {
|
|
registerCalled = true;
|
|
throw new Error("resolveDesktopRuntimePrimaryProject must not register a project");
|
|
},
|
|
} as unknown as import("@fusion/core").CentralCore;
|
|
|
|
const result = await resolveDesktopRuntimePrimaryProject(central);
|
|
expect(result).toBeNull();
|
|
expect(registerCalled).toBe(false);
|
|
});
|
|
|
|
it("returns the first existing project as primary without registering", async () => {
|
|
const projects = [{ id: "proj_1" }, { id: "proj_2" }];
|
|
let registerCalled = false;
|
|
const central = {
|
|
listProjects: async () => projects,
|
|
registerProject: async () => {
|
|
registerCalled = true;
|
|
return projects[0];
|
|
},
|
|
} as unknown as import("@fusion/core").CentralCore;
|
|
|
|
const result = await resolveDesktopRuntimePrimaryProject(central);
|
|
expect(result?.id).toBe("proj_1");
|
|
expect(registerCalled).toBe(false);
|
|
});
|
|
});
|