fix: ensure proper output rendering in CLI by flushing stdout
- Added a flush of the StdoutProxy buffer to ensure that tool/status lines render above the response box, preventing interleaving of output. - Combined the rendering of the response and the surrounding box into a single _cprint call for improved visual consistency and clarity.
This commit is contained in:
19
cli.py
19
cli.py
@@ -1503,7 +1503,11 @@ class HermesCLI:
|
||||
agent_thread.join(0.1)
|
||||
|
||||
agent_thread.join() # Ensure agent thread completes
|
||||
|
||||
|
||||
# Drain any remaining agent output still in the StdoutProxy
|
||||
# buffer so tool/status lines render ABOVE our response box.
|
||||
sys.stdout.flush()
|
||||
|
||||
# Update history with full conversation
|
||||
self.conversation_history = result.get("messages", self.conversation_history) if result else self.conversation_history
|
||||
|
||||
@@ -1527,15 +1531,12 @@ class HermesCLI:
|
||||
w = min(self.console.width, 80)
|
||||
label = " ⚕ Hermes "
|
||||
fill = w - 2 - len(label) # 2 for ╭ and ╮
|
||||
top = f"╭─{label}{'─' * max(fill - 1, 0)}╮"
|
||||
bot = f"╰{'─' * (w - 2)}╯"
|
||||
top = f"{_GOLD}╭─{label}{'─' * max(fill - 1, 0)}╮{_RST}"
|
||||
bot = f"{_GOLD}╰{'─' * (w - 2)}╯{_RST}"
|
||||
|
||||
print()
|
||||
_cprint(f"{_GOLD}{top}{_RST}")
|
||||
print()
|
||||
print(response)
|
||||
print()
|
||||
_cprint(f"{_GOLD}{bot}{_RST}")
|
||||
# Render box + response as a single _cprint call so
|
||||
# nothing can interleave between the box borders.
|
||||
_cprint(f"\n{top}\n\n{response}\n\n{bot}")
|
||||
|
||||
# If we have a pending message from interrupt, re-queue it for process_loop
|
||||
# instead of recursing (avoids unbounded recursion from rapid interrupts)
|
||||
|
||||
Reference in New Issue
Block a user