Unify the two truncate helpers and measure display width - #698
Conversation
truncate_cols (trigger param table) and truncate_breadcrumb_part (breadcrumb) did the same job with different ellipsis characters, so the UI clipped text two different ways. Both also counted chars rather than terminal columns, which under-truncates wide characters: a CJK dag_id or task_id clipped to N chars renders up to 2N columns and overflows its cell. Replace both with a single ui::common::truncate_cols that measures display width via unicode-width, already a direct dependency used the same way in ui::tabs. Breadcrumbs now clip with '…' instead of '...'; the total width budget is unchanged. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0127jzUgqqy8JVX5RydfQxh8
|
Warning Review limit reached
Next review available in: 48 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: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
✨ 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 |
What
The codebase had two truncate-with-ellipsis helpers doing the same job:
truncate_colstruncate_breadcrumb_parttrigger/text.rsstate/breadcrumb.rs…...So the UI clipped text two visibly different ways depending on which widget you were looking at.
The width bug
Both counted
chars()rather than terminal columns. A CJK or emojidag_idtruncated to N chars renders up to 2N columns and overflows its cell — anddag_id,task_id,owners, andtagsare all free-form user data.unicode-widthis already a direct dependency (Cargo.toml:103), used correctly for exactly this inui/tabs.rs:26. The helper namedtruncate_**cols**simply wasn't using it.Change
One
ui::common::truncate_colsthat measures display width, replacing both copies. Walks chars accumulatingch.width()and stops before exceeding the budget, reserving one column for the ellipsis.Behavior change
Breadcrumbs now clip with
…instead of.... The total width budget is unchanged — the old code reserved 3 chars for..., the new one reserves 1 column for…— so breadcrumbs keep slightly more of the original text within the same footprint.Verification
Two tests on the shared helper, including the case the fix exists for:
cargo test --workspace --lib --bins(95 passing),cargo clippy --workspace --all-targets --all-features -- -D warnings, andcargo fmt --all --checkall clean.🤖 Generated with Claude Code
https://claude.ai/code/session_0127jzUgqqy8JVX5RydfQxh8
Generated by Claude Code