fix(cli): respect sys.stdout.isatty() in stream renderer (#3265)#3271
Merged
Re-bin merged 3 commits intoHKUDS:mainfrom Apr 18, 2026
Merged
fix(cli): respect sys.stdout.isatty() in stream renderer (#3265)#3271Re-bin merged 3 commits intoHKUDS:mainfrom
Re-bin merged 3 commits intoHKUDS:mainfrom
Conversation
The old test `test_make_console_uses_force_terminal` hardcoded `force_terminal is True`, which contradicts the fix: we now defer to sys.stdout.isatty() so piped / non-TTY output gets plain text instead of ANSI escape codes. Split into two tests covering both branches: - test_make_console_force_terminal_when_stdout_is_tty: TTY path (force_terminal=True, rich output) - test_make_console_force_terminal_false_when_stdout_is_not_tty: non-TTY path (force_terminal=False, plain text) — regression guard for the bug reported in HKUDS#3265 Co-authored with Claude Opus 4.7
Re-bin
approved these changes
Apr 18, 2026
Collaborator
Re-bin
left a comment
There was a problem hiding this comment.
This is the right kind of fix.
The intent is narrow, the boundary is clear, and the implementation solves the actual problem without making the CLI renderer more complicated than it needs to be. Respecting sys.stdout.isatty() is the right way to avoid Rich control sequences leaking into piped or non-interactive output while keeping the existing rich rendering in real terminals.
I pulled in the latest main and reran the relevant tests locally:
pytest tests/cli/test_cli_input.py -qpytest tests/cli -qpytest -q
All of them passed locally.
From my side, this is clean, practical, and ready to merge.
Contributor
Author
|
Thanks @Re-bin Really appreciate you pulling and rerunning the suite locally. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When stdout is not a TTY (e.g. docker exec -i, pipes), nanobot emitted
cursor-visibility escape sequences and braille spinner frames mixed into
the response output. Forcing force_terminal=True overrode Rich's isatty()
detection. Deferring to sys.stdout.isatty() keeps rich output in real
terminals and plain text everywhere else.
Co-authored with Claude Opus 4.7