Skip to content

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

Open
Copilot wants to merge 12 commits into
mainfrom
copilot/fix-line-wrapping-description
Open

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

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 7, 2026

Description

When CLI commands like rad resource-type show render tables with long values (e.g., property descriptions), the output previously broke mid-word at the terminal edge, producing misaligned and hard-to-read output. This PR replaces the text/tabwriter-based renderer with a custom line-by-line renderer that detects the terminal width and intelligently word-wraps the last column, padding continuation lines so columns stay aligned.

Before: A long description wraps mid-word at the terminal boundary, breaking alignment:

size         string    false     false      The size of the PostgreSQL database, non production environments can be (S)
mall or (M)edium, production environments can be or (S)mall, (M)edium, (L)arge, or (XL)arge

After: The last column wraps on word boundaries and continuation lines are padded to stay aligned:

size         string    false     false      The size of the PostgreSQL database, non production
                                            environments can be (S)mall or (M)edium, production
                                            environments can be or (S)mall, (M)edium, (L)arge,
                                            or (XL)arge

Key implementation details:

  • Terminal width is detected via golang.org/x/term; when output is piped (width unknown), no wrapping is applied.
  • All column-width and padding calculations use utf8.RuneCountInString so multi-byte UTF-8 content stays aligned.
  • Long unbreakable words (e.g., URLs) are split on rune boundaries, never inside a UTF-8 sequence.
  • Internal whitespace within cells is preserved; only trailing whitespace at wrap boundaries is dropped.

Type of change

  • This pull request fixes a bug in Radius and has an approved issue (issue link required).

Fixes: #9756

Contributor checklist

Please verify that the PR meets the following requirements, where applicable:

  • An overview of proposed schema changes is included in a linked GitHub issue.
    • Not applicable
  • A design document is added or updated under eng/design-notes/ in this repository, if new APIs are being introduced.
    • Not applicable
  • The design document has been reviewed and approved by Radius maintainers/approvers.
    • Not applicable
  • A PR for resource-types-contrib is created, if resource types or recipes are affected by the changes in this PR.
    • Not applicable
  • A PR for dashboard is created, if the Radius Dashboard is affected by the changes in this PR.
    • Not applicable
  • A PR for the documentation repository is created, if the changes in this PR affect the documentation or any user facing updates are made.
    • Not applicable

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.

OpenSSF Scorecard

PackageVersionScoreDetails
gomod/golang.org/x/term 0.42.0 UnknownUnknown

Scanned Files

  • go.mod

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 7, 2026

Unit Tests

1 files   -     1  0 suites   - 422   0s ⏱️ - 7m 17s
0 tests  - 5 127  0 ✅  - 5 125  0 💤  - 2  0 ❌ ±0 
0 runs   - 6 156  0 ✅  - 6 154  0 💤  - 2  0 ❌ ±0 

Results for commit edce9e5. ± Comparison against base commit 48bcd09.

♻️ 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.45%. Comparing base (0b326ae) to head (ac7ae62).

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.38%   51.45%   +0.07%     
==========================================
  Files         716      716              
  Lines       45106    45195      +89     
==========================================
+ Hits        23178    23257      +79     
- Misses      19725    19733       +8     
- Partials     2203     2205       +2     

☔ 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 thread pkg/cli/output/table.go Outdated
Comment thread pkg/cli/output/table.go Outdated
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 15, 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 edce9e5
Unique ID func011425be7c
Image tag pr-func011425be7c
  • 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-func011425be7c
  • 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-func011425be7c
  • dynamic-rp test image location: ghcr.io/radius-project/dev/dynamic-rp:pr-func011425be7c
  • controller test image location: ghcr.io/radius-project/dev/controller:pr-func011425be7c
  • ucp test image location: ghcr.io/radius-project/dev/ucpd:pr-func011425be7c
  • 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 failed
❌ Test recipe publishing failed

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

4 participants