Port upstream 0.69.0: show Grok product usage breakdown on the grok.com billing fallback (stacked on #656) - #692
Conversation
…om billing fallback Decode the per-product shares of the GetGrokCreditsConfig gRPC-web answer ([1, 7] entries) with a bounded shared protobuf reader, trust them only when they compose the same payload's config percent, and show them as plain detail rows. Billing frames now fail closed on truncated or reserved-flag frames.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
|
Adversarial validation (Claude Opus 5.5) passed at f9833f5 Reviewed the whole diff against base What I checked:
Checks run (from worktree
|
Summary
Grok bearer and cookie logins that read usage from the grok.com
GetGrokCreditsConfiggRPC-web answer now show the per-product credit breakdown (for exampleGrok Chat 4%,Grok Build 2%) as plain detail rows under the single weekly bar, the same presentation the credits-proxy path already has. Before this change that path published only the total, because its parser never paired the[1, 7]product ids with their percentages.The protobuf wire reader is now one bounded shared implementation used by the billing scan, the new product decoder and the reset-coupon parser, replacing three private copies.
Upstream reference
GrokWebBillingFetcher.decodeProductUsage,GrokProtobufField,GrokWebBillingProductUsageTests, read at tagv0.69.0only).Stacking note. This PR is stacked on #656 (product usage from the credits proxy), which is stacked on #652 (credits proxy). It needs
GrokProductUsage,LossyProductUsageanddisplay_detailsfrom #656.port/upstream-0.69.0currently points at the same commit asport/upstream-0.67.0, which does not contain that code, so the base isport/micro-0.67.0-grok-product-usagerather thanport/upstream-0.69.0. Retarget after #656 lands.Ported / Deferred
Ported:
billing/protobuf.rs(new): boundedProtobufFieldreader (varint capped at 10 bytes with overflow rejection, length-delimited values bounded by the enclosing message, unknown wire types and out-of-range field numbers malformed).billing/web_product_usage.rs(new): decodes repeated[1, 7]entries{1: product id varint, 2: fixed32 percent}; an omitted percent means 0; only ids 2 (GrokBuild) and 4 (GrokChat) are named; the whole list is dropped on a malformed or duplicate entry, a duplicate scalar field, or an unnamed id with a nonzero share.[1, 1]field, and the shares compose that percent within 1.0 (compose, shared with the credits proxy).GrokBillingSnapshotcarriesproduct_usage;result_from_billingturns it into detail rows, so bearer (proxy-failed and period-only-proxy adoption) and cookie paths all show it. The proxy's own shares still never accompany a grok.com percent.Deferred: none of the upstream behavior. Differences kept on purpose:
Validation
cargo +1.98.0 fmt --all: clean.cargo +1.98.0 clippy -p codexbar --all-targets -- -D warnings: clean.cargo +1.98.0 clippy --workspace --all-targets -- -D warnings: the Tauri crate build script fails in this environment while reading a stale tauri plugin-permissions path from another machine-local target directory (failed to read plugin permissions ... doubao-agent-icon ... app_hide.toml). No Tauri code or bridge type changed; CI's hosted gate covers it.cargo +1.98.0 test -p codexbar grok -- --test-threads=4: 88 passed, 0 failed.cargo +1.98.0 test -p codexbar -- --test-threads=4: 2202 passed, 0 failed, 1 ignored (plus the bin target: 1 passed).Affected areas
rust/src/providers/grok/billing/(mod.rs,protobuf.rs,web_product_usage.rs,reset_coupons.rs, tests)rust/src/providers/grok/(credits_proxy.rs,product_usage.rs,mod.rs, tests)grok/mod.rs, 850).UI proof
Not applicable. This adds rows through the existing provider detail-row pipeline; no UI code, layout, tray, settings or float-bar change.