feat(rate-limits): Grok CLI OAuth weekly credit usage (#7869)
* feat(rate-limits): Grok CLI OAuth weekly credit usage in status bar Read ~/.grok/auth.json (read-only), fetch billing credits via cli-chat-proxy, and surface Grok in Settings, status bar toggles, and rate-limit polling alongside other usage providers. * fix(grok): clarify comments and address CodeRabbit review - Shorten Why comments per AGENTS.md; fix billing period end fallback. - Share GrokAccountStatus type; hash-based locale keys; reload why in Settings. * docs(grok): plain-language comments and Settings copy * feat(stats): subscription usage section with Grok in Stats & Usage Surface rate-limit weekly credits in Settings > Stats & Usage and link to Accounts for setup. * feat(stats): Grok tab in Usage Analytics dropdown * refactor(stats): drop Subscription usage block; align Grok pane with Codex * fix(grok): align settings copy and visibility tests * fix(grok): add localization catalog entries * fix(grok): avoid eager usage refresh fanout * fix(grok): harden usage refresh visibility * test(grok): cover account status privacy boundary * fix(grok): target refreshes and redact auth errors * fix(grok): hide usage UI for signed-out users and align empty states - Treat a token-less auth.json (e.g. after grok logout) as signed out instead of surfacing a permanent status-bar error. - Map billing responses without credit usage to 'unavailable' so plans with no weekly credits hide the bar like Claude API-key billing. - Gate the grok status-bar item and toggle on CLI PATH detection, matching claude/codex/gemini/kimi. - Guard an empty GROK_CLI_CHAT_PROXY_BASE_URL from producing a relative billing URL. - Drop dead minimax/kimi Stats & Usage search keywords left from the removed subscription section. - Add missing grok search keyword catalog entries and translate the English-stubbed stats keywords in es/ja/ko/zh. * test(ipc): mock grok account registrar in register-core-handlers test --------- Co-authored-by: Brennan Benson <brennanbenson@Brennans-MacBook-Pro.local>
This commit is contained in:
co-authored by
Brennan Benson
parent
770a9d5dc3
commit
fa2b228ad3
@@ -14,7 +14,9 @@ describe('RateLimitState', () => {
|
||||
opencodeGo: null,
|
||||
kimi: null,
|
||||
minimax: null,
|
||||
grok: null,
|
||||
minimaxCookieConfigured: false,
|
||||
grokAuthConfigured: false,
|
||||
claudeTarget: { runtime: 'host', wslDistro: null },
|
||||
codexTarget: { runtime: 'host', wslDistro: null },
|
||||
inactiveClaudeAccounts: [],
|
||||
|
||||
@@ -44,7 +44,7 @@ export type UsageRateLimitMetadata = {
|
||||
}
|
||||
|
||||
export type ProviderRateLimits = {
|
||||
provider: 'claude' | 'codex' | 'gemini' | 'opencode-go' | 'kimi' | 'minimax'
|
||||
provider: 'claude' | 'codex' | 'gemini' | 'opencode-go' | 'kimi' | 'minimax' | 'grok'
|
||||
/** 5-hour session window, null if not available. */
|
||||
session: RateLimitWindow | null
|
||||
/** 7-day weekly window, null if not available. */
|
||||
@@ -95,6 +95,14 @@ export type InactiveAccountUsage = {
|
||||
isFetching: boolean
|
||||
}
|
||||
|
||||
export type GrokAccountStatus = {
|
||||
signedIn: boolean
|
||||
email: string | null
|
||||
teamId: string | null
|
||||
tokenFresh: boolean
|
||||
error: string | null
|
||||
}
|
||||
|
||||
export type RateLimitState = {
|
||||
claude: ProviderRateLimits | null
|
||||
codex: ProviderRateLimits | null
|
||||
@@ -102,6 +110,7 @@ export type RateLimitState = {
|
||||
opencodeGo: ProviderRateLimits | null
|
||||
kimi: ProviderRateLimits | null
|
||||
minimax: ProviderRateLimits | null
|
||||
grok: ProviderRateLimits | null
|
||||
/**
|
||||
* True when a MiniMax session cookie is persisted on disk. The cookie lives
|
||||
* outside GlobalSettings, so this flag is the durable signal that the
|
||||
@@ -109,6 +118,8 @@ export type RateLimitState = {
|
||||
* between snapshot refreshes.
|
||||
*/
|
||||
minimaxCookieConfigured: boolean
|
||||
/** True when main finds a Grok CLI session file (~/.grok/auth.json or GROK_HOME). */
|
||||
grokAuthConfigured: boolean
|
||||
claudeTarget: RateLimitRuntimeTarget
|
||||
codexTarget: RateLimitRuntimeTarget
|
||||
inactiveClaudeAccounts: InactiveAccountUsage[]
|
||||
|
||||
@@ -7,6 +7,7 @@ export const DEFAULT_STATUS_BAR_ITEMS: StatusBarItem[] = [
|
||||
'opencode-go',
|
||||
'kimi',
|
||||
'minimax',
|
||||
'grok',
|
||||
'ssh',
|
||||
'resource-usage',
|
||||
'ports'
|
||||
|
||||
@@ -3154,6 +3154,7 @@ export type StatusBarItem =
|
||||
| 'opencode-go'
|
||||
| 'kimi'
|
||||
| 'minimax'
|
||||
| 'grok'
|
||||
| 'ssh'
|
||||
| 'resource-usage'
|
||||
| 'ports'
|
||||
@@ -3269,6 +3270,8 @@ export type PersistedUIState = {
|
||||
_kimiStatusBarDefaultAdded?: boolean
|
||||
/** One-shot migration flag for adding the default-on MiniMax status item. */
|
||||
_minimaxStatusBarDefaultAdded?: boolean
|
||||
/** One-shot migration flag for adding the default-on Grok status item. */
|
||||
_grokStatusBarDefaultAdded?: boolean
|
||||
statusBarItems: StatusBarItem[]
|
||||
statusBarVisible: boolean
|
||||
dismissedUpdateVersion: string | null
|
||||
|
||||
Reference in New Issue
Block a user