makecindy / makecindy/cindy

feat(desktop): GLM Coding Plan 状态栏看不到订阅用量,只显示价值估算或「无订阅额度明细」

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

Description

### 使用场景 / Use case

用智谱 GLM Coding Plan(国内 `open.bigmodel.cn` / 海外 `z.ai` 的编码订阅套餐)在 Cindy 里跑 Claude Code / Codex 时,希望和 Claude / ChatGPT 订阅一样,在底部消费提示看到**本期额度用了多少、还剩多少、什么时候重置**。

现在要看这些数字,只能离开 Cindy,去 open.bigmodel.cn 控制台的「用量统计」页。

GLM Coding Plan 的额度是**多窗口**机制:官方 FAQ 写明「每 5 小时限额 + 每周限额」,且模型与 MCP 工具共享套餐额度。

### 当前问题 / Current limitation

Cindy 已能通过远端 catalog 预设配置 GLM Coding Plan(#1164 处理过 cindy.cn 发布包预设缺失的问题),请求走 `open.bigmodel.cn/api/anthropic`(Claude Code)或 `/api/coding/paas/v4`(其他工具)正常出活。

但状态栏的配额分支只认三种:`usesCodexQuotaForm`(Codex OAuth / ChatGPT bridge)、`isClaudeSubscription`、xAI 的 `x-ratelimit-*`。GLM Coding Plan 三者都不命中,两边的配额窗都拿不到,chip 走通用兜底路径:只显示价值估算 + token 累计,标注「无订阅额度明细」。

仓库里没有请求智谱用量接口的代码(`main @ 0857cb73c` 全仓搜 `monitor/usage` / `quota/limit` 零命中)。

### 期望方案 / Proposed solution

已配置 GLM Coding Plan 供应商时,用它的 API key 拉订阅用量,塞进状态栏现有位置:

- **展示**:5 小时窗 + 周期窗的**双窗形状和 Claude 订阅最接近**,可借它的双窗形态;但窗口标签按服务端返回动态命名,不写死时长(窗口口径以服务端返回为准,避免智谱调整周期时展示失真)。MCP 月度是产品分项,单独一窗,不与 token 池相加。
- **拉取**:新写薄 GET(Claude 订阅那条的请求 / 超时 / 401/403 清缓存 / 429 留缓存模式可以直接搬)。端点与认证有官方参照——智谱官方 Claude Code 插件 `glm-plan-usage`([zai-org/zai-coding-plugins](https://github.com/zai-org/zai-coding-plugins))的 `query-usage.mjs`:

```
GET {base}/api/monitor/usage/quota/limit ← 无参,额度上限(第一版只需要这条)
GET {base}/api/monitor/usage/model-usage?... ← 模型用量明细(可选,后续悬浮卡)
GET {base}/api/monitor/usage/tool-usage?... ← MCP 工具用量明细(可选)
```

- `{base}` 按供应商 Base URL 的域名推导:`open.bigmodel.cn`(含 dev.)/ `api.z.ai`
- 认证:`Authorization` 头直接传 API key 原文(无 `Bearer` 前缀,官方插件实测口径)
- `quota/limit` 返回 `limits[]`:`TOKENS_LIMIT`(5 小时窗,`percentage`)+ `TIME_LIMIT`(MCP 月度,`percentage` / `currentValue` / `usage` / `usageDetails`)
- **风险如实说**:`/api/monitor/` 未列入智谱正式 API 文档,是官方插件在用的事实接口,可能变动——按内部接口做兼容(401/403/429、字段缺失不硬报 0)。官方插件口径仅支持**个人版套餐**,团队版返回什么未验证。
- 凭据:API key 只发给 bigmodel.cn / z.ai 第一方,不经第三方中转。

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

- 只显示价值估算(现状):回答不了「这个 5 小时窗还剩多少」
- 让用户去 open.bigmodel.cn「用量统计」看:能用,但和 Claude / ChatGPT 在 Cindy 里直接看不一致
- 让用户在 Claude Code 里装官方 `glm-plan-usage` 插件:那是 Claude Code 插件生态的方案;Cindy 用户用的是 Cindy 自己的状态栏,且 Cindy 已持有该供应商的 API key,不需要用户额外装东西
- 并进 #2633(SuperGrok 用量)一起做:两边认证模型(OAuth session vs 静态 API key)、窗口形状(单周共享池 vs 5h + 月度双窗)都不同,分开实现更清晰;#119 的统一额度视图是聚合层的事,各自 reader 先行不冲突
- 用第三方监控工具(cc-switch / GCMP 等):能查,但不该变成 Cindy 的运行时依赖

Contributor guide

Open the contributing guide

Research direction

Trace the existing Claude subscription quota reader and status-bar chip path, then compare its request, timeout, authentication-error, and rate-limit handling with the proposed quota/limit endpoint. Verify the supported Base URL domains and response fields, and make the chip render dynamically named 5-hour, weekly, and MCP windows without treating missing data as zero.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.