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 d62e76a.
Note
Medium Risk
Adds a new Codex-specific usage read path (including a new WS RPC) and introduces caching/normalization around provider rate-limit payloads, which could affect provider session/runtime behavior if edge cases are missed.
Overview
Adds an end-to-end Codex usage remaining indicator: a new client setting
codexUsageIndicatorMode(defaultfive-hour, supportsboth/offwith legacyweekly→bothmigration) and a toolbar chip (CodexUsageIndicator) that polls usage via React Query.On the server, introduces a normalized
CodexUsageSnapshotcontract andnormalizeCodexUsageSnapshotto convert multiple Codexaccount/rateLimits/*payload shapes into displayable 5h/weekly windows, caches snapshots from notifications/reads, and exposes them throughCodexAdapter.readCodexUsage→ProviderService.getCodexUsage→ new websocket RPCserver.getCodexUsage(wired throughlocalApi/RPC client). Also refactors provider-instance selection by centralizing the logic inresolveSelectedProviderInstanceIdand updates tests/mocks accordingly.Reviewed by Cursor Bugbot for commit d62e76a. Bugbot is set up for automated code reviews on this repo. Configure here.