Story 15: Implement New Session cancellation

- Call cancel_chat before clearing session state
- Prevents tools from executing silently in background
- Prevents streaming from leaking into new session
- Uses same cancellation infrastructure as Story 13
- Clean session start with no side effects

Closes Story 15
This commit is contained in:
Dave
2025-12-27 18:39:28 +00:00
parent e1fb0e3d19
commit 71ce87d836
2 changed files with 8 additions and 2 deletions

View File

@@ -197,11 +197,17 @@ export function Chat({ projectPath, onCloseProject }: ChatProps) {
); );
if (confirmed) { if (confirmed) {
// Cancel any in-flight backend requests first
try {
await invoke("cancel_chat");
} catch (e) {
console.error("Failed to cancel chat:", e);
}
// Then clear frontend state
setMessages([]); setMessages([]);
setStreamingContent(""); setStreamingContent("");
setLoading(false); setLoading(false);
// TODO: Add backend call to cancel in-flight requests and clear context
// invoke("cancel_chat").catch(console.error);
} }
}; };