feat(tui): rebuild overview snapshot as donut-chart sections - #178
Conversation
Replace the text-only Overview snapshot panel with three sections split by vertical dividers: metrics (now with dashed separators and an Active Days row), a Tokens donut with legend, and a Sources donut with legend. - Add a DonutChart widget: braille dot-matrix ring, segments laid out clockwise from 12 o'clock, center text, and a minimum visible arc so tiny non-zero segments stay visible (legends keep exact values) - Progressive width tiers: >=110 cols show all sections, >=80 drops the Sources section, >=40 keeps metrics only, below falls back to stacked text - Cache Read/Clean segments follow theme.accent; Cache Write and Partial use fixed LightBlue/LightMagenta so arcs never merge with cyan-ish theme accents - Data pipeline, the Tokens-per-Day chart above, and the footer are unchanged
|
Warning Review limit reached
Next review available in: 44 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the 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 configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughChanges概览甜甜圈图
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant Snapshot
participant DonutChart
participant Buffer
Snapshot->>Snapshot: 根据可用宽度选择布局
Snapshot->>DonutChart: 创建 Tokens 或 Sources 图表
DonutChart->>Buffer: 绘制 Braille 环与中心文本
Snapshot->>Buffer: 绘制指标、图例和分隔线
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 03b3e1d5ea
ℹ️ 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".
There was a problem hiding this comment.
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/src/tui/ui/overview_snapshot.rs`:
- Around line 443-452: Update source_buckets so the donut chart contains only
source-level counts: Clean, Degraded, Partial, and Failed. Remove
rejected_records from the returned segments and adjust the array size and any
dependent rendering code accordingly; display rejected records separately if the
existing UI requires them.
🪄 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
Run ID: 5d8763e9-aad5-4265-90ec-9d3057c88649
📒 Files selected for processing (3)
crates/tokscale-cli/src/tui/ui/donut.rscrates/tokscale-cli/src/tui/ui/mod.rscrates/tokscale-cli/src/tui/ui/overview_snapshot.rs
Rejected counts individual parser records rather than sources, so its ring share contradicted the source-state health percentage shown in the center (e.g. 9 clean + 1 degraded + 10 rejected rendered a ~45%-clean ring under a 90% label). The donut now uses only the four source-state counts, matching the center percentage; the exact rejected count stays in the legend below.
What
Rebuilds the Overview tab's Snapshot panel as three sections with donut charts, replacing the previous text-only layout:
Active Daysrow (days with >0 tokens, matching the footer's day count)Sections are split by vertical dividers with uniform 1-cell padding on both sides.
How
DonutChartwidget (crates/tokscale-cli/src/tui/ui/donut.rs): braille dot-matrix ring (2x4 dots per cell, true circle in dot space), segments laid out clockwise from 12 o'clock, center text on a cleared background, and anempty_colorring when all weights are zero.theme.accent. Cache Write (LightBlue) and Partial (LightMagenta) use fixed colors because most themes setaccentto cyan or near-cyan, which previously made those arcs and legend markers indistinguishable. Segment colors are shared between donut and legend via singletoken_buckets/source_bucketsdefinitions.Out of scope (unchanged): the data pipeline, the Tokens-per-Day chart above the panel, and the footer.
Verification
cargo test -p tokscale-cli— 845 tests pass, including 15 newDonutCharttests and 15 rewritten panel tests (tiers, dividers, separators, overflow policy, segment colors, tiny-arc visibility, all-clean ring stays single-colored)cargo clippy,cargo fmt— cleanSummary by CodeRabbit