Skip to content

fix(console): Windows piped output keeps the full configured width - #4410

Merged
Daniel Meppiel (danielmeppiel) merged 4 commits into
mainfrom
danielmeppiel-windows-piped-console-width
Nov 21, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 4 commits into
mainfrom
danielmeppiel-windows-piped-console-width

Conversation

@danielmeppiel

Copy link
Copy Markdown
Collaborator

Description

On Windows, Rich treats any stream without VT support as a legacy console, and that includes every piped stdout. It then renders one column narrower than the configured width. So APM's panels and tables printed 399 columns on Windows CI against 400 on Linux and macOS with COLUMNS=400, and the golden lifecycle journey J01 differed by exactly that column.

The change is inside the single console constructor, _ascii_console in src/apm_cli/utils/console.py, which new_console and both singletons use:

  • On Windows, when the console's stream is not a terminal, it passes legacy_windows=False, so piped or captured output keeps the full width.
  • An interactive console keeps Rich's own detection. A real old conhost without VT still gets Rich's one-column guard against auto-wrap, and a VT-capable terminal is already non-legacy in Rich.
  • An explicit legacy_windows argument is respected.

Unit tests in tests/unit/test_console_utils.py, simulating Windows with no VT support:

  • piped stream: width = COLUMNS (400);
  • interactive stream: Rich's auto-detection stays (399).

Issue and approved scope

Issue: Fixes #4409

Human scope-approval comment: the 0.37 steward ruling relayed by the Stream T lead (J01 golden must be green on the RC; the fix stays inside the console factory).

Does this PR complete the issue, or what remains? It completes it.

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Maintenance / refactor

Testing

  • Tested locally
  • All existing tests pass
  • Added tests for new functionality (if applicable)

Results:

  • pytest tests/unit/test_console_utils.py: 46 passed.
  • ruff check / format: clean.

Changelog

  • One line in one section under ## [Unreleased] in CHANGELOG.md.
  • N/A -- internal-only change (CI, tests, refactor).

Spec conformance (OpenAPM v0.1)

  • N/A -- this PR does not change OpenAPM-observable behaviour.

…minal keeps Rich's detection (#4409)

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
@danielmeppiel Daniel Meppiel (danielmeppiel) added this to the 0.37.0 milestone Nov 20, 2026
Copilot AI balanced review requested due to automatic review settings November 20, 2026 16:27
Co-authored-by: copilot-swe-agent[bot] <[email protected]>

Copilot AI 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.

🟡 Changes recommended

The regression test lacks the windows_compat marker, so both new cases are deselected by the PR-time Windows gate, leaving the Windows-specific width contract unchecked before merge.

1 open issue
What changed in this PR

Fixes #4409 by preserving the full configured width for piped Windows output in APM's shared console factory.

Changes:

  • Disables Rich's legacy Windows width adjustment for non-terminal streams while preserving interactive detection and explicit overrides.
  • Adds regression cases for piped and interactive Windows console widths.
  • Records the user-visible fix in the changelog.
File Description
tests/​unit/​test_console_utils.py Adds simulated Windows width regression tests.
src/​apm_cli/​utils/​console.py Adjusts legacy-console handling for non-terminal Windows streams.
CHANGELOG.md Documents consistent piped output width across platforms.

Review effort: Balanced

Comment thread tests/unit/test_console_utils.py Outdated
pass


@pytest.mark.parametrize(("tty", "width"), [(False, 400), (True, 399)])
…n, not a fixed column count (#4409)

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit 895b2e9 into main Nov 21, 2026
37 of 42 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the danielmeppiel-windows-piped-console-width branch November 21, 2026 05:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows piped output renders Rich panels one column narrower than COLUMNS

2 participants