Repository navigation
fix(rate-limits): send Codex usage through the proxy set in Orca's settings - #26497
petersindex wants to merge 2 commits into
Conversation
…ttings Codex usage ignored Settings > Advanced > Network. The backend fallback called Node's global fetch, which doesn't use the proxy Orca applies to Electron's default session, and the codex app-server probe started with plain process.env, so it never saw the configured proxy either. Behind a proxy the Usage panel showed Codex as limited. The backend requests now use net.fetch, like Claude and Kimi already do, and the probe gets buildConfiguredProxyEnv(networkProxySettings), the same environment Orca gives terminals. The rate-limit service passes the configured proxy to every Codex fetch, as it already does for Claude. The Codex fetcher tests move from a global fetch stub to the electron net.fetch mock the other fetchers' tests use. Fixes stablyai#26477
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughCodex rate-limit fetching now uses Electron’s Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to Codex usage requests use the configured proxy on the normal startup path. No merge-blocking issue remains in the reviewed changes. Pre-merge checks |
|
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
b059b88a-5524-4db9-9c46-f4848c8eeff7
📒 Files selected for processing (14)
src/main/rate-limits/codex-fetcher-auth-errors.test.tssrc/main/rate-limits/codex-fetcher-backend.test.tssrc/main/rate-limits/codex-fetcher-credit-balance.test.tssrc/main/rate-limits/codex-fetcher-network-proxy.test.tssrc/main/rate-limits/codex-fetcher-probe-shutdown.test.tssrc/main/rate-limits/codex-fetcher-runtime-pairing.test.tssrc/main/rate-limits/codex-fetcher-session-supplement.test.tssrc/main/rate-limits/codex-fetcher.test.tssrc/main/rate-limits/codex-fetcher.tssrc/main/rate-limits/codex-rate-limit-fetch-options.tssrc/main/rate-limits/service/service-fetch-targets.tssrc/main/rate-limits/service/service-full-cycle-preparation.tssrc/main/rate-limits/service/service-inactive-accounts.tssrc/main/rate-limits/service/service-provider-cycles.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.
wsl.exe only passes host variables that WSLENV names, so the proxy set on the wsl.exe spawn never reached codex inside the distro.
|
closing this one. #26942 fixed the same proxy issue for Codex usage, so mine's not needed. |
Fixes #26477
ELI5
Orca lets you set an HTTP proxy in Settings, Advanced, Network. Claude and Kimi usage follow it, but Codex usage went straight out to the internet instead. On a network where everything has to go through the proxy, that direct request fails, so the Usage panel showed Codex as "Limited". Now Codex usage goes through the proxy like the others.
What changed
codex app-serverprobe and the backend usage requests both go through the configured proxy.codex-fetcher.tsused Node's globalfetchfor the backend usage, reset-credit and redeem requests. Node'sfetchdoesn't use the proxy Orca applies to Electron's default session. They now usenet.fetch, asclaude-oauth-usage-request.tsandkimi-fetcher.tsalready do.process.env. It now also getsbuildConfiguredProxyEnv(networkProxySettings), the same helper that gives terminals the configuredHTTPS_PROXY,HTTP_PROXY,ALL_PROXYandNO_PROXY.CodexRateLimitFetchOptionsgainsnetworkProxySettings, and the rate-limit service passesthis.networkProxySettingsResolver?.()at all four Codex call sites, the way it already does for Claude.Why this approach
net.fetchis how the other usage fetchers already pick up Orca's proxy, so Codex now follows the same path instead of growing its own proxy agent.buildConfiguredProxyEnvalready builds that environment for terminals, bypass rules included.Testing
Live, on macOS 27.0.1 with Codex signed in. I pointed Orca Dev's proxy setting at a local proxy that logs every tunnel, then refreshed usage:
main): the proxy logged onlyCONNECT api.anthropic.com:443(Claude). Codex reachedchatgpt.comdirectly. It still showed numbers only because my network doesn't require the proxy.CONNECT chatgpt.com:443three times alongside Claude's request, and Codex came backokwith its usage.Tests:
codex-fetcher-network-proxy.test.ts: the probe starts with the configuredHTTPS_PROXY,HTTP_PROXYandNO_PROXY, and the backend fallback callsnet.fetchand never Node's globalfetch. Both fail onmain.fetch. They now mockelectron'snet.fetchlike the Kimi and Claude fetcher tests do, so their checks still mean something. For example, "no HTTP fallback after an auth error" would otherwise pass without checking anything. Three{ ok, json } as Responsecasts became realResponseobjects.src/main/rate-limitspasses (56 files).pnpm tc:node, oxlint, oxfmt andcheck:code-quality:changedpass.Visual Proof
N/A: the change is where network requests go. The proxy log above shows the before and after on the same machine.
AI review
net.fetchand the proxy environment are platform-neutral. For a WSL Codex home the probe runs throughwsl.exe, and Windows environment variables don't cross into WSL withoutWSLENV. That part is unchanged here; the WSL backend fallback does go throughnet.fetchnow.normalizeProxyUrl. No new inputs.networkProxySettingsis optional, and with no proxy set the probe environment is unchanged. The backend requests now use Electron's network stack, the same one Claude and Kimi usage already use.net.fetch. Managed Codex accounts get the same proxy settings, and WSL homes are covered in the cross-platform note above.X: @petersindex