orca icon indicating copy to clipboard operation
orca copied to clipboard

fix(rate-limits): recover WSL Codex usage RPC refresh (#7567)

Open rodboev opened this issue 4 months ago â€ĸ 2 comments

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 windowsHide and hidden cwd setup.
  • CODEX_HOME remains 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_HOME is 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.

rodboev avatar Jul 07 '26 04:07 rodboev

Review Change Stack

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.ts
  • src/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.

â¤ī¸ Share

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

coderabbitai[bot] avatar Jul 07 '26 04:07 coderabbitai[bot]

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.

euclodius avatar Jul 07 '26 07:07 euclodius