Skip to content

fix(cli): size result table columns by terminal cell width - #1977

Merged
wowi42 merged 1 commit into
pyinfra-dev:3.xfrom
orbi-build:fix/1438-display-width
Oct 13, 2026
Merged

wowi42 merged 1 commit into
pyinfra-dev:3.xfrom
orbi-build:fix/1438-display-width

Conversation

@xqliu

@xqliu xqliu commented Sep 28, 2026 •

Copy link
Copy Markdown

print_rows measured each cell with len(), so a CJK operation name, where every character takes two terminal cells, pushed the following columns right of the header and the Results table looked misaligned.

Cells are now measured with rich.cells.cell_len after the existing ANSI strip: wide and fullwidth characters take two cells, and combining marks and emoji modifiers take none, so rows that already lined up keep doing so. rich is already installed through cyclopts; it is now declared directly, at 13.7.1, the first release that gives an emoji skin tone modifier no width.

Fixes #1438

  • Pull request is based on the default branch (3.x at this time)
  • Pull request includes tests for any new/updated operations/facts
  • Pull request includes documentation for any new/updated operations/facts
  • Tests pass (see scripts/dev-test.sh)
  • Type checking & code style passes (see scripts/dev-lint.sh)
  • Pull request title follows the
    conventional commits format

AI disclosure: the commit is authored by orbi-build[bot], the GitHub App identity of Orbi, an AI coding agent (deepseek-flash) that wrote the first version. I then reworked it with Claude Code after a review found it made emoji-modifier rows worse, and I reviewed and tested the final diff myself, including running pyinfra @local exec with the issue's example. I'm opening this PR and am responsible for it.

print_rows measured each cell with len(), so a CJK operation name, where
every character takes two terminal cells, pushed the following columns
right of the header and the Results table looked misaligned.

Cells are now measured with rich.cells.cell_len after the existing ANSI
strip: wide and fullwidth characters take two cells, and combining marks
and emoji modifiers take none, so rows that already lined up keep doing
so. rich is already installed through cyclopts; it is now declared
directly, at 13.7.1, the first release that gives an emoji skin tone
modifier no width.

Fixes pyinfra-dev#1438
@wowi42 wowi42 added bug Label for all kind of bugs. CLI CLI mode specific issues. labels Sep 28, 2026

@wowi42 wowi42 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Fixes #1438: print_rows measured cells with len(), so CJK operation names shifted the Results table. Cells are now measured with rich.cells.cell_len after the ANSI strip, and rich is declared as a direct dependency at >=13.7.1.

Checks performed:

  • Base is 3.x, title is Conventional Commits, all CI green (tests-done, lint, type-check, unit/e2e on all platforms).
  • Fix verified locally: cell_len on installed rich 15.0.0 returns 4 for 中文, 2 for 👍🏽, 0 for combining marks, 5 for ANSI-wrapped "hello". Ran the patched print_rows algorithm verbatim against all four new tests in tests/test_cli/test_cli_prints.py: all pass, including ASCII output byte-identical to before (no regression for existing users).
  • rich was already a transitive dep via cyclopts; making it direct is correct since prints.py now imports it. The 13.7.1 floor matches the rich changelog ("Updated the widths of some characters"). The uv.lock change is the minimal 2-line registration of the new direct dep, not bundled lock maintenance.
  • No shell commands touched, no injection surface. No asserts in src/. No fixtures needed: this is CLI display code, and tests/test_cli/ already uses plain Python tests.
  • Scope is atomic: 4 files, all tied to the fix. rich>=13.7.1 has no upper bound, consistent with existing unbounded deps (click>2, gevent>=1.5).
  • AI_POLICY.md followed: full disclosure in the body, human review and testing stated.

@wowi42
wowi42 merged commit e7e42b6 into pyinfra-dev:3.x Oct 13, 2026
42 checks passed
@xqliu
xqliu deleted the fix/1438-display-width branch October 13, 2026 12:14
@xqliu

xqliu commented Oct 13, 2026

Copy link
Copy Markdown
Author

Thanks for reviewing and merging this, @wowi42. If it's ever useful, open-source repos can use Orbi Cloud free for 3 months to take a first pass at labeled issues here. Just ping me.

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

Labels

bug Label for all kind of bugs. CLI CLI mode specific issues.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CJK chracters causing result table columns to shift

2 participants