Skip to content

Unify the two truncate helpers and measure display width - #698

Open
jvanbuel wants to merge 1 commit into
mainfrom
claude/unify-truncate-helpers
Open

Unify the two truncate helpers and measure display width#698
jvanbuel wants to merge 1 commit into
mainfrom
claude/unify-truncate-helpers

Conversation

@jvanbuel

Copy link
Copy Markdown
Owner

What

The codebase had two truncate-with-ellipsis helpers doing the same job:

truncate_cols truncate_breadcrumb_part
Location trigger/text.rs state/breadcrumb.rs
Ellipsis ...
Reserve 1 char 3 chars

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 emoji dag_id truncated to N chars renders up to 2N columns and overflows its cell — and dag_id, task_id, owners, and tags are all free-form user data.

unicode-width is already a direct dependency (Cargo.toml:103), used correctly for exactly this in ui/tabs.rs:26. The helper named truncate_**cols** simply wasn't using it.

Change

One ui::common::truncate_cols that measures display width, replacing both copies. Walks chars accumulating ch.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:

assert_eq!(truncate_cols("日本語テスト", 6), "日本…");  // char-counting kept 5, overflowing to 10 columns
assert_eq!(truncate_cols("日本語", 6), "日本語");       // exact fit is left alone

cargo test --workspace --lib --bins (95 passing), cargo clippy --workspace --all-targets --all-features -- -D warnings, and cargo fmt --all --check all clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_0127jzUgqqy8JVX5RydfQxh8


Generated by Claude Code

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
@coderabbitai

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

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

Next review available in: 48 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 1e6d3d13-da4d-422a-bdbf-cd50613b7d9f

📥 Commits

Reviewing files that changed from the base of the PR and between c16ad73 and 0bf6b9b.

📒 Files selected for processing (4)
  • src/app/model/dagruns/popup/trigger/table.rs
  • src/app/model/dagruns/popup/trigger/text.rs
  • src/app/state/breadcrumb.rs
  • src/ui/common.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/unify-truncate-helpers

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.

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