fix(usage): separate subscription refresh from local refresh
Merged
MA
5mo ago+1708+1708+0123456789012345678901234567890123456789-590-590-012345678901234567890123456789
What changed
- Added explicit TUI subscription provider selection via
usageProviders. - Kept an empty
usageProviderslist as cache-display mode: the Usage tab may show cached data, but it will not send remote subscription requests. - Kept global
rscoped to local report refreshes; subscription refresh isuin the Usage tab only. - Stopped subscription auto-polling; each TUI session may fetch once on first Usage-tab entry when enabled providers are configured.
- Made explicit TUI provider selections report missing credentials instead of silently collapsing into "no data".
- Removed the generic MiniMax usage provider; MiniMax subscription usage is only
minimax-token-plan-cnorminimax-token-plan-global. - Added Kimi Code API key support via
TOKSCALE_USAGE_KIMI_CODING_PLAN_API_KEY, while retaining Kimi Code OAuth credentials. - Updated the Usage footer/status text so Usage no longer reuses local-report refresh time.
- Updated README variants and added ADR 0014 for the local-report vs remote-subscription boundary.
Provider credential policy
Purpose-specific subscription credentials only:
- Z.ai/Zhipu GLM Coding Plan:
TOKSCALE_USAGE_ZAI_CODING_PLAN_API_KEY - Kimi Code:
TOKSCALE_USAGE_KIMI_CODING_PLAN_API_KEYor Kimi Code OAuth credentials - MiniMax CN Token Plan:
TOKSCALE_USAGE_MINIMAX_TOKEN_PLAN_CN_KEY - MiniMax Global Token Plan:
TOKSCALE_USAGE_MINIMAX_TOKEN_PLAN_GLOBAL_KEY
General provider API keys such as ZAI_API_KEY, GLM_API_KEY, KIMI_API_KEY, MINIMAX_API_KEY, and MINIMAX_API_TOKEN are intentionally ignored for subscription quota lookups.
Validation
cargo fmt --all -- --checkcargo test -p tokscale-cli usage -- --nocapturecargo test -p tokscale-cli footer -- --nocapturecargo test -p tokscale-cli app::tests::test_usage -- --nocapturecargo test -p tokscale-clicargo test
Closes #80
Summary by CodeRabbit
-
新功能
- 新增订阅使用量(Usage)相关说明与配置选项,支持启用 Usage 标签并选择可用提供方。
- 补充 TUI 快捷键说明,明确
u、r、R在 Usage 与本地报告中的不同刷新行为。
-
文档
- 更新多语言 README,完善订阅额度、支持的 provider、环境变量与示例配置说明。
- 新增一份 ADR,说明订阅使用量远程请求的边界与使用规则。