Skip to content

feat(usage): add Grok reports to desktop and mobile - #5830

Open
jakeleventhal wants to merge 11 commits into
pingdotgg:mainfrom
jakeleventhal:t3code/add-grok-usage-report-1
Open

feat(usage): add Grok reports to desktop and mobile#5830
jakeleventhal wants to merge 11 commits into
pingdotgg:mainfrom
jakeleventhal:t3code/add-grok-usage-report-1

Conversation

@jakeleventhal

@jakeleventhal jakeleventhal commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

What Changed

  • Added Grok Build transcript scanning, exact provider-reported cost handling, per-model response counts, and cache-version support.
  • Added Grok provider metadata to the shared desktop/web and mobile usage dashboards.
  • Documented usage reports and included an example screenshot with simulated Grok activity.

Why

Usage reports scanned Claude Code and Codex transcripts but omitted Grok activity. This reads persisted Grok ACP modelUsage updates from GROK_HOME or ~/.grok without modifying provider data.

UI Changes

Before, Grok activity was absent from the usage report.

After — simulated Grok data

Usage report showing simulated Grok activity

The screenshot uses an isolated randomized Grok transcript fixture with a 30-day total close to the Claude total. No real Grok usage data was changed.

Validation

  • vp test run apps/server/src/usage apps/web/src/components/usage packages/shared/src/usageMerge.test.ts packages/shared/src/usageFormat.test.ts — 87 tests passed
  • Contracts, shared, server, web, and mobile typechecks passed
  • Targeted lint and format checks passed
  • Read-only reconciliation against real ~/.grok transcripts matched the source totals
  • Desktop usage UI verified with isolated simulated Grok data

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

Built with GPT-5.6 Codex in T3 Code.


Note

Medium Risk
Touches usage aggregation, scan-cache invalidation (cold rescan), and contract version 5; parsing/dedupe mistakes could misstate Grok totals or costs, but changes are read-only and well covered by tests.

Overview
Adds Grok to usage reporting end-to-end: the contract now includes grok and bumps to version 5, and desktop/web/mobile charts show Grok alongside Codex and Claude.

On the server, usage scans GROK_HOME or ~/.grok/sessions for updates.jsonl, parses Grok ACP modelUsage via parseGrokLine (per-model rows, provider cost ticks, fork dedupe), and skips subagent ledgers that are already rolled into the parent session. UsageRecord.recordCount tracks bundled modelCalls; aggregation and the scan cache (v4) use it so response counts stay accurate when one line represents multiple calls.

readGrokHomeOverride normalizes GROK_HOME; user docs note Grok and deduplicated transcript directories.

Reviewed by Cursor Bugbot for commit 9e7c555. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Add Grok usage parsing and reporting across platforms

  • Adds parseGrokLine to parse Grok ACP transcripts into UsageRecord rows, including subagent filtering to avoid double-counting and support for the GROK_HOME environment variable.
  • Introduces recordCount to UsageRecord to track multiple model calls per record, replacing fixed counts in aggregation and scan cache encoding.
  • Bumps usage contract version to 5 and adds 'grok' to UsageProviderKind. Adds Grok provider charts, labels, and colors to web and mobile UI.
  • Behavioral Change: Bumps USAGE_SCAN_CACHE_VERSION to 4, which invalidates existing older caches and triggers a cold rescan.

Macroscope summarized 9e7c555.

@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown

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: 5393327a-77ab-4bd0-b928-0327e5152745

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.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Aug 9, 2026
Comment thread apps/web/src/components/usage/usageProviders.ts Outdated
@jakeleventhal
jakeleventhal marked this pull request as ready for review August 9, 2026 13:40
@macroscopeapp

macroscopeapp Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Not approved

Macroscope's review found this PR not approvable — This PR adds a new Grok transcript ingestion path with parsing, deduplication, cost handling, cache invalidation, contract changes, and desktop/mobile presentation. Because it changes production scanning and usage aggregation across multiple components, the scope warrants human review.

You can add or adjust custom eligibility rules. Learn more.

@jakeleventhal
jakeleventhal force-pushed the t3code/add-grok-usage-report-1 branch from 435d4c6 to a735cc3 Compare August 10, 2026 19:20
Comment thread apps/server/src/usage/usageTranscripts.ts Outdated

@macroscopeapp macroscopeapp Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

One finding: the new Grok home resolution reads process.env imperatively inside the UsageService constructor instead of acquiring the host environment from the Effect environment. Everything else in the changed scope (pure transcript parsers, scan cache, contracts, UI provider tables) is outside the Effect service surface and follows the conventions.

Posted via Macroscope — Effect Service Conventions

Comment thread apps/server/src/usage/UsageService.ts Outdated
@jakeleventhal
jakeleventhal force-pushed the t3code/add-grok-usage-report-1 branch from a735cc3 to b5ce524 Compare August 10, 2026 19:32
Comment thread apps/server/src/usage/UsageService.ts
Comment thread apps/server/src/usage/UsageService.ts
@jakeleventhal
jakeleventhal force-pushed the t3code/add-grok-usage-report-1 branch from fa29bdf to 18b417e Compare August 10, 2026 20:19
Comment thread apps/server/src/usage/usageTranscripts.ts
sheehanmunim added a commit to munimtechnologies/mtcode that referenced this pull request Aug 17, 2026
Merge Grok Build transcript scanning alongside Cursor, OpenCode, Claude,
and Codex. Bumps usage contract to v6 with all five providers.

Co-authored-by: Cursor <cursoragent@cursor.com>
@t3dotgg t3dotgg added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. and removed vouch:unvouched PR author is not yet trusted in the VOUCHED list. labels Aug 24, 2026
# Conflicts:
#	apps/server/src/usage/usageAggregation.ts
#	apps/web/src/components/usage/UsagePage.tsx
#	apps/web/src/components/usage/usageProviders.ts
#	docs/user/usage.md

@macroscopeapp macroscopeapp Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

One finding on the new Grok usage presentation entry: the series/swatch color is a hardcoded gray instead of a semantic token, so it does not follow theme or the contrast appearance setting.

Posted via Macroscope — UI Consistency

Comment thread apps/web/src/components/usage/usageProviders.ts Outdated

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 8f832a8. Configure here.

Comment thread apps/server/src/usage/usageTranscriptReader.ts
Comment thread apps/server/src/usage/usageTranscripts.ts Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 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