Repository navigation
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds Grok Build support to the agents usage panel by introducing a new Grok usage/limits collector, wiring it into the plugin manifest, and documenting/validating behavior with assets and shell-based tests.
Changes:
- Added a new
omarchy-agent-usage-grokcollector that scans local Grok session files and optionally probes Grok billing/user endpoints. - Enabled the Grok provider in the agents plugin manifest and added Grok icon assets.
- Updated user-facing docs and added a shell test covering token aggregation, session filtering, cache behavior, and offline/expired-auth scenarios.
Reviewed changes
Copilot reviewed 4 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| test/shell.d/agent-usage-grok-scanner-test.sh | Adds end-to-end shell test fixtures and assertions for Grok usage scanning and limits probing behavior. |
| shell/plugins/agents/manifest.json | Registers/enables the new grok provider and updates plugin description. |
| shell/plugins/agents/assets/grok.svg | Adds dark-surface Grok icon asset. |
| shell/plugins/agents/assets/grok-light.svg | Adds light-surface Grok icon asset variant. |
| shell/plugins/agents/README.md | Documents Grok provider data sources, env vars, and auth handling. |
| manual/17-ai.md | Mentions Grok Build as supported out of the box in the manual. |
| bin/omarchy-agent-usage-grok | Introduces the Grok Build collector implementation (local scan + optional limits probe + caching). |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Ship omarchy-agent-usage-grok so the agents panel can show SuperGrok weekly pool, extra credits, and local session token stats. Session turn_completed events under $GROK_HOME are scanned; limits come from Grok Build's cli-chat-proxy billing and user endpoints, the same ones /usage uses.
05b6d3c to
8146bb0
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 7 changed files in this pull request and generated no new comments.
Suppressed comments (2)
test/shell.d/agent-usage-grok-scanner-test.sh:199
- This test hard-codes an absolute billing period end timestamp and asserts it verbatim. That makes the test brittle over time (and can also fail in environments where fixtures are expected to be relative to ‘now’). Prefer generating the
start/endtimestamps relative to the test’s runtime (similar to howexpires_atis generated), and assert the derived/expected value (or assert shape + presence rather than an exact, fixed date).
"start": "2026-08-08T14:46:02.562637+00:00",
"end": "2026-08-15T14:46:02.562637+00:00"
test/shell.d/agent-usage-grok-scanner-test.sh:213
- This test hard-codes an absolute billing period end timestamp and asserts it verbatim. That makes the test brittle over time (and can also fail in environments where fixtures are expected to be relative to ‘now’). Prefer generating the
start/endtimestamps relative to the test’s runtime (similar to howexpires_atis generated), and assert the derived/expected value (or assert shape + presence rather than an exact, fixed date).
[[ $(jq -c '[.limits[] | {label, percent, resetsAt}]' <<<"$limits") == '[{"label":"Weekly","percent":0.24,"resetsAt":"2026-08-15T14:46:02.562637+00:00"}]' ]] ||
The field is 0-100 alongside productUsage's percentages, so the fraction branch turned 0.4% used into 40% and 1% into a fully spent pool. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
An HTTP status means the endpoint is up, so the panel's 30-second retry just pesters it; a 429 or 503 outage put every refresh on that treadmill. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Nice! Literally just built this and was going to make a PR. Should have checked. 👍🏼 |
A SuperGrok subscription used through pi or omp never writes a Grok Build transcript. Merge those xAI assistant messages the same way Claude and Codex already do, and skip every other provider.
|
Rather than open a competing Grok collector, I branched off this PR and added the SuperGrok usage that never writes a Grok Build transcript: pi/omp sessions on an PR onto this branch: https://github.com/csfh/omarchy/pull/1 |
|
Hello. I had my agent review your PR (lol). One potential bug. Please take a look, thank you sir. |
|
Two small extras from running this locally on Grok Build 1.0.5 (SuperGrok Heavy), if useful before merge. Happy to push them onto this branch rather than open another collector.
Everything else here (weekly meter from |
|
Let's tag it on to this branch no problem. |
…without a full scan Read subscription_tier_display from GET /v1/settings so the panel shows the same plan string as Grok's own UI, falling back to subscriptionTier. Count turn_completed rows that put the ledger on the update itself or use event_name instead of sessionUpdate. --limits-only reuses any same-day session scan so opening the panel can refresh the weekly meter without walking every transcript. Collector test fixtures use padded dummy ids, not live UUIDv7s.
Grok 1.0.x writes session_kind: subagent. Older builds used subagent_fork. The collector only skipped the old name, so child sessions on current Grok were counted again on top of the parent turn_completed ledger.
|
One more follow-up from a live Grok 1.0.5 scan, offered the same way as #1 and #2 on this branch. Grok 1.0.x writes Patch onto this branch: https://github.com/csfh/omarchy/pull/3 Closing the competing Basecamp PR (#7784) in favor of this one. |
|
Great. Thanks @shawnyeager |
Skip Grok 1.0.x subagent sessions in the usage collector
Count pi and omp xAI sessions in the Grok usage collector. Skip non-dict JSONL lines and require type=message plus assistant role, matching Claude. Co-authored-by: Cursor <[email protected]>
Prefer live plan label and accept flat turn_completed usage Co-authored-by: Cursor <[email protected]>
A non-dict params field in updates.jsonl raised AttributeError and took the collector down. Skip those rows, treat an empty nested usage as the flat ledger, and ignore non-assistant pi JSONL the same way Claude does. Co-authored-by: Cursor <[email protected]>
A SuperGrok subscription burned entirely through OpenCode never writes a Grok Build transcript. Merge those messages the same way Claude and Codex already do, skip every other provider, and do not cache an interrupted scan. Co-authored-by: Cursor <[email protected]>
SuperGrok grants "reset tokens": banked resets that clear the credit period before it runs out. The CLI chat proxy this collector speaks to carries no trace of them, so the count comes from the grpc-web RPC grok.com itself calls, on the same bearer token the proxy requests use. Reported as resetCreditsAvailable, the provider-neutral field basecamp#7799 adds for Codex, so the panel prints it with no further change here. The fetch is advisory: a failure reports nothing rather than disturbing a weekly meter that was read successfully.
|
@thehamsti @jkubo @shawnyeager All should be merged. |
|
Heya, I tried this PR on my machine, I like it. One thing, omp’s provider id is xai-oauth, not xai / xai-auth. Without that match daily and model usage is empty. |
|
Omp is Pi? Oh my pi? |
SuperGrok reset tokens are not on the CLI chat proxy, so the collector reads them from grok.com's GetRemainingResets grpc-web RPC and reports the still-valid count as resetCreditsAvailable.
|
Automated duplication check: this pull request looks similar to #9498, which covers the same Grok usage collector. I keep that one open and close this one to consolidate review. If you feel this is the wrong decision, please open the PR again with a note on the difference. |



Summary
Adds a Grok Build collector so the agents panel can show SuperGrok weekly usage, extra credits, and local token history.
omarchy-agent-usage-updatealready globsomarchy-agent-usage-*. This shipsbin/omarchy-agent-usage-grok; the panel picks up the record with no QML changes.Change
$GROK_HOME(default~/.grok): eachturn_completedevent inupdates.jsonlis one prompt (nestedusage, flat token fields, orevent_name). Cache read is split out of input.session_kindvalues that start withsubagent(subagenton Grok 1.0.x,subagent_forkon older builds) are skipped so parent totals are not counted twice.xai/xai-authprovider, and OpenCode messages withproviderIDxai, are merged in the same way Claude and Codex pick up those agents. Other providers, non-assistant rows, prefix-colliding ids such asxai-proxy, and non-object JSONL / malformed OpenCode rows are ignored. An interrupted OpenCode scan is not cached./v1/billing?format=credits(weekly or monthly pool aslimits[], prepaid / leftover on-demand credits asbalance). Plan label prefers/v1/settingssubscription_tier_display(the string Grok's UI shows) and falls back to/v1/usersubscriptionTier(SuperGrokPro→SuperGrok Pro).creditUsagePercentis read as 0-100, matchingproductUsage. A retry is advised only on a transport miss; an HTTP status means the endpoint answered, so the panel's 30-second retry is not set.auth.jsonkeeps local stats and asks forgrok login. The token is never written into the usage record.~/.cache/omarchy/agent-usage/.--limits-onlyreuses any same-day scan so opening the panel refreshes the weekly percent without walking transcripts;--forcerereads the files. An unwritable cache still prints a complete record.assets/grok.svg/grok-light.svgmark (from the official Grok favicon paths). Manifest and manual list Grok Build next to Claude, Codex, and Fireworks.Related: #6477 also adds a grok collector (with Kimi). This PR is Grok Build only, and it counts billed
turn_completedusage rather than peak_meta.totalTokenscontext size.Testing
Focused collector tests passed, including pi xAI merge, OpenCode xAI merge, subagent skip, live plan label, flat turns, malformed
params, and cache reuse.