Skip to content

feat(desktop): Electron 45, sandboxed preloads, origin-pinned IPC [SAP-4382] - #1269

Closed
antoine-berger wants to merge 10 commits into
mainfrom
antoine-berger/ship-plan-sap-4382
Closed

antoine-berger wants to merge 10 commits into
mainfrom
antoine-berger/ship-plan-sap-4382

Conversation

@antoine-berger

@antoine-berger antoine-berger commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Primary change type

  • Bug fix
  • Documentation
  • Feature
  • Tests
  • Dependency update
  • Maintenance or refactor

Problem and motivation

Desktop hardening for Agent Studio (@sapiom/harness-desktop): move to a supported Electron release and tighten the app's defaults (sandboxed preload windows, desktop IPC limited to the harness page, explicit restart for Windows updates until builds are code-signed).

Summary and scope

  • Electron 33 -> 45.1.0 (exact pin, equal to electronVersion in electron-builder.yml). Electron 44+ requires macOS 13: mac.minimumSystemVersion sets the Info.plist floor, and pack.mjs --mac stamps minimumSystemVersion: 22.0.0 (the Darwin version of macOS 13) into the *-mac.yml update manifests, so installs on macOS 12 skip this update instead of installing a build they cannot launch (electron-updater 6.8.9+, what installs already run, honours the key).
  • Sandboxed preloads. scripts/build-preloads.mjs bundles each src/preload/*.mts with esbuild into one IIFE script, dist/preload/<name>.cjs (ipc.ts inlined, electron the only external). The setup, main and update windows now all run with sandbox: true.
  • IPC pinned to the harness origin. setTrustedWindow(win, origin) records the origin the main window loaded; isTrustedSender requires the call to come from the main window's top frame, on that exact origin, at /. will-navigate keeps only that origin in the main window; other local origins open in the existing preview window (navigation-policy.ts).
  • Windows install-on-quit. autoInstallAllowed (update-policy.ts) keeps autoInstallOnAppQuit off on Windows until the baked app-update.yml carries a non-null publisherName. Downloads still happen; the update window hides the auto-update toggle and the update installs only through "Restart now". Lifts by itself once a signed build ships.
  • Lockfile refresh (separate commit): pnpm update -r --no-save, no package.json change.

Out of scope: Windows code signing itself, an Intel macOS build, and the remaining advisories below (each needs a major bump or an upstream release).

Related work

Related issue or discussion: SAP-4382 (internal tracker).

Validation

pnpm install --frozen-lockfile                           OK
pnpm build                                               OK
pnpm typecheck                                           OK
pnpm --filter @sapiom/harness-desktop test               31 files, 293 tests passed
pnpm test (all packages, sequential)                     all passed
pnpm lint                                                0 errors
pnpm terminology:check / credential-header:check / provider-copy:check / examples:check   OK
packaged Linux smoke (pack.mjs --linux, smoke.sh)        17 passed, 1 skipped (Windows-only agent-shim); CI desktop-smoke green
macOS / Windows packaging + smoke                         not run pre-merge; first desktop-release run after merge
pnpm audit --prod: 52 advisories on main -> 5 after the refresh, 0 new

Remaining pnpm audit --prod advisories, all blocked by a declared range:

Package Severity Path Blocked by
toml 4.3.0 (3 advisories) high @sapiom/opencode > @opencode-ai/plugin > effect @opencode-ai/plugin pinned to 1.18.29
zod 4.1.8 / 3.25.76 high @opencode-ai/plugin, @sapiom/agent-map the same pin; zod ^3.25.0 in agent-map (fix is in 4.6.6)
uuid 10.0.0 moderate @sapiom/agent-map uuid ^10.0.0

Tests and documentation

New: navigation-policy.test.ts, trusted-sender.test.ts, preload-bundle.test.ts (bundles really are classic scripts requiring only electron), window-sandbox.test.ts (every preload window keeps sandbox: true, contextIsolation: true, nodeIntegration: false). Extended: update-policy.test.ts (autoInstallAllowed, withMinimumSystemVersion and its pack.mjs wiring), dialogs.test.ts, paths.test.ts, update.html.test.ts. The packaged --smoke checks (preload-bridge, desktop-bridge) prove the bundled preloads load in sandboxed windows. packages/harness-desktop/CLAUDE.md updated.

Compatibility and release impact

  • Breaking or externally visible changes: Agent Studio now requires macOS 13 or later; installs on macOS 12 stay on their current version. On Windows, a downloaded update no longer installs on quit; the user installs it with "Restart now" until builds are signed.
  • Changeset: Added (@sapiom/harness-desktop minor).

Security

  • I have not included secrets, credentials, private data, or unsanitized logs.
  • This pull request does not publicly disclose a suspected vulnerability. I will follow the Security Policy for private reporting.

AI assistance

  • I did not use AI assistance for this change.
  • I used AI assistance and have described it below.

Claude Code (Craft Agent) planned and implemented the change from the tracked issue, then ran the checks listed above. The plan was fact-checked by an independent agent before implementation and the diff goes through an independent review before this PR leaves draft.

Checklist

  • I read CONTRIBUTING.md, and this contribution follows the direct-PR or issue-first policy.
  • This pull request addresses one focused problem and contains no unrelated cleanup.
  • I added or updated tests, or explained above why tests are not applicable.
  • I ran the relevant build, typecheck, lint, and test commands, or explained any N/A checks above.
  • I updated documentation for user-facing changes, or marked it N/A above.
  • I added a Changeset for a published-package change, or explained why it is not applicable.
  • I can explain and maintain every submitted change, including any AI-assisted work.

🤖 Generated with Claude Code

antoine-berger and others added 2 commits October 28, 2026 01:34
…P-4382]

- Electron 33 -> 45.1.0 (macOS 13 minimum). Preloads are bundled into one
  IIFE script each so every preload window can run with sandbox: true.
- The IPC sender check and in-window navigation are pinned to the harness
  origin the main window loaded; other local origins open in the preview
  window.
- Install-on-quit stays off on Windows until the build bakes a publisherName.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
pnpm update -r --no-save: no package.json change, electron stays 45.1.0.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@antoine-berger

Copy link
Copy Markdown
Contributor Author

/devin review

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Starting Devin Review.

Devin Review

@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 57 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f7cbf5fc-c688-484e-995c-b4c20b3e4979
Commits

Reviewing files that changed from the base of the PR and between 8d77192 and 9b7f940.

Files ignored due to path filters: 1
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
Files selected for processing: 27
  • .changeset/desktop-electron-45-hardening.md
  • .github/workflows/harness.yml
  • packages/harness-desktop/CLAUDE.md
  • packages/harness-desktop/electron-builder.yml
  • packages/harness-desktop/package.json
  • packages/harness-desktop/scripts/build-preloads.mjs
  • packages/harness-desktop/scripts/pack.mjs
  • packages/harness-desktop/src/main/dialogs.test.ts
  • packages/harness-desktop/src/main/index.ts
  • packages/harness-desktop/src/main/ipc.ts
  • packages/harness-desktop/src/main/navigation-policy.test.ts
  • packages/harness-desktop/src/main/navigation-policy.ts
  • packages/harness-desktop/src/main/paths.test.ts
  • packages/harness-desktop/src/main/paths.ts
  • packages/harness-desktop/src/main/preload-bundle.test.ts
  • packages/harness-desktop/src/main/trusted-sender.test.ts
  • packages/harness-desktop/src/main/trusted-sender.ts
  • packages/harness-desktop/src/main/update-policy.test.ts
  • packages/harness-desktop/src/main/update-policy.ts
  • packages/harness-desktop/src/main/update-window.ts
  • packages/harness-desktop/src/main/updater.ts
  • packages/harness-desktop/src/main/window-sandbox.test.ts
  • packages/harness-desktop/src/main/windows.ts
  • packages/harness-desktop/src/preload/update.mts
  • packages/harness-desktop/src/renderer/update.html.test.ts
  • packages/harness-desktop/src/renderer/update.ts
  • pnpm-workspace.yaml
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 2 potential issues.

Devin Review

Comment thread pnpm-lock.yaml Resolved
antoine-berger and others added 8 commits October 28, 2026 05:12
…4382]

electron-builder writes no minimumSystemVersion into latest-mac.yml, so an
install on macOS 12 would auto-update into a build it cannot launch.
pack.mjs --mac now stamps the Darwin version of macOS 13 into every
*-mac.yml manifest; electron-updater (6.8.9+, what installs already run)
skips an update whose minimumSystemVersion is above os.release().

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…nts [SAP-4382]

- isTrustedSender now requires the calling frame to be the main window's top
  frame and reads its URL from that frame.
- A null publisherName (empty, ~, null, comment-only) no longer re-enables
  install-on-quit on Windows.
- mac.minimumSystemVersion 13.0 in the Info.plist.
- Comments corrected or shortened where they no longer matched the code.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ate toggle [SAP-4382]

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…382]

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…AP-4382]

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…iour [SAP-4382]

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
… [SAP-4382]

The key hashed packages/harness/package.json, whose ^1.61.0 range did not
change when the lockfile refresh moved Playwright to 1.64.1, so the job
restored 1.61 browsers and every spec failed to launch chromium.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…-4382]

An empty version would turn the cache key into a constant and mask the
next browser bump.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@antoine-berger
antoine-berger marked this pull request as ready for review October 29, 2026 00:23
@gwitwer

gwitwer commented Oct 29, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the thorough work on this, Antoine. We're going to pass on this one for now.

The gap is real but narrow: it needs a user to open or run a project they chose to clone, on a surface (Studio / the local dev tooling) that isn't core product today. Against that, the change adds behaviour developers and customers will notice, and the cost of reviewing, releasing and supporting it is higher than the risk it removes. We'd rather keep the security effort on the server-side gaps (billing scope, payment replay, OAuth, auth claims), which are approved.

Please close this PR and move the ticket to Canceled with a one-line note pointing here. If this area becomes core, or we see the gap exploited, we'll reopen it from the ticket.

Specific to this one: the Electron 33 → 45 upgrade is worth doing as desktop maintenance on the Studio team's schedule, with macOS and Windows packaged builds tested before a v* tag (installed users can't be rolled back). It doesn't need to ride as a security fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants