makecindy / makecindy/cindy

feat(desktop): SuperGrok 状态栏看不到订阅用量,只显示限流或「无配额明细」

Open
#2,633 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
2.7k
Forks
401
Avg merge
21h 48m
Merged PRs (30d)
776

Description

### 使用场景 / Use case

用 SuperGrok 订阅在 Cindy 里跑 Claude Code / Codex 时,希望底部消费提示和 Claude / ChatGPT 一样,能看到**这期订阅用了多少、还剩多少、何时重置**。

现在要看这些数字,只能离开 Cindy,去 grok.com 的 Settings → Usage。

### 当前问题 / Current limitation

Cindy 已经能登录 SuperGrok(OAuth scope 含 `grok-cli:access`),也能正常发请求。但状态栏这条路径只解析 `api.x.ai` 响应头里的 `x-ratelimit-*`:

- 有头:显示这一分钟还剩几个请求 / token(限流余量)
- 没头:提示「xAI 未提供订阅配额明细,此处仅显示价值估算」

这两样都不是 SuperGrok 的订阅共享池。Claude / ChatGPT 订阅有专门的用量窗口;xAI 这边代码注释也按「api.x.ai 没有这种端点」来实现。

同仓库里没有请求消费者 billing 的代码(没有 `cli-chat-proxy` / `GetGrokCreditsConfig` / `creditUsagePercent`)。这和目录缺不缺某个 Grok 型号、档位全不全无关(#2597 / #2601 是另一件事;线上目录已有 4.6,但那是模型列表)。

### 期望方案 / Proposed solution

在已登录 SuperGrok 时,用现有消费者 session 去拉订阅用量,并在状态栏现有 xAI 位置展示:

- 已用百分比 / 剩余百分比
- 周期类型(周 / 月)
- 重置时间

不要把产品分项再加总成总额度(Chat / Imagine / Build 可能是同一共享池的拆分视图)。`creditUsagePercent` 是**已用**百分比,剩余应算 `100 - 已用`。

接口方面:xAI 官方开源客户端 `xai-org/grok-build` 的 `/usage` 走的是

`GET https://cli-chat-proxy.grok.com/v1/billing?format=credits`

本机用同一套 grok.com / grok-cli OAuth session 打过这条接口,返回值与 grok.com Settings → Usage 同一账号一致。这不是公开 REST 文档里的稳定合同,实现时需要按内部接口来做兼容(401/403/429、字段缺失不要硬报成 0)。

凭据只发给 xAI / Grok 第一方,不要经第三方中转。实现上:

- **展示**更适合复用 ChatGPT / Codex 订阅 chip(`usesCodexQuotaForm`):窗口是 `{ usedPercent, windowMinutes, resetsAt }`,名称按服务端时长动态派生,**不写死 5 小时窗**(代码注释写明 2026-07 曾取消 5h,且可能再变)。Grok 实测就是一个共享池,映射成 `primary` 即可,没有的槽不渲染。
- **不要**套 Claude 的 `QuotaHoverCard`(写死 5h / 总周限 / 分模型周窗)。
- **拉取**仍要新写薄接口:Codex 数据来自 ChatGPT 事件,换不了 URL。可借 Claude 那条的 Bearer GET、超时、401/403 清缓存、429 留缓存。登录继续用现有 SuperGrok token,映射成 `{ usedPercent, resetsAt }` 塞进现成 xAI chip 位。

### 已考虑的替代方案 / Alternatives considered

- 继续只显示 `x-ratelimit-*`:解决不了「这期还剩多少」
- 让用户自己去 grok.com 看:能用,但和 Claude / ChatGPT 在 Cindy 里直接看用量不一致
- 把 Claude 订阅用量的 URL 换成 Grok:形状对不上(Claude 写死 5h / 周 / 分模型;Grok 是一个共享池)
- 复用 ChatGPT / Codex 的**取数**管道:那是事件推送,不是 Cindy 自己 GET,换不了接口;只复用它的 chip 展示形态
- 第三方 CLI(如 tokscale / quota-axi):能查,但不该变成 Cindy 的运行时依赖;Cindy 自己已经有 SuperGrok 登录

Contributor guide

Open the contributing guide

Research direction

Locate the existing xAI status-bar chip and the usesCodexQuotaForm path, then compare the Claude Bearer GET and its 401/403/429 handling. Verify the existing SuperGrok session against the billing endpoint, preserve cached data when appropriate, and confirm the chip shows used and remaining percentages, a dynamic weekly or monthly window, and reset time without treating missing fields as zero.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, desktop
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.