# Fix a Failing CI Run for an Electron App

Yes. An agent reads the failed step on the failing OS, reruns package, lint, type check, tests and the smoke test in its sandbox, fixes the cause and opens a PR.

[Run this on Rush](https://cloud.getrush.ai/run/fix-failing-ci/electron/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

An Electron app's CI runs the same steps on three operating systems, so the first thing the agent establishes is which OS and which step failed, and whether the other two legs passed. In an app shaped like electron-react-boilerplate, `.github/workflows/test.yml` runs on pushes to `main` and on pull requests with a matrix of `macos-latest`, `windows-latest` and `ubuntu-latest`: `actions/checkout@v7.0.1`, `actions/setup-node@v7.0.0` on Node 24 with the npm cache, `npm ci`, then one step that runs `npm run package`, `npm run lint`, `npm exec tsc -- --noEmit` and `npm test` in sequence with `GH_TOKEN` set, and a last step that runs `npm run test:smoke`, under `xvfb-run --auto-servernum` on Linux. `gh run view <id> --log-failed` gives the leg and the first failing command; a failure on all three legs is in the code, a failure on one is in that platform's packaging or startup.

Then it reads what each command does here, because the scripts are not the defaults. `package.json` requires Node `>=24.0.0` and npm `>=10.0.0`; its `postinstall` installs a second package set under `.erb/tooling`, downloads Electron, and runs `electron-builder install-app-deps` for the native dependencies declared in `release/app/package.json`. `package` is `electron-vite build` followed by `electron-builder build --publish never`, which on Linux produces an AppImage, on macOS a DMG with `hardenedRuntime` and notarization turned off, and on Windows an NSIS installer, per the `build` block in `package.json`. `lint` runs ESLint under `NODE_ENV=development` with the flat config in `eslint.config.js`, which loads the TypeScript plugin and parser from `.erb/tooling`, plus the React, hooks, `jsx-a11y`, import, Jest, promise, compat and Prettier plugins. `jest.config.js` uses `ts-jest` from the same tooling directory, a `jsdom` environment, and a `setupFiles` entry, `.erb/scripts/check-build-exists.ts`, that throws unless `release/app/dist/main/main.js` and the renderer bundle exist, which is why `npm run package` has to precede `npm test` and why running `npm test` alone on a laptop fails with a message about building first.

The two test files and the smoke test are small enough to read whole. `src/__tests__/App.test.tsx` renders `App` and expects a heading named `electron-react-boilerplate` and two links with exact hrefs; `src/__tests__/updates.test.ts` mocks `electron`, `electron-updater` and `electron-log` and checks that `startAutoUpdates` in `src/main/updates.ts` does nothing in development and calls `checkForUpdatesAndNotify` once when packaged. `.erb/scripts/smoke-test.cjs` spawns `npm start -- --remoteDebuggingPort 9335` with `PORT=1213` (and `--noSandbox` on Linux under `CI`), polls `http://127.0.0.1:9335/json/list` for up to two minutes for a page target at `http://localhost:1213`, opens its WebSocket debugger URL and collects `Runtime.exceptionThrown` events. So a smoke failure is either the main process exiting before the window opened, which `src/main/main.ts` would show in the captured output, or a renderer exception the test reports verbatim.

Reproduction on Linux covers the Ubuntu leg exactly and the shared steps of the other two. In the sandbox the agent runs `npm ci` (which runs the tooling install and Electron download), `npm run package` for the AppImage, `npm run lint`, `npm exec tsc -- --noEmit` and `npm test`, then `xvfb-run --auto-servernum npm run test:smoke`. A macOS-only failure in `electron-builder` (signing, the `afterSign` notarize hook, entitlements) or a Windows-only one (an NSIS step, a path separator) cannot be rerun here, so the agent reads the log, `package.json`'s `build` block and `.erb/scripts/notarize.js`, and says in the pull request that the fix is reasoned from the log. The fix is the smallest one: a type after a dependency bump, an ESLint or Prettier finding in the file named, a test expectation that a deliberate UI change made stale (with the change named), or a main-process error that stops the window from opening. It does not add `continue-on-error`, skip a leg of the matrix, or turn a rule off, and it reruns the whole sequence before opening the pull request.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "The CI workflow for this Electron app failed; the failed workflow run follows this prompt. Read .github/workflows/test.yml, package.json including its build block and scripts, release/app/package.json, electron.vite.config.ts, jest.config.js, eslint.config.js, .erb/scripts/check-build-exists.ts, .erb/scripts/smoke-test.cjs, src/main/main.ts and every file under src/__tests__, then read the failed job's log with gh run view <run id> --log-failed. Name the matrix OS, the first failing command and whether the other legs passed. Reproduce in the sandbox in the workflow's order: npm ci, npm run package, npm run lint, npm exec tsc -- --noEmit, npm test, then the smoke test under xvfb-run. If the failure is only on macOS or Windows, reason from the log, the build block and the notarize script, and say so. Make the smallest change that fixes the cause: fix a type or a lint finding in the named file, update a test expectation only when a deliberate UI change made it stale and name that change, or fix the main-process error that keeps the window from opening. Do not add continue-on-error, remove a matrix entry, or disable a rule. Rerun the whole sequence and open a pull request that names the failed run, quotes the failing lines, explains the cause in one paragraph and pastes each command with its output.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

The pull request names the failed run, the OS leg and the step, and quotes the lines that decided it. The diff sits in one of a few places: a file under `src/renderer` or `src/main` for a type, lint or startup error; one of the two files under `src/__tests__` when an expectation went stale, with the UI change that made it so named in the body; or a line in `package.json`'s `build` block for a platform packaging error, with the reasoning from the log when the agent could not rerun that platform.

The repository's `test.yml` runs on the pull request across all three operating systems, which is the check the sandbox cannot replace: the Linux leg confirms what the agent reran, and the macOS and Windows legs test the platform-specific fix it could only read about. The body separates the commands it ran from the reasoning it did, so a reviewer knows which is which.

A reviewer reads the cause against the quoted log, checks that `test.yml` still has three matrix entries and no `continue-on-error`, and reads any changed test expectation as a product change that needs the person who made it to agree. A `build` block change is checked against electron-builder's documentation for the target it touches.

## Run it on every failed CI run on the default branch

Add an automation to the Project for this repository with the prompt above and a `github` trigger on `workflow_run.failure`, with `branch_patterns` set to `main` so only the default branch's failures start a run; CI runs from forks never fire. The trigger appends the run event after the prompt, so the agent reads the run id, the workflow and the commit from it rather than listing runs. `max_runs_per_hour` caps a day of red pushes.

From your own server instead, a handler for GitHub's `workflow_run` webhook with `conclusion: failure` sends `POST /o/{org}/sessions` with this prompt and the run id in `input`, the repository in `resources`, and a `request_id` that is a UUID v5 of the run id so a redelivery returns the same run. A `webhook_url` on the key receives `run.completed` with `data.session_url` to read the pull request from.

## Why run it on Rush?

An Electron CI failure is expensive to reproduce by hand: a full `npm ci` with the tooling install and the Electron download, a packaging step that builds an installer you do not need, a Jest setup that refuses to run until the app is built, and a smoke test that needs a display. Most developers rerun the job and hope. In a Rush sandbox the agent runs the exact sequence under `xvfb-run`, and every command with its output is in the transcript, including the renderer exceptions the smoke test collected.

The three-OS matrix stays the referee. The agent fixes the Linux leg it can rerun and reasons about the macOS and Windows legs from their logs, and the pull request says which was which; the matrix on the pull request then runs all three, and nothing merges until it is green and a person has read the cause.

## Frequently asked questions

### Can it reproduce a macOS or Windows failure?

No. The sandbox is Linux, so it reruns the Ubuntu leg exactly and reads the other legs' logs, `package.json`'s `build` block and `.erb/scripts/notarize.js` for a signing or packaging error. The pull request says the fix was reasoned from the log, and the matrix on the pull request is the rerun.

### Why does npm test fail without a build?

`jest.config.js` lists `.erb/scripts/check-build-exists.ts` in `setupFiles`, and that script throws unless `release/app/dist/main/main.js` and the renderer bundle exist. That is why `test.yml` runs `npm run package` first, and the agent does the same.

### What does the smoke test actually check?

`.erb/scripts/smoke-test.cjs` starts the app with a remote debugging port, waits up to two minutes for a renderer page at `http://localhost:1213`, connects to its debugger and collects thrown exceptions. A failure there is the main process exiting early or a renderer error, and the captured output names it.

### Will it skip the failing platform to get green?

No. The prompt forbids `continue-on-error`, removing a matrix entry or disabling a rule. A platform-only failure gets a fix reasoned from the log and a clear statement that it was not rerun, so the reviewer knows what the pull request's own checks are about to test.

## More Electron jobs

- [Turn Sentry Errors Into Fix Pull Requests for an Electron App](https://getrush.ai/run/fix-sentry-errors/electron/)
- [Audit the Dependency Licenses of an Electron App](https://getrush.ai/run/license-audit/electron/)
- [Turn Linear Issues Into Pull Requests for an Electron App](https://getrush.ai/run/linear-issue-to-pr/electron/)

## The same job on other stacks

- [Fix Failing GitHub Actions Checks in an Express API](https://getrush.ai/run/fix-failing-ci/express/)
- [Fix Failing GitHub Actions Checks in a FastAPI App](https://getrush.ai/run/fix-failing-ci/fastapi/)
- [Fix a Failing CI Build in a Fastify API](https://getrush.ai/run/fix-failing-ci/fastify/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
