Skip to content

feat(usage): show Grok Build billing limits - #9205

Merged
diegosouzapw merged 4 commits into
cheaper-inference:release/v3.8.50from
xz-dev:feat/grok-cli-provider-limits
Aug 4, 2026
Merged

diegosouzapw merged 4 commits into
cheaper-inference:release/v3.8.50from
xz-dev:feat/grok-cli-provider-limits

Conversation

@xz-dev

@xz-dev xz-dev commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Summary

  • expose stored grok-cli connections in Dashboard → Provider Quota using Grok Build's read-only /user?include=subscription, /billing?format=credits, and /auto-topup-rule surfaces
  • show the live membership label when supplied, shared weekly usage/reset, product usage, Extra Usage Credits, and Auto Top-Up state while linking Additional Credits management back to Grok
  • preserve sparse/unknown upstream state and last-known-good Auto Top-Up data without exposing tokens, user IDs, emails, payment data, raw responses, or adding any account mutation

Related Issues

Validation

Choose the change type and focused loop from the
Contribution Golden Path. The full unit suite,
Vitest, the 60% coverage gate, and the production build all run in CI on this PR (#8329):

  • Change type: provider / UI / i18n
  • Focused tests and category gates from the golden path
  • npm run lint
  • Reconciled with the current active release base; focused checks rerun afterward
  • Production-code changes include a new or updated automated test in this PR
  • SonarQube PR analysis is green or any remaining issues are explicitly documented below

Focused and related validation:

node --import tsx/esm --import ./open-sse/utils/setupPolyfill.ts --test \
  tests/unit/grok-cli-provider-limits.test.ts \
  tests/unit/grok-cli-provider-limits-ui.test.ts \
  tests/unit/provider-limits-ui.test.ts \
  tests/unit/codex-plan-label-2570.test.ts
# 45 passed

npm run lint
npm run typecheck:core
npm run i18n:check-ui-coverage
npm run i18n:check-value-drift
npm run check:dead-code
git diff --check origin/release/v3.8.50...HEAD

A broader Grok and Provider Limits compatibility selection also passed 289 tests during review. The independent final review concluded Approved — C0 / I0 / M0.

npm run check:file-size retains three failures that reproduce identically on the exact release baseline and are outside this diff:

  • open-sse/executors/base.ts
  • open-sse/handlers/chatCore.ts
  • tests/unit/chatcore-translation-paths.test.ts

npm run check:provider-consistency could not run in this local dependency tree because Bun's package postinstall was not executed; the exact release baseline fails identically. CI has the canonical install environment.

Tests Added Or Updated

  • tests/unit/grok-cli-provider-limits.test.ts
  • tests/unit/grok-cli-provider-limits-ui.test.ts

Coverage Notes

  • the provider test covers the fixed GET-only endpoints, full Grok Build client headers, bounded responses, sparse failures, membership/user-ID independence, signed/omitted cent values, Auto Top-Up disabled/unknown semantics, sanitized cache persistence, and last-known-good merging
  • the UI test covers product normalization, tier inference restrictions, page-level tier filtering, translated/fallback billing rows, missing versus explicit-zero balances, disabled/unavailable Auto Top-Up, and the fixed Additional Credits link
  • intentional-break checks were performed for endpoint routing, currency locale handling, signed-cent normalization, cache preservation, missing-balance omission, and page-level provider propagation before restoring and rerunning green

Reviewer Notes

  • all upstream calls are fixed-host GET requests with redirect: "error", a 10-second timeout, and a 256 KiB declared/streamed response limit
  • Auto Top-Up is read-only; if /user?include=subscription does not provide a canonical user ID, the rule request is skipped and shown as unavailable
  • Extra Usage Credits and Auto Top-Up amounts follow the official signed-cent/proto3 omission semantics and are normalized to non-negative display minor units
  • missing values are omitted or shown unavailable rather than inferred; unknown future membership tiers and products are preserved safely
  • no migration, credential writeback, subscription inference from stored metadata, or xAI account-changing endpoint is included
  • Additional Credits links only to https://grok.com/build?_s=usage

@xz-dev
xz-dev requested a review from diegosouzapw as a code owner August 2, 2026 09:38
xz-dev added a commit to xz-dev/OmniRoute that referenced this pull request Aug 3, 2026
@diegosouzapw

Copy link
Copy Markdown
Collaborator

Merged via local merge-train on 192.168.0.113 (32 cores) @ train tip 7eb0840f219a403081d79244e61e7747cfec92a4 — log /srv/omniroute-train/.claude/worktrees/train-20260804-200844-suite.log.

Green: typecheck:core, check-complexity, check-cognitive-complexity, check-changelog-integrity.

This was the first train of the day to run against a genuinely clean base — #9447 and #9392 had just taken the release back to green after 15 unit failures inherited from #9275 — so every red here was re-run in isolation on the exact train tip rather than assumed. All of them passed:

Failure Suite Isolated on the train tip
consoleInterceptor-writes — log-unavailable notice unit 6/6 pass (also failing on the bare tip)
modelsDevSync-extended — duplicate timers unit 13/13 pass (also 13/13 on the bare tip)
audit.test.ts ×3 (shutdown checkpoint, node:sqlite fallback) vitest pass — the documented WAL/timeout-under-load flake class
Sidebar.search.test.tsx ×2 vitest pass — timed out at 20s/10s under the full concurrent run

No failure was attributable to any boarded PR.

For reference, check-file-size remains a pre-existing base-red on the bare tip (src/sse/handlers/chat.ts 1846>1845, open-sse/executors/base.ts 1623>1578) — baseline drift for the release captain.

@diegosouzapw
diegosouzapw merged commit 3440c11 into cheaper-inference:release/v3.8.50 Aug 4, 2026
15 of 16 checks passed
muhamadgalihsaputra pushed a commit to niyatna/NiyatnaRoute that referenced this pull request Sep 27, 2026
* feat(usage): show Grok Build billing limits

* test(usage): keep Grok quota reset fixture in the future

* fix(i18n): add Grok billing labels to pt-BR

* fix(i18n): add Grok billing labels to Vietnamese
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants