diff --git a/config/electron-builder.config.cjs b/config/electron-builder.config.cjs index 30b61e6b2e7..ef545043146 100644 --- a/config/electron-builder.config.cjs +++ b/config/electron-builder.config.cjs @@ -301,6 +301,7 @@ module.exports = { // disappears from Agent Session History in packaged builds only. Worker // entries reached solely from the Electron main process stay packed, since // asar redirects their app.asar paths. + // Why: `orca serve` runs the orcad selection entry under ELECTRON_RUN_AS_NODE too (#27307). asarUnpack: [ 'out/package.json', 'out/cli/**', @@ -327,6 +328,7 @@ module.exports = { 'out/main/plugin-host-entry.js', 'out/main/computer-sidecar.js', 'out/main/parcel-watcher-process-entry.js', + 'out/main/orcad/orcad-local-serve-selection-entry.js', 'out/main/chunks/**', 'resources/**', 'node_modules/ws/**', diff --git a/config/scripts/electron-builder-config.test.mjs b/config/scripts/electron-builder-config.test.mjs index 3daa56d1aa6..2c0af72da98 100644 --- a/config/scripts/electron-builder-config.test.mjs +++ b/config/scripts/electron-builder-config.test.mjs @@ -357,6 +357,28 @@ describe('electron-builder config', () => { expect(viteConfig).toMatch(new RegExp(`'${entryFilename.replace(/\.js$/, '')}':\\s*resolve\\(`)) }) + // Why: the CLI runs this entry under ELECTRON_RUN_AS_NODE, which cannot read + // app.asar, so a packed copy sends every `orca serve` to Electron (#27307). + it('unpacks the orcad serve-selection entry the CLI runs', async () => { + const sharedSource = await readFile( + join(REPO_ROOT, 'src', 'shared', 'orcad-local-serve-selection.ts'), + 'utf8' + ) + const entryName = sharedSource.match(/ORCAD_LOCAL_SERVE_SELECTION_ENTRY = '([^']+)'/)?.[1] + expect(entryName).toBeDefined() + + const matcher = new FileMatcher( + '/app', + '/dest', + (value) => value, + electronBuilderConfig.asarUnpack + ) + const isUnpacked = matcher.createFilter() + expect( + isUnpacked(join('/app', 'out', 'main', `${entryName}.js`), { isDirectory: () => false }) + ).toBe(true) + }) + // Why: the scanner service is forked with ELECTRON_RUN_AS_NODE, so asar is // invisible to it and a packed worker entry fails closed — dropping every // OpenCode session in packaged builds while dev stays green. Three legs must