From 7cee4b30a4aff5750b9f728ac32b4630563bc568 Mon Sep 17 00:00:00 2001 From: Julius Olsson Date: Sat, 28 Nov 2026 01:49:34 -0800 Subject: [PATCH 1/3] docs(release): plan the Electron startup correction --- docs/plans/2026-11-28-electron-agy-startup.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 docs/plans/2026-11-28-electron-agy-startup.md diff --git a/docs/plans/2026-11-28-electron-agy-startup.md b/docs/plans/2026-11-28-electron-agy-startup.md new file mode 100644 index 000000000..2bb4c64d7 --- /dev/null +++ b/docs/plans/2026-11-28-electron-agy-startup.md @@ -0,0 +1,16 @@ +# Restore Electron startup for the Antigravity release + +## Evidence + +The unpublished 0.1.11 candidate stalled at the packaged smoke step. +Starting the compiled main process under native Electron reported a missing +Terminal export from the CommonJS package @xterm/headless before app readiness. +The existing file-presence check passed on that binary. + +## Changes + +1. Import the CommonJS default value in the Antigravity terminal composer. +2. Start the compiled main bundle under Electron during package verification + and fail within a bounded interval when startup fails. +3. Recheck draft-preservation behavior and the native smoke on the fixed build. +4. Run the normal signed release workflow and verify the published feed. From 66fb4b43cbb36cf613fd2d7fe2867c95f0fb03c5 Mon Sep 17 00:00:00 2001 From: Julius Olsson Date: Sat, 28 Nov 2026 01:51:57 -0800 Subject: [PATCH 2/3] fix(release): load the terminal composer in native Electron Use the CommonJS export supported by Electron and launch the compiled main bundle with a disposable profile and a bounded deadline before signing. Retain the independent packaged-app checks for both Mac architectures. Refs #1562 --- .github/workflows/release.yml | 2 +- .../workflows/reusable-app-build-macos.yml | 2 +- package.json | 2 +- scripts/smoke-packaged-mac.mjs | 60 +++++++++++++------ src/main/index.ts | 5 +- .../antigravity/runtime/terminalComposer.ts | 8 ++- 6 files changed, 55 insertions(+), 24 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9667d7b82..182ad57d0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -183,7 +183,7 @@ jobs: run: npm run runtime:prepare:mac - name: Build app - run: npm run build + run: npm run test:package - name: Archive app build # WHY a tar instead of uploading `out/` directly: upload-artifact zips its diff --git a/.github/workflows/reusable-app-build-macos.yml b/.github/workflows/reusable-app-build-macos.yml index d7c3ac548..499b573bd 100644 --- a/.github/workflows/reusable-app-build-macos.yml +++ b/.github/workflows/reusable-app-build-macos.yml @@ -142,7 +142,7 @@ jobs: run: npm run runtime:prepare:mac - name: Build app - run: npm run build + run: npm run test:package - name: Archive app build # WHY a tar instead of uploading `out/` directly: upload-artifact zips its diff --git a/package.json b/package.json index e58da3ae9..2d7e9d9ea 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "test:live:conversations": "NODE_ENV=test AGENT_CODE_LIVE_CONVERSATIONS=1 vitest run --config vitest.live.config.ts src/main/conversations/conversations.live.test.ts", "test:live:image-corpus": "NODE_ENV=test AGENT_CODE_LIVE_IMAGE_CORPUS=1 vitest run --config vitest.live.config.ts src/providers/shared/renderer/protocols/media/imageAttachment.live.test.ts", "test:coverage": "npm run workflow-mcp:build && NODE_ENV=test vitest run --coverage", - "test:package": "npm run build && node scripts/verify-build-output.mjs", + "test:package": "npm run build && node scripts/verify-build-output.mjs && node scripts/smoke-packaged-mac.mjs --built-main", "test:contract": "node scripts/check-test-contract.mjs", "check:worktree-live-fixtures": "tsx --tsconfig tsconfig.web.json scripts/extract-worktree-live-attribution-fixtures.mts --verify-checked-in", "extract:conversations": "tsx --tsconfig tsconfig.node.json scripts/extract-conversation-corpus.mts", diff --git a/scripts/smoke-packaged-mac.mjs b/scripts/smoke-packaged-mac.mjs index 2fb45bfde..a66ed5b24 100644 --- a/scripts/smoke-packaged-mac.mjs +++ b/scripts/smoke-packaged-mac.mjs @@ -1,21 +1,45 @@ #!/usr/bin/env node -import { spawn } from 'node:child_process' -import { resolve } from 'node:path' +import { spawnSync } from 'node:child_process' +import { mkdtempSync, rmSync } from 'node:fs' +import { tmpdir } from 'node:os' +import { join, resolve } from 'node:path' +import { fileURLToPath, pathToFileURL } from 'node:url' +import electron from 'electron' -// Run only the host-native thin app. The structural verifier checks both -// artifacts byte-for-byte; trying to execute the opposite slice would add a -// hidden Rosetta dependency to otherwise clean CI runners. -const dir = process.arch === 'arm64' ? 'mac-arm64' : 'mac' -const executable = resolve('release', dir, 'Agent Code.app', 'Contents', 'MacOS', 'Agent Code') - -const code = await new Promise((resolvePromise, reject) => { - const child = spawn(executable, ['--packaging-smoke'], { - stdio: 'inherit', - env: { ...process.env, AGENT_CODE_PERF: '0' }, - }) - child.once('error', reject) - child.once('exit', exitCode => resolvePromise(exitCode ?? 1)) -}) - -if (code !== 0) process.exit(code) +if (process.versions.electron) { + // Loading the build through a bootstrap lets an ESM linking error reach CI + // immediately. Electron's default application loader can leave an error + // dialog open forever before our main entry has installed its own handlers. + try { + electron.app.setAppPath(process.cwd()) + await import(pathToFileURL(resolve('out/main/index.js')).href) + } catch (error) { + console.error('[packaging-smoke] main entry failed to load', error) + electron.app.exit(1) + } +} else { + // Before packaging use the installed Electron with the production bundle. + // After packaging run the host-native thin app itself (the other slice is + // verified structurally), retaining the strict isPackaged check in main. + const builtMain = process.argv.includes('--built-main') + const archDir = process.arch === 'arm64' ? 'mac-arm64' : 'mac' + const executable = builtMain ? electron : resolve('release', archDir, 'Agent Code.app', 'Contents', 'MacOS', 'Agent Code') + const args = builtMain ? [fileURLToPath(import.meta.url), '--packaging-smoke', '--built-main-smoke'] : ['--packaging-smoke'] + const profile = mkdtempSync(join(tmpdir(), 'agent-code-startup-smoke-')) + try { + const env = { ...process.env, HOME: profile, AGENT_CODE_PERF: '0' } + delete env.ELECTRON_RUN_AS_NODE + const result = spawnSync(executable, [`--user-data-dir=${profile}`, '--noerrdialogs', ...args], { + env, encoding: 'utf8', timeout: 30_000, killSignal: 'SIGKILL', + }) + process.stdout.write(result.stdout ?? '') + process.stderr.write(result.stderr ?? '') + if (result.error) throw result.error + if (result.status !== 0 || !/^\[packaging-smoke\] OK /m.test(result.stdout)) { + throw new Error(`Electron did not confirm startup (exit ${result.status}, signal ${result.signal})`) + } + } finally { + rmSync(profile, { recursive: true, force: true }) + } +} diff --git a/src/main/index.ts b/src/main/index.ts index 5497ab5ea..8320e230c 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -381,7 +381,10 @@ async function runPackagingSmoke(): Promise { join(app.getAppPath(), 'out', 'main', 'runtime', 'cloudflared', 'manifest.json'), ] const missing = required.filter(path => !existsSync(path)) - if (!app.isPackaged || missing.length > 0) { + // PR CI also runs the compiled bundle in Electron's default app before signing. + // An unbundled binary still cannot pass the packaged launcher's check. + const expectPackaged = !process.argv.includes('--built-main-smoke') + if (app.isPackaged !== expectPackaged || missing.length > 0) { console.error('[packaging-smoke] failed', { isPackaged: app.isPackaged, missing }) app.exit(1) return diff --git a/src/providers/antigravity/runtime/terminalComposer.ts b/src/providers/antigravity/runtime/terminalComposer.ts index 2d65186d6..685972adf 100644 --- a/src/providers/antigravity/runtime/terminalComposer.ts +++ b/src/providers/antigravity/runtime/terminalComposer.ts @@ -1,4 +1,8 @@ -import { Terminal } from '@xterm/headless' +import xterm, { type Terminal } from '@xterm/headless' + +// Electron links the production bundle as native ESM. xterm-headless 5.x +// publishes a CommonJS value whose Terminal property is available at runtime +// but is absent from Node's synthetic named exports. /** Read only the current editable region. A chat message can contain a fake * prompt; agy's native cursor, two full-width rules and empty-only hint bind @@ -12,7 +16,7 @@ export class AntigravityTerminalComposer { private disposed = false constructor(cols: number, rows: number, private readonly changed: () => void) { - this.screen = new Terminal({ cols, rows, scrollback: 0, allowProposedApi: true }) + this.screen = new xterm.Terminal({ cols, rows, scrollback: 0, allowProposedApi: true }) } output(data: string): Promise { From 647d60969485919a55ebcea02db3ad5cf93e3aa2 Mon Sep 17 00:00:00 2001 From: Julius Olsson Date: Sat, 28 Nov 2026 01:52:56 -0800 Subject: [PATCH 3/3] test(release): run packaged smoke without the development Electron binary --- scripts/smoke-packaged-mac.mjs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/scripts/smoke-packaged-mac.mjs b/scripts/smoke-packaged-mac.mjs index a66ed5b24..b99e3b4d5 100644 --- a/scripts/smoke-packaged-mac.mjs +++ b/scripts/smoke-packaged-mac.mjs @@ -5,18 +5,18 @@ import { mkdtempSync, rmSync } from 'node:fs' import { tmpdir } from 'node:os' import { join, resolve } from 'node:path' import { fileURLToPath, pathToFileURL } from 'node:url' -import electron from 'electron' if (process.versions.electron) { // Loading the build through a bootstrap lets an ESM linking error reach CI // immediately. Electron's default application loader can leave an error // dialog open forever before our main entry has installed its own handlers. + const { app } = await import('electron') try { - electron.app.setAppPath(process.cwd()) + app.setAppPath(process.cwd()) await import(pathToFileURL(resolve('out/main/index.js')).href) } catch (error) { console.error('[packaging-smoke] main entry failed to load', error) - electron.app.exit(1) + app.exit(1) } } else { // Before packaging use the installed Electron with the production bundle. @@ -24,7 +24,9 @@ if (process.versions.electron) { // verified structurally), retaining the strict isPackaged check in main. const builtMain = process.argv.includes('--built-main') const archDir = process.arch === 'arm64' ? 'mac-arm64' : 'mac' - const executable = builtMain ? electron : resolve('release', archDir, 'Agent Code.app', 'Contents', 'MacOS', 'Agent Code') + const executable = builtMain + ? (await import('electron')).default + : resolve('release', archDir, 'Agent Code.app', 'Contents', 'MacOS', 'Agent Code') const args = builtMain ? [fileURLToPath(import.meta.url), '--packaging-smoke', '--built-main-smoke'] : ['--packaging-smoke'] const profile = mkdtempSync(join(tmpdir(), 'agent-code-startup-smoke-')) try {