diff --git a/packages/desktop/electron-builder.config.test.ts b/packages/desktop/electron-builder.config.test.ts index 3e29318dcac..f6c479a5bd4 100644 --- a/packages/desktop/electron-builder.config.test.ts +++ b/packages/desktop/electron-builder.config.test.ts @@ -80,6 +80,20 @@ test.each(channels)("channel identity for $channel", ({ channel, appId, feed }) expect(config.deb?.fpm).not.toContain("--rpm-rpmbuild-define=_build_id_links none") }) +test.each([ + { channel: "dev", inspect: false }, + { channel: "beta", inspect: true }, + { channel: "prod", inspect: false }, +])("Electron fuses for $channel", ({ channel, inspect }) => { + // Absent keys keep Electron's defaults: NODE_OPTIONS stays on, the asar and file: fuses stay as they are. + expect(load(channel).electronFuses).toEqual({ + enableCookieEncryption: true, + runAsNode: false, + enableNodeCliInspectArguments: inspect, + resetAdHocDarwinSignature: true, + }) +}) + test("legacy Linux launcher stays hidden", async () => { const desktop = await Bun.file(path.join(import.meta.dirname, "resources/linux/opencode-desktop.desktop")).text() expect(desktop).toContain("Exec=/opt/OpenCode/ai.opencode %U") diff --git a/packages/desktop/electron-builder.config.ts b/packages/desktop/electron-builder.config.ts index 2d4f6f7933a..e60d6270a0c 100644 --- a/packages/desktop/electron-builder.config.ts +++ b/packages/desktop/electron-builder.config.ts @@ -113,7 +113,18 @@ const getBase = (appId: string): Configuration => { // https://www.electronjs.org/docs/latest/tutorial/fuses#cookieencryption // Flipping a fuse breaks the macOS signature. A build without a signing identity is not signed again, so re-sign it // ad hoc or Apple Silicon refuses to launch it. A signed build is signed again after the fuses anyway. - electronFuses: { enableCookieEncryption: true, resetAdHocDarwinSignature: true }, + electronFuses: { + enableCookieEncryption: true, + // Started as plain Node (ELECTRON_RUN_AS_NODE) or with an inspector, the signed binary would run any code under + // the app's identity, which macOS lets read the app's Keychain key and so every cookie. Nothing runs the app as + // Node: the CLI is its own executable. Beta keeps --inspect, as it keeps its on-request debugging port, for the + // startup benchmark's Node timings (perf/startup.bench.ts). + runAsNode: false, + enableNodeCliInspectArguments: resolveChannel() === "beta", + // NODE_OPTIONS stays: a packaged app already ignores every option but --http-parser and --max-http-header-size, + // and turning the fuse off would also strip NODE_EXTRA_CA_CERTS from the environment the CLI and its terminals get. + resetAdHocDarwinSignature: true, + }, afterPack: async (context) => { const arch = Arch[context.arch]