feat(grok): decode the product breakdown on the grok.com billing path - #4041
Conversation
The "Usage breakdown" rows came only from the CLI credits proxy. When the
grok CLI login is gone (grok deletes ~/.grok/auth.json after a rejected
refresh), CodexBar falls back to grok.com GetGrokCreditsConfig, which
carries the same shares but was never paired, so the rows vanished.
Decode the repeated [1, 7] entries ({1: product id, 2: float percent,
omitted = 0}) from a single complete data frame whose aggregate is
[1, 1], and run them through the same all-or-nothing add-up guard as the
proxy (now a shared GrokProductUsage.composing). Only live-verified ids
are named (2 = GrokBuild, 4 = GrokChat); an unnamed id with a nonzero
share, a malformed or duplicate entry, or a mismatched sum drops the
breakdown. The aggregate, reset, and usage flags are unchanged.
The live grok.com response (6 = Chat 4 + Build 2) is checked in verbatim
as a fixture.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 27, 2026, 2:22 PM ET / 18:22 UTC (Revision 4). ClawSweeper reviewWhat this changesThe branch decodes product shares from grok.com billing responses, displays them in CodexBar’s existing Grok usage breakdown, and shares a bounded protobuf reader with reset-coupon parsing. Merge readiness✅ Ready for maintainer review Current main still loses the Grok product breakdown on the grok.com billing path. This PR addresses that distinct gap with live visual proof and focused coverage; I found no concrete introduced defect. Priority: P2 Review scores
Verification
How this fits togetherCodexBar gets Grok usage from a CLI credits proxy or grok.com billing. The selected snapshot feeds the menu card and CLI JSON output. flowchart LR
A[Grok credentials] --> B{Billing source}
B --> C[CLI credits proxy]
B --> D[grok.com billing]
C --> E[Validated product shares]
D --> E
E --> F[Usage snapshot]
F --> G[Menu card and CLI]
Before mergeNone. Agent review detailsSecurityNone. Review metrics
Technical reviewBest possible solution: Populate the existing usage-details model from validated shares in the same grok.com response, preserving its aggregate and reset values. Do we have a high-confidence way to reproduce the issue? Yes, from source and the captured response: current main omits shares on the grok.com path, while the frame specifies the missing rows. This read-only review did not execute the app. Is this the best way to solve the issue? Yes. The branch uses the existing details section and composition guard without adding another request or UI path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against e2846df2a4fd. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles) |
Retain the grok.com product breakdown while sharing one bounded wire reader with quota and reset-coupon parsing. Reject ambiguous scalar fields and malformed frame flags, and cover the shared CLI JSON detail section. Merge main ca85f2d without rewriting contributor history. Refs steipete#4041. Co-authored-by: olddonkey <olddonkeyblog@gmail.com>
Resolve the 0.68.1 unreleased CHANGELOG section by keeping main's entries and placing the Grok (steipete#4041) line under its existing Fixed list. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
What this PR does
Follow-up to #3988. The Grok "Usage breakdown" rows come only from the CLI credits proxy. When the grok CLI login is gone, CodexBar falls back to grok.com
GetGrokCreditsConfig. That response carries the same per-product shares, but they were never decoded, so the rows silently disappear while the weekly bar stays.This happened on a real account. At 07:53 UTC grok's silent token refresh got
RefreshTokenRejected, and grok deleted~/.grok/auth.json(grok's own log:"auth: cleared credentials after permanent refresh failure", "disk_mutation": "file deleted (no scopes left)"). From then on the card showed the bar without the breakdown untilgrok login.This PR decodes the breakdown on the grok.com path too, with the same guard as the proxy path.
The wire shape
GetGrokCreditsConfigconfig (field 1) has the aggregate at[1, 1]and repeated[1, 7]entries{1: product id (varint), 2: percent (float, omitted when 0)}. Live response for the same account at the same moment the CLI proxy reportedcreditUsagePercent 6 = GrokChat 4 + GrokBuild 2:Only ids verified against live proxy samples are named: 2 =
GrokBuild, 4 =GrokChat. Other ids we have seen (5, 7, 8) stay unnamed.Rules
Products are decoded only from a single complete data frame whose aggregate is wire-published at
[1, 1]. They go through the same all-or-nothing add-up guard as the proxy (moved to a sharedGrokProductUsage.composing, with unchanged proxy behavior). The breakdown is dropped when:An unnamed id with a zero or omitted share is simply skipped. The aggregate, reset, and wire-published/implicit-zero flags are computed exactly as before; products never affect them or throw.
Proof
Live: grok.com
GetGrokCreditsConfigfetched with theauth.jsonbearer (no cookies, no Keychain) and parsed by this branch:Menu card: the production
UsageMenuCardViewrendered offscreen from that live snapshot withhidePersonalInfoon (how). There is no plan label or pace here, because this path has no tier or window duration. That is unchanged.Tests
New
GrokWebBillingProductUsageTests:[GrokChat 4, GrokBuild 2]and renders one bar plus the two rows.GrokWebFetchStrategy) now shows the rows.[1, 1].[1, 7]entries.Existing
GrokCreditsProxyFetcherTestsandGrokWebBillingFetcherTestspass unchanged.Commands run:
make check: 0 violationsmake test: exit 0; 129/129 groups passed on the first run (1,426 selections, 0 failures, 0 timeouts, 1,233 s) ond0a11a4aa; it merges cleanly with current main🤖 Generated with Claude Code