Skip to content

Your lightweight open-source personal agent.

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

Alfredo Arenas261b84383980
diff --git a/nanobot/cli/stream.py b/nanobot/cli/stream.py
index 9454edac6..addf4fe7c 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: