Skip to content
Source
Sign inSign up
pingdotgg/t3code

feat(usage): include Grok Build in the usage view #6051

ClosedEliasofIX(GitHub profile, opens in a new tab)wants to merge 5 commits intomain fromrefs/pull/6051/headopened View on GitHub

Summary

The usage page only scanned Claude Code and Codex session transcripts, so Grok Build work never showed up even though sessions under ~/.grok already carry per-turn token and cost data.

This adds Grok as a third usage provider end to end:

  • Parse turn_completed usage from Grok updates.jsonl (per-model modelUsage, cache breakdown, costUsdTicks at 10^10 ticks per USD)
  • Scan $GROK_HOME/sessions (default ~/.grok/sessions), restricted to updates.jsonl so large chat/events logs stay out of the cold path
  • Surface Grok Build in the web and mobile usage charts/labels
  • Bump the usage contract version for the new provider kind

Test plan

  • Open Usage after pairing a local server that has Grok sessions in ~/.grok
  • Confirm Grok Build appears in the provider split, daily chart, and model table
  • Confirm Claude/Codex totals still match the previous behavior
  • vp test run apps/server/src/usage/usageTranscripts.test.ts

Made with Grok Build (xAI).


Note

Medium Risk New transcript parsing and cost pro-rating logic could mis-attribute tokens or dollars for edge-case Grok logs, but changes are confined to usage scanning/aggregation with broad test coverage and a contract version bump for older clients.

Overview Grok Build is added as a third usage provider alongside Claude Code and Codex, so local Grok sessions under ~/.grok (or GROK_HOME) show up on the usage page.

The server scans `~/.grok/sessions//updates.jsonl** only—skipping large chat_history/events logs—and parses **turn_completed** lines into per-model usage records with cache breakdowns and **costUsdTicks** converted to USD (10¹⁰ ticks per dollar). Multi-model turns get **pro-rated cost** when per-model ticks are missing or only partially reported. The usage contract adds **grok** to UsageProviderKind and bumps **USAGE_CONTRACT_VERSION to 5**; the scan cache accepts **grok`** entries.

Web and mobile usage UI gain Grok Build labels, chart bands, icons, and theme-aware colors; the time breakdown table’s empty-state colSpan follows PROVIDER_ORDER so a third provider column doesn’t break layout.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 4c7a2762468c2db08e5498059fca12c17b761669. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).

Note

Add Grok Build as a provider in the usage view

  • Adds a parseGrokLine function in usageTranscripts.ts that parses Grok updates.jsonl session logs into per-model UsageRecord entries with cost tick-to-USD conversion and pro-rated cost attribution.
  • Extends the server-side usage scanner in UsageService.ts to discover Grok sessions via $GROK_HOME or ~/.grok, filtering to updates.jsonl files only.
  • Adds "grok" to UsageProviderKind and bumps the contract version from 4 to 5 in usage.ts.
  • Updates mobile and web UI provider registries to display Grok Build with a label, color, and icon in charts and tables.
  • Fixes the empty-state table colspan in UsagePage.tsx to compute dynamically from PROVIDER_ORDER.length instead of a hardcoded value.
Macroscope summarized 4c7a276.
    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      Important

      Review skipped

      Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

      ⚙️ Run configuration

      Configuration used: Repository UI

      Review profile: CHILL

      Plan: Pro Plus

      Run ID: 768538bd-fb54-4ea7-ae9f-9a73bed604b0

      You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

      Use the checkbox below for a quick retry:

      • 🔍 Trigger review

      Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

      ❤️ Share
      Comment `@coderabbitai help` to get the list of available commands.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    3. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Needs human review

      This PR introduces a new feature adding Grok Build as a third usage provider with substantial new parsing logic, contract version bump, and new user-facing behavior. New feature integrations warrant human review.

      You can customize Macroscope's approvability policy. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. Submitting pending review so follow-up fix replies can land on the nits below.

    5. Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

      Fix All in Cursor ❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the [Cursor dashboard](https://www.cursor.com/dashboard/bugbot). Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 0d56431a655d962959d1899e171ec784c5b3c311. Configure [here](https://www.cursor.com/dashboard/bugbot).
    6. Note

      🤖 GPT-5.6 Sol responding on behalf of Theo

      I am closing this because #8358 has landed in main and covers the same Grok historical usage reporting. I checked the current implementation and did not find any remaining change from this PR that we still need to merge.

      Thank you for putting this together. The closure is only because the work is now covered elsewhere, not because there was a problem with your contribution.

Sign in to join this conversation.