fix(task): use terminal width instead of hardcoded 60-char limit for task display#6218
Merged
fix(task): use terminal width instead of hardcoded 60-char limit for task display#6218
Conversation
…task display Replace hardcoded 60-character truncation limit in Task Display implementation with terminal-width-based calculation. This fixes premature truncation of task commands in CI environments and wide terminals. - Use console::measure_text_width() to properly handle ANSI color codes - Calculate max width based on TERM_WIDTH minus prefix length and buffer - Maintains consistent truncation behavior with runtime task execution - Fixes issue where long commands were truncated at 60 chars regardless of terminal size 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull Request Overview
Fixes task display truncation by replacing a hardcoded 60-character limit with dynamic terminal width calculation. This prevents premature truncation of task commands in CI environments and wide terminals.
- Import
measure_text_widthfrom console module to handle ANSI color codes properly - Replace hardcoded 60-character limit with dynamic calculation based on terminal width
- Calculate max width by subtracting prefix length and buffer space from terminal width
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| write!(f, "{} {}", self.prefix(), truncate_str(cmd, 60, "…")) | ||
| let prefix = self.prefix(); | ||
| let prefix_len = measure_text_width(&prefix); | ||
| let max_width = (*env::TERM_WIDTH).saturating_sub(prefix_len + 4); // 4 chars buffer for spacing and ellipsis |
There was a problem hiding this comment.
The magic number 4 should be defined as a named constant to improve code readability and maintainability. Consider defining const DISPLAY_BUFFER: usize = 4; at the module level.
Hyperfine Performance
|
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2025.9.5 x -- echo |
18.4 ± 0.4 | 17.9 | 23.4 | 1.00 ± 0.02 |
mise x -- echo |
18.4 ± 0.2 | 17.9 | 19.8 | 1.00 |
mise env
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2025.9.5 env |
17.8 ± 0.3 | 17.3 | 21.3 | 1.00 ± 0.03 |
mise env |
17.7 ± 0.4 | 17.3 | 23.3 | 1.00 |
mise hook-env
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2025.9.5 hook-env |
17.4 ± 0.2 | 16.9 | 18.6 | 1.01 ± 0.02 |
mise hook-env |
17.3 ± 0.2 | 17.0 | 18.5 | 1.00 |
mise ls
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2025.9.5 ls |
15.9 ± 0.3 | 15.4 | 19.0 | 1.00 ± 0.02 |
mise ls |
15.8 ± 0.2 | 15.4 | 17.3 | 1.00 |
xtasks/test/perf
| Command | mise-2025.9.5 | mise | Variance |
|---|---|---|---|
| install (cached) | 163ms | ✅ 101ms | +61% |
| ls (cached) | 61ms | 61ms | +0% |
| bin-paths (cached) | 65ms | 65ms | +0% |
| task-ls (cached) | 467ms | 469ms | +0% |
✅ Performance improvement: install cached is 61%
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Changes Made
console::measure_text_widthinsrc/task/mod.rstruncate_str(cmd, 60, "…")with dynamic width calculation in Task DisplayTERM_WIDTH - prefix_len - 4with 20-char minimumsrc/cli/run.rsBefore vs After
Before: Tasks were always truncated at 60 characters regardless of terminal width
After: Tasks respect terminal width and show minimum 20 chars even with long prefixes
Test plan
test_task_display_truncationpassesFixes task output truncation issue where commands were being cut off at 60 characters regardless of terminal size or color formatting. The fix ensures both display and runtime truncation use consistent, intelligent width calculations.
🤖 Generated with Claude Code