mirror of
https://github.com/outbackdingo/optimclaw.git
synced 2026-08-27 08:00:17 +00:00
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:
co-authored by
Claude Opus 4.5
parent
b52122a275
commit
9232e623e8
@@ -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(());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user