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 New feature introducing a Codex usage indicator with new UI components, settings, RPC endpoints, and provider integration. The scope of new functionality—including user-facing UI, new data flows, and external API integration—warrants careful review. You can customize Macroscope's approvability policy. Learn more. |
…ndicator # Conflicts: # apps/web/src/localApi.ts
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 6b8a1a4. Configure here.
| if (byKind) return byKind.instanceId; | ||
|
|
||
| const anyEnabled = input.entries.find((entry) => entry.enabled); | ||
| return anyEnabled?.instanceId ?? input.entries[0]?.instanceId ?? ProviderInstanceId.make("codex"); |
There was a problem hiding this comment.
Refactored fallback drops thread/project model selection IDs
Low Severity
The extracted resolveSelectedProviderInstanceId final fallback returns anyEnabled?.instanceId ?? entries[0]?.instanceId ?? ProviderInstanceId.make("codex"), but the original inline code in ChatComposer additionally tried activeThreadModelSelection?.instanceId ?? activeProjectDefaultModelSelection?.instanceId before the hardcoded "codex" default. When no entries exist at all, the old code could return a meaningful persisted instance ID while the new code always returns the hardcoded "codex" fallback.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 6b8a1a4. 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 toBranchToolbarthat displays five-hour and/or weekly Codex rate limit usage with a tooltip and amber styling when a limit is reached; controlled by a newcodexUsageIndicatorModesetting (default:five-hour).normalizeCodexUsageSnapshoton the server to convert heterogeneous Codex rate limit payload shapes into a typedCodexUsageSnapshotwith clamped percents, ISO reset times, and a resolvedrateLimitReachedType.readCodexUsageto the Codex adapter, which reads account rate limits from the active session runtime or a short-lived temporary runtime, normalizing and caching results; cached snapshots are returned when subsequent reads yield no displayable windows.getCodexUsage(instanceId)onProviderServiceand wires a newserver.getCodexUsageWebSocket RPC, polled every 60 seconds from the client viacodexUsageQueryOptions.CodexUsageIndicatorModeto client settings with a legacy migration: the old"weekly"value decodes to"both"; the new default is"five-hour".Macroscope summarized 6b8a1a4.
Note
Medium Risk
Adds a new Codex usage read path (including a new WS RPC) and caching/normalization logic around rate-limit payloads, which could affect provider session runtime behavior and UI polling. Changes are contained to Codex-specific paths but touch server adapter/runtime initialization and client settings persistence.
Overview
Adds an end-to-end Codex usage remaining feature: a new client setting
codexUsageIndicatorMode(defaultfive-hour, with legacyweeklymigrated toboth) and a toolbarCodexUsageIndicatorchip that polls and displays remaining 5h/weekly limits with tooltip/reset-time formatting.On the server, introduces a typed
CodexUsageSnapshotcontract plus normalization utilities, and extends the Codex provider stack to readaccount/rateLimits/read(via the active session runtime or a short-lived runtime when no session exists), cache the last usable snapshot, and update the cache fromaccount/rateLimits/updatednotifications.Exposes this through
ProviderService.getCodexUsageand a new WS RPCserver.getCodexUsage, wires it through the weblocalApi+ react-query helper (codexUsageQueryOptions, 60s polling), and updates tests/mocks to include the new APIs and settings persistence.Reviewed by Cursor Bugbot for commit 6b8a1a4. Bugbot is set up for automated code reviews on this repo. Configure here.