Add Codex usage indicator#2484
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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 |
4e9f527 to
d28c0ed
Compare
d28c0ed to
8075d94
Compare
ApprovabilityVerdict: Needs human review This PR introduces a new user-facing feature (Codex usage indicator) with new UI components, settings, API endpoints, and schemas across multiple packages. New features introducing user-facing behavior warrant human review. You can customize Macroscope's approvability policy. Learn more. |
3cae74f to
072624f
Compare
a7796fc to
7246156
Compare
7246156 to
5af6aa1
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 3d4194f. Configure here.

Summary
What Changed
Codex usage remainingsetting with5h window,5h + weekly, andOffaccount/rateLimits/readandaccount/rateLimits/updated5hand secondary usage toWeeklyScreenshots
Testing
bun fmtbun lintbun typecheckbun run test -- src/settings.test.tsbun run test -- src/provider/codexUsage.test.ts src/provider/Layers/CodexAdapter.test.ts src/provider/Layers/ProviderService.test.tsbun run test:browser -- src/components/chat/CodexUsageIndicator.browser.tsxNote
Add Codex usage indicator showing rate limit windows in the chat toolbar
CodexUsageIndicatorcomponent to the branch toolbar that displays 5-hour and/or weekly Codex rate limit usage, controlled by a newcodexUsageIndicatorModesetting ('five-hour', 'both', 'off') in General Settings.normalizeCodexUsageSnapshotincodexUsage.tsto normalize various Codex rate-limit payload shapes into a consistentCodexUsageSnapshotwith clamped percents, window kinds, andresetsAttimestamps.CodexSessionRuntimewithreadAccountRateLimits, which lazily initializes the client so usage can be fetched without an active session.readCodexUsageto the Codex adapter, using the active session runtime or a short-lived ephemeral runtime, with a cache updated by both reads and provider notifications.ProviderService.getCodexUsageand aserver.getCodexUsageWebSocket RPC endpoint, wired through to the web client via React Query (codexUsageQueryOptions) with a 60-second refetch interval.ClientSettingsgainscodexUsageIndicatorModedefaulting to'five-hour'; the legacy value'weekly'decodes to'both'.Macroscope summarized a97e7c2.
Note
Medium Risk
Adds a new end-to-end Codex usage pipeline (runtime call + adapter caching + ProviderService routing + WebSocket RPC + React Query UI), which could affect provider event handling and increase server/client coupling. Risk is mitigated by being Codex-only and returning
nullon failures, but correctness depends on normalizing multiple payload shapes and session-less runtime initialization.Overview
Adds a Codex usage remaining status chip in the web chat toolbar (next to the branch/env controls), controlled by a new client setting
codexUsageIndicatorMode(five-hour,both,off, defaulting tofive-hourwith legacyweeklymigrated toboth).Introduces an end-to-end usage fetch path:
CodexSessionRuntimegainsreadAccountRateLimitswith lazy one-time initialization,CodexAdapteraddsreadCodexUsagewith caching updated from bothaccount/rateLimits/readandaccount/rateLimits/updatednotifications (including session-less reads via an ephemeral runtime), and a newnormalizeCodexUsageSnapshotmaps varied payload shapes into a consistentCodexUsageSnapshotcontract.Exposes usage to clients via
ProviderService.getCodexUsageand a newserver.getCodexUsageWebSocket RPC, consumed in the web app throughcodexUsageQueryOptions(60s polling) and newCodexUsageIndicatorUI/tests; related tests and mocks are updated to include the new optional adapter/service methods.Reviewed by Cursor Bugbot for commit a97e7c2. Bugbot is set up for automated code reviews on this repo. Configure here.