fix(cli): respect sys.stdout.isatty() in stream renderer (#3265)

This commit is contained in:
Alfredo Arenas
2026-04-19 04:19:59 +08:00
committed by Xubin Ren
parent 9773d4b8ab
commit 261b843839
+11 -1
View File
@@ -18,7 +18,17 @@ from nanobot import __logo__
def _make_console() -> Console:
return Console(file=sys.stdout, force_terminal=True)
"""Create a Console that emits plain text when stdout is not a TTY.
Rich's spinner, Live render, and cursor-visibility escape codes all
key off ``Console.is_terminal``. Forcing ``force_terminal=True`` overrode
the ``isatty()`` check and caused control sequences (``\\x1b[?25l``,
braille spinner frames) to pollute programmatic consumers such as
``docker exec -i`` or pipes, even with ``NO_COLOR`` or ``TERM=dumb``.
Deferring to ``isatty()`` keeps Rich output in interactive terminals
and plain text everywhere else (#3265).
"""
return Console(file=sys.stdout, force_terminal=sys.stdout.isatty())
class ThinkingSpinner: