Skip to content

fix(usage): usage requests answer authenticated-proxy challenges on a cold start - #28411

Merged
Jinwoo-H merged 4 commits into
mainfrom
usage-shared-http-client
Oct 14, 2026
Merged

Jinwoo-H merged 4 commits into
mainfrom
usage-shared-http-client

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 13 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​276 $\color{#cf222e}{\Huge{\mathbf{−}}}$​265 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​11
Prod 8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​19 $\color{#cf222e}{\Huge{\mathbf{−}}}$​20 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1

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

  • Eight usage requests in src/main/rate-limits/ that called Electron's net.fetch directly now call getMainHttpClient().fetch, the same client Codex and ZCode already use. Each request's options are unchanged (headers, timeout signal, redirect:'manual', credentials:'omit').
  • Claude and OpenCode Go no longer pass session.defaultSession into the proxy setup. That function already defaults to the same session, so their Electron imports are gone.
  • Tests use the existing setMainHttpClient hook instead of mocking Electron's net. 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 Required on 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.fetch directly 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:

  • Before (main c745051): cloudcode-pa.googleapis.com, platform.minimax.io, api.kimi.com, cli-chat-proxy.grok.com, cursor.com and api.anthropic.com each got 407, with no retry carrying credentials. Only chatgpt.com (Codex, already on the shared client) retried with credentials.
  • After: Gemini, Kimi, Grok and MiniMax retried with credentials about 4 ms after their 407. Cursor, Claude, Codex and OpenCode Go authenticated in the first round.

Testing

  • pnpm tc passes.

  • 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:changed are 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

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Not covered: OpenCode Go's and MiniMax's cookie-based requests use their own sessions, so they still skip the proxy login. Fixing that needs proxy credentials set up per session first (follow-up).
  • Remote and SSH: usage requests run in the Electron main process of whichever Orca runtime owns the accounts, and both desktop and orca serve install the shared client at startup. The headless server entry does not run these requests.
  • No platform-specific code changes.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

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

coderabbitai Bot commented Oct 13, 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: a250ebe0-6354-4633-a40a-070661f64e46
📥 Commits

Reviewing files that changed from the base of the PR and between 55c2693 and 38df9c0.

📒 Files selected for processing: 9
  • src/main/rate-limits/claude-oauth-usage-extra-usage.test.ts
  • src/main/rate-limits/claude-oauth-usage-request.ts
  • src/main/rate-limits/gemini-usage-fetcher.test.ts
  • src/main/rate-limits/gemini-usage-fetcher.ts
  • src/main/rate-limits/grok-fetcher.test.ts
  • src/main/rate-limits/grok-fetcher.ts
  • src/main/rate-limits/kimi-fetcher.test.ts
  • src/main/rate-limits/kimi-fetcher.ts
  • src/main/rate-limits/opencode-go-usage-api.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.

📝 Walkthrough

Rate-limit requests for Claude, Cursor, Gemini, Grok, Kimi, MiniMax, and OpenCode Go now use the main HTTP client instead of Electron’s net.fetch. Two proxy checks no longer pass Electron’s default session explicitly. Related tests inject the main HTTP client’s fetch mock, and the Cursor end-to-end fixture routes requests through that client. Existing request options, response handling, and tested scenarios remain unchanged.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to 38df9

No identified issue blocks merging the migrated usage requests after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 10.53% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 19 functions across 21 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: fixing usage requests so they handle authenticated-proxy challenges during cold start.
Description check Passed The description is comprehensive and follows the template. It explains the user impact, implementation, rationale, testing, limitations, and compatibility considerations. The linked issue is marked N/…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • 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

Comment @coderabbitai help to get the list of available commands.

@Jinwoo-H
Jinwoo-H merged commit 23bd828 into main Oct 14, 2026
40 checks passed
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.

1 participant