Repository navigation
fix(usage): usage requests answer authenticated-proxy challenges on a cold start - #28411
Conversation
… cold start Claude, Cursor, Gemini, Grok, Kimi, OpenCode Go (API key) and MiniMax (API key) usage fetchers called Electron's net.fetch directly, which cancels every proxy login challenge. They now go through the shared desktop HTTP client, which answers the challenge with the configured proxy credentials (#26957), like Codex and ZCode already do.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to
|
# Conflicts: # src/main/rate-limits/cursor-fetcher.test.ts
# Conflicts: # src/main/rate-limits/gemini-usage-fetcher.ts
ELI5
Some companies route internet traffic through a proxy that asks for a username and password. Orca's main network client already knows how to answer that request, but most usage meters (Claude, Cursor, Gemini, Grok, Kimi, MiniMax, OpenCode Go) skipped it. So on a fresh start behind such a proxy, their first usage check was rejected. Now every usage meter uses the shared client, so those checks get through.
What Changed
src/main/rate-limits/that called Electron'snet.fetchdirectly now callgetMainHttpClient().fetch, the same client Codex and ZCode already use. Each request's options are unchanged (headers, timeout signal,redirect:'manual',credentials:'omit').session.defaultSessioninto the proxy setup. That function already defaults to the same session, so their Electron imports are gone.setMainHttpClienthook instead of mocking Electron'snet. Assertions are unchanged.Before, on a cold start behind a password-protected proxy: Claude, Cursor, Gemini, Grok, Kimi and MiniMax each got
407 Proxy Authentication Requiredon their first usage request and never retried. After: all of them authenticate on that first refresh.Why
One network path for usage instead of two. The shared client already answers a password-protected proxy's challenge on a cold start (#26957). Calling
net.fetchdirectly silently skipped that. Moving the handling into each fetcher would have duplicated it.Linked Issue
N/A. This is a follow-up from the agent-usage proxy investigation (STA-9799 / STA-8273 area); there is no dedicated ticket.
Visual Proof
N/A for UI: nothing on screen changes. The evidence is a proxy log. A local proxy requiring Basic auth (407 without credentials) received the requests from a hidden, isolated build of Orca on a cold start:
cloudcode-pa.googleapis.com,platform.minimax.io,api.kimi.com,cli-chat-proxy.grok.com,cursor.comandapi.anthropic.comeach got 407, with no retry carrying credentials. Onlychatgpt.com(Codex, already on the shared client) retried with credentials.Testing
pnpm tcpasses.pnpm test src/main/rate-limits src/main/host src/main/network: 939 passed, 1 failed, 1 skipped. The failure (codex-fetcher-process-contract"preserves inherited proxy settings") also fails on main.oxlint and
check:code-quality:changedare clean.macOS real-app run as described above.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Review
An Opus review checked correctness and design simplicity. It confirmed every request option reaches the shared client's request unchanged, that cancellation and response-body handling are the same, and that the shared client is installed at startup before any usage request. Its suggestions are applied: drop the redundant session argument and the Electron mocks, and rename the test mocks.
Agent skill upstream boundary
Notes
orca serveinstall the shared client at startup. The headless server entry does not run these requests.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)