From 261b843839806849d496c3640b8f19d41fc3283d Mon Sep 17 00:00:00 2001 From: Alfredo Arenas Date: Sat, 18 Apr 2026 00:09:20 -0600 Subject: [PATCH] fix(cli): respect sys.stdout.isatty() in stream renderer (#3265) --- nanobot/cli/stream.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/nanobot/cli/stream.py b/nanobot/cli/stream.py index 9454edac..addf4fe7 100644 --- a/nanobot/cli/stream.py +++ b/nanobot/cli/stream.py @@ -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: