Skip to content

feat(browser): support Chrome extension proxy settings - #43097

Open
ninecc wants to merge 9 commits into
stablyai:mainfrom
ninecc:feat/browser-extension-proxy
Open

ninecc wants to merge 9 commits into
stablyai:mainfrom
ninecc:feat/browser-extension-proxy

Conversation

@ninecc

@ninecc ninecc commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

ZeroOmega can install in Orca but cannot apply its proxy settings. This adds the extension
proxy API so browser pages can use fixed proxies and PAC-based automatic switching.

What Changed

  • Implement permission-checked chrome.proxy.settings.get/set/clear, settings.onChange,
    and request-level onProxyError through the existing page/worker bridge.
  • Support direct, system, automatic discovery, fixed proxy rules and PAC configurations.
  • Persist overrides per browser profile, resolve extension precedence, and restore the
    latest underlying app policy when an override is cleared or its extension is disabled.
  • Serialize writes with the existing proxy queue, restore the previous configuration on
    failure, and keep recovery API calls available when network requests must be blocked.
  • Recheck both native and extension proxy readiness after request rules settle and after
    waiting for proxy updates, including failed rule decisions.
  • Read native proxy failover lists and whitespace around protocol assignments, and normalize
    native bypass separators so a representable setting can be read and reapplied.
  • Preserve native candidate order across repeated protocol assignments, ignore unsupported
    protocol assignments, and follow native single-proxy/per-protocol parsing precedence.
  • Report all-direct native rules as direct mode. Reject DIRECT-first lists with proxy
    fallbacks and mixed explicit DIRECT/proxy rules that cannot be represented safely.
  • Match native extension callbacks' global receiver, fixing ZeroOmega's
    _proxyChangeWatchers startup error.

Why

Electron does not expose this API to extensions. Reusing Orca's extension bridge and proxy
queue keeps permission checks and network policy ownership in their existing layers.

Linked Issue

Fixes #43075

Visual Proof

Before: ZeroOmega installs, but chrome.proxy.settings is unavailable and proxy profiles
cannot be applied.

After: the actual ZeroOmega UI applies a fixed proxy and a PAC profile. Local HTTP listeners
identify which endpoint received each request. With the same PAC selected, a matching host
reaches the proxy listener and the direct URL reaches the origin listener.

1. Before: failure on the baseline build

Read-only diagnostics run inside an unmodified Orca build of the issue's baseline commit,
5ff527c30b7f, show that chrome.proxy.settings is absent and record ZeroOmega's actual
"Your browser does not support proxy settings!" startup error.

Baseline API failure in Orca

2. PAC match: the request reaches PROXY-A

PAC proxy branch in Orca

3. Same PAC, direct branch: the request reaches DIRECT

PAC direct branch in Orca

Testing

  • Tested on macOS arm64 with ZeroOmega 3.5.2: fixed proxy, both PAC branches,
    disable/re-enable, and restoration after restarting Orca.

  • Regression coverage exercises actual routing, profile isolation, persistence,
    unload races, rollback, and callback compatibility in the real extension worker.

  • Focused request/proxy/persistence checks: 3 files / 14 tests passed. Coverage includes
    native SOCKS URI/default syntax and proxy failure during asynchronous request decisions.

  • Native readback regression: verified protocol whitespace roundtrips, explicit DIRECT
    rules and WebSocket routing in real Electron; a readback error still permits setting an
    override and clearing it to restore the original native routes. Proxy/persistence checks
    passed. The expanded native comparison matrix also covers DIRECT-first fallbacks,
    repeated assignments, ignored protocols and mixed single/per-protocol precedence.

  • Final head e8d2aa24ff: pnpm check:changed --base=upstream/main --timeout=30
    passed all 25 checks, including the complete related-test selection, in 523.0 seconds.

Built and ad-hoc-signed a local macOS arm64 app for UI verification. Windows/Linux UI and
native popup positioning/focus have not been tested. The official popup page was exercised
as an Orca browser tab.

Reproduce the routing and restart checks:

ORCA_BACKGROUND_LAUNCH=1 pnpm test \
  src/main/browser/extensions/proxy/browser-extension-proxy.electron.test.ts \
  src/main/browser/extensions/profile-storage/browser-extension-persistence.electron.test.ts \
  --maxWorkers=2

Risk

Level: Medium

The main risk is overriding or incorrectly restoring a profile's existing proxy policy.
Shared serialization, rollback, lifecycle cancellation and recovery guards address this.
Changing the effective configuration closes pooled connections and may interrupt downloads
or persistent connections.

Electron 43.8.7 forces mandatory PAC mode: PAC failures block requests even when callers
omit mandatory or pass false. The effective setting reports true; ZeroOmega 3.5.2
already requests this mode. Proxy authentication and complete PAC diagnostics are outside scope.

Chrome's settings model exposes one server per scheme: native failover lists are reported
using their first server. The complete underlying native policy remains intact and is
restored when the extension override is cleared. Native DIRECT-first lists with proxy fallbacks, and rules mixing explicit per-scheme DIRECT
entries with proxy entries, cannot be represented by Chrome's fixed-server model.
For these rules, settings.get returns a descriptive error instead of a setting that changes
routing when reapplied. Reading does not modify the native policy, and settings.set and
settings.clear remain available. All-direct native rules report mode: "direct".

A revert removes the API; older code ignores the optional saved proxy field. No dependency,
version or data migration changes are included.

AI Disclosure

OpenAI Codex (GPT-6) assisted implementation and testing. The contributor also manually
tested the local build.

Review

Self-reviewed permission enforcement, cancellation and policy restoration. The implementation
uses cross-platform Electron/Node APIs; local validation is limited to macOS. Only local
browser profiles attach the API; SSH/remote routing retains its existing ownership. No mobile
RPC changes are included. Unchanged effective configurations avoid connection cleanup.

Agent skill upstream boundary

  • Not applicable; no upstream skill source was copied or translated.

Notes

This targets Orca's Electron desktop browser on macOS, Windows and Linux. Mobile and ordinary
web clients are outside scope. Screenshots and local build artifacts are not committed.

Checklist

  • Focused on extension proxy support; split into callback compatibility, network
    override support, and extension API/lifecycle commits.
  • Explained behavior, mechanism, risk and rollback; linked the issue.
  • Self-reviewed cross-platform, SSH/remote, mobile, security and performance impact.
  • Captured baseline failure evidence from the unmodified source baseline.
  • Three selected screenshots uploaded as GitHub attachments.
  • Test expectations use explicit values and exercise the behavior-owning layer;
    regression failures were reproduced before the fixes. CI covers remaining platforms.

Serialize overrides with application proxy policy, restore the latest baseline on release, and keep recovery requests available when proxy application fails.
Implement permission-checked proxy settings, persistence, precedence, lifecycle cleanup, and proxy error events. Cover actual proxy routing, PAC switching, restart restoration, and unload races with Electron fixtures.

Refs stablyai#43075
@ninecc
ninecc marked this pull request as ready for review November 16, 2026 11:05
@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • Resume reviews
  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

The change adds the proxy extension namespace with settings methods and events, validates and converts proxy configurations, and manages extension proxy settings per Electron session. It connects proxy readiness to extension loading and HTTP, HTTPS, and WebSocket requests. It also adds persistence validation, proxy lifecycle and routing fixtures, and callback receiver checks.

Merge Risk: Minimal · up to e8d2a

Extension proxy settings now read back and reject native proxy configurations that cannot be represented, rather than reporting a route that differs from what Chromium uses. Spaced native assignments such as http = host:port are parsed correctly. No unresolved merge-blocking issues remain, apart from the author-reported gaps in Windows/Linux and native popup testing.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "feat(browser): support Chrome extension proxy settings" matches the main change: the PR adds the chrome.proxy.settings get/set/clear API, settings.onChange, and onProxyError for browser ext…
Linked Issues check Passed Only #43075 is an active direct link. No parent or contextual targets apply, so its coding requirements govern this assessment. The whole-PR summary at head e8d2aa2 (merge base 2e71fad) maps…
Out of Scope Changes check Passed Each changed area supports #43075 or its stated proxy scope:

- browser-extension-main-world.ts: invokes callbacks and listeners with globalThis. The PR states this fixes the ZeroOmega _proxyChangeWat…
Description check Passed The description follows the repository template closely. It has an ELI5, a detailed What Changed list, Why, a linked issue (Fixes #43075), Visual Proof with before/after evidence, Testing with checkbo…
Full details: Title check

Explanation

The title "feat(browser): support Chrome extension proxy settings" matches the main change: the PR adds the chrome.proxy.settings get/set/clear API, settings.onChange, and onProxyError for browser extensions in Orca's Electron browser. It is specific and follows conventional-commit style, so it summarizes the primary change clearly.

Full details: Linked Issues check

Explanation

Only #43075 is an active direct link. No parent or contextual targets apply, so its coding requirements govern this assessment. The whole-PR summary at head e8d2aa2 (merge base 2e71fad) maps to each requirement:

  • [#43075] Permission-checked chrome.proxy.settings.get/set/clear: registerProxyNamespace in api/proxy.ts; namespace registered in register-browser-extension-namespaces.ts; permission wired in permissions.ts; API surface in browser-extension-api-surface.ts.
  • [#43075] settings.onChange and onProxyError: declared in proxy.ts and the API surface; error forwarding in browser-extension-web-request-observer.ts.
  • [#43075] Fixed-proxy and PAC configurations: browser-extension-proxy-config.ts (fixed servers, per-protocol rules, PAC data or URL, bypass validation, Electron conversion).
  • [#43075] Profile-scoped persistence, precedence, and lifecycle cleanup: browser-extension-profile-state-store.ts and browser-extension-proxy-session.ts (install-time priority, unload reconciliation, pending-update cancellation in the Electron fixture).
  • [#43075] Restoration of underlying policy on clear or disable: proxy-settings.ts (override apply/restore, rollback, AggregateError on failed rollback) and session-proxy-application.ts.
  • [#43075] Other profiles and SSH/remote routes unaffected: per-session state in session-proxy-application.ts; PR description states that only local browser profiles attach the API.
  • [#43075] Automated tests: Electron fixtures and tests in browser-extension-proxy.electron.test.ts, browser-extension-proxy-readback-electron-fixture.ts, persistence tests, and session-services request-decision tests.

The issue asks that Electron's mandatory PAC behavior be documented. The PR description Risk section documents it. This is documentation, not a code requirement, and is non-blocking. Windows and Linux manual checks are non-coding.

No concrete unmet coding requirement was found. This relies on the summary and PR description; implementation hunks were not read in this review.

Full details: Out of Scope Changes check

Explanation

Each changed area supports #43075 or its stated proxy scope:

  • browser-extension-main-world.ts: invokes callbacks and listeners with globalThis. The PR states this fixes the ZeroOmega _proxyChangeWatchers startup error, which blocks proxy API use by the target extension.
  • browser-certificate-request-guard.ts: gates proxy readiness only for http, https, ws, and wss. This supports the requirement that recovery API calls stay available.
  • browser-extension-session-services.ts and its test: applies proxy readiness to DNR request decisions. This enforces proxy policy on network requests.
  • permissions.ts and register-browser-extension-namespaces.ts: wire the proxy permission and namespace.
  • proxy-settings.ts, session-proxy-application.ts, proxy-policy-resolution.ts, electron-default-proxy-session.ts: implement override, serialization, rollback, and policy keys required for restoration.
  • browser-extension-proxy-readback-electron-fixture.ts and related config code: native readback whitespace, failover, and DIRECT handling. These support reading and reapplying native policy during restoration, which the issue requires.
  • browser-extension-web-request-observer.ts: supports onProxyError.
  • Tests and fixtures cover these behaviors.

No demonstrated unrelated change was found. This relies on the summary; implementation hunks were not read in this review.

Full details: Description check

Explanation

The description follows the repository template closely. It has an ELI5, a detailed What Changed list, Why, a linked issue (Fixes #43075), Visual Proof with before/after evidence, Testing with checkboxes and commands, a Risk section with level Medium and a rollback path, AI Disclosure, Review, the upstream boundary checkbox, Notes, and a completed checklist. The Visual Proof section is complete for a UI-facing change. Minor gaps: the Testing checkbox for "Every added test fails without this change" is not explicitly confirmed, and the PR states Windows/Linux UI was not tested. The description also gives a head commit that differs from the objectives text (e8d2aa2 versus cf57d57), which a reviewer should reconcile.

  • 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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f1049478-159a-462d-abd6-22316acb3a07
Commits

Reviewing files that changed from the base of the PR and between cf57d57 and e8d2aa2.

Files selected for processing: 2

  • src/main/browser/extensions/proxy/browser-extension-proxy-config.ts
  • src/main/browser/extensions/proxy/browser-extension-proxy-readback-electron-fixture.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

@coderabbitai coderabbitai 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.

Actionable comments posted: 3

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 908a36cc-676c-461f-abd7-33609eee158d
Commits

Reviewing files that changed from the base of the PR and between ece3008 and fd13aa9.

Files selected for processing: 22

  • src/main/browser/certificate-trust/browser-certificate-request-guard.ts
  • src/main/browser/certificate-trust/browser-certificate-trust-controller.test.ts
  • src/main/browser/extensions/api/permissions.ts
  • src/main/browser/extensions/api/proxy.ts
  • src/main/browser/extensions/profile-sessions/browser-extension-session-services.test.ts
  • src/main/browser/extensions/profile-sessions/browser-extension-session-services.ts
  • src/main/browser/extensions/profile-storage/browser-extension-persistence-electron-fixture.ts
  • src/main/browser/extensions/profile-storage/browser-extension-persistence.electron.test.ts
  • src/main/browser/extensions/profile-storage/browser-extension-profile-state-store.test.ts
  • src/main/browser/extensions/profile-storage/browser-extension-profile-state-store.ts
  • src/main/browser/extensions/proxy/browser-extension-proxy-config.ts
  • src/main/browser/extensions/proxy/browser-extension-proxy-electron-fixture.ts
  • src/main/browser/extensions/proxy/browser-extension-proxy-session.ts
  • src/main/browser/extensions/proxy/browser-extension-proxy.electron.test.ts
  • src/main/browser/extensions/register-browser-extension-namespaces.ts
  • src/main/browser/extensions/requests/browser-extension-web-request-observer.ts
  • src/main/network/electron-default-proxy-session.ts
  • src/main/network/proxy-policy-resolution.ts
  • src/main/network/proxy-settings.ts
  • src/main/network/session-proxy-application.ts
  • src/preload/browser/extensions/api/browser-extension-api-surface.ts
  • src/preload/browser/extensions/api/browser-extension-main-world.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@coderabbitai coderabbitai 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.

Actionable comments posted: 2

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 20c2f485-3e84-42e7-8845-0d403eeddc31
Commits

Reviewing files that changed from the base of the PR and between fd13aa9 and 7c391c4.

Files selected for processing: 4

  • src/main/browser/extensions/profile-sessions/browser-extension-session-services.test.ts
  • src/main/browser/extensions/profile-sessions/browser-extension-session-services.ts
  • src/main/browser/extensions/proxy/browser-extension-proxy-config.ts
  • src/main/browser/extensions/proxy/browser-extension-proxy-electron-fixture.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@coderabbitai coderabbitai 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.

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (2)

Minor · Preserve explicit direct rules when reporting a… · browser-extension-proxy-config.ts:103-104

src/main/browser/extensions/proxy/browser-extension-proxy-config.ts:103-104
Minor · Data Integrity & Integration · Heavy lift

Preserve explicit direct rules when reporting a baseline.

For http=direct://;socks=socks://proxy:1080, this removes the HTTP rule but retains fallbackProxy. Chromium treats the explicit HTTP rule as direct; the returned settings instead describe HTTP traffic as using the fallback proxy. An extension that reapplies these settings changes the route. (raw.githubusercontent.com)

Handle this configuration without returning a misleading rule set.

Minor · Trim the protocol name before matching it. · browser-extension-proxy-config.ts:119-121

src/main/browser/extensions/proxy/browser-extension-proxy-config.ts:119-121
Minor · Functional Correctness · Quick win

Trim the protocol name before matching it.

Chromium accepts http = proxy.example:8080 by trimming the protocol name. This expression does not match it, so server() passes the entire assignment to new URL, which throws. The baseline settings.get call then fails for this valid proxy switch. (raw.githubusercontent.com)

Trim the assignment name before matching it.

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 936e3402-3427-4b15-bd10-4a4a8fe66405
Commits

Reviewing files that changed from the base of the PR and between 7c391c4 and a58ad9e.

Files selected for processing: 4

  • src/main/browser/extensions/profile-sessions/browser-extension-session-services.test.ts
  • src/main/browser/extensions/profile-sessions/browser-extension-session-services.ts
  • src/main/browser/extensions/proxy/browser-extension-proxy-config.ts
  • src/main/browser/extensions/proxy/browser-extension-proxy-electron-fixture.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 90380eb6-5eb3-4508-af38-d334065038b5
Commits

Reviewing files that changed from the base of the PR and between a58ad9e and cf57d57.

Files selected for processing: 3

  • src/main/browser/extensions/proxy/browser-extension-proxy-config.ts
  • src/main/browser/extensions/proxy/browser-extension-proxy-readback-electron-fixture.ts
  • src/main/browser/extensions/proxy/browser-extension-proxy.electron.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

This branch has not been deployed

No deployments
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.

[Feature]: Support the Chrome extension proxy API in Orca's desktop browser

1 participant