Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): Grok accounts with no usage yet no longer vanish from Limits #12799

Mergedjakeleventhal(GitHub profile, opens in a new tab)merged 1 commit intomain fromrefs/pull/12799/headmerged by juliusmarminge View on GitHub

xAI omits creditUsagePercent from its billing response entirely until an account has accrued metered usage — it sends the field late rather than sending 0. We mapped that absence to unavailable: { reason: "unsupported" }, which the contract reserves for accounts that can never report quota (API keys, Bedrock). collectLimitAccounts drops those accounts, and collectLimitNotices deliberately mutes their notice because there is nothing to act on. The result: a freshly signed-in Grok account disappears from the Limits view with no bar and no explanation, until it happens to be used. applyUsageLimitsUpdate also refuses mid-turn windows for an unsupported snapshot, so nothing could recover it in the meantime.

I hit this with a second Grok account: it was signed in, listed in the model picker, and running threads, but simply absent from Usage with nothing to indicate why.

grokUsageResponseToLimits now reports no windows and leaves the unavailable marker off when the billing read succeeds but carries no percentage. The account keeps its row and picks up the existing "No limits reported." notice, and the bar appears on its own once usage registers. The genuine can-never-report paths in readGrokUsageLimits (API key, alternate auth deployments, custom config layers) still return unsupported and are untouched.

Before

The second Grok account is signed in and working, but nothing on the page mentions it.

Before

After

After

Captured against a dev server with two Grok instances, with the billing response for the second stubbed to the real payload xAI returns for an unmetered account (currentPeriod present, no creditUsagePercent). That stub was only for the screenshots and is not part of the diff.

vp test run apps/server/src/provider/Layers/GrokProvider.test.ts packages/shared/src/usageLimits.test.ts — 62 passing. The shared side already covered this shape: a provider with empty windows and no marker yields "No limits reported." while an unsupported one is skipped, so no client change was needed.

Model: Claude Opus 5 (1M context). Harness: Claude Code in T3 Code.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Accounts with temporarily unavailable or incomplete billing usage data now remain visible in the Limits view.
    • Missing or invalid usage measurements no longer classify accounts as unsupported.
    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    2. Approvability

      Verdict: Approved at 81e95dc

      Macroscope's review found this PR approvable — This is a narrowly scoped Grok limits bug fix that changes only how successful responses with no metered usage are represented, keeping those accounts visible without altering valid usage or genuinely unsupported paths. The production change is covered by focused test expectations and introduces no schema, deployment, or static-analysis changes.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    3. 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: 431ab3d5-0829-40ea-a45a-7c4b65afe5fb

      📥 Commits

      Reviewing files that changed from the base of the PR and between 45e06f48a03354b600782259010ae6222241aff0 and 81e95dcb81cab8f14a1f38f1affb541831778591.

      📒 Files selected for processing (2)
      • apps/server/src/provider/Layers/GrokProvider.test.ts
      • apps/server/src/provider/Layers/grokUsageLimits.ts

      Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


      📝 Walkthrough

      Walkthrough

      Grok billing responses without valid metering data now produce empty usage limits instead of unsupported limits. The related test verifies that the account remains available in the Limits view.

      Changes

      Grok usage limits

      Layer / File(s)Summary
      Handle missing metering data
      apps/server/src/provider/Layers/grokUsageLimits.ts, apps/server/src/provider/Layers/GrokProvider.test.ts
      grokUsageResponseToLimits returns empty usage limits when creditUsagePercent is missing or non-finite. The test verifies that limits.unavailable is undefined.

      Priority: ➖ Normal

      Estimated code review effort: 2 (Simple) | ~10 minutes

      Change: Bug fix · Severity of issue fixed: Medium

      Suggested reviewers: maria-rcks

      🚥 Pre-merge checks | ✅ 4 | ❌ 1

      ❌ Failed checks (1 warning)

      Check nameStatusExplanationResolution
      Docstring Coverage⚠️ WarningDocstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files.Write docstrings for the functions missing them to satisfy the coverage threshold.
      ✅ Passed checks (4 passed)
      Check nameStatusExplanation
      Title check✅ PassedThe title clearly and concisely identifies the Grok Limits visibility fix. It matches the primary change in the pull request.
      Description check✅ PassedThe description explains what changed, why the change was needed, the expected behavior, unchanged unsupported cases, UI impact, evidence, and test results. It does not include the template's checklis…
      Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.
      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create a new PR

      Comment `@coderabbitai help` to get the list of available commands.
    4. @@ -41,4 +41,11 @@
      4141 ) {
      4242 const usedPercent = response.config?.creditUsagePercent;
      4343 if (usedPercent === undefined || !Number.isFinite(usedPercent)) {
      44- return makeUnavailableUsageLimits({ checkedAt, reason: "unsupported" });
      44+ // A billing read that succeeded but carries no percentage is an account
      45+ // with nothing metered yet, not one that can never report: xAI omits the
      46+ // field entirely (rather than sending 0) until usage registers, then fills
      47+ // it in. Calling that `unsupported` would strand the account — the Limits
      48+ // view drops unsupported entries and deliberately mutes their notice, so a
      49+ // freshly signed-in Grok account would vanish with no explanation until it
      50+ // happened to be used, and `applyUsageLimitsUpdate` would refuse the
      51+ // mid-turn windows that could have recovered it.

      since the t3 team has collaborated with grok, maybe something to ask them to fix on their end

    5. juliusmarminge merged this0cab7d5

    6. juliusmarminge closed this

Sign in to join this conversation.