Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reusable-app-build-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions docs/plans/2026-11-28-electron-agy-startup.md
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
62 changes: 44 additions & 18 deletions scripts/smoke-packaged-mac.mjs
Original file line number Diff line number Diff line change
@@ -1,21 +1,47 @@
#!/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'

// 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.
const { app } = await import('electron')
try {
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)
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
? (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 {
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 })
}
}
5 changes: 4 additions & 1 deletion src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,10 @@ async function runPackagingSmoke(): Promise<void> {
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
Expand Down
8 changes: 6 additions & 2 deletions src/providers/antigravity/runtime/terminalComposer.ts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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<void> {
Expand Down
Loading