Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

fix(desktop): avoid macOS crash during app icon scan

vastsa1a901ed57744
diff --git a/apps/desktop/electron/main/local-apps.ts b/apps/desktop/electron/main/local-apps.ts
index 0b7bcb6f5..40d95ff32 100644
--- a/apps/desktop/electron/main/local-apps.ts
+++ b/apps/desktop/electron/main/local-apps.ts
@@ -503,10 +503,7 @@ export async function createDefaultLocalAppDeps(): Promise<LocalAppDeps> {
},
async getFileIcon(target) {
try {
- // `large` is the 32px native icon: at the panel's tile size the small
- // variant reads as a blurry square. Oversized results are dropped by
- // the byte budget instead of being downscaled here.
- const icon = await app.getFileIcon(target, { size: "large" });
+ const icon = await app.getFileIcon(target, { size: "small" });
return icon ?? null;
} catch {
return null;
diff --git a/apps/desktop/test/local-apps.test.mjs b/apps/desktop/test/local-apps.test.mjs
index 957b08214..3f0080fbd 100644
--- a/apps/desktop/test/local-apps.test.mjs
+++ b/apps/desktop/test/local-apps.test.mjs
@@ -384,12 +384,12 @@ test("icon failures and oversized icons never fail the scan", async () => {
assert.equal(state.iconRequests, 3);
});
-test("the icon budget is 32 KiB so a large native icon still fits", () => {
+test("the icon budget is 32 KiB and startup uses the stable small native icon", () => {
assert.equal(LOCAL_APP_MAX_ICON_BYTES, 32_768);
- // The small variant reads as a blurry square on the launcher's tiles.
+ // The large lookup triggered a native startup SIGTRAP on macOS.
assert.match(
readMainModuleSync("local-apps.ts"),
- /app\.getFileIcon\(target, \{ size: "large" \}\)/,
+ /app\.getFileIcon\(target, \{ size: "small" \}\)/,
);
});
diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.md
index f2fe7d69a..eae188a62 100644
--- a/docs/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/spec/06-delivery/04-e2e-test-plan.md
@@ -1141,7 +1141,9 @@ The minimum selection is:
- Cross-cutting runtime, host, or IPC: `pnpm test:e2e`.
- Electron startup, preload, or window lifecycle: `pnpm test:e2e` and
- `pnpm test:e2e:boot`.
+ `pnpm test:e2e:boot`. For packaged-startup regressions, also run
+ `node scripts/e2e-electron-boot.mjs <packaged-executable>` against the
+ installed-layout artifact with an isolated profile.
- Session-list refresh or model capability lookup: `pnpm test:e2e` and
`pnpm test:e2e:boot`, including the synthetic large-list responsiveness check.
- Settings/composer/plugin search theme surfaces: `pnpm build:js` followed by
diff --git a/docs/spec/07-plugins/18-plugin-launcher.md b/docs/spec/07-plugins/18-plugin-launcher.md
index 6971a3bf6..08206990d 100644
--- a/docs/spec/07-plugins/18-plugin-launcher.md
+++ b/docs/spec/07-plugins/18-plugin-launcher.md
@@ -227,7 +227,7 @@ ordinary `storage` event.
`/usr/local/share/applications`, and `~/.local/share/applications`.
Bounds: the scan result is cached for 5 minutes, holds at most 600 entries and
-extracts icons for the first 200 of them. Each icon is the platform's `large`
+extracts icons for the first 200 of them. Each icon is the platform's `small`
variant, capped at 32 KiB, and cached across scans keyed by item id and icon
path; an entry that disappears prunes its cached icon, so a rescan does not pay
for a lookup it already has. An entry whose target no longer exists is dropped.
diff --git a/scripts/README.md b/scripts/README.md
index a382349fb..ee911dd79 100644
--- a/scripts/README.md
+++ b/scripts/README.md
@@ -127,6 +127,13 @@ notarize, and staple macOS artifacts; `workflow_dispatch` may set
`sign_macos: false` only for unsigned debug artifacts. See the [release
runbook](../docs/spec/06-delivery/06-release-runbook.md).
+### Packaged startup regression
+
+For a packaged startup check, run
+`node scripts/e2e-electron-boot.mjs <packaged-executable>` after `pack`.
+It exercises the installed layout with an isolated profile and the same boot
+probe as `pnpm test:e2e:boot`.
+
### Provider certificate regression
- `node scripts/e2e-provider-certificates.mjs`: real desktop launcher and
diff --git a/scripts/e2e-electron-boot.mjs b/scripts/e2e-electron-boot.mjs
index d97501b43..8526efc86 100644
--- a/scripts/e2e-electron-boot.mjs
+++ b/scripts/e2e-electron-boot.mjs
@@ -5,31 +5,37 @@
* E2E-SESSION-list-refresh-keeps-desktop-responsive against 800 synthetic
* sessions (BOOT_PROBE emitted by electron/main/bootstrap/startup.ts).
*
- * Prereqs: `pnpm --filter @pi-desktop/desktop build` and a host-core binary
- * (target/debug or target/release, or PI_DESKTOP_HOST_BIN).
+ * Pass a packaged executable path to run the same assertions against an
+ * installed-layout artifact. Without it, build out/ and a host-core binary
+ * (target/debug or target/release, or PI_DESKTOP_HOST_BIN) are required.
*/
import { spawn } from "node:child_process";
import { rmSync, existsSync, readFileSync } from "node:fs";
-import { join } from "node:path";
+import { join, resolve } from "node:path";
import {
createTempDataDir,
+ desktopPaths,
repositoryRoot,
resolveElectronBinary,
} from "./e2e/boot.mjs";
const root = repositoryRoot();
-const { appDir, electronBinary: electronBin } = resolveElectronBinary(root);
+const packagedExecutable = process.argv[2];
+const { appDir } = desktopPaths(root);
+const executable = packagedExecutable
+ ? resolve(packagedExecutable)
+ : resolveElectronBinary(root).electronBinary;
-if (!existsSync(join(appDir, "out/main/index.js"))) {
+if (!packagedExecutable && !existsSync(join(appDir, "out/main/index.js"))) {
console.error("desktop app not built. Run: pnpm --filter @pi-desktop/desktop build");
process.exit(1);
}
-if (!existsSync(electronBin)) {
- console.error("Electron binary missing:", electronBin);
+if (!existsSync(executable)) {
+ console.error("Electron executable missing:", executable);
process.exit(1);
}
-for (const preloadPath of [
+for (const preloadPath of packagedExecutable ? [] : [
join(appDir, "out/preload/index.cjs"),
join(appDir, "out/preload/plugin-panel.js"),
]) {
@@ -49,7 +55,7 @@ for (const preloadPath of [
const dataDir = createTempDataDir("pi-desktop-boot-");
const env = { ...process.env };
delete env.ELECTRON_RUN_AS_NODE;
-const child = spawn(electronBin, ["."], {
+const child = spawn(executable, packagedExecutable ? [] : ["."], {
cwd: appDir,
env: {
...env,