Surface Grok unified-billing monthly usage instead of a permanent warning#8769
Conversation
…ning Unified-billing Grok accounts have no weekly credits: the /billing?format=credits view returns a config without creditUsagePercent, so the status bar was stuck on 'Grok billing response did not include credit usage' even though the account has a real quota. The default (format-less) /billing view reports it as an included monthly budget (monthlyLimit/used with the billing period). When the credits view has no weekly credit usage, read the default view and surface monthly usage as the provider's 30-day window (already supported by the tooltip and chip visibility for OpenCode Go). If the fallback read fails, the previous 'unavailable' presentation stands rather than escalating to an error chip.
… stale data - StatusBar ProviderSegment: monthly window is chip-visible when it is the sole window (Grok unified billing); fetching/error no-data guards and the icon-only dot now count monthly, matching tooltip.tsx. OpenCode Go chips are unchanged (monthly stays tooltip-only next to session/weekly). - grok-fetcher: monthly-fallback request failures propagate as 'error' so applyStalePolicy keeps the last good monthly snapshot; 'unavailable' is reserved for a successful response without monthly fields.
Why: the Grok accounts section only rendered the weekly-credits row, so unified-billing accounts showed a signed-in state with no usage at all.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughGrok rate-limit fetching now falls back from weekly credits to monthly unified-billing data, with parsing, reset calculations, and typed HTTP or network error handling. Tests cover fallback success, unavailable results, failures, and avoided requests. The status bar recognizes monthly data, displays a monthly-only chip, preserves session and weekly output, and updates provider-dot styling. Grok account settings now display either weekly credits or monthly usage. The shared type documentation identifies Grok unified billing as a monthly-window source. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: e9021f87-f395-4178-b885-088502063f6e
📒 Files selected for processing (1)
src/renderer/src/components/settings/GrokAccountsSection.tsx
Problem
Unified-billing Grok accounts have no weekly credits. For them,
/billing?format=creditsreturns a config withoutcreditUsagePercent, so the status bar was permanently stuck on:even though the account has a real quota. Verified live: the credits view returns only period + zeroed on-demand/prepaid fields, while the default (format-less)
/billingview reports the actual included budget —monthlyLimit: 150000, used: 837with the monthly billing period.Fix
When the credits view yields no weekly credit usage, read the default billing view and surface the included monthly budget as the provider's 30-day window (
monthly— already supported by the tooltip sections and chip visibility for OpenCode Go). If the fallback read fails, the previous 'unavailable' presentation stands rather than escalating to an error chip. Weekly-credit plans still make exactly one request.Testing
vitest rungrok + status-bar suites — 192 tests pass;typecheck:tsc:nodeclean.