All jobs

Turn Sentry Errors Into Fix Pull Requests for an Electron App

Yes. A Sentry alert on your Electron app starts a run; the agent reads the scrubbed event, maps frames to the right module, reproduces it in Vitest and opens a PR.

Run this on RushOpens the console with this prompt ready to send, in a Project that has your repository.

What the agent does

The agent begins with the alert payload after the prompt and the Sentry connection: it fetches the issue and its latest event and reads what an Electron app actually sends. In an app set up like electron/fiddle, packages/app/src/main/crash/sentry.ts starts @sentry/electron 7 in the main process only when the app is packaged, not in test mode and the crashReports setting is on, with defaultIntegrations: false and an explicit list: breadcrumbs, context, child process, uncaught exception, unhandled rejection, session tracking and dedupe, and no console, network or local-variable integrations. beforeSend runs prepareEvent from scrub.ts, which drops extra, user, server_name and modules, keeps only the app, os, device, runtime, electron, chrome, node, gpu, culture and trace contexts, replaces the home directory with ~, redacts tokens and key=value secrets, strips URL query strings, turns gist ids into <gist-id> and never sends a native minidump. So the event the agent reads has a release of the form Electron-Fiddle@1.2.3 from releaseName, the Electron, Chrome and Node versions, the OS, a stack with scrubbed paths and breadcrumbs with no console or network entries, and nothing else.

That shapes the work. The release names the version, so the agent checks out the matching tag before reading frames, because the main process is bundled by Forge's Vite plugin from vite.main.config.mts and a line number from the bundle only means something against the build that produced it; release.yml runs getsentry/action-release for the electronjs org, so the agent checks whether the event's frames are already unminified. It tells main from renderer from preload by the event's contexts.electron and the module path, then follows the app's own rules in CLAUDE.md: main owns state through the StateHub, renderers only render and request changes over EIPC bindings, and errors are FiddleErrors with a stable code. A frame in packages/app/src/main/documents/ or packages/app/src/main/github/ points at main-process logic that runs under plain Node in tests; one in packages/app/src/renderer/ points at a React component tested under jsdom.

It reproduces the error as a Vitest test beside the module, the way the repository already does: vitest.config.ts defines the core, app:node and app:jsdom projects, main modules mock electron with vi.mock as sentry.test.ts and commands.test.ts do, and yarn vitest run --project app:node runs one project. The test calls the function the top in-app frame names with the state the breadcrumbs describe, asserts the exception, and fails first. Then the fix: a missing guard, a FiddleError with the right code where a raw Error escaped, or a store update that assumed a window still existed, kept to the module the frame named. If the error is reachable from the UI, the agent can also run yarn start:xvfb with FIDDLE_DEV_SCREENSHOT to see the state, but the pull request stands on the test.

Before opening the pull request it runs what ci.yml runs: yarn generate, yarn i18n:check, yarn format:check, yarn lint, yarn typecheck and yarn test, with the user-visible string, if the fix adds one, placed in the i18n catalog with a description as the project requires. The pull request links the Sentry issue, quotes the exception, the release and the scrubbed frames, and shows the test failing before and passing after. If it cannot reproduce the error from what the event carries, which is the price of an event that sends no console output, it opens no pull request and says what the scrubbed event lacked.

Start it with one API call

POST https://api.phoenix.so/o/{org}/sessions with this body:

{
  "agent": "claude",
  "input": "A Sentry alert fired for this Electron app; the alert payload follows this prompt. Use the Sentry connection to read the issue's latest event: the release, the contexts.electron, os and app blocks, the in-app frames and the breadcrumbs. Read CLAUDE.md, packages/app/src/main/crash/sentry.ts and scrub.ts first so you know what the event does and does not carry, and vitest.config.ts for the test projects. Check out the tag the release names before matching frames to source, and tell main, preload and renderer apart. Write a Vitest test beside the module the top in-app frame names, mocking electron the way the existing tests do, that reproduces the exception and fails first; then fix the cause in that module, following the rules in CLAUDE.md: main owns state, errors are FiddleErrors with a stable code, user-visible strings go in the i18n catalog. Run yarn generate, yarn i18n:check, yarn format:check, yarn lint, yarn typecheck and yarn test. Open a pull request that links the Sentry issue, quotes the release and frames, and shows the test failing before the fix. Change nothing unrelated. If the scrubbed event is not enough to reproduce the error, open no pull request and say what was missing.\n\nAlert payload:\n{payload}",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ],
  "connections": [
    "sentry"
  ]
}
  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 changes one main-process or renderer module under packages/app/src/ and adds or extends the *.test.ts or *.test.tsx file beside it, with an i18n catalog entry under packages/app/src/i18n/locales/ when the fix shows the user a message. Its description names the Sentry issue, the release and the frames it matched to source, and quotes the Vitest run before and after the fix together with the lint, typecheck, format and i18n checks.

The description also records how the frame was matched: the tag it checked out, whether the event's frames were already mapped to source by the release upload, and which process the error came from. Anything the scrubbed event could not tell, such as which document was open, is stated as an assumption the test encodes.

Before merging, a reviewer checks that the fix sits in the module that owns the behaviour, that a new FiddleError code is one the renderer can show, and that the test would catch the regression on all three CI platforms. A run that could not reproduce the error ends with a note and no branch.

Run it on every Sentry issue alert

Give the Sentry project an alert rule whose action is a webhook to a handler on your server. The handler verifies Sentry's own signature on the delivery, sends this request with the alert JSON after the prompt and a request_id that is a UUID v5 of the Sentry issue id, so a redelivered alert returns the existing run. Each distinct issue becomes one run and, when it reproduces, one pull request.

Set a webhook URL on the API key and Rush POSTs run.completed or run.failed to it with the session_url. To keep the prompt in Rush instead, create an automation in the Project with a webhook trigger and have the handler forward the alert body to it with the trigger's secret as Authorization: Bearer; Sentry signs its own requests and cannot send that header itself. max_runs_per_hour on the automation keeps a release that crashes on launch from starting a run per event.

The use case this job follows, with its automation and trigger: Fix a bug from an alert.

Why run it on Rush?

An Electron crash report is thinner than a server one by design: this app strips console output, network breadcrumbs, local variables and anything with a path or a token before sending, so reading it well means knowing what scrub.ts removed and matching the rest to the right process and the right build. The agent reads the scrubbing code first, checks out the release's tag, and reproduces the error in the project's own Vitest projects, with Electron mocked the way the existing tests do, rather than guessing from a line number in a bundle.

The result is a pull request whose test fails on the reported exception and passes after the fix, backed by a transcript of every command, including the full ci.yml check list run in a sandbox with the pinned Node from .nvmrc. Several issues from one release each get their own sandbox and branch, and an event too scrubbed to reproduce ends as a note rather than a guess.

Frequently asked questions

The frames point into a Vite bundle. How does it find the source line?

It reads the event's release, which sentry.ts sets to Electron-Fiddle@<version>, checks out that tag, and matches by function name and module path rather than trusting a bundle line number. release.yml runs getsentry/action-release, so the agent also checks whether the event's frames were already mapped to source for that release and uses those when present.

Why is there no console output or request history in the event?

Because the app turns those off on purpose: sentry.ts sets defaultIntegrations: false and lists no console or network integration, and scrubBreadcrumb drops console, fetch, xhr, http and net breadcrumbs. What remains is the exception, the scrubbed stack, the app, OS and Electron contexts and the remaining breadcrumbs, and the agent works from those. When that is not enough to reproduce the error, it says so instead of opening a pull request.

Does the test need a real Electron?

No. The repository's own tests mock electron with vi.mock, as sentry.test.ts does for app, and run under the app:node or app:jsdom Vitest project. The agent follows that pattern, so the reproduction runs in the same yarn test CI already runs on Linux, macOS and Windows. The in-house e2e driver is for behaviour that needs a window, and the pull request stands on the unit test.

What if the fix needs a message shown to the user?

CLAUDE.md says every user-visible string comes from the i18n catalog under packages/app/src/i18n/locales/, with a description for each English key, and that errors are FiddleErrors with a stable code. The agent adds the key, runs yarn generate and yarn i18n:check, and throws a FiddleError with a code the renderer can localise rather than a raw Error with English text.

How does it read the Sentry issue?

Through the Sentry connection named in connections, which is connected once under Settings → Connections in the console. The run reads the issue and its latest event with that connection; no Sentry token is pasted into the prompt, and the alert payload after the prompt only tells it which issue to open.

More Electron jobs

The same job on other stacks

Keep reading