fix(cli): refresh TUI before background task output to prevent status bar overlap (#3048)
When a background task (/bg command) prints its output while the main agent is processing with the thinking spinner visible, the status bar could render on the same row as the spinner, causing visual overlap. This fix adds an explicit app.invalidate() call with a brief pause before printing background task output, ensuring the TUI layout is in a consistent state before the output is written. Changes: - Add TUI refresh before success output in _handle_background_command - Add TUI refresh before error output in the exception handler - Add tests for the refresh behavior Closes #2718 Co-authored-by: Bartok9 <bartokmagic@proton.me>
This commit is contained in:
13
cli.py
13
cli.py
@@ -4029,7 +4029,13 @@ class HermesCLI:
|
||||
if not response and result and result.get("error"):
|
||||
response = f"Error: {result['error']}"
|
||||
|
||||
# Display result in the CLI (thread-safe via patch_stdout)
|
||||
# Display result in the CLI (thread-safe via patch_stdout).
|
||||
# Force a TUI refresh first so spinner/status bar don't overlap
|
||||
# with the output (fixes #2718).
|
||||
if self._app:
|
||||
self._app.invalidate()
|
||||
import time as _tmod
|
||||
_tmod.sleep(0.05) # brief pause for refresh
|
||||
print()
|
||||
ChatConsole().print(f"[{_accent_hex()}]{'─' * 40}[/]")
|
||||
_cprint(f" ✅ Background task #{task_num} complete")
|
||||
@@ -4066,6 +4072,11 @@ class HermesCLI:
|
||||
sys.stdout.flush()
|
||||
|
||||
except Exception as e:
|
||||
# Same TUI refresh pattern as success path (#2718)
|
||||
if self._app:
|
||||
self._app.invalidate()
|
||||
import time as _tmod
|
||||
_tmod.sleep(0.05)
|
||||
print()
|
||||
_cprint(f" ❌ Background task #{task_num} failed: {e}")
|
||||
finally:
|
||||
|
||||
Reference in New Issue
Block a user