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:
parent
21c3e9973a
commit
d0c8dd78c2
1 changed files with 10 additions and 9 deletions
17
cli.py
17
cli.py
|
|
@ -1504,6 +1504,10 @@ class HermesCLI:
|
||||||
|
|
||||||
agent_thread.join() # Ensure agent thread completes
|
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
|
# Update history with full conversation
|
||||||
self.conversation_history = result.get("messages", self.conversation_history) if result else self.conversation_history
|
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)
|
w = min(self.console.width, 80)
|
||||||
label = " ⚕ Hermes "
|
label = " ⚕ Hermes "
|
||||||
fill = w - 2 - len(label) # 2 for ╭ and ╮
|
fill = w - 2 - len(label) # 2 for ╭ and ╮
|
||||||
top = f"╭─{label}{'─' * max(fill - 1, 0)}╮"
|
top = f"{_GOLD}╭─{label}{'─' * max(fill - 1, 0)}╮{_RST}"
|
||||||
bot = f"╰{'─' * (w - 2)}╯"
|
bot = f"{_GOLD}╰{'─' * (w - 2)}╯{_RST}"
|
||||||
|
|
||||||
print()
|
# Render box + response as a single _cprint call so
|
||||||
_cprint(f"{_GOLD}{top}{_RST}")
|
# nothing can interleave between the box borders.
|
||||||
print()
|
_cprint(f"\n{top}\n\n{response}\n\n{bot}")
|
||||||
print(response)
|
|
||||||
print()
|
|
||||||
_cprint(f"{_GOLD}{bot}{_RST}")
|
|
||||||
|
|
||||||
# If we have a pending message from interrupt, re-queue it for process_loop
|
# If we have a pending message from interrupt, re-queue it for process_loop
|
||||||
# instead of recursing (avoids unbounded recursion from rapid interrupts)
|
# instead of recursing (avoids unbounded recursion from rapid interrupts)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue