Skip to content

feat(tui): tui table --column-sizes sets column widths - #19560

Merged
fdncred merged 1 commit into
nushell:mainfrom
stepelu:tui-table-column-sizes
Nov 17, 2026
Merged

fdncred merged 1 commit into
nushell:mainfrom
stepelu:tui-table-column-sizes

Conversation

@stepelu

@stepelu stepelu commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

Description

tui table gives every shown column an equal share of its width, so short columns waste space and long ones get truncated (#19503).

This PR adds --column-sizes, which takes one width per shown column, in the same forms as tui split --sizes. Without the flag, columns keep their equal shares, so existing tables render as before.

User-facing changes (Release notes)

Set column widths in tui table with --column-sizes

tui table now accepts --column-sizes, with one width per shown column, using the same sizes as tui split --sizes. Columns without an entry share the remaining space. Without the flag, columns still share the width equally.

[{time: '12:34:56', entry: 'A very long entry that does not fit the screen.'}] | tui table --column-sizes [10 1fr] | tui run
ls | tui table --columns [name type size] --column-sizes ["40%" 8 1fr] | tui run

Additional notes

closes #19503

@fdncred fdncred left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review overview

🟡 Changes recommended

--column-sizes does what #19503 asked for. [10 1fr] gives the issue's layout, --multi keeps its checkbox column, and tables without the flag render as before. One real problem remains. On a wide table, a missing entry hangs the render.

Findings: 1 High severity · 0 Medium severity · 2 Low severity

Open (3)

Notes from my clanker, checked on e9b62b0. Built the branch (debug) and ran cargo fmt --all --check and cargo test -p nu-tui (83 unit + 80 integration passed). Clippy and typos come from CI, which is green. Ran each case on the branch binary and on 0.117.1. For the hang, I also timed ratatui 0.30.2's Layout::split on its own in a release build, and built and reverted a trial of the fix in the first thread.

Comment thread crates/nu-tui/src/widgets/table.rs Resolved
Comment thread crates/nu-tui/src/commands/table.rs Resolved
Comment thread crates/nu-tui/tests/commands/tui.rs Resolved
@stepelu
stepelu force-pushed the tui-table-column-sizes branch from e9b62b0 to 43ca5f7 Compare November 17, 2026 04:45
@stepelu

stepelu commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review!

As you noticed (#19566) the first identified issue affected tui split as well.

I investigated the original freeze through Nushell → Ratatui → Kasuari. I tested the proposed solver fix in Kasuari #24 (ratatui/kasuari#24). It resolved the 40-column/child reproductions, but some larger cases still timed out or returned an unbounded-objective error. Given the workaround now adopted in #19566, this PR reuses that mechanism:

  • Extracted split’s existing flag-reading logic into flag_sizes, shared by both commands. Moved the unchanged size parser and its existing unit test alongside it.
  • Added command tests for dynamically typed scalar sizes, invalid sizes, and column widths with --multi.
  • Reused pin_fills from fix(tui): tui split no longer hangs with many 1fr children #19566 for table layouts, accounting for borders, the selection marker, and column spacing.
  • Added a 40-column rendering test, covering omitted widths and explicitly specified fractional widths, including a table with checkboxes.

@fdncred fdncred added notes:ready Indicates Ready for Release notes notes:additions Noted in "Additions" section labels Nov 17, 2026
@fdncred
fdncred merged commit 5e8f309 into nushell:main Nov 17, 2026
14 checks passed
@fdncred

fdncred commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Thanks

@github-actions github-actions Bot added this to the v0.118.0 milestone Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

notes:additions Noted in "Additions" section notes:ready Indicates Ready for Release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Set column widths in tui table

2 participants