feat(desktop): add HTTP proxy setting in advanced preferences#350
Conversation
Lets users route Chromium and Node outbound traffic through a custom proxy via Settings → Advanced. The URL is persisted in preferences.json and applied immediately on save and at boot, with no restart needed. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
There was a problem hiding this comment.
Review mode: initial
Findings
- [Minor]
applyProxyConfigonly sets uppercaseHTTP_PROXY/HTTPS_PROXYenvironment variables but does not handle lowercase equivalents (http_proxy/https_proxy). Node'shttpmodule prefers lowercase when both are present, so if a user already has a lowercase proxy set system-wide, the app's proxy setting may be silently ignored. For complete coverage, also set (and clear) the lowercase variants.
Suggested fix: Inapps/desktop/src/main/preferences-ipc.ts,applyProxyConfig, add:if (cleanUrl.length > 0) { process.env['HTTP_PROXY'] = cleanUrl; process.env['HTTPS_PROXY'] = cleanUrl; process.env['http_proxy'] = cleanUrl; process.env['https_proxy'] = cleanUrl; } else { delete process.env['HTTP_PROXY']; delete process.env['HTTPS_PROXY']; delete process.env['http_proxy']; delete process.env['https_proxy']; }
Summary
The PR cleanly adds an HTTP proxy field to Settings → Advanced, persisted via bumped schemaVersion (8→9) and applied immediately to both Chromium's network stack and Node's env vars. Tests cover round-trip, env var clear, trimming, and non-string rejection. No new dependencies, i18n strings in all four locales, and a changeset included. Good adherence to project constraints.
Residual observations
- The
applyProxyConfigJSDoc mentions it is safe to call beforesession.defaultSessionis ready, but in that case the Chromium side is silently skipped. Currently all calls happen afterapp.whenReady(), so this is not a bug, but if future code calls it earlier the renderer proxy would not be applied without a warning. Consider logging when the session is unavailable.
Testing
- New Vitest tests cover
applyProxyConfig(set, clear, trim) andpreferences:v1:updateround-trip with proxyUrl. Existing tests updated for schema version. Automated CI passes. - Manual test steps described in PR body (set proxy, confirm routing, clear) are appropriate.
Open-CoDesign Bot
…ssing session Node's http module prefers lowercase http_proxy/https_proxy when both spellings exist, so leaving them untouched could let a stale shell value silently override the in-app proxy choice. Also log a warning when applyProxyConfig is called before session.defaultSession is ready so a future early caller isn't met with a silent Chromium-side skip. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
There was a problem hiding this comment.
Review mode: follow-up after new commits
Findings
No new findings. The previous Minor finding (missing lowercase http_proxy/https_proxy env var handling) has been addressed in this revision — applyProxyConfig now writes and clears both uppercase and lowercase spellings, and a logger.warn call covers the missing-session case. The accompanying test coverage (lowercase mirror + stale lowercase clearance) confirms correctness.
Summary
The PR is ready to merge. All material issues from the initial review are resolved. The implementation correctly handles env var casing, immediate proxy application, persistence via schema bump (8→9), and i18n for four locales. No new dependencies, no direct SDK imports, no silent fallbacks for user-visible behavior. Changeset included.
Residual observations
- The
MemoryTab.tsxnow includesproxyUrl: ''in its localDEFAULT_PREFSto satisfy type conformance. This is harmless but technically dead state since memory settings don't render a proxy field. Not worth a follow-up, just an observation.
Testing
- Existing and new Vitest tests pass (1837 workspace tests green).
- Manual test plan from PR body covers set/clear proxy with real LLM routing.
Open-CoDesign Bot
Summary
proxyUrlpreference in Settings → Advanced. The URL is applied to Chromium's network stack (session.defaultSession.setProxy) and to Node'sHTTP_PROXY/HTTPS_PROXYenv vars, so both renderer fetches and main-process outbound traffic (LLM APIs, update feed) route through the configured proxy.~/.config/open-codesign/preferences.jsonunder a bumpedschemaVersion(8 → 9). Defaults to'', so existing installs are unaffected.Four principles
schemaVersionbumped to 9;parsePersistedFileignores unknown keys from stale builds.electron.sessionand Node env vars already in the runtime.applyProxyConfig(url)helper, commit-on-blur input so we don't thrash the file/proxy on every keystroke.Test plan
pnpm lintpnpm typecheckpnpm test(1837 tests across workspace — all green; new vitest cases cover proxy round-trip, env-var clear, whitespace trimming, and rejection of non-stringproxyUrl)Notes
Reference: maintainer green-light on the proxy-settings discussion. Changeset included (
.changeset/proxy-settings.md):@open-codesign/desktopminor,@open-codesign/i18npatch.