Skip to content

Wrap last column to terminal width in CLI table formatter#11829

Open
Copilot wants to merge 9 commits intomainfrom
copilot/fix-line-wrapping-description
Open

Wrap last column to terminal width in CLI table formatter#11829
Copilot wants to merge 9 commits intomainfrom
copilot/fix-line-wrapping-description

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 7, 2026

  • Replace text/tabwriter-based renderer with manual line-by-line renderer that wraps the last column to terminal width.
  • Detect terminal width via golang.org/x/term; pad continuation lines.
  • Address PR review feedback:
    • Use utf8.RuneCountInString for column-width and padding calculations so multi-byte UTF-8 stays aligned.
    • Slice long words on rune boundaries (never inside a UTF-8 sequence).
    • Replace strings.Fields-based wrap with a rune-walking wrapper that preserves internal whitespace and only drops trailing whitespace at wrap boundaries.
    • Add tests for Unicode alignment / wrapping and internal-whitespace preservation.

Copilot AI changed the title [WIP] Fix incorrect line wrapping for property description in rad resource-type show Wrap last column to terminal width in CLI table formatter May 7, 2026
Copilot AI requested a review from zachcasper May 7, 2026 16:10
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 7, 2026

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 7, 2026

Unit Tests

    2 files  ±0    420 suites  ±0   6m 47s ⏱️ +8s
5 028 tests +5  5 026 ✅ +5  2 💤 ±0  0 ❌ ±0 
6 055 runs  +5  6 053 ✅ +5  2 💤 ±0  0 ❌ ±0 

Results for commit aaf72f2. ± Comparison against base commit 8ad0d19.

♻️ This comment has been updated with latest results.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 7, 2026

Codecov Report

❌ Patch coverage is 79.50820% with 25 lines in your changes missing coverage. Please review.
✅ Project coverage is 51.29%. Comparing base (8ad0d19) to head (aaf72f2).

Files with missing lines Patch % Lines
pkg/cli/output/table.go 79.50% 14 Missing and 11 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #11829      +/-   ##
==========================================
+ Coverage   51.19%   51.29%   +0.10%     
==========================================
  Files         715      715              
  Lines       45081    45170      +89     
==========================================
+ Hits        23079    23171      +92     
  Misses      19803    19803              
+ Partials     2199     2196       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@zachcasper zachcasper marked this pull request as ready for review May 7, 2026 17:29
@zachcasper zachcasper requested a review from a team as a code owner May 7, 2026 17:29
Copilot AI review requested due to automatic review settings May 7, 2026 17:29
@zachcasper zachcasper requested review from a team as code owners May 7, 2026 17:29
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes misaligned CLI table output by replacing the text/tabwriter-based table renderer with a custom renderer that can word-wrap the last column to the detected terminal width, keeping continuation lines aligned under the correct column.

Changes:

  • Replaced the table output implementation with a manual renderer that computes column widths and wraps the last column when terminal width is known.
  • Added tests validating last-column wrapping behavior (including unbreakable tokens) and no-wrap behavior when terminal width is unknown.
  • Promoted golang.org/x/term (and github.com/hashicorp/go-version) to direct dependencies in go.mod.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
pkg/cli/output/table.go New manual table renderer with terminal-width detection and last-column wrapping.
pkg/cli/output/table_test.go Added unit tests covering wrapping/no-wrapping scenarios.
go.mod Updated direct dependencies to include golang.org/x/term (and go-version).

Comment thread pkg/cli/output/table.go Outdated
Comment on lines +224 to +228
func padRight(s string, width int) string {
if len(s) >= width {
return s
}
return s + strings.Repeat(" ", width-len(s))
Comment thread pkg/cli/output/table.go Outdated
Comment on lines +251 to +252
lines = append(lines, word[:width])
word = word[width:]
Comment thread pkg/cli/output/table.go Outdated
Comment on lines +242 to +245
var lines []string
current := ""
for _, word := range strings.Fields(s) {
// Break words that are themselves longer than the column width.
Copilot AI requested a review from zachcasper May 8, 2026 16:36
@radius-functional-tests
Copy link
Copy Markdown

radius-functional-tests Bot commented May 8, 2026

Radius functional test overview

🔍 Go to test action run

Click here to see the test run details
Name Value
Repository radius-project/radius
Commit ref aaf72f2
Unique ID func3d55d2c0ff
Image tag pr-func3d55d2c0ff
  • gotestsum 1.13.0
  • KinD: v0.29.0
  • Dapr: 1.14.4
  • Azure KeyVault CSI driver: 1.4.2
  • Azure Workload identity webhook: 1.3.0
  • Bicep recipe location ghcr.io/radius-project/dev/test/testrecipes/test-bicep-recipes/<name>:pr-func3d55d2c0ff
  • Terraform recipe location http://tf-module-server.radius-test-tf-module-server.svc.cluster.local/<name>.zip (in cluster)
  • applications-rp test image location: ghcr.io/radius-project/dev/applications-rp:pr-func3d55d2c0ff
  • dynamic-rp test image location: ghcr.io/radius-project/dev/dynamic-rp:pr-func3d55d2c0ff
  • controller test image location: ghcr.io/radius-project/dev/controller:pr-func3d55d2c0ff
  • ucp test image location: ghcr.io/radius-project/dev/ucpd:pr-func3d55d2c0ff
  • deployment-engine test image location: ghcr.io/radius-project/deployment-engine:latest

Test Status

⌛ Building Radius and pushing container images for functional tests...
✅ Container images build succeeded
⌛ Publishing Bicep Recipes for functional tests...
✅ Container images build succeeded
⌛ Publishing Bicep Recipes for functional tests...
✅ Recipe publishing succeeded
✅ Recipe publishing succeeded
⌛ Starting ucp-cloud functional tests...
⌛ Starting corerp-cloud functional tests...
⌛ Starting ucp-cloud functional tests...
⌛ Starting corerp-cloud functional tests...
✅ ucp-cloud functional tests succeeded
✅ ucp-cloud functional tests succeeded
✅ corerp-cloud functional tests succeeded
✅ corerp-cloud functional tests succeeded

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect line wrapping for property description in rad resource-type show

3 participants