Skip to content
This repository was archived by the owner on Jul 30, 2026. It is now read-only.

feat(tui): unify visual semantics and interface state - #193

Merged
makoMakoGo merged 11 commits into
personal/local-clientsfrom
codex/tui-theme-and-state-fixes
Jul 25, 2026
Merged

feat(tui): unify visual semantics and interface state#193
makoMakoGo merged 11 commits into
personal/local-clientsfrom
codex/tui-theme-and-state-fixes

Conversation

@makoMakoGo

@makoMakoGo makoMakoGo commented Jul 24, 2026

Copy link
Copy Markdown
Owner

Summary

  • derive discrete contribution grades from token activity inside the visible 52-week window, keep empty days structurally distinct from missing cells, and encode every grade with both theme color and glyph density
  • make all 12 configured palettes complete RGB semantic themes, replace ambiguous muted/disabled text with readable primary/secondary roles, and enforce the actual role-to-surface contrast matrix
  • resolve model-family and client-catalog identity colors once when a theme is constructed, then use consistent O(1) lookups across Overview, tables, portraits, and Day Insights
  • keep cold-start scan progress in the footer while data acquisition runs
  • isolate subscription-usage state and actions from local report generation, with the state boundary recorded in the existing ADRs

Theme contract

  • preserve the existing colorPalette key and its 12 accepted values
  • remove terminal-capability detection and ANSI palette fallbacks
  • reserve Empty for zero-token contribution days and reject contradictory cached grades
  • document the RGB-only semantic theme and contribution-grade contracts in ADRs 0010 and 0029

Validation

  • cargo test — 2090 passed, 5 ignored
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo build -p tokscale-cli
  • bun run build:core
  • cargo fmt --all -- --check
  • git diff --check

Summary by CodeRabbit

  • 新功能
    • Usage 订阅用量视图拥有独立的提示/空/结果/刷新状态与页脚摘要;本地刷新/导出等交互在 Usage 期间进一步受限。
    • CLI 主题参数新增帮助说明。
  • 改进
    • 全面升级 TUI 语义主题体系,统一面板/文本/指标/状态/可视化配色,并进行 WCAG 对比度适配。
    • 贡献图活动强度改为基于可见窗口 Token 的分级(grade)。
    • 状态消息引入语气(Info/Success/Warning/Danger),并显示后台/订阅抓取耗时反馈。
  • 问题修复
    • 缓存格式升级后按 miss 重建;订阅与本地的状态/快捷键/提示更清晰隔离(如移除 Jump Today)。

Derive contribution grades from visible-window token activity with Log-MAD, restore brighter high-activity ramps, and route client labels through the catalog-backed contrast-aware resolver.
Define all 12 palettes as RGB semantic themes, route interface chrome and state through theme roles, and adapt identity colors to their rendered surfaces. Remove terminal-capability color fallbacks and document the RGB-only theme contract.
@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@makoMakoGo, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 7 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 944c3cc4-ca85-4669-a2cc-6d2e73a357f8

📥 Commits

Reviewing files that changed from the base of the PR and between bde99b0 and 6b95b89.

📒 Files selected for processing (6)
  • crates/tokscale-cli/src/tui/ui/footer.rs
  • crates/tokscale-cli/src/tui/ui/loading.rs
  • crates/tokscale-cli/src/tui/ui/mod.rs
  • crates/tokscale-cli/src/tui/ui/overview_snapshot.rs
  • crates/tokscale-cli/src/tui/ui/view_footer.rs
  • docs/adr/0010-period-views-derive-from-daily.md

Walkthrough

该 PR 将 TUI 迁移到语义化主题,新增 WCAG 对比度与身份色处理;Usage 获得独立的订阅状态、动作、页脚和刷新生命周期;贡献图从浮点强度改为基于可见 token 的离散等级并更新缓存格式。

Changes

订阅 Usage 生命周期

Layer / File(s) Summary
订阅状态、动作与计时
crates/tokscale-cli/src/tui/{presentation.rs,actions.rs,app.rs}
Usage 根据独立订阅状态生成呈现和动作,隔离本地刷新控制,并追踪订阅抓取时间与状态 tone。
订阅内容与响应式页脚
crates/tokscale-cli/src/tui/ui/{usage.rs,footer.rs,view_footer.rs,mod.rs,loading.rs}
Usage 内容、帮助、摘要、状态行及加载/失败页面按订阅状态渲染,并支持窄屏截断。

语义主题

Layer / File(s) Summary
主题契约与对比度
crates/tokscale-cli/src/tui/{themes.rs,colors.rs,contrast.rs,model_family.rs}
Theme 聚合 surfaces、text、chrome、selection、metrics、status 和 visualization 调色板;身份色与贡献色执行对比度约束。
渲染器迁移
crates/tokscale-cli/src/tui/ui/*
表格、图表、对话框、统计、快照、页眉、画像和空状态改用语义主题字段及统一选中样式。

贡献图等级与缓存

Layer / File(s) Summary
Token-based contribution grades
crates/tokscale-core/src/{usage_views.rs,aggregate/tui.rs}, crates/tokscale-cli/src/tui/cache.rs
贡献等级使用可见 token 的对数 median/MAD 计算,缓存保存 grade 并校验其与 token 数的一致性。

CLI 与文档契约

Layer / File(s) Summary
CLI 与配置验证
crates/tokscale-cli/src/{cli.rs,tui/settings.rs}, crates/tokscale-cli/tests/cli_tests.rs
主题参数增加帮助文本,并补充 legacy 主题读写及未知主题校验测试。
架构文档
docs/adr/*.md, docs/configuration.md
文档描述订阅 Usage 边界、贡献等级算法、语义主题契约及 colorPalette 覆盖范围。

Estimated code review effort: 5 (Critical) | ~120 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant App
  participant SubscriptionPresentation
  participant ActionSet
  participant UsageView
  participant Footer
  User->>App: open Usage tab
  App->>SubscriptionPresentation: classify subscription state
  SubscriptionPresentation->>ActionSet: construct scoped actions
  SubscriptionPresentation->>UsageView: select subscription content state
  SubscriptionPresentation->>Footer: select subscription summary and status
  User->>ActionSet: request subscription refresh
  ActionSet->>App: start subscription usage fetch
Loading

Possibly related PRs

Poem

小兔挥爪换新装,
语义主题亮堂堂。
Usage 状态分清楚,
Token 月影画成图。
对比度达标,胡萝卜香!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 57.98% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确概括了本次 PR 的核心:统一 TUI 的视觉语义与界面状态处理。
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/tui-theme-and-state-fixes

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3516fbd766

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/tokscale-cli/src/tui/ui/footer.rs
@codspeed-hq

codspeed-hq Bot commented Jul 24, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 37 untouched benchmarks


Comparing codex/tui-theme-and-state-fixes (6b95b89) with personal/local-clients (344f768)1

Open in CodSpeed

Footnotes

  1. No successful run was found on personal/local-clients (4224589) during the generation of this report, so 344f768 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/tokscale-cli/tests/cli_tests.rs`:
- Around line 824-851: Update both CLI integration tests, including
test_tui_accepts_all_legacy_theme_values_before_terminal_validation and the test
covering lines 853–885, to pass the global --no-spinner option when invoking
tokstake via cargo_bin_cmd!. Preserve their existing arguments and assertions;
these tests do not exercise spinner behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 70cabfe8-3384-48c2-b0c2-1a2cea344f1b

📥 Commits

Reviewing files that changed from the base of the PR and between 4224589 and 3516fbd.

📒 Files selected for processing (43)
  • crates/tokscale-cli/src/cli.rs
  • crates/tokscale-cli/src/tui/actions.rs
  • crates/tokscale-cli/src/tui/app.rs
  • crates/tokscale-cli/src/tui/cache.rs
  • crates/tokscale-cli/src/tui/colors.rs
  • crates/tokscale-cli/src/tui/contrast.rs
  • crates/tokscale-cli/src/tui/mod.rs
  • crates/tokscale-cli/src/tui/presentation.rs
  • crates/tokscale-cli/src/tui/settings.rs
  • crates/tokscale-cli/src/tui/themes.rs
  • crates/tokscale-cli/src/tui/ui/achievements.rs
  • crates/tokscale-cli/src/tui/ui/agents.rs
  • crates/tokscale-cli/src/tui/ui/bar_chart.rs
  • crates/tokscale-cli/src/tui/ui/daily.rs
  • crates/tokscale-cli/src/tui/ui/daily_profile.rs
  • crates/tokscale-cli/src/tui/ui/dialog/client_picker.rs
  • crates/tokscale-cli/src/tui/ui/dialog/group_by_picker.rs
  • crates/tokscale-cli/src/tui/ui/dialog/overlay.rs
  • crates/tokscale-cli/src/tui/ui/empty_state.rs
  • crates/tokscale-cli/src/tui/ui/footer.rs
  • crates/tokscale-cli/src/tui/ui/header.rs
  • crates/tokscale-cli/src/tui/ui/hourly.rs
  • crates/tokscale-cli/src/tui/ui/hourly_profile.rs
  • crates/tokscale-cli/src/tui/ui/loading.rs
  • crates/tokscale-cli/src/tui/ui/mod.rs
  • crates/tokscale-cli/src/tui/ui/models.rs
  • crates/tokscale-cli/src/tui/ui/overview.rs
  • crates/tokscale-cli/src/tui/ui/overview_snapshot.rs
  • crates/tokscale-cli/src/tui/ui/period.rs
  • crates/tokscale-cli/src/tui/ui/portraits.rs
  • crates/tokscale-cli/src/tui/ui/sessions.rs
  • crates/tokscale-cli/src/tui/ui/stats.rs
  • crates/tokscale-cli/src/tui/ui/usage.rs
  • crates/tokscale-cli/src/tui/ui/usage_profile.rs
  • crates/tokscale-cli/src/tui/ui/view_footer.rs
  • crates/tokscale-cli/tests/cli_tests.rs
  • crates/tokscale-core/src/aggregate/tui.rs
  • crates/tokscale-core/src/usage_views.rs
  • docs/adr/0010-period-views-derive-from-daily.md
  • docs/adr/0014-explicit-subscription-usage-boundary.md
  • docs/adr/0028-tui-client-universe-and-view-selection.md
  • docs/adr/0029-semantic-tui-theme-contract.md
  • docs/configuration.md

Comment thread crates/tokscale-cli/tests/cli_tests.rs
Represent contribution activity as discrete token-derived grades, render empty and active levels with independent glyphs, and validate cache invariants.

Replace ambiguous muted and disabled roles with readable secondary text, resolve identity palettes at theme construction, and enforce role-to-surface contrast matrices.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/adr/0010-period-views-derive-from-daily.md`:
- Around line 204-212: Update the contribution-graph activity-grade description
to define deterministic boundary ownership: after handling Empty and MAD=0
cases, map x < center − MAD to Low, center − MAD ≤ x < center to Medium, center
≤ x < center + MAD to High, and x ≥ center + MAD to Peak. Explicitly state that
the maximum active day is assigned Peak as an overriding rule, including when
threshold mapping would produce another grade.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 030b160f-ee9a-4db8-b149-a18d97732c9d

📥 Commits

Reviewing files that changed from the base of the PR and between 3516fbd and 7d6a838.

📒 Files selected for processing (34)
  • crates/tokscale-cli/src/tui/actions.rs
  • crates/tokscale-cli/src/tui/app.rs
  • crates/tokscale-cli/src/tui/cache.rs
  • crates/tokscale-cli/src/tui/colors.rs
  • crates/tokscale-cli/src/tui/contrast.rs
  • crates/tokscale-cli/src/tui/data/mod.rs
  • crates/tokscale-cli/src/tui/model_family.rs
  • crates/tokscale-cli/src/tui/themes.rs
  • crates/tokscale-cli/src/tui/ui/achievements.rs
  • crates/tokscale-cli/src/tui/ui/agents.rs
  • crates/tokscale-cli/src/tui/ui/bar_chart.rs
  • crates/tokscale-cli/src/tui/ui/daily.rs
  • crates/tokscale-cli/src/tui/ui/dialog/client_picker.rs
  • crates/tokscale-cli/src/tui/ui/dialog/group_by_picker.rs
  • crates/tokscale-cli/src/tui/ui/empty_state.rs
  • crates/tokscale-cli/src/tui/ui/footer.rs
  • crates/tokscale-cli/src/tui/ui/header.rs
  • crates/tokscale-cli/src/tui/ui/loading.rs
  • crates/tokscale-cli/src/tui/ui/mod.rs
  • crates/tokscale-cli/src/tui/ui/models.rs
  • crates/tokscale-cli/src/tui/ui/overview.rs
  • crates/tokscale-cli/src/tui/ui/overview_snapshot.rs
  • crates/tokscale-cli/src/tui/ui/period.rs
  • crates/tokscale-cli/src/tui/ui/portraits.rs
  • crates/tokscale-cli/src/tui/ui/radar.rs
  • crates/tokscale-cli/src/tui/ui/sessions.rs
  • crates/tokscale-cli/src/tui/ui/stats.rs
  • crates/tokscale-cli/src/tui/ui/usage.rs
  • crates/tokscale-cli/src/tui/ui/usage_profile.rs
  • crates/tokscale-cli/src/tui/ui/view_footer.rs
  • crates/tokscale-core/src/aggregate/tui.rs
  • crates/tokscale-core/src/usage_views.rs
  • docs/adr/0010-period-views-derive-from-daily.md
  • docs/adr/0029-semantic-tui-theme-contract.md
🚧 Files skipped from review as they are similar to previous changes (23)
  • crates/tokscale-cli/src/tui/ui/portraits.rs
  • crates/tokscale-cli/src/tui/ui/loading.rs
  • crates/tokscale-cli/src/tui/ui/overview.rs
  • crates/tokscale-cli/src/tui/ui/models.rs
  • crates/tokscale-cli/src/tui/ui/agents.rs
  • docs/adr/0029-semantic-tui-theme-contract.md
  • crates/tokscale-cli/src/tui/ui/dialog/client_picker.rs
  • crates/tokscale-cli/src/tui/actions.rs
  • crates/tokscale-cli/src/tui/ui/view_footer.rs
  • crates/tokscale-cli/src/tui/contrast.rs
  • crates/tokscale-cli/src/tui/ui/header.rs
  • crates/tokscale-cli/src/tui/ui/usage_profile.rs
  • crates/tokscale-core/src/aggregate/tui.rs
  • crates/tokscale-cli/src/tui/ui/sessions.rs
  • crates/tokscale-cli/src/tui/ui/usage.rs
  • crates/tokscale-cli/src/tui/ui/dialog/group_by_picker.rs
  • crates/tokscale-cli/src/tui/ui/daily.rs
  • crates/tokscale-cli/src/tui/ui/mod.rs
  • crates/tokscale-cli/src/tui/ui/period.rs
  • crates/tokscale-cli/src/tui/ui/overview_snapshot.rs
  • crates/tokscale-cli/src/tui/ui/footer.rs
  • crates/tokscale-cli/src/tui/app.rs
  • crates/tokscale-cli/src/tui/ui/stats.rs

Comment thread docs/adr/0010-period-views-derive-from-daily.md Outdated
@makoMakoGo
makoMakoGo merged commit 9ab8ac6 into personal/local-clients Jul 25, 2026
9 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant