Fix TUI shutdown: send /shutdown message and handle in agent loop

When the TUI quits (Ctrl+D twice), it now:
1. Sends a "/shutdown" message through the channel before closing
2. Explicitly drops msg_tx to ensure channel closure

The agent loop now:
1. Returns Option<String> from handle_message (None = shutdown)
2. Handles /quit, /exit, /shutdown commands by returning None
3. Breaks out of the main loop on shutdown signal
4. Lists /quit in help menu

Co-Authored-By: Claude Opus 4.5 <[email protected]>
This commit is contained in:
Illia Polosukhin
2026-02-02 23:59:28 -08:00
co-authored by Claude Opus 4.5
parent b52122a275
commit 9232e623e8
2 changed files with 58 additions and 33 deletions
+6 -1
View File
@@ -26,8 +26,13 @@ pub fn run_event_loop(
// Render
terminal.draw(|f| render::render(f, app))?;
// Check for quit
// Check for quit - send shutdown signal and exit
if app.should_quit {
// Send a shutdown message so the agent loop knows to exit
let shutdown_msg = IncomingMessage::new("tui", "system", "/shutdown");
let _ = msg_tx.blocking_send(shutdown_msg);
// Explicitly drop to close the channel
drop(msg_tx);
return Ok(());
}