fix(server): keep usage-limits incomplete after sparse post-probe updates #12700
main fromrefs/pull/12700/head·opened View on GitHubWhat Changed#
In applyUsageLimitsUpdate (providerUsageLimits.ts): copy unavailable on rebuild the same way resetCredits is copied; merge onto previous === undefined as probeFailed; keep identity on no-op so a probeFailed snapshot is not rebuilt and stripped.
Adds regression tests so a sparse { id: "seven_day" } update after a failed/missing probe stays marked incomplete (not a clean one-window “complete” list).
Fixes #12170
Why#
A turn rate_limit_event after a failed Claude boot probe was upserted onto [] / probeFailed and published as an unmarked weekly-only snapshot. Clients treated that as a full limits read. resolveUsageLimitsAfterProbe is unchanged — a still-marked snapshot is not last-good.
UI Changes#
No UI change. Existing Limits notice (“Could not read limits.”) stays correct while the incomplete marker is on. Screenshots/video not applicable.
Verification#
From apps/server at commit d28ff58b3:
vp test run src/provider/providerUsageLimits.test.ts
Result: 1 file passed, 8 tests passed (206ms). Probe-failure coverage includes "keeps a failed probe marked when a sparse update lands on it", "marks a sparse update with no previous snapshot as probeFailed", and "does not keep a probeFailed merge as last-good through a later failed probe".
vp run typecheck
Result: passed (exit 0, 46.85s). tsc --noEmit reported suggestions only.
Limitations: Ran on Linux x64. These are pure update-merge unit tests; a live provider usage probe was not run.
Checklist#
- This PR is small and focused
- I explained what changed and why
- I included before/after screenshots for any UI changes
- I included a video for animation/interaction changes
Summary by CodeRabbit#
Bug Fixes
- Improved usage-limit tracking for partial updates when provider availability information is incomplete.
- Preserved existing unavailable status across unchanged or partial updates.
- Ensured sparse updates without prior usage data remain marked as unverified until a complete probe succeeds.
- Prevented incomplete failed-probe results from being treated as the latest valid usage snapshot.
Tests
- Added coverage for sparse updates, unavailable status preservation, repeated identical updates, and failed probe resolution.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:S
@coderabbitai review
⚠️ Action not completed
Already reviewed the last commit. Use
@coderabbitai full reviewto rerun a review of the entire changeset.Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.
@coderabbitai review
⚠️ Action not completed
Already reviewed the last commit. Use
@coderabbitai full reviewto rerun a review of the entire changeset.Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.
Note
This comment is posted by Julius' dot
Closing for missing verification. The regression tests are included, but the PR gives no executed test command or observed result for the failed-probe and sparse-update cases. Add the focused command and its observed results, plus any affected-platform checks and limitations. Then request reconsideration.
juliusmarminge closed this
@juliusmarminge I added a Verification section to the description with the focused test command, its observed results, and the platform limits. Could you reconsider this PR?
Sign in to join this conversation.
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:
792c064b-fd15-4ca3-a7d3-4a463567da0d📥 Commits
Reviewing files that changed from the base of the PR and between 7445aa733ada33e45289e5aa5055f79142556513 and d28ff58b3a50a2c44b4f038c9548b4ea4bd64b44.
📒 Files selected for processing (2)
apps/server/src/provider/providerUsageLimits.test.tsapps/server/src/provider/providerUsageLimits.tsIncluded review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.
📝 Walkthrough
Walkthrough#
The provider usage limit merge now preserves
probeFailedstatus for sparse snapshots and marks new sparse snapshots accordingly. Probe resolution no longer treats these partial snapshots as last-good results. Tests cover both behaviors.Changes#
Usage limits handling
apps/server/src/provider/providerUsageLimits.ts,apps/server/src/provider/providerUsageLimits.test.tsapplyUsageLimitsUpdatepreserves existing unavailable status, marks new snapshots asprobeFailed, and returns unchanged snapshots for no-op updates. Tests cover these cases.apps/server/src/provider/providerUsageLimits.ts,apps/server/src/provider/providerUsageLimits.test.tsresolveUsageLimitsAfterProbedoes not retain sparseprobeFailedsnapshots after a later failed probe. Tests verify the probe result is returned.Priority: ➖ Normal
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix · Severity of issue fixed: Medium
Suggested reviewers:
yashranaway🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
#12170.applyUsageLimitsUpdatepreservesunavailableon aprobeFailedsnapshot and marks a sparse update with no previous snapshot asprobeFailed. `resolveUsageLimitsAfterP…#12170. The production changes update usage-limit merge and probe-resolution behavior. The added tests verify the required failure scenarios. No UI or unrelated changes are pre…✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment `@coderabbitai help` to get the list of available commands.