Skip to content

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

Merged
juliusmarminge merged 1 commit into
pingdotgg:mainfrom
jakeleventhal:fix/grok-usage-not-reported
Sep 25, 2026
Merged

juliusmarminge merged 1 commit into
pingdotgg:mainfrom
jakeleventhal:fix/grok-usage-not-reported

Conversation

@jakeleventhal

@jakeleventhal jakeleventhal commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

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.

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Sep 20, 2026
@macroscopeapp

macroscopeapp Bot commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

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.

@coderabbitai

coderabbitai Bot commented Sep 20, 2026 •

Copy link
Copy Markdown

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 45e06f4 and 81e95dc.

📒 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 name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring 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 name Status Explanation
Title check ✅ Passed The title clearly and concisely identifies the Grok Limits visibility fix. It matches the primary change in the pull request.
Description check ✅ Passed The 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 ✅ 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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

Comment @coderabbitai help to get the list of available commands.

Comment on lines +44 to +51
// A billing read that succeeded but carries no percentage is an account
// with nothing metered yet, not one that can never report: xAI omits the
// field entirely (rather than sending 0) until usage registers, then fills
// it in. Calling that `unsupported` would strand the account — the Limits
// view drops unsupported entries and deliberately mutes their notice, so a
// freshly signed-in Grok account would vanish with no explanation until it
// happened to be used, and `applyUsageLimitsUpdate` would refuse the
// mid-turn windows that could have recovered it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

…mits

xAI omits `creditUsagePercent` from its billing response entirely until an
account has accrued metered usage, rather than sending 0. We treated that
absence as `unsupported`, which the contract reserves for accounts that can
never report quota, such as API keys and Bedrock. The Limits view drops those
accounts and deliberately mutes their notice, so a freshly signed-in Grok
account disappeared from Usage with no bar and no explanation until it
happened to be used. `applyUsageLimitsUpdate` also refuses mid-turn windows
for an `unsupported` snapshot, so nothing could recover it in the meantime.

Report no windows instead, leaving the `unavailable` marker off. The account
keeps its row and gets 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)
still return `unsupported` and are unaffected.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@jakeleventhal
jakeleventhal force-pushed the fix/grok-usage-not-reported branch from 81e95dc to e5de07b Compare September 24, 2026 23:40
@juliusmarminge
juliusmarminge merged commit 0cab7d5 into pingdotgg:main Sep 25, 2026
21 checks passed
github-actions Bot added a commit to omarcresp/t3code-flake that referenced this pull request Sep 25, 2026
## What's Changed
* fix(web): sidebar Back always returns to the main app by @t3dotgg in pingdotgg/t3code#13516
* fix(desktop): desktop updates reconnect in seconds, not minutes by @t3dotgg in pingdotgg/t3code#12006
* fix(connect): remove tunnels after hosts go offline by @t3dotgg in pingdotgg/t3code#9386
* fix(mobile): capture a lit 6.9-inch lock screen in the agent-activity showcase by @juliusmarminge in pingdotgg/t3code#13522
* feat(grok): offer one-click updates through `grok update` by @juliusmarminge in pingdotgg/t3code#13523
* fix(mobile): make Android subscription usage widgets scrollable by @tris203 in pingdotgg/t3code#13474
* fix(web): keep sidebar terminal pulses in sync by @t3dotgg in pingdotgg/t3code#12962
* feat(web): add iPhone Duo 3D controls by @juliusmarminge in pingdotgg/t3code#12813
* fix(relay): export tunnel cleanup counters to Axiom by @juliusmarminge in pingdotgg/t3code#13528
* fix(server): Grok accounts with no usage yet no longer vanish from Limits by @jakeleventhal in pingdotgg/t3code#12799
* fix(server): report the Grok account email so usage limits merge across environments by @jakeleventhal in pingdotgg/t3code#12588
* feat(web): add usage page keybinding by @jakeleventhal in pingdotgg/t3code#9434
* chore: clear Effect language service suggestions by @juliusmarminge in pingdotgg/t3code#13536
* ci(relay): add a forced manual relay deploy by @juliusmarminge in pingdotgg/t3code#13550
* fix(web): selected text stays visible on a revealed file line by @t3dotgg in pingdotgg/t3code#13548
* fix(web): collapsed composer bar stops flipping its labels while you scroll by @t3dotgg in pingdotgg/t3code#13555
* fix(clients): sync status no longer flickers when opening running threads by @t3dotgg in pingdotgg/t3code#13551
* fix(server): newer Codex models get T3 Code's instructions again by @t3dotgg in pingdotgg/t3code#13547


**Full Changelog**: pingdotgg/t3code@v0.0.43-nightly.20260924.2223...v0.0.43-nightly.20260925.2237

Upstream release: https://github.com/pingdotgg/t3code/releases/tag/v0.0.43-nightly.20260925.2237
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants