fix: improve CLI output rendering and response display
- Adjusted console width handling to ensure consistent output formatting. - Introduced a short sleep after flushing stdout to allow for proper rendering of tool/status lines before displaying responses. - Enhanced the response display by modifying the rendering logic to improve visual clarity and prevent interleaving of output.
This commit is contained in:
parent
d0c8dd78c2
commit
2daf5e4296
1 changed files with 7 additions and 3 deletions
10
cli.py
10
cli.py
|
|
@ -1465,7 +1465,7 @@ class HermesCLI:
|
||||||
# Add user message to history
|
# Add user message to history
|
||||||
self.conversation_history.append({"role": "user", "content": message})
|
self.conversation_history.append({"role": "user", "content": message})
|
||||||
|
|
||||||
w = min(self.console.width, 80)
|
w = self.console.width
|
||||||
_cprint(f"{_GOLD}{'─' * w}{_RST}")
|
_cprint(f"{_GOLD}{'─' * w}{_RST}")
|
||||||
print(flush=True)
|
print(flush=True)
|
||||||
|
|
||||||
|
|
@ -1506,7 +1506,11 @@ class HermesCLI:
|
||||||
|
|
||||||
# Drain any remaining agent output still in the StdoutProxy
|
# Drain any remaining agent output still in the StdoutProxy
|
||||||
# buffer so tool/status lines render ABOVE our response box.
|
# buffer so tool/status lines render ABOVE our response box.
|
||||||
|
# The flush pushes data into the renderer queue; the short
|
||||||
|
# sleep lets the renderer actually paint it before we draw.
|
||||||
|
import time as _time
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
|
_time.sleep(0.15)
|
||||||
|
|
||||||
# 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
|
||||||
|
|
@ -1528,7 +1532,7 @@ class HermesCLI:
|
||||||
response = response + "\n\n---\n_[Interrupted - processing new message]_"
|
response = response + "\n\n---\n_[Interrupted - processing new message]_"
|
||||||
|
|
||||||
if response:
|
if response:
|
||||||
w = min(self.console.width, 80)
|
w = self.console.width
|
||||||
label = " ⚕ Hermes "
|
label = " ⚕ Hermes "
|
||||||
fill = w - 2 - len(label) # 2 for ╭ and ╮
|
fill = w - 2 - len(label) # 2 for ╭ and ╮
|
||||||
top = f"{_GOLD}╭─{label}{'─' * max(fill - 1, 0)}╮{_RST}"
|
top = f"{_GOLD}╭─{label}{'─' * max(fill - 1, 0)}╮{_RST}"
|
||||||
|
|
@ -1536,7 +1540,7 @@ class HermesCLI:
|
||||||
|
|
||||||
# Render box + response as a single _cprint call so
|
# Render box + response as a single _cprint call so
|
||||||
# nothing can interleave between the box borders.
|
# nothing can interleave between the box borders.
|
||||||
_cprint(f"\n{top}\n\n{response}\n\n{bot}")
|
_cprint(f"\n{top}\n{response}\n\n{bot}")
|
||||||
|
|
||||||
# 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