feat: 用量数据缺少展示入口,且看不到 Cindy 之外的订阅消耗
- Dominant language
- TypeScript
- Stars
- 2.7k
- Forks
- 395
- Avg merge
- 21h 48m
- Merged PRs (30d)
- 776
Description
### 使用场景 / Use case
(先交代背景,避免重复讨论:此前在 X 上跟你聊到这块时,你提到「如果是 Cindy 里的确实更适合先只取 Cindy 的数据」「UI 层的话,也会不止一个地方需要」「包括用户自己的详细历史耗量等等,现在也缺少这方面的数据展示,未来都需要补上的」。这个 issue 就是顺着这个方向,把我读代码后看到的具体情况和几个需要定夺的问题列出来。)
用户想回答两类问题,目前在 Cindy 里都没有地方看:
**一、这段时间以来,我在 Cindy 里用了多少**
- 这周/这个月各个模型分别花了多少、用了多少 token
- 缓存命中率随时间的变化(单轮命中率能在会话 chip 的悬浮卡里看到,但没有历史视角)
- 订阅额度消耗和 API 实际计费各占多少
- 哪些天用得特别多
目前唯一的用量入口是会话右下角的 `TodaySpendChip` 及其悬浮卡,它回答的是「当前这一轮 / 这个任务」,回答不了「这段时间以来」。
**二、我这个订阅账号总共用掉了多少(含没通过 Cindy 用掉的部分)**
同一个 Claude / ChatGPT 订阅,用户往往既在 Cindy 里用,也会直接用 Claude Code、Codex 等 CLI。想知道额度到底被什么消耗掉了的时候,目前只能在 Cindy 里看到其中一部分。
### 当前问题 / Current limitation
#### 1. 用量聚合与组件都已存在,只是没有接上入口
以下都可以自行核对(`main @ a034e93a`):
**数据层是完整的**
- `apps/desktop/src/main/usage/usageHistory.ts` 已聚合出:日总额(20 周窗口)、近 30 天按 `(agentKind, model)` 拆分(含 input / output / cacheRead / cacheCreate 四分项,以及 API 实报金额、订阅 token 价值估算、可比金额三种口径)、每日 × 模型明细、streak、异常检测
- IPC 通道 `maker:usage:history` 已注册(`maker-ipc/channels.ts` → `usageHandlers.ts` → `preload.ts` 全通)
- renderer 侧 `hooks/useUsageHistory.ts` 已实现
**渲染组件也是完整的**
- `components/new-chat/HomeUsageDashboard.tsx`:统计条 + 热力图 + 每日堆叠柱状图 + token 分布
- `components/new-chat/UsageHeatmap.tsx`、`UsageDailyBars.tsx`、`usagePalette.ts`
**断在挂载这一环**
- `HomeUsageDashboard` 在生产代码里没有任何 JSX 挂载点,只被 3 个测试文件 import
- 它的显示开关 `hooks/useHomeUsageDashboardPreference.ts` 没有任何调用方
- `renderer/__tests__/newMakerCreateAgentVisualContract.test.ts` 有一条断言:
`expect(source).not.toContain('
Contributor guide
Research direction
Start with apps/desktop/src/main/usage/usageHistory.ts, hooks/useUsageHistory.ts, and components/new-chat/HomeUsageDashboard.tsx, then inspect the preference hook and the not-to-contain contract in renderer/__tests__/newMakerCreateAgentVisualContract.test.ts. The first step is to resolve the dashboard entry point and whether that contract is intentional. The CLI-import portion requires separate decisions and investigation of ~/.codex and ~/.claude formats, cross-platform behavior, deduplication, and performance before it has a defined done condition.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- electron, typescript
- Domain
- analytics, desktop, frontend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 42/100