Skip to content

Your lightweight open-source personal agent.

fix(cli): stop spinner after non-streaming interactive replies

Xubin Ren8f5c2d1a062d
diff --git a/nanobot/cli/commands.py b/nanobot/cli/commands.py
index db348ed90..d0ec145d8 100644
--- a/nanobot/cli/commands.py
+++ b/nanobot/cli/commands.py
@@ -752,6 +752,7 @@ def agent(
on_stream_end=renderer.on_end,
)
if not renderer.streamed:
+ await renderer.close()
_print_agent_response(
response.content if response else "",
render_markdown=markdown,
@@ -873,9 +874,13 @@ def agent(
if turn_response:
content, meta = turn_response[0]
if content and not meta.get("_streamed"):
+ if renderer:
+ await renderer.close()
_print_agent_response(
content, render_markdown=markdown, metadata=meta,
)
+ elif renderer and not renderer.streamed:
+ await renderer.close()
except KeyboardInterrupt:
_restore_terminal()
console.print("\nGoodbye!")
diff --git a/nanobot/cli/stream.py b/nanobot/cli/stream.py
index 161d53082..16586ecd0 100644
--- a/nanobot/cli/stream.py
+++ b/nanobot/cli/stream.py
@@ -119,3 +119,10 @@ class StreamRenderer:
self._start_spinner()
else:
_make_console().print()
+
+ async def close(self) -> None:
+ """Stop spinner/live without rendering a final streamed round."""
+ if self._live:
+ self._live.stop()
+ self._live = None
+ self._stop_spinner()