feat(grok): show product usage breakdown - #3988
Conversation
Preserve same-response product shares from the credits proxy and render plain rows through the shared provider details. Keep reset-credit enrichment from replacing product details and omit malformed breakdowns without changing the main quota. Adopt #3975 with parser, routing, card-model, and synthetic render proof. Co-authored-by: olddonkey <olddonkeyblog@gmail.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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0e372dc1a7
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| windowMinutes: windowMinutes, | ||
| subscriptionTier: subscriptionTier) | ||
| subscriptionTier: subscriptionTier, | ||
| productUsage: Self.composingProducts(config.productUsage?.values ?? [], creditUsagePercent: percent)) |
There was a problem hiding this comment.
Reject product details when the total is negative
When the proxy returns a negative creditUsagePercent, the primary total is clamped to 0, but product composition is still checked against the raw negative value. For example, a total of -0.5 with one product at 0.5 falls exactly within the one-point tolerance, so the UI shows a 0% total alongside a nonzero product row. Drop the breakdown for negative raw totals (or validate it against the normalized total) so malformed responses cannot present contradictory usage.
Useful? React with 👍 / 👎.
|
Codex review: needs changes before merge. Reviewed September 25, 2026, 8:32 AM ET / 12:32 UTC. ClawSweeper reviewWhat this changesThe branch decodes Grok billing product percentages and displays them as text rows beneath the existing quota bar, with documentation and tests. Merge readiness⛔ Needs changes before merge - 2 items remain Current main and v0.66.0 do not show Grok product usage, so this owner-authored PR remains useful. The introduced composition guard can show a nonzero product row beside a 0% total; that focused defect blocks merge. Priority: P2 Review scores
Verification
How this fits togetherCodexBar's Grok provider converts billing responses into a usage snapshot. The CLI and menu card display its quota bar and supporting details. flowchart TD
A[Grok billing response] --> B[Decode total and products]
B --> C{Products compose total?}
C -->|Yes| D[Quota bar and product rows]
C -->|No| E[Quota bar only]
D --> F[CLI and menu card]
E --> F
Before merge
Findings
Agent review detailsSecurityNone. Review metrics
Technical reviewBest possible solution: Keep Grok's single quota bar and guarded product rows, but reject positive product details whenever the displayed aggregate is zero; add focused negative and zero-total cases. Do we have a high-confidence way to reproduce the issue? Yes for the review finding: a billing payload with total -0.5 and one product at 0.5 follows a clear source path to a 0% total with a nonzero detail row. The branch was not executed in this read-only review. Is this the best way to solve the issue? Yes, with the guard corrected: the existing detail section is a narrow fit for product shares without suggesting separate quotas. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 9f76e11944d1. LabelsLabel changes: No label changes. Label justifications:
EvidenceAcceptance criteria:
What I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
Grok credits responses containing
config.productUsagecurrently lose that breakdown during decoding. Preserve validated product shares from the same response as the published credit total, then render plain rows through the existing provider detail section. Reset-credit enrichment now preserves those rows. Malformed or inconsistent breakdowns are omitted without changing the main quota or period; there are no new requests or UI components.Adopts @olddonkey's #3975 with contributor credit, documentation, the 0.66.1 Unreleased entry, and a reproducible synthetic render test. Production changes are 4 files, 115 insertions and 17 deletions (net +98).
Verification
Swift commands used
CODEXBAR_SUPPRESS_TEST_KEYCHAIN_ACCESS=1,CODEXBAR_TEST_CODEX_FILE_ISOLATION=1, andCODEXBAR_TEST_SESSION_FILE_ISOLATION=1. The green run additionally setCODEXBAR_GROK_PRODUCT_PROOF_DIRto its synthetic output directory.swift test --jobs 2 --filter GrokProductUsageTests: before implementation, 1 test failed becauseusage.details.firstwas nil.swift test --jobs 4 --filter 'Grok|ProviderArchitectureGatekeeperTests|ProviderDetailSectionTests|ProviderDetailSectionsContentTests': 269 Swift Testing tests passed, 1 live-only test skipped; XCTest synthetic render passed, 3 unrelated opt-in proof tests skipped; 0 failures. The previously failing regression passed.make check: passed; 0/2658 files required formatting and 0 SwiftLint violations in 2657 files.The installed signed 0.65.0 CLI returned a Grok provider error, so there is no successful live product sample from this run. Verification uses contributor payload fixtures and synthetic rendering.
Synthetic before / after
Both images render the production card with a synthetic 6% total (Grok Chat 4%, Grok Build 2%). The before model clears the previously absent details. Light and dark captures were inspected; no account identity, credentials, desktop content, or private data is present.
Related Linux assessment
No Linux code is adopted here. #3973 routes ordinary launch,
--usage, and tray activation to Quick View and introduces a cost scan on open, so it needs the owner's default-window decision. Recommend an explicit--quick-viewroute andcompactQuickView: falsetray preference while retaining normal launch and--usagebehavior. #3971 remains open.Portable baseline checks passed:
node --test Integrations/Omarchy/test.mjs Integrations/Omarchy/notifications.test.mjs(38),python3 Integrations/Linux/tests/test_package.py(3), andpython3 Integrations/Omarchy/test_install.py(6).python3 Integrations/Linux/tests/test_desktop.pycould not execute behavior: all 17 tests errored at startup because the Linux Qt executable is absent on this Mac.Closes #3975
Refs #3973
Refs #3971