fix(rate-limits): recover WSL Codex usage RPC refresh (#7567)
Summary
- Fixes the Windows+WSL Codex usage refresh path so Orca launches the background Codex app-server RPC through the same interactive WSL shell shape used by WSL Codex login.
- Keeps the selected WSL
CODEX_HOME, hidden rate-limit working directory, host env cleanup, Windows no-PTY-fallback policy, and host/non-WSL command paths unchanged.
Closes #7567.
Testing
- [ ]
pnpm lint - [ ]
pnpm typecheck - [ ]
pnpm test - [ ]
pnpm build - [x] Added or updated high-quality tests that catch the WSL launch regression, host-path negative space, and PTY fallback preservation.
Focused validation run after rebasing onto current main:
pnpm exec vitest run --config config/vitest.config.ts src/main/rate-limits/codex-fetcher.test.ts- passed, 15 tests.pnpm run typecheck:node- passed.- Windows+WSL owner proof - not run; manual-owner-proof remains required on a live Windows 11 WSL2 Codex environment.
AI Review Report
The diff is scoped to the Windows WSL Codex rate-limit child process launcher and its tests. Cross-platform behavior outside that path is unchanged by construction.
Review points:
- Windows and WSL path handling stay centralized in
buildWslCodexCommand. - Hidden subprocess launch behavior stays intact through the existing
windowsHideand hidden cwd setup. CODEX_HOMEremains scoped to the WSL child environment and is stripped from the host env in that path.- Host and non-WSL Codex homes still route through the existing host spawn logic.
- No UI, SSH, browser, shortcut, remote-runtime, or provider-selection code changed.
Security Audit
The change adds no IPC surface, storage format, credential format, network endpoint, dependency, or new subprocess type.
Security properties preserved:
- The selected Codex home stays scoped to the subprocess environment.
- Host
CODEX_HOMEis still removed for WSL children. - The WSL launch path stays hidden and background-only.
- The host command path continues to resolve through the existing Windows spawn helper.
Notes
Thanks to @euclodius for isolating that both the system default WSL Codex home and a separate Orca-managed WSL Codex home can authenticate and return rateLimits from inside WSL.
Live recovery still needs manual-owner-proof on a Windows+WSL profile with shell-initialized Codex.
No actionable comments were generated in the recent review. đ
âšī¸ Recent review info
âī¸ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 73b98072-88d7-4660-8571-f2abf4486315
đĨ Commits
Reviewing files that changed from the base of the PR and between 6ba1a63f7fe05cc7db81cf0128edd1f3bb35cc59 and 081b72476d7daad4e5180b2d6496c8c90e00c6bb.
đ Files selected for processing (2)
src/main/rate-limits/codex-fetcher.test.tssrc/main/rate-limits/codex-fetcher.ts
đ Walkthrough
Walkthrough
The Codex RPC launch path now builds WSL commands through shared login-shell and escaping helpers, with optional RPC stdio isolation enabled for the WSL RPC path. Tests were updated to assert the new WSL command composition more precisely, cover the PTY fallback command shape, and verify that on Windows with a host Codex home path the RPC path spawns codex directly with CODEX_HOME set in the child environment.
đĨ Pre-merge checks | â 5
â Passed checks (5 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title check | â Passed | The title is concise and accurately summarizes the main fix for WSL Codex usage RPC refresh. |
| Description check | â Passed | It covers the required summary, testing, AI review, security, and notes, with only the non-critical screenshots section omitted. |
| Linked Issues check | â Passed | The changes address the Windows+WSL Codex usage refresh regression by fixing the WSL RPC launch path and adding targeted tests. |
| Out of Scope Changes check | â Passed | The diff stays scoped to the WSL Codex rate-limit launcher and its tests, with no unrelated feature or behavior changes. |
| Docstring Coverage | â Passed | No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. |
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.
Comment @coderabbitai help to get the list of available commands.
This looks like the right fix for the Codex usage/rate-limit RPC failure in #7567.
One small cross-link to avoid conflating two Codex WSL symptoms: #6907 is still the Codex agent-status/sidebar path, not the usage RPC path. The local #6907 diagnostics suggested Codex sidebar status needs Codex hook events (SessionStart / UserPromptSubmit / Stop) to cross the WSL -> Windows listener boundary. This PR appears scoped to launching the background Codex app-server RPC through the interactive WSL shell for usage refresh, so I would not expect it to close #6907 by itself.
Happy to retest both separately once the relevant PRs land.