Skip to content

Surface Grok unified-billing monthly usage instead of a permanent warning#8769

Merged
brennanb2025 merged 4 commits into
mainfrom
brennanb2025/grok-unified-billing-monthly-usage
Jul 15, 2026
Merged

Surface Grok unified-billing monthly usage instead of a permanent warning#8769
brennanb2025 merged 4 commits into
mainfrom
brennanb2025/grok-unified-billing-monthly-usage

Conversation

@brennanb2025

Copy link
Copy Markdown
Contributor

Problem

Unified-billing Grok accounts have no weekly credits. For them, /billing?format=credits returns a config without creditUsagePercent, so the status bar was permanently stuck on:

Grok billing response did not include credit usage

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) /billing view reports the actual included budget — monthlyLimit: 150000, used: 837 with 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

  • New: unified-billing → monthly window (percent, 43,200-min window, resetsAt from period end); fallback failure keeps 'unavailable'; weekly-credit plans don't issue the second request.
  • vitest run grok + status-bar suites — 192 tests pass; typecheck:tsc:node clean.

…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.
@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 4321f4c7-0ee1-4d88-9033-d55e23afb836

📥 Commits

Reviewing files that changed from the base of the PR and between e695109 and a30dab7.

📒 Files selected for processing (6)
  • src/renderer/src/components/settings/GrokAccountsSection.tsx
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/renderer/src/components/settings/GrokAccountsSection.tsx

📝 Walkthrough

Walkthrough

Grok 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)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description covers the problem, fix, and testing, but it omits required template sections for screenshots, AI review report, security audit, and notes. Add the missing template sections with screenshots or 'No visual change', an AI review summary with cross-platform checks, a security audit, and any notes.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: exposing Grok unified-billing monthly usage instead of the permanent warning.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: e9021f87-f395-4178-b885-088502063f6e

📥 Commits

Reviewing files that changed from the base of the PR and between 8c475a2 and e695109.

📒 Files selected for processing (1)
  • src/renderer/src/components/settings/GrokAccountsSection.tsx

Comment thread src/renderer/src/components/settings/GrokAccountsSection.tsx
@brennanb2025 brennanb2025 merged commit a4cfc82 into main Jul 15, 2026
1 check passed
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.

1 participant