Skip to content

Add a Grok usage collector for the agents panel - #6803

Closed
jason-watts wants to merge 1 commit into
omacom:quattrofrom
jason-watts:add-grok-agent-usage
Closed

jason-watts wants to merge 1 commit into
omacom:quattrofrom
jason-watts:add-grok-agent-usage

Conversation

@jason-watts

Copy link
Copy Markdown

What

Adds omarchy-agent-usage-grok so the existing omarchy.agents bar widget can show Grok usage the same way it already shows Claude, Codex, and Fireworks. The panel does not need a QML change: it already draws any record that lands in ~/.local/state/omarchy/agents/usage/.

How

  • Local stats come from ~/.grok/sessions (or GROK_HOME). Each turn_completed event in updates.jsonl is one prompt; token buckets are summed per turn, not taken as a running session total.
  • Limits / plan come from the same cli-chat-proxy endpoints the CLI's /usage command uses (/v1/billing and /v1/settings). The collector only reads the OIDC token already stored in ~/.grok/auth.json. It never writes credentials and does not refresh them — that stays with grok login.
  • A zero monthly prepaid allowance (typical SuperGrok / X Premium+ login) is treated as "no meter", not 0% used. Those tabs still show the plan label and local token charts.
  • Prepaid monthly credit, an on-demand cap, and a live prepaid balance are reported when the billing payload actually has them.
  • Ships assets/grok.svg plus a light-surface twin, and enables grok in the widget defaults.

Tests

./test/shell.d/agent-usage-grok-scanner-test.sh covers empty/unauthenticated records, per-turn summing, idle sessions, monthly/on-demand/balance mapping, expired tokens, and --limits-only cache reuse.

Verified on a live X Premium+ login: the panel gained a Grok tab with today's token totals and the X Premium+ plan line, and no invented monthly meter.

Ship omarchy-agent-usage-grok so the existing agents widget can show
Grok the same way it shows Claude, Codex, and Fireworks. Local token
stats come from ~/.grok/sessions turn-completed events. Monthly prepaid
credit, the on-demand cap, and the plan label come from the cli-chat-proxy
endpoints the CLI already uses for /usage. SuperGrok / X Premium+
subscriptions have no prepaid monthly meter, so those tabs show local
tokens and the plan name.
Copilot AI balanced review requested due to automatic review settings August 13, 2026 13:35

Copilot AI 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.

Pull request overview

Adds Grok usage collection and display support to the agents panel.

Changes:

  • Collects local session statistics and xAI billing limits.
  • Enables Grok with light/dark icons.
  • Adds documentation and scanner tests.

Tip

If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.

Reviewed changes

Copilot reviewed 3 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
bin/omarchy-agent-usage-grok Implements Grok usage collection.
test/shell.d/agent-usage-grok-scanner-test.sh Tests collection, billing, authentication, and caching.
shell/plugins/agents/README.md Documents Grok support and configuration.
shell/plugins/agents/manifest.json Enables Grok by default.
shell/plugins/agents/assets/grok.svg Adds the dark-surface icon.
shell/plugins/agents/assets/grok-light.svg Adds the light-surface icon.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@jason-watts

Copy link
Copy Markdown
Author

Agent should have checked for duplicates before writing this. Closig.

@dghelm dghelm mentioned this pull request Aug 20, 2026
5 of 6 tasks
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