fix(desktop): packaged macOS app launched with no window / blank white screen

In packaged Electron builds, `process.argv[1]` is undefined (Electron loads
the main script via package.json `main`, not via argv), so the bottom-of-file
guard never invoked `run()` and the app started without creating a window.
Also build the dashboard client with `--base ./` so its `file://`-loaded
index.html resolves `./assets/*` from inside the asar instead of the
filesystem root, which was producing a blank white window.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
gsxdsm
2026-05-17 22:01:51 -07:00
parent 56a7178aca
commit e5af9c93ae
3 changed files with 14 additions and 2 deletions

View File

@@ -48,5 +48,8 @@ export async function buildDashboard(): Promise<void> {
}
export async function buildDashboardClient(): Promise<void> {
await runWorkspaceBin("vite", ["build"], resolve(workspaceRoot, "packages", "dashboard"));
// Desktop loads index.html via file:// from inside the asar, so absolute
// asset paths (/assets/...) resolve to the filesystem root and fail. Build
// with a relative base so the bundled HTML references ./assets/... instead.
await runWorkspaceBin("vite", ["build", "--base", "./"], resolve(workspaceRoot, "packages", "dashboard"));
}

View File

@@ -267,6 +267,10 @@ export function run(): void {
}
const modulePath = fileURLToPath(import.meta.url);
if (process.argv[1] && resolve(process.argv[1]) === modulePath) {
const isElectronMain =
(process as NodeJS.Process & { type?: string }).type === "browser";
const isDirectInvocation =
!!process.argv[1] && resolve(process.argv[1]) === modulePath;
if (isElectronMain || isDirectInvocation) {
run();
}