#7467·cc-switch

[Feature] Cross-platform Usage HUD for at-a-glance token monitoring / 新增能够监控 token 用量的小浮窗

Author: RocioGinsbergCreated Sep 17, 2026Updated Sep 17, 2026
Labelsenhancement

Self Checks / 自检

Related App / 涉及应用

General / 通用

Problem or Motivation / 问题或动机

  • CC Switch already provides a comprehensive Usage dashboard, but checking today’s token usage, estimated cost, and request count requires opening the main window and navigating to Settings → Usage. CC Switch 已有完整的 Usage 统计页面,但查看今日 Token 用量、预估费用和请求数,仍需要打开主窗口并进入“设置 → Usage”。

  • For users who work with coding agents for extended periods, it would be useful to monitor these key metrics at a glance without interrupting the current workflow. A compact, optional desktop surface could improve usage visibility while preserving the existing full dashboard for detailed analysis. 对于长时间使用 Agent 的用户,如果能在不打断当前工作流的前提下快速查看这些核心指标,会更方便。一个紧凑、可选开启的小面板,可以提升用量可见性,同时更方便路由到现有完整 Dashboard 查看详细分析数据。

  • A related request, #5455, proposes a native macOS widget for the same at-a-glance monitoring need. This proposal focuses instead on a cross-platform solution that can be available to macOS, Windows, and Linux users. 相关 Issue #5455 提出了原生 macOS Widget,以满足相同的快速用量查看需求。本提案则聚焦跨平台方案,使 macOS、Windows 和 Linux 用户都能使用。

  • #7431 also mentioned this demand, and this proposal provides an executive solution.

#7431 也提到了类似需求,本提案给出了可执行方案。

Proposed Solution / 建议方案

Add an optional cross-platform “Usage HUD”: a compact floating window that acts as a lightweight view of the existing Usage Dashboard. 新增一个默认关闭的跨平台“Usage HUD”悬浮面板,作为现有 Usage Dashboard 的轻量展示层。

Image

Concept mockup only. The HUD is disabled by default and can be shown or hidden from the Usage page or tray menu; exact visual design and interaction details remain open for discussion.

上图仅为概念原型。HUD 默认关闭,可从 「使用统计」 页面或托盘菜单显示/隐藏;具体视觉与交互细节仍可讨论。

It reuses the current Usage data flow and avoids introducing platform-specific extension, signing, sandbox, or packaging requirements in the first iteration.
该方案使限定在现有 Tauri 应用内部实现,复用当前 Usage 数据流,避免 #5455 方案中引入操作系统平台专属扩展、签名、沙盒或打包要求的风险。

To keep the change focused and easy to evaluate, the initial scope would be limited to: 为保持改动聚焦、便于评估,第一版范围限定为:

  • A separate Tauri window that is frameless, draggable, and can stay on top. 独立的 Tauri 小窗口:无边框、可拖动、可置顶。
  • Display today’s real total tokens, estimated cost, request count, and optionally the top model. 展示今日真实消耗 Token、预估费用、请求数,以及可选的 Top 模型。
  • Open or hide it from the tray menu and the existing Usage page. 通过托盘菜单和现有 Usage 页面显示或隐藏。
  • Keep it disabled by default, persist the user’s visibility preference and window position. 默认关闭,并保存用户的显示偏好及窗口位置。
  • Reuse existing Usage commands, query models, and the usage-log-recorded event for refreshes. 复用既有 Usage commands、查询模型和 usage-log-recorded 事件完成刷新。
  • Reuse existing accounting rules, data-source deduplication, and pricing logic. 复用现有统计口径、数据源去重与定价逻辑。
  • Do not add a data source, modify the database schema, or query the database directly from the HUD. 不新增数据源、不修改数据库 schema,也不由 HUD 直接查询数据库。
  • no new charts, filters, or system-native widget extensions. 不新增图表、筛选器或系统原生桌面组件扩展。

Additional Context / 补充信息

  • Related: #5455 proposes a future native macOS WidgetKit implementation. 相关 Issue:#5455 提出了未来实现原生 macOS WidgetKit 组件的需求。

  • This HUD is intended as a complementary, lower-maintenance cross-platform solution rather than a replacement for a possible native macOS widget. It addresses the shared “at-a-glance token monitoring” use case first, while leaving platform-specific desktop integrations for future discussion. HUD 旨在作为一个更易维护的跨平台补充方案,而非替代未来可能的 macOS 原生组件。它优先解决“快速观察 Token 用量”的共同需求;各平台原生桌面组件的接入可在后续再讨论。

  • The repository already has the main building blocks for a focused implementation: 仓库中已具备实现小型、聚焦 PR 的主要基础:

  • Existing Usage summary and model-statistics commands; 已有 Usage 汇总与模型统计 commands;
  • Existing React Query hooks for the Usage dashboard; 已有 Usage Dashboard 使用的 React Query hooks;
  • The debounced usage-log-recorded event for near-real-time refreshes; 已有经过防抖的 usage-log-recorded 事件,可用于近实时刷新;
  • Existing Tauri tray and window-management code. 已有 Tauri 托盘及窗口管理代码。

I’m interested in contributing a small, focused PR if maintainers agree that this direction fits the project. 如果维护者认为这个方向符合项目规划,我愿意提交一个小而聚焦的 PR。

Contribution / 参与贡献

  • I am interested in contributing to this feature. 我有兴趣参与开发此功能。