Skip to content

Add a clock and usage screen saver with token activity and storage - #2

Closed
dan-zong-hao wants to merge 5 commits into
Cheney-0821:mainfrom
dan-zong-hao:feature/fullscreen-screen-saver
Closed

dan-zong-hao wants to merge 5 commits into
Cheney-0821:mainfrom
dan-zong-hao:feature/fullscreen-screen-saver

Conversation

@dan-zong-hao

@dan-zong-hao dan-zong-hao commented Dec 2, 2026 •

Copy link
Copy Markdown

概要

这个 PR 为 Curtain 增加「时钟与用量」屏保、Codex 和 Claude Code 的用量统计,以及屏保详情面板里的「本机存储」标签。改动按功能拆成 5 个提交,可以逐个审阅,也可以只合并其中一部分。

测试安装包(0.4.5-beta.4,自带 .NET 10):https://github.com/dan-zong-hao/Curtain/releases/tag/v0.4.5-beta.4

效果图(示例数据)

屏保主界面:时钟、额度卡片和 Token 活动

详情面板:Codex Token 活动的 3D 视图

详情面板的「本机存储」标签:左为 Codex,右为 Claude Code

提交说明

1. Keep the .NET SDK, NuGet caches and temp files under .local

  • 新增 scripts/With-BuildEnvironment.ps1:项目里有 .local/dotnet 时,把 SDK、NuGet 缓存、CLI 目录和临时目录都指向 .local;没有时照常使用系统 SDK。
  • scripts/verify.ps1、run-app.ps1、B3-Pack.ps1 改为通过它运行;.gitignore 忽略 /.local/。

2. Add a clock and usage screen saver

  • 全屏保护样式新增「时钟与用量」,可立即显示,也可按每周计划定时开启(「常规 → 屏保」)。
  • 屏保内容:时钟、本机今日输出、每个 5 小时 / 7 天额度一张卡片;「Token 活动」可在 Codex(账号历史)和 Claude Code(本机日志)之间切换,含 52 周热力图;详情面板有 26 周平面 / 3D 视图、最忙一天、每周节律和每周趋势。
  • 额度结果保存在 %LOCALAPPDATA%\Curtain\quota-cache.json,打开屏保立即显示上次结果,后台刷新;首次查询时用占位卡片,避免卡片跳动。查询 Claude Code 时设置 DISABLE_AUTOUPDATER,查询本身不会触发 Claude Code 更新,也快 2~3 秒。
  • Claude Code 每日统计读取本机会话日志,按消息 ID 跨文件去重;缓存只保存哈希、偏移和每日合计,Claude Code 清理旧日志后已统计的日子仍保留。
  • 主要文件:src/Curtain.App/Windows/ScreenSaverWindow.*、src/Curtain.App/Controls/*、src/Curtain.App/Services/ClientQuotaReader.cs、src/Curtain.App/MainWindow.ScreenSaver.cs、src/Curtain.Core/Rendering/*、src/Curtain.Core/Settings/ScreenSaverSchedule.cs、CurtainUserSettings.cs、ScreenPrivacyManager.cs、ScreenPrivacyWindow.cs。

3. Add a storage tab to the screen saver's detail pane

  • 点击「查看活动详情」打开的右侧面板分为「Token 活动」和「本机存储」两个标签,面板内也有 Codex | Claude Code 切换。两个标签共用同一块区域,切换时面板缩放比例不变,选中的标签淡入。
  • 「本机存储」显示总占用、聊天记录占比和月份数或项目数;按类别(聊天记录、工作树或文件快照、可视化内容、插件与技能、其他)显示的占用条;以及 Codex 按月份、Claude Code 按项目的聊天记录明细。Codex 的分类与 Codex 应用自带的存储页一致。Claude Code 项目名取自会话日志里记录的工作目录(cwd),中文目录名也能正常显示。
  • 面板打开期间在后台统计,最多每十分钟一次,也可点「刷新」;多个显示器共用一次统计。
  • 只读取文件大小和会话日志开头几行,不修改或删除任何文件;不跟随链接,避免重复统计。
  • 文件:src/Curtain.App/Windows/ScreenSaverWindow.Storage.cs(新增)、ScreenSaverWindow.xaml、.Activity.cs、.xaml.cs,src/Curtain.Core/Storage/ClientStorage.cs(新增),tests/Curtain.Core.Tests/StorageTests.cs(新增)。

4. Register local test builds 0.4.5-beta.1 to 0.4.5-beta.4

  • release/diagnostic-version-map.json 增加 0.4.5-beta.1~4,用于 fork 上的测试安装包。如果与上游版本规划冲突,可以直接丢弃这个提交。

5. Add detail pane and storage screenshots

  • 新增 assets/screen-saver-details.zh-CN.png 和 assets/screen-saver-storage.zh-CN.png,README.zh-CN.md 中显示,README.md 中给出链接。截图使用示例数据和示例客户端文件夹,不含真实路径、项目名或用量。

兼容性与隐私

  • 没有写死任何用户路径:客户端目录取自 CLAUDE_CONFIG_DIR / CODEX_HOME,未设置时使用当前用户目录下的 .claude / .codex。
  • 额度通过本机已登录的客户端查询,不读取凭据文件。本地缓存只保存百分比、重置时间、哈希和每日合计,不含路径、消息 ID 或对话内容,也不会进入诊断包。
  • 默认保护样式仍是毛玻璃,已有设置不受影响。

测试

  • scripts/verify.ps1 通过:263 项核心断言(新增屏保计划、额度解析与缓存、Claude 日志统计、存储统计和项目目录读取等用例)、15 项输入断言、Debug / Release 构建。
  • 在隐藏桌面上用真实的 Claude Code(Max)和 Codex(Pro)客户端验证了屏保、额度缓存与占位卡片、Claude 每日统计,以及详情面板两个标签在 Codex 和 Claude Code 下的显示;安装包在去掉所有 .NET 路径的环境下可以启动。

English summary. Adds a clock and usage screen saver (quota cards, today's output, Codex and Claude Code token activity with a 3D detail view, weekly schedules), a cached quota display so cards appear at once, local Claude Code daily statistics, and a Storage tab in the detail pane for the Codex and Claude Code data folders. Five commits, split by feature; the fourth only registers the fork's test versions and can be dropped, and the fifth adds screenshots. scripts/verify.ps1 passes (263 core and 15 input assertions).

🤖 Generated with Claude Code

dan-zong-hao and others added 5 commits December 2, 2026 16:05
- scripts/With-BuildEnvironment.ps1 (new): runs a command with DOTNET_ROOT, the
  NuGet folders, the .NET CLI home and TEMP pointed at the repository's .local
  folder when .local/dotnet/dotnet.exe exists. Without it, the machine SDK is used.
- scripts/verify.ps1, scripts/run-app.ps1, scripts/B3-Pack.ps1: run through it.
- .gitignore: ignore /.local/.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Full-screen protection can show a dashboard instead of frosted glass, on demand
or on a weekly schedule.

Screen saver (src/Curtain.App/Windows/ScreenSaverWindow.xaml, .xaml.cs, .Activity.cs;
src/Curtain.App/Controls/TokenActivityChart.cs, ActivitySummaryCharts.cs, FigureText.cs)
- Card layout: clock, today's local output, one card per reported 5-hour or
  7-day quota with percentage, bar and reset time.
- Token activity with a Codex | Claude Code switch: lifetime figures, streaks
  and a 52-week dot calendar.
- Detail pane: 26 weeks as a grid or as 3D columns that rise week by week,
  busiest day, weekday rhythm and weekly totals.
- The last quota reading is kept in %LOCALAPPDATA%\Curtain\quota-cache.json and
  shown at once; a client that has not answered yet keeps a placeholder card,
  and new cards fade in instead of shifting the row.

Data (src/Curtain.Core/Rendering/, src/Curtain.App/Services/ClientQuotaReader.cs)
- PlanQuota, ClientQuotaReader: quota from the signed-in Claude Code and Codex
  clients. Claude Code runs with DISABLE_AUTOUPDATER so a query never updates it.
- CodexActivity: Codex account usage history.
- ClaudeTokenHistory: daily Claude Code output tokens from local session logs.
  Replies count once across resumed sessions; the cache keeps only hashes,
  offsets and daily sums, so days survive Claude Code's log cleanup.
- LocalTokenUsage: today's output tokens for both clients.
- ActivityWindow, DailySummary, TokenFormat, QuotaCache.

Settings (src/Curtain.Core/Settings/, src/Curtain.App/MainWindow.ScreenSaver.cs,
MainWindow.xaml, MainWindow.xaml.cs, Services/ScreenPrivacyManager.cs,
Windows/ScreenPrivacyWindow.cs)
- Protection style (frosted glass or clock and usage), optional display name
  and weekly schedules. Client folders come from CLAUDE_CONFIG_DIR and
  CODEX_HOME, or the defaults in the current user's profile.

Tests: tests/Curtain.Core.Tests/ScreenSaverTests.cs. Docs: README sections and
screenshots (sample data).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The pane that opens from "Explore activity" now has two tabs, Token activity
and Storage, and its own Codex | Claude Code switch. Both tabs share one cell,
so switching keeps the pane at the same scale; the chosen tab fades in.

- src/Curtain.App/Windows/ScreenSaverWindow.Storage.cs (new): the Storage tab.
  Total, chat storage and month or project count; a bar by category (chats,
  worktrees or file snapshots, visualizations, plugins and skills, other) that
  grows in on a new reading; chat storage by month for Codex or by project for
  Claude Code, largest first. Sizes are measured in the background while the
  pane is open, at most every ten minutes or on Refresh, shared by all displays.
- ScreenSaverWindow.xaml, .Activity.cs: tab and source switches in the pane.
  The pane can open without activity data and says so in the activity tab.
- ScreenSaverWindow.xaml.cs: ClientRoot resolves CODEX_HOME and
  CLAUDE_CONFIG_DIR, or .codex and .claude in the current user's profile.
- src/Curtain.Core/Storage/ClientStorage.cs (new): measures a data folder by
  top-level rules without following links. Codex categories match the Codex
  app's own storage page. ProjectDirectory reads the working directory a Claude
  Code project's session log records, so projects show readable folder names.
- Strings (en-US, zh-CN), README, tests/Curtain.Core.Tests/StorageTests.cs.

Only file sizes and the first lines of session logs are read. Nothing is
changed or deleted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
B3-Pack requires a FileVersion mapping for every packaged version. These
builds were published on the fork for testing. Drop this commit if the
upstream release numbering differs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- assets/screen-saver-details.zh-CN.png: the detail pane with Codex token
  activity in 3D.
- assets/screen-saver-storage.zh-CN.png: the Storage tab for Codex and
  Claude Code side by side.
- README.zh-CN.md shows both; README.md links to them.

Both use sample data and sample client folders, so no real paths, project
names or usage appear.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dan-zong-hao

Copy link
Copy Markdown
Author

补充效果图(均为示例数据,不含真实路径、项目名或用量)。图片也已提交到分支的 assets/,并在 README.zh-CN.md 中显示,见新提交 a544695。PR 说明顶部也加上了这几张图。

屏保主界面:时钟、额度卡片和 Token 活动

详情面板:Codex Token 活动的 3D 视图

详情面板的「本机存储」标签:左为 Codex,右为 Claude Code

Copy link
Copy Markdown
Owner

感谢你花时间为 Curtain 实现这些功能,也谢谢你提供了详细的说明和演示。

Curtain 专注于 Windows 的窗口和桌面隐私保护。时钟屏保、AI 用量统计和存储面板超出了项目的功能范围,因此我们会关闭这条 PR。

@Cheney-0821 Cheney-0821 closed this Dec 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants