From 71ce87d836a8a4df45f888dfb1f4ffb3eec318a9 Mon Sep 17 00:00:00 2001 From: Dave Date: Sat, 27 Dec 2025 18:39:28 +0000 Subject: [PATCH] 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 --- .../{ => archive}/15_new_session_cancellation.md | 0 src/components/Chat.tsx | 10 ++++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) rename .living_spec/stories/{ => archive}/15_new_session_cancellation.md (100%) diff --git a/.living_spec/stories/15_new_session_cancellation.md b/.living_spec/stories/archive/15_new_session_cancellation.md similarity index 100% rename from .living_spec/stories/15_new_session_cancellation.md rename to .living_spec/stories/archive/15_new_session_cancellation.md diff --git a/src/components/Chat.tsx b/src/components/Chat.tsx index 9545780..d2c8815 100644 --- a/src/components/Chat.tsx +++ b/src/components/Chat.tsx @@ -197,11 +197,17 @@ export function Chat({ projectPath, onCloseProject }: ChatProps) { ); 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([]); setStreamingContent(""); setLoading(false); - // TODO: Add backend call to cancel in-flight requests and clear context - // invoke("cancel_chat").catch(console.error); } };