You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. To continue using code reviews, add credits to your account and enable them for code reviews in your settings.
fix(server): update all Claude unified usage windows#14441
Claude can stream session and weekly usage together in rate_limit_info.unifiedWindows without naming a top-level window. T3 Code dropped those events, leaving usage stale until the next probe.
The mapper now reads every supported nested window and merges the legacy top-level window last, preserving its precedence. It reuses the overage bucket name established by the probe and ignores malformed or unsupported entries. The fix follows the module relocation on current main; no wire or client changes are needed.
Verification on head 5e7d4ba029f1738b8e38310d44ce2f946a64fa86:
- Reduced the original three added tests to two focused cases in the existing test file: 10 tests before → nine after, including seven unchanged main cases.
- Against main, both new regressions fail and seven cases pass. With the fix, all nine pass. The cases cover nested-only updates, IDs, percentages, reset times, named/unnamed overage, malformed entries, and top-level precedence while retaining another nested window.
- Scoped lint, formatting, and diff checks pass. Server typecheck passes (suggestions only). Validation runs serially with
nice -n 10, Vitest--maxWorkers=2. - Independent full-diff Opus and Sol reviews found no blockers.
These are synthetic mapper fixtures following the serializer shape identified by the contributor and independently confirmed in the installed Claude CLI 2.1.303, plus static inspection of the adapter-to-snapshot update path. No live Claude usage event, browser, or device was exercised. macOS, Windows, iOS, Android, and Electron desktop were not verified live; screenshots do not establish this server-side mapping behavior.
Thanks @nightyard for tracing the unified-window payload and precedence in #14441. Original commits are preserved, with main merged in. The production approach was retained after a fresh implementation assessment; redundant test structure and the stale module header were removed.
Implementation: GPT-6.1 Sol; tests: GPT-6 Astra; independent reviews: Claude Opus 5.5 and GPT-6 Sol. Harnesses: Codex and Claude Code through T3 Code.
Checks
Added 1 commit
- fix(server): update all Claude unified usage windowsdc1d8f3
Approvability
Verdict: Approved at 5e7d4ba
Macroscope's review found this PR approvable — This is a localized server-side fix that makes the existing Claude usage mapper consume all supported unified windows while preserving legacy precedence and sparse ID-based merging. The accompanying changes are tests only, with no schema, configuration, deployment, security, or billing impact.
You can add or adjust custom eligibility rules. Learn more.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Repository: pingdotgg/t3code/.coderabbit.yaml
Review profile: CHILL
Plan: Advanced
Run ID:
8d9b2766-03ba-4a29-bec6-3627b3d3e304
📥 Commits
Reviewing files that changed from the base of the PR and between c2fa9fc911daeac97df4760f95fc57dca42b84c8 and dc1d8f383db08ba7c83ceca0ba3bac98509d107a.
📒 Files selected for processing (2)
apps/server/src/provider/Layers/claudeUsageLimits.test.tsapps/server/src/provider/Layers/claudeUsageLimits.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
📝 Walkthrough
The Claude rate-limit event mapper now processes unified windows alongside legacy top-level fields. It validates utilization values, maps recognized windows, and returns all mapped updates. Tests cover conversion, precedence, and invalid or unknown entries.
Changes: Claude usage limit event mapping
Layer / File(s) Summary Map and validate usage windows
apps/server/src/provider/Layers/claudeUsageLimits.ts,apps/server/src/provider/Layers/claudeUsageLimits.test.tsThe mapper combines recognized unified windows with legacy top-level values. It skips malformed or invalid utilization values and returns mapped updates. Tests cover percentage conversion, reset timestamps, top-level precedence, and rejected entries. Priority: ⬇️ Low
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix
Merge Risk: ⚪ Minimal · up to dc1d8
The change updates supported Claude usage windows together while preserving legacy precedence and bounded percentages. No actionable merge-blocking risk remains after normal checks.
Security architecture risk: 🔵 Low · up to dc1d8
The change preserves the existing instance-specific update path and validates recognized usage windows. No new privileged action or security vulnerability was established. Remaining uncertainty concerns upstream data assumptions and lifecycle behavior, rather than a demonstrated boundary bypass.
Retained concerns No architecture-level concerns identified.
Security review details
Security Blast Radius
- inferred — The demonstrated impact is usage telemetry within the originating provider instance. The exported mapper remains behind the existing SDK message handler; the traced update path changes snapshot usageLimits, not credentials, permissions, tool authority, or enforcement decisions.
Trust Boundaries and Controls
- observed — ProviderService obtains source identity from the adapter registry, rejects provider or instance mismatches, and stamps providerInstanceId before publishing events. Ingestion discards events without an identity or a matching registered instance. This resolves the concern raised by the adapter’s locally unstamped event.
Resilience and Maintainability Implications
- observed — The mapper skips unsupported entries and nonnumeric, negative, or nonfinite utilization. Downstream ingestion isolates failures per event. Multiplication of an extremely large finite fraction can produce Infinity, which the existing clamp converts to zero; this preserves schema bounds but not saturated usage semantics.
Pre-merge checks: Passed 5
Check name Status Explanation Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. Linked Issues check Passed Check skipped because no linked issues were found for this pull request. Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request. Title check Passed The title clearly and concisely describes the server fix for updating all Claude unified usage windows. Description check Passed The description explains the problem, implementation, scope, verification results, test limitations, and review context. It does not use the template headings or provide an explicit maintainer approva… Full details: Description check
Explanation
The description explains the problem, implementation, scope, verification results, test limitations, and review context. It does not use the template headings or provide an explicit maintainer approval comment, but the required information is mostly present.
✨ Finishing Touches
🧪 Generate unit tests (beta)
- Create a new PR
- Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Autopilot is currently an internal CodeRabbit preview.
Comment @coderabbitai help to get the list of available commands.
Taking over this one as maintainer for batch claude-04. I will preserve your commits, move the focused mapper fix onto current main, trim the regression coverage, and run independent reviews before pushing. Thanks for tracing the unified-window stream payload and top-level precedence.
Added 2 commits
Live confirmation for the gap noted in the verification ("No live Claude usage event").
Environment: T3 Code nightly 0.1.2-nightly.20261022.3512 (3b95e7831b11), Claude Code 2.1.309, macOS, Max subscription.
I scanned the 80 most recent provider event logs in ~/.t3/userdata/logs/provider. All 773 rate_limit_event messages have this shape, with unifiedWindows and no top-level utilization:
| 1 | {"status":"allowed","resetsAt":1793034600,"rateLimitType":"five_hour","overageStatus":"rejected","overageDisabledReason":"org_level_disabled","isUsingOverage":false,"unifiedWindows":{"five_hour":{"utilization":0.53,"resetsAt":1793034600},"seven_day":{"utilization":0.24,"resetsAt":1793433600}}} |
I fed that payload, verbatim, to claudeRateLimitEventToUpdate:
origin/main(210b2e7c): returnsundefined, so the event is dropped.- This PR (
5e7d4ba0): returnsfive_hourat 53% andseven_dayat 24%, with the matching reset times. The existing tests inclaudeUsageLimits.test.tsalso pass (10/10 with the extra case).
The user-visible effect is that the Limits bars never move during a turn. They update only on the 5-minute probe, and when that probe fails the client keeps the last good bars. In my case /api/oauth/usage was returning 429 with retry-after: 967, so the bars stayed stale for long stretches.
Checked with Claude Code (Opus 5.5).
Cross-reference for the missing-bars case: I added native-subscription reproduction details on #24119.
The mapper change here parses the captured Claude events, but after a null get_usage response the snapshot can retain probeFailed, and collectLimitAccounts still excludes it. Combining this mapper with #24119’s available:true recovery mechanism restores the account and preserves it through later failed probes.
The focused local regression fails on main, still fails with the mapper alone, and passes with both mechanisms. This is evidence for reconciling the existing work, rather than a competing fix. The detailed test results and verification boundaries are on #24119.
[GPT-6.1 Sol][Codex] on behalf of shivam.
Investigation of https://github.com/pingdotgg/t3code/issues/28852 points to the stale-meter path this PR addresses. At main 1db31d0ea13887c4c77dd14b24920a3496945979, claudeRateLimitEventToUpdate returns undefined when top-level utilization is absent, including the live unifiedWindows payload reported above. The adapter otherwise publishes mapped usage updates immediately, while successful Claude capability/usage probes are cached for five minutes. Dropping streamed updates therefore leaves the meter dependent on those probes.
The reporter compares the desktop meter with Claude Code /usage after ordinary turns on Pro. The explicit-refresh cache change in https://github.com/pingdotgg/t3code/pull/28720 addresses another path; it does not restore these streamed updates.
Handing the dropped-event investigation to this existing maintainer-owned PR rather than opening a competing fix. I inspected this PR at 5e7d4ba029f1738b8e38310d44ce2f946a64fa86, including Julius's takeover and test commit. No new tests, live account comparison, or desktop run were started after finding the takeover. The exact reported roughly 2x timing and Pro-specific behavior remain unverified.
Thanks @nightyard for the earlier work tracing the unified-window events and precedence. This PR has not had a new head since October 19, and #28869 by @juliusmarminge addresses the same dropped updates with regression tests and an end-to-end CLI/server runtime reproduction. Closing this duplicate in favor of that work.