Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): keep usage-limits incomplete after sparse post-probe updates #12700

Closedmacodev00(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/12700/headopened View on GitHub

What 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

    2. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Review Change StackReview Change Stack

      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.ts
      • apps/server/src/provider/providerUsageLimits.ts

      Included 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 probeFailed status 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

      Layer / File(s)Summary
      Sparse update snapshot handling
      apps/server/src/provider/providerUsageLimits.ts, apps/server/src/provider/providerUsageLimits.test.ts
      applyUsageLimitsUpdate preserves existing unavailable status, marks new snapshots as probeFailed, and returns unchanged snapshots for no-op updates. Tests cover these cases.
      Probe resolution for partial snapshots
      apps/server/src/provider/providerUsageLimits.ts, apps/server/src/provider/providerUsageLimits.test.ts
      resolveUsageLimitsAfterProbe does not retain sparse probeFailed snapshots 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)
      Check nameStatusExplanation
      Linked Issues check✅ PassedThe changes satisfy #12170. applyUsageLimitsUpdate preserves unavailable on a probeFailed snapshot and marks a sparse update with no previous snapshot as probeFailed. `resolveUsageLimitsAfterP…
      Out of Scope Changes check✅ PassedThe changes stay within #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…
      Docstring Coverage✅ PassedDocstring 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.
      Title check✅ PassedThe title clearly and concisely describes the main change: preserving the incomplete usage-limits state after sparse post-probe updates.
      Description check✅ PassedThe description includes the required What Changed, Why, UI Changes, and Checklist sections. It explains the bug, the fix, the regression tests, and the lack of UI changes. The description is complete…
      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create a new PR

      Comment `@coderabbitai help` to get the list of available commands.
    3. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      ⚠️ Action not completed

      Already reviewed the last commit. Use @coderabbitai full review to 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.

    4. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      ⚠️ Action not completed

      Already reviewed the last commit. Use @coderabbitai full review to 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.

    5. 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.

    6. juliusmarminge closed this

    7. @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.