Skip to content

fix(codex): classify weekly-only rate limits on the backend path - #10466

Closed
brennanb2025 wants to merge 2 commits into
mainfrom
brennanb2025/codex-backend-weekly-only-classify
Closed

brennanb2025 wants to merge 2 commits into
mainfrom
brennanb2025/codex-backend-weekly-only-classify

Conversation

@brennanb2025

Copy link
Copy Markdown
Contributor

Summary

#10136 taught the app-server RPC path to classify Codex rate-limit windows by duration, but the backend HTTPS path — the one WSL uses — still assumed primary = 5h / secondary = weekly by position. Weekly-only plans (current Pro) expose their sole 7-day quota as the primary window, so WSL users saw it mislabeled as a 5h session.

Verified against the live backend for a weekly-only Pro account:

primary_window:   used_percent=100  limit_window_seconds=604800  (=10080 min)
secondary_window: null

Changes:

  • Route backend windows through the same duration classifier by reshaping them into the shared window snapshot, preserving the exact bucket duration the backend reports.
  • Rename the classifier's input types to be transport-neutral now that both paths share them (CodexRpc* → CodexRateLimitWindows*).
  • Status bar: follow the weekly window when there is no session window, so weekly-only plans keep their compact mini meter instead of losing it (p.session ?? p.weekly).

5h-only, 5h+weekly, and unknown-duration plans are unchanged on both paths.

Context

Found while retesting #9969 on v1.4.156-rc.0. The native (RPC) half of that mislabel is already fixed by #10136 — confirmed live, the Codex row went from 5h · Resets in 6d 15h to wk · Resets in 5d 19h. This PR closes the remaining WSL half.

Note this does not fix #9969's reported symptom (limits resetting earlier than the displayed countdown) — that is upstream OpenAI reset behavior, not a client-side parsing bug.

Testing

  • typecheck:node + typecheck:web clean
  • 59 test files / 601 tests green (src/main/rate-limits/ + src/renderer/src/components/status-bar/), incl. 3 new/updated test files
  • Live-verified the backend payload shape for a weekly-only Pro account (macOS)
  • Not verified on real WSL — the changed path only runs on WSL. Needs a WSL smoke check: weekly-only Codex account should show wk (not 5h) plus its mini meter.

…keep the mini meter

The app-server RPC path already classifies Codex rate-limit windows by
duration, but the backend HTTPS path (used for WSL) still assumed
primary=5h / secondary=weekly by position. Weekly-only plans expose their
sole 7-day quota as the primary window, so WSL users saw it mislabeled as a
5h session.

Route the backend windows through the same duration classifier by
reshaping them into the shared window snapshot, preserving the exact bucket
duration the backend reports. Rename the classifier input types to be
transport-neutral now that both paths share them. In the status bar, follow
the weekly window when no session window exists so weekly-only plans keep
their compact mini meter instead of losing it.

5h-only, 5h+weekly, and unknown-duration plans are unchanged on both paths.
@coderabbitai

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

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 Plus

Run ID: 386556a6-c1ad-4d3f-a10c-e6c7defb6c1c

📥 Commits

Reviewing files that changed from the base of the PR and between d5340fd and dde2566.

📒 Files selected for processing (6)
  • src/main/rate-limits/codex-fetcher-backend.test.ts
  • src/main/rate-limits/codex-fetcher.ts
  • src/main/rate-limits/codex-rate-limit-window-classification.test.ts
  • src/main/rate-limits/codex-rate-limit-window-classification.ts
  • src/renderer/src/components/status-bar/StatusBar.tsx
  • src/renderer/src/components/status-bar/inline-usage-bars.test.tsx

📝 Walkthrough

Walkthrough

Codex rate-limit handling now uses snapshot-based window types and derives window durations from backend data. Backend classification identifies weekly-only usage when the secondary window is absent and maps its duration and reset values. The status bar renders a mini meter using the weekly window when no session window exists. Tests cover backend weekly-only mapping and weekly meter rendering.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The summary and testing are present, but the required Screenshots, AI Review Report, Security Audit, and Notes sections are missing. Add the missing template sections, or note why each is unnecessary; include screenshots/no-visual-change, review, security, and notes.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: fixing weekly-only Codex rate-limit classification on the backend path.
Linked Issues check ✅ Passed The code changes address #9969's weekly-only Codex display bug by classifying backend windows by duration and preserving the weekly meter when session is absent.
Out of Scope Changes check ✅ Passed The changes stay focused on Codex rate-limit classification and status-bar rendering, with tests added to cover the new weekly-only case.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Closing as superseded: a merged PR already covers this change. Merged #11415 (b21f978) body: 'incorporates the remaining backend work from #10466'; it changed the same files (codex-fetcher.ts, codex-rate-limit-window-classification.ts, StatusBar.tsx) to run backend windows through the duration

(Stale-PR cleanup 2026-10-20, approved by Brennan. Reopen if something here is still missing on main.)

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 Codex is not showing the reset time for the limits correctly.

1 participant