Files
fusion/packages/desktop/src/engine-runtime.ts
gsxdsm b331f26f3d fix(desktop,cli): never auto-create a project in home/cwd; onboard instead
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>
2026-07-02 20:16:42 -07:00

22 lines
1.1 KiB
TypeScript

import type { CentralCore, RegisteredProject } from "@fusion/core";
/*
* FNXC:DesktopRuntime 2026-07-03-03:30:
* The desktop app must NEVER auto-register a project for its runtime root (the user's home
* directory). Doing so created a bogus "cwd-mode" project in ~ on first launch and dropped the
* operator straight onto a board for a directory they never chose. Instead the embedded runtime
* starts with NO default project when none exist, and the dashboard's empty state prompts the
* operator through onboarding (ProjectOverview "Add your first project" -> SetupWizard ->
* POST /api/projects) to register a real project directory.
*
* This resolver only PICKS an existing project as the primary engine target (for operators who
* already onboarded projects); it registers nothing. Returns null when there are no projects yet.
* It must not call helpers that initialize Git repositories as a side effect.
*/
export async function resolveDesktopRuntimePrimaryProject(
centralCore: CentralCore,
): Promise<RegisteredProject | null> {
const projects = await centralCore.listProjects();
return projects.length > 0 ? projects[0]! : null;
}