Skip to content

fix(rate-limits): send Codex usage through the proxy set in Orca's settings - #26497

Closed
petersindex wants to merge 2 commits into
stablyai:mainfrom
petersindex:fix-codex-usage-proxy
Closed

petersindex wants to merge 2 commits into
stablyai:mainfrom
petersindex:fix-codex-usage-proxy

Conversation

@petersindex

@petersindex petersindex commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

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

  • Before: with a proxy set in Orca, Codex usage requests skip it. Behind a proxy-only network the Usage panel shows Codex as Limited.
  • After: the codex app-server probe and the backend usage requests both go through the configured proxy.
  • Mechanism:
    • codex-fetcher.ts used Node's global fetch for the backend usage, reset-credit and redeem requests. Node's fetch doesn't use the proxy Orca applies to Electron's default session. They now use net.fetch, as claude-oauth-usage-request.ts and kimi-fetcher.ts already do.
    • The app-server probe started with plain process.env. It now also gets buildConfiguredProxyEnv(networkProxySettings), the same helper that gives terminals the configured HTTPS_PROXY, HTTP_PROXY, ALL_PROXY and NO_PROXY.
    • CodexRateLimitFetchOptions gains networkProxySettings, and the rate-limit service passes this.networkProxySettingsResolver?.() at all four Codex call sites, the way it already does for Claude.

Why this approach

  • net.fetch is 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.
  • The probe is a separate process, so it only sees the proxy through its environment. buildConfiguredProxyEnv already 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:

  • Before (this branch's Codex files swapped back to main): the proxy logged only CONNECT api.anthropic.com:443 (Claude). Codex reached chatgpt.com directly. It still showed numbers only because my network doesn't require the proxy.
  • After: the proxy logged CONNECT chatgpt.com:443 three times alongside Claude's request, and Codex came back ok with its usage.

Tests:

  • New codex-fetcher-network-proxy.test.ts: the probe starts with the configured HTTPS_PROXY, HTTP_PROXY and NO_PROXY, and the backend fallback calls net.fetch and never Node's global fetch. Both fail on main.
  • The existing Codex fetcher tests stubbed the global fetch. They now mock electron's net.fetch like 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 Response casts became real Response objects.
  • All of src/main/rate-limits passes (56 files). pnpm tc:node, oxlint, oxfmt and check:code-quality:changed pass.

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

  • Cross-platform: net.fetch and the proxy environment are platform-neutral. For a WSL Codex home the probe runs through wsl.exe, and Windows environment variables don't cross into WSL without WSLENV. That part is unchanged here; the WSL backend fallback does go through net.fetch now.
  • SSH / remote: usage is fetched on the host that runs it; nothing here crosses the relay.
  • Performance: no change to how often usage is fetched.
  • Security: the proxy URL comes from Orca's own setting, already validated by normalizeProxyUrl. No new inputs.
  • Backwards compatibility: networkProxySettings is 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.
  • Agents and integrations: only Codex usage changes; Claude and Kimi usage already used net.fetch. Managed Codex accounts get the same proxy settings, and WSL homes are covered in the cross-platform note above.

X: @petersindex

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

coderabbitai Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ca86647f-c803-405e-b21b-71b706501793

📥 Commits

Reviewing files that changed from the base of the PR and between 13ef705 and 87c54f6.


📒 Files selected for processing (2)
  • src/main/rate-limits/codex-fetcher-network-proxy.test.ts
  • src/main/rate-limits/codex-fetcher.ts

🚧 Files skipped from review as they are similar to previous changes (2)
  • src/main/rate-limits/codex-fetcher.ts
  • src/main/rate-limits/codex-fetcher-network-proxy.test.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.



📝 Walkthrough

Walkthrough

Codex rate-limit fetching now uses Electron’s net.fetch for HTTP requests and adds configured proxy variables to the spawned Codex process environment. Service call sites pass resolved proxy settings through the fetch options. Tests mock Electron networking and include checks for proxy environment variables and the backend request.


Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 87c54

Codex usage requests use the configured proxy on the normal startup path. No merge-blocking issue remains in the reviewed changes.

Pre-merge checks | Passed 3 | Failed 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Linked Issues check Warning Issue [#26477] requires Codex usage retrieval to honor the configured proxy and bypass rules. The changed codex-fetcher.ts uses Electron net.fetch, applies buildConfiguredProxyEnv, forwards prox… Implement Codex usage error propagation and UI presentation that distinguish network or proxy failures from an actual account rate limit. Add automated tests for the classification and displayed result.
Docstring Coverage Warning Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 14 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: routing Codex usage through the proxy configured in Orca’s settings.
Description check Passed The description is detailed and mostly complete. It explains the user impact, implementation, rationale, linked issue, testing, visual-proof status, and cross-platform considerations. Some template se…
Out of Scope Changes check Passed The production changes route Codex probe and backend requests through Orca's configured proxy and propagate proxy settings to Codex call sites. The tests verify proxy environment forwarding and Electr…

Full details: Linked Issues check

Explanation

Issue [#26477] requires Codex usage retrieval to honor the configured proxy and bypass rules. The changed codex-fetcher.ts uses Electron net.fetch, applies buildConfiguredProxyEnv, forwards proxy variables through WSLENV, and the four Codex call sites pass networkProxySettings. The PR also adds tests for these paths. Issue [#26477] requires a useful UI error when retrieval fails. The reviewed changes add no error classification or UI presentation that distinguishes a network or proxy failure from an account rate limit.



  • Fix all pre-merge checks with AI
  • Autopilot · 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.

@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
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b059b88a-5524-4db9-9c46-f4848c8eeff7
📥 Commits

Reviewing files that changed from the base of the PR and between 0eee1ce and 13ef705.

📒 Files selected for processing (14)
  • src/main/rate-limits/codex-fetcher-auth-errors.test.ts
  • src/main/rate-limits/codex-fetcher-backend.test.ts
  • src/main/rate-limits/codex-fetcher-credit-balance.test.ts
  • src/main/rate-limits/codex-fetcher-network-proxy.test.ts
  • src/main/rate-limits/codex-fetcher-probe-shutdown.test.ts
  • src/main/rate-limits/codex-fetcher-runtime-pairing.test.ts
  • src/main/rate-limits/codex-fetcher-session-supplement.test.ts
  • src/main/rate-limits/codex-fetcher.test.ts
  • src/main/rate-limits/codex-fetcher.ts
  • src/main/rate-limits/codex-rate-limit-fetch-options.ts
  • src/main/rate-limits/service/service-fetch-targets.ts
  • src/main/rate-limits/service/service-full-cycle-preparation.ts
  • src/main/rate-limits/service/service-inactive-accounts.ts
  • src/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.

Comment thread src/main/rate-limits/codex-fetcher.ts Resolved
wsl.exe only passes host variables that WSLENV names, so the proxy set on
the wsl.exe spawn never reached codex inside the distro.
@petersindex

Copy link
Copy Markdown
Contributor Author

closing this one. #26942 fixed the same proxy issue for Codex usage, so mine's not needed.

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.

[Bug]: Codex usage statistics appear to ignore the HTTP proxy configured in Advanced settings

1 participant