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

This commit is contained in:
Xubin Ren
2026-03-23 03:27:13 +00:00
parent a46803cbd7
commit 8f5c2d1a06
2 changed files with 12 additions and 0 deletions

View File

@@ -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!")

View File

@@ -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()