Skip to content

The agent that grows with you

fix(desktop): verify the renderer bundle once per build, not twice

teknium10954ad4b9b9b
diff --git a/apps/desktop/package.json b/apps/desktop/package.json
index 3b50f3f1a67..d77ff788721 100644
--- a/apps/desktop/package.json
+++ b/apps/desktop/package.json
@@ -29,7 +29,6 @@
"start": "npm run build && electron .",
"build": "node scripts/build.mjs",
"i18n:keys": "node scripts/i18n-keys.mjs",
- "postbuild": "node scripts/assert-dist-built.mjs",
"prebuilder": "node scripts/patch-electron-builder-mac-binary.mjs",
"builder": "node scripts/run-electron-builder.mjs",
"pack": "npm run build && npm run builder -- --dir --publish never",
diff --git a/apps/desktop/scripts/assert-dist-built.mjs b/apps/desktop/scripts/assert-dist-built.mjs
index 3a74fea13b5..24626f2165b 100644
--- a/apps/desktop/scripts/assert-dist-built.mjs
+++ b/apps/desktop/scripts/assert-dist-built.mjs
@@ -7,8 +7,11 @@
// packages an app with an empty or missing `dist/`. The result launches but
// blank-pages with `ERR_FILE_NOT_FOUND` for dist/index.html, with no clue why.
//
-// This runs at the tail of `build`, after vite build, so any packaging path
-// inherits it. It fails loud and early instead of shipping a broken bundle.
+// The desktop compiler (scripts/build/desktop.mjs) runs it on the scratch
+// product before publishing dist/, so every `npm run build` path inherits it
+// once. It is deliberately not also a `postbuild` hook: that re-ran the same
+// check on the bytes just verified, doubling its cost in every update.
+// It fails loud and early instead of shipping a broken bundle.
// See issues #39484 (renderer blank page) and #41327 / #39472 (dashboard 404).
import { existsSync, readFileSync, statSync, readdirSync } from "fs"
diff --git a/nix/desktop.nix b/nix/desktop.nix
index b638a9e5761..a96e9d6fcba 100644
--- a/nix/desktop.nix
+++ b/nix/desktop.nix
@@ -117,7 +117,7 @@ let
pushd apps/desktop
- npm run postbuild
+ node scripts/assert-dist-built.mjs
# validate staged node-pty native binary is present.
STAGED_PTY_NODE="./dist/node_modules/node-pty/build/Release/pty.node"