Skip to content

fix(rate-limits): apply the configured proxy to Codex usage fetches - #19931

Closed
mmarabel wants to merge 9 commits into
stablyai:mainfrom
mmarabel:mmarabel/codex-proxy-usage-stats
Closed

mmarabel wants to merge 9 commits into
stablyai:mainfrom
mmarabel:mmarabel/codex-proxy-usage-stats

Conversation

@mmarabel

@mmarabel mmarabel commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

Orca has a setting for sending traffic through a proxy server. Claude and OpenCode Go usage checks respected it, but Codex usage checks did not. On a Mac launched from the Dock there are no shell proxy variables, so a Codex usage refresh could leave from your own IP while you believed it went through your proxy.

What Changed

Two halves, closing the same gap:

  • The probe spawn. Both Codex RPC and PTY probes receive buildConfiguredProxyEnv(options.networkProxySettings). All four production paths pass the configured proxy: provider cycles, fetch targets, inactive accounts, and full-cycle preparation.
  • The backend calls. fetchCodexUsage, fetchCodexResetCredits and consumeCodexResetCredit used the platform global, which is undici and ignores Chromium's proxy. They now go through getMainHttpClient(), whose desktop implementation is net.fetch and therefore follows the session proxy. On a host without Chromium the port falls back to the global, so behaviour there is unchanged.

Tests: a new codex-fetcher-proxy-env.test.ts covers the RPC and PTY spawn envs, and codex-fetcher-backend.test.ts gains a case proving the backend calls go through the main HTTP client (asserting the global is not used). The shared probe doubles moved to codex-fetcher.test-fixtures.ts because codex-fetcher.test.ts is at the max-lines ceiling.

Why

The asymmetry is the bug. service-full-cycle-preparation.ts passes networkProxySettings to Claude (:147) and OpenCode Go (:162) but not to Codex (:155-159). The comment in claude-pty.ts spells out why that matters: a probe that spawns the CLI directly, rather than the user's shell wrapper, "would reach api.anthropic.com from the app's own IP — bypassing the proxy the user set". Codex had no equivalent, on either the probe or the backend path.

Scope note: this fixes the Codex half only. Claude's OAuth usage path already honours the proxy via net.fetch on defaultSession, so nothing there is claimed as changed.

Fixes #19755

Visual Proof

N/A — no UI or interaction change. The fix is in how the usage fetch egresses.

Testing

  • pnpm test src/main/rate-limits/codex-fetcher.test.ts src/main/rate-limits/codex-fetcher-proxy-env.test.ts src/main/rate-limits/codex-fetcher-backend.test.ts — 31 passed.
  • Red first: the spawn-env test failed with AssertionError: expected undefined to be 'http://127.0.0.1:7890' before the change.
  • pnpm tc — clean (exit 0). Explicit return-type annotations were needed on the exported fixtures, because exporting an inferred vi.fn() type trips TS2883.
  • oxlint src/main/rate-limits/ — clean.
  • pnpm run check:code-quality:changed reports only pre-existing findings in src/renderer/src/components/native-chat/NativeChatTaskList.tsx, which this diff does not touch — the gate compares against an older base, so upstream commits in between are counted as "changed".

Platform testing: verified on Linux only. The proxy plumbing is platform-neutral; the macOS-specific symptom (Dock launch, no inherited shell proxy vars) is what the change addresses.

AI Disclosure

Written with an AI coding agent (deepseek-flash via opencode-go). All commands in Testing were run by the agent on Linux.

Review

AI-assisted code review summary, per CONTRIBUTING:

  • Cross-platform: the configured proxy environment also reaches WSL through WSLENV, without translating the proxy address. The Node-host HTTP fallback remains globalThis.fetch; no new proxy support is claimed for that fallback.
  • SSH/remote/local: getMainHttpClient() is the existing main-process HTTP port (already used by src/main/jira/authenticated-request.ts). No host-specific assumptions added; nothing here touches execution-host ownership.
  • Agents and integrations: Codex-only. No other provider path changes.
  • Performance: no new requests. The probe gains a few env keys; the backend swaps one fetch implementation for another. Neither adds work to a hot path.
  • UI quality: no UI change.
  • Security: the proxy env derives from settings the user already controls, and this improves the privacy posture — a configured proxy is no longer silently bypassed. No new inputs, no credential handling touched.

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Ensure no issues in: Security, Cross-platoform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance

networkProxySettings is optional. The configured proxy is passed through all four production fetch paths, not only the full-cycle service call.

Checklist

  • This PR is small and focused
  • I explained what changed and why (including ELI5)
  • 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)

Known WSL limitation

Under WSL2 NAT, a configured Windows proxy at 127.0.0.1 still points at the guest after its address is imported through WSLENV. This PR does not resolve a Windows-host proxy address or silently bypass the configured proxy. That networking policy is explicitly held; no live proxy/WSL endpoint validation is claimed.

Orca's configured proxy reached Claude and OpenCode Go usage fetches but not
Codex, so on a Dock-launched macOS app — where the shell proxy vars are absent —
a Codex usage refresh could reach the backend from the app's own IP while the
user believed their traffic went through their proxy.

Two halves:

- The probe is spawned with the app process env, so the configured proxy never
  reached it. Both spawn sites now merge `buildConfiguredProxyEnv`, mirroring
  `claude-pty.ts`, and the service passes its resolver into `fetchCodexRateLimits`.
- The three backend helpers used the platform global, which is undici and ignores
  Chromium's proxy. They now go through `getMainHttpClient()`, whose desktop
  implementation is `net.fetch` and therefore follows the session proxy. The Node
  fallback is the global, so hosts without Chromium are unchanged.

Tests live in their own file because `codex-fetcher.test.ts` is at the max-lines
ceiling; the shared probe doubles move to a fixtures module.

Fixes stablyai#19755
@coderabbitai

coderabbitai Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

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: 03e3642e-bb6b-439d-944a-4bd1fc12566b

📥 Commits

Reviewing files that changed from the base of the PR and between b772a24 and fb2e62b.

📒 Files selected for processing (8)
  • src/main/rate-limits/codex-fetcher-proxy-env.test.ts
  • src/main/rate-limits/codex-fetcher.test-fixtures.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; 3 remain after this review.


📝 Walkthrough

Walkthrough

Codex rate-limit fetches now use the main HTTP client for usage and reset-credit requests. The fetch options accept network proxy settings, which the rate-limit service passes to Codex fetches. RPC probe processes receive proxy environment variables. For WSL probes, the variable names are added to WSLENV. Tests cover HTTP client routing, proxy environment values, and WSL handling of proxy credentials.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to fb2e6

Codex usage requests and probes now receive the configured proxy. No concrete merge-blocking issue remains in the supplied evidence; normal checks should complete before merging.

Security Architecture Review

Security architecture risk: 🔵 Low · up to fb2e6

The change brings Codex traffic under the selected proxy while preserving account selection and request destinations. No introduced security defect was established. The remaining uncertainty concerns effective routing during proxy-setting changes and across desktop and WSL environments.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The supported exposure is the local user's Codex traffic: active and inactive managed accounts, local or selected WSL probes, and usage or reset-credit operations. The selected proxy gains its intended role in carrying this traffic; the inspected changes do not add an attacker-controlled backend URL.

Trust Boundaries and Controls

  • observed — Configured proxy credentials are intentionally disclosed to the spawned probe through its environment, but are not serialized into WSL command arguments. The inspected WSL test asserts credential exclusion from command text and presence in the environment.
  • observed — The HTTP dispatch test verifies use of the registered client instead of global fetch. This supports the transport handoff, but does not establish actual proxy traversal, proxy authentication behavior, or routing during concurrent settings changes.

Resilience and Maintainability Implications

  • observed — Reset consumption retains a required idempotency key, selected-home authentication, a bounded request timeout, one application-level POST, explicit terminal-outcome mapping, and error-response cleanup. Post-reset retries reread usage rather than repeating the mutation; provenance checks and generation invalidation protect publication after account changes. Server-side atomicity is not established by this source.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 10 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes satisfy the Codex proxy requirement in issue #19755. Codex rate-limit call sites pass networkProxySettings. Codex RPC and PTY probes receive proxy variables, including WSLENV propagati…
Out of Scope Changes check ✅ Passed The changes remain within issue #19755. The fixture supports the new regression tests, and the tests verify proxy propagation and HTTP client routing. No unrelated production behavior or UI change is …
Title check ✅ Passed The title clearly and concisely identifies the main change: applying the configured proxy to Codex usage fetches.
Description check ✅ Passed The description includes all required sections, links issue #19755, explains the change and rationale, documents testing, limitations, security and platform considerations, and states that no UI chang…

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.

@pullfrog pullfrog 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.

Important

The proxy fix only lands on the full-cycle fetch. Three sibling fetchCodexRateLimits call sites still spawn the RPC/PTY probe without networkProxySettings, so a configured proxy is still bypassed on those paths.

Reviewed changes

  • Proxy env on the Codex probe spawn — fetchViaRpc and resolvePtyCommand now merge buildConfiguredProxyEnv(options.networkProxySettings) into the child env, mirroring claude-pty.ts.
  • Backend calls through the main HTTP client — fetchCodexUsage, fetchCodexResetCredits, and consumeCodexResetCredit now go through getMainHttpClient() (Electron net.fetch, which follows the session proxy) instead of the undici global.
  • Call-site wiring — service-full-cycle-preparation.ts passes its networkProxySettingsResolver value into fetchCodexRateLimits.
  • Tests — a new codex-fetcher-proxy-env.test.ts covers the RPC and PTY spawn envs; codex-fetcher-backend.test.ts gains a case asserting backend calls go through the main client and not the global. Shared probe doubles were extracted to codex-fetcher.test-fixtures.ts.

⚠️ Configured proxy still bypassed on three sibling Codex fetch paths

The fix reaches only the full-cycle call site in service-full-cycle-preparation.ts. Three other production callers of fetchCodexRateLimits spawn the codex CLI without networkProxySettings, so buildConfiguredProxyEnv returns {} and the probe still egresses from the app's own IP — the exact symptom #19755 fixes. The Claude-only cycle already passes the resolver (service-provider-cycles.ts:112), so these are just missed siblings, and the asymmetry the PR sets out to close persists on them.

Technical details
# Pass `networkProxySettings` to the remaining Codex fetch call sites

## Affected sites
- src/main/rate-limits/service/service-provider-cycles.ts:41 — `runFetchCodexOnlyCycle` (the Codex-only refresh path)
- src/main/rate-limits/service/service-fetch-targets.ts:85 — `fetchCodexResetResultState` (re-fetch after a reset-credit redeem)
- src/main/rate-limits/service/service-inactive-accounts.ts:147 — inactive-account switcher preview (RPC-only, `allowPtyFallback: false`)

Each spawns the RPC/PTY probe, and none passes `networkProxySettings`. On non-WSL homes
(native macOS/Linux/Windows) the probe therefore runs without `HTTP_PROXY`/`HTTPS_PROXY`.

## Required outcome
- Add `networkProxySettings: this.networkProxySettingsResolver?.()` to each call, matching
  `service-full-cycle-preparation.ts:158`. The resolver field is `protected` on
  `src/main/rate-limits/service/service-state.ts:96`, so all three classes already have access.

## Notes
- The backend-supplement phase (`supplementCodexSessionWindow` / `supplementCodexRateLimitResetCredits`)
  is unaffected: it goes through `getMainHttpClient()` regardless of the options, so it already follows
  the session proxy.
- WSL homes route through `fetchWslBackend` (also `getMainHttpClient()`), so they are covered even on
  these three call sites; the gap is specific to the native probe spawn.

ℹ️ Nitpicks

  • The proxy env added to the WSL spawn branches (codex-fetcher.ts fetchViaRpc and resolvePtyCommand) is a no-op: wsl.exe does not forward arbitrary env vars into the distro without WSLENV — which is why claude-pty.ts exports the proxy inside the shell command instead. WSL homes are covered by the backend path via getMainHttpClient(), so this is inert rather than a bug, but the WSL RPC/PTY fallback (after a backend failure) still bypasses the proxy.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

Review caught two gaps in the previous commit.

Only one of four production `fetchCodexRateLimits` call sites passed
`networkProxySettings`, so a configured proxy was still bypassed on the
provider-cycle, fetch-target and inactive-account paths. `service-provider-cycles.ts`
already passed the resolver to Claude in the same file, which is precisely the
asymmetry this changeset set out to close.

The proxy env merged into the WSL spawn branches was also inert: `wsl.exe` does not
forward arbitrary env vars into the distro without `WSLENV`, which `claude-pty.ts`
already documents. `buildWslCodexCommand` now exports the proxy inside the shell
command instead, matching that precedent, and the env merge applies only to the
local branch.

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes — the delta since the prior pullfrog review (7f55dec) closes both findings.

  • Wired the proxy through the remaining Codex call sites — service-provider-cycles.ts, service-fetch-targets.ts, and service-inactive-accounts.ts now pass networkProxySettings: this.networkProxySettingsResolver?.(), so all four production fetchCodexRateLimits paths honour the configured proxy.
  • Exported the proxy inside the WSL distro command — buildWslCodexCommand gained a proxyEnv parameter and adds export <KEY>='<value>' for each proxy var inside the shell command (same shape as claude-pty.ts), fixing the WSL RPC/PTY fallback that previously bypassed the proxy. Local spawns still merge the env and skip the inert wsl.exe env.

The WSL export branch has no direct test, but it mirrors the established claude-pty.ts pattern and is gated behind win32 + a UNC path, so it is low-risk.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@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: cf59f919-b471-40fd-890f-47938670e255

📥 Commits

Reviewing files that changed from the base of the PR and between 7f55dec and 171544a.

📒 Files selected for processing (4)
  • src/main/rate-limits/codex-fetcher.ts
  • src/main/rate-limits/service/service-fetch-targets.ts
  • src/main/rate-limits/service/service-inactive-accounts.ts
  • src/main/rate-limits/service/service-provider-cycles.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Comment thread src/main/rate-limits/codex-fetcher.ts Resolved
…aining call sites

Follow-up addressing review on stablyai#19931.

Only the full-cycle fetch passed networkProxySettings, so a configured proxy was
still bypassed on the provider-cycle, fetch-target and inactive-account paths — the
last of which already passed the resolver to Claude in the same file. All four
production fetchCodexRateLimits call sites now pass it.

The WSL branch also serialized proxy values into the wsl.exe command line, where
local processes could inspect them (and the URL is a protected secret at rest).
Values now cross via WSLENV names using the shared addWslEnvKeys helper, and the
command carries no proxy material. The local spawn keeps reading them from its
own env.
@mmarabel

Copy link
Copy Markdown
Contributor Author

Addressed in f4f82de — both points were correct.

Sibling call sites: all four production fetchCodexRateLimits paths now pass networkProxySettings (provider cycles, fetch targets, inactive accounts, plus the full-cycle fetch). You're right that service-provider-cycles.ts already passed the resolver to Claude in the same file — that was the same asymmetry, missed.

WSL command line: agreed, serializing the URL there was wrong — the value is a protected secret at rest and the quoting helper only stops injection, not inspection. The WSL branch no longer puts any proxy material in the command; values cross via WSLENV names through the shared addWslEnvKeys helper (same mechanism as glab-exec-file.ts), and the local spawn keeps reading them from its own env. Covered by a new test that stubs the platform to win32 and asserts the credential string is absent from the built command while WSLENV carries the names.

One scoping note: claude-pty.ts has the identical in-command export shape — I left it untouched as out of scope for this PR, but it may want the same treatment as a follow-up.

@pullfrog pullfrog 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.

Important

The new WSL proxy transport is a silent no-op — the configured proxy is still bypassed for WSL Codex homes, regressing the previous commit that exported it in-distro.

Reviewed changes

  • Swapped the WSL proxy transport from in-command export to WSLENV — buildWslCodexCommand no longer serializes export <KEY>=<value> into the wsl.exe command line (avoiding credential exposure per CWE-200); fetchViaRpc and resolvePtyCommand now name the proxy vars in WSLENV instead.
  • Added a WSL credential-exposure test — a new case fakes win32 plus a UNC home and asserts the credentials stay out of the command text while the keys land in WSLENV.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

Comment thread src/main/rate-limits/codex-fetcher.ts Resolved
…LENV import

Follow-up to review: naming the proxy keys in WSLENV is not enough on its own —
WSLENV only imports variables that already exist in the wsl.exe process
environment, so excluding the values left nothing to import and the proxy never
reached the distro. Both spawn sites now always merge the values (they ride the
child env, never the command line) and add the WSLENV names on the WSL branch.

The WSL test now asserts the value as well as the name, so a value-less WSLENV
entry fails.
@onetom

onetom commented Sep 11, 2026

Copy link
Copy Markdown

I'm the submitter of this PR's issue: #19755
I just tried commit f4f82de075 and it worked for me.
Thank you!

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes — the delta since the prior pullfrog review (f4f82de) resolves the WSL silent no-op finding.

  • Merged the proxy env unconditionally into the WSL spawn env — fetchViaRpc and resolvePtyCommand now apply ...proxyEnv in both branches, so the values ride the child env while WSLENV names them for wsl.exe import; the values never enter the command line, keeping the CWE-200 posture.
  • Asserted the value in the WSL credential-exposure test — codex-fetcher-proxy-env.test.ts now checks spawnEnv.HTTPS_PROXY equals the configured proxy, so a value-less WSLENV entry fails rather than passes.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

# Conflicts:
#	src/main/rate-limits/codex-fetcher.test.ts
#	src/main/rate-limits/codex-fetcher.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
@greptile-apps

greptile-apps Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 4/5

[Medium risk] Routes Codex rate-limit calls through the configured proxy.

The PR should not merge until a WSL probe can reach a proxy configured on Windows loopback.

Findings

  1. P1 WSL receives unreachable proxy address ▶
  2. P2 Redemption routing remains untested ▶

Summary

The PR passes configured proxy settings to Codex usage probes and routes Codex backend usage and reset-credit requests through the main HTTP client.

  • It covers the rate-limit service’s Codex fetch paths and adds spawn-environment and backend-routing tests.
  • WSL probes still need a guest-reachable address when the configured proxy is on Windows loopback.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart TD
  S[Rate-limit service] --> F[Fetch Codex rate limits]
  S --> P[Configured proxy settings]
  P --> F
  F --> B[Backend usage via main HTTP client]
  B -->|No result| R[Codex RPC probe]
  F --> R
  R -->|Windows WSL home| W[WSLENV forwards proxy URL to guest]
  R -->|Local home| L[Child reads proxy environment]
Loading

Reviews (1) · Last reviewed commit: "test(rate-limits): keep proxy probe fixt..."

Comment on lines +122 to +123
if (wslCodex && Object.keys(proxyEnv).length > 0) {
addWslEnvKeys(spawnEnv, Object.keys(proxyEnv))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 WSL receives unreachable proxy address

If a Windows user configures a proxy at 127.0.0.1 and a WSL Codex account falls back to the RPC probe, this forwards the Windows proxy URL unchanged into WSL. In the usual WSL NAT configuration, that address points to the guest rather than the Windows proxy, so the probe cannot refresh usage.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This WSL2 NAT limitation remains, as documented in the PR’s Known WSL limitation section. Forwarding a Windows-loopback proxy URL through WSLENV does not make that address reachable from the guest. I’m retaining the networking-policy hold: no address rewriting, silent proxy bypass or live WSL/proxy validation is claimed. The test-only update in c8fa2d0b63 addresses the separate redemption coverage finding; it does not fix this topology limitation.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. The WSL2 NAT behavior is an explicitly documented limitation, and this PR intentionally preserves the configured proxy rather than rewriting it, bypassing it, or validating the topology. Since the redemption-coverage change is separate, there is no additional issue to raise here.

Comment on lines +293 to +297
try {
await fetchCodexRateLimits({ codexHomePath: wslHome })

expect(clientFetch).toHaveBeenCalled()
expect(vi.mocked(fetch)).not.toHaveBeenCalled()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Redemption routing remains untested

This test checks usage and credit reads, but never calls consumeCodexRateLimitResetCredit. The existing redemption tests use the global-fetch fallback, so they would still pass if redemption stopped using the desktop HTTP client. That leaves a future proxy-bypass regression in the redemption path undetected.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Covered in c8fa2d0b63 through the actual consumeCodexRateLimitResetCredit consumer. The injected-client regression now checks the reset outcome, consume POST URL, idempotency payload, authorization/account headers and request signal, and confirms global fetch is unused. A redemption-only mutation back to global fetch fails the new assertion (three client calls expected, two received). Production routing is unchanged. All 670 rate-limit tests pass with one skip; full typecheck, normal hooks and the unchanged review-delta quality gate pass.

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes — the delta since the prior pullfrog review is a merge of upstream main plus a test-only trim; the proxy fix survives the merge intact.

  • Re-applied the proxy env onto upstream's refactored RPC spawn — upstream removed the entire Codex PTY fallback path (resolvePtyCommand, allowPtyFallback, child_process.spawn) and made spawnProcess the single spawn seam. The merge keeps the fix on that seam: buildConfiguredProxyEnv(...) still merges into the child env, addWslEnvKeys still names the proxy keys in WSLENV for WSL homes, and all four service call sites still pass networkProxySettings. The backend calls still route through getMainHttpClient().
  • Trimmed the extracted test fixtures — codex-fetcher.test-fixtures.ts now exports only makeRpcChild; the PTY/RPC shutdown doubles and the FakePtyTerm/FakeDisposable types were dropped along with the PTY path.

Verification: the three focused suites (29 tests) and the full src/main/rate-limits directory (670 passed, 1 skipped) are green, and pnpm tc:node exits 0. spawnProcess forwards env straight to nodeSpawn, so the WSLENV crossing is unchanged.

One informational note, no code change needed: the PR description still describes a "PTY fallback" and resolvePtyCommand proxy coverage that upstream's refactor removed, and the fixture module is now imported only by codex-fetcher-proxy-env.test.ts (it is no longer shared with codex-fetcher.test.ts). Refreshing the description would keep it accurate.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes — the delta since the prior pullfrog review (fb2e62b) is test-only and adds coverage for the redemption path.

  • Covered consumeCodexRateLimitResetCredit through the main HTTP client — a new case in codex-fetcher-backend.test.ts drives a WSL UNC home through the backend, then asserts the reset-credit POST lands on clientFetch (the main HTTP client) and that the undici global is never called. The assertion set is exact enough to fail if the call reverts to the global.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@nwparker

Copy link
Copy Markdown
Contributor

Thanks @mmarabel for the work here. Closing as superseded: Codex usage requests now honor the configured proxy via #26942. Appreciate the contribution, and feel free to open a fresh PR against current main if you see anything still missing.

@nwparker nwparker closed this Oct 24, 2026
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]: Orca httpProxyUrl doesn't apply to usage stats

3 participants