fix: widen token columns and add overflow-safe formatting#124
fix: widen token columns and add overflow-safe formatting#124
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (5)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdded a TOKEN_COL_WIDTH constant and a new width-aware formatter Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~30 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
Input (8) and Output (9) columns were too narrow for large token counts. A value like 106529574 (9 digits) got its leading digit clipped in the 8-wide Input column, displaying as 06529574. - Unify all token columns (Cached, Input, Output, Reasoning) to width 12 via TOKEN_COL_WIDTH constant, in both daily and session views - Add format_number_fit() that cascades through progressively compact formats (user pref → human-readable → fewer decimals → plain digits) so significant digits are never silently clipped - Separator rows now use the constant for consistency - Fix clippy::collapsible_match in tui.rs, codex_cli.rs, copilot.rs - 10 new tests for format_number_fit
95a8606 to
94b5792
Compare
|
@coderabbitai Review. |
|
✅ Actions performedReview triggered.
|
Problem
The Input (width 8) and Output (width 9) token columns in the TUI were too narrow for large values. A number like
106529574(9 digits) got its leading digit clipped in the 8-wide Input column, displaying as06529574— silently losing magnitude information.The four token columns also had inconsistent widths (8, 9, 10, 11, 12 depending on column and view), making the issue worse for some columns than others.
Fix
Widen columns: Unify all token columns (Cached, Input, Output, Reasoning) to width 12 via a
TOKEN_COL_WIDTHconstant, in both daily and session views. Separator rows use the same constant.Overflow-safe formatting: Add
format_number_fit(value, options, max_width)which cascades through progressively compact representations when the formatted number exceeds the column width:48.1b)48b)This ensures significant digits are never silently clipped — the number gets abbreviated instead.
Testing
format_number_fitcovering overflow fallback, boundary conditions, comma/human/plain modes, u64 totals, and zero valuesCloses #123
Summary by CodeRabbit
Refactor
Bug Fix
Tests