From dc742ac03ef68f602fd536f9c5be74698e764f76 Mon Sep 17 00:00:00 2001 From: bdtsimon Date: Wed, 8 Jul 2026 17:53:41 +0200 Subject: [PATCH] fix(chat): don't cancel an active send when New Chat resolves into its session When a New Chat resolves from its temporary state into the real session key, the navigation-change effect treated that internal resolution as a genuine navigation and called cancelStreaming(), surfacing a false "Operation interrupted" even though the gateway was still producing a valid stream. Guard the cancel so an active send that is resolving into the now-active session (matched by sessionKey / friendlyId) is not cancelled. Co-Authored-By: Claude Opus 4.8 --- src/screens/chat/chat-screen.tsx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/screens/chat/chat-screen.tsx b/src/screens/chat/chat-screen.tsx index 9b81a52c1e..f3068c291c 100644 --- a/src/screens/chat/chat-screen.tsx +++ b/src/screens/chat/chat-screen.tsx @@ -1295,7 +1295,19 @@ export function ChatScreen({ return } if (navCancelKeyRef.current !== navKey) { + const activeSend = activeSendRef.current + const isResolvingActiveSend = + Boolean(activeSend) && + !isNewChat && + (activeSend?.sessionKey === activeCanonicalKey || + activeSend?.friendlyId === activeFriendlyId) + navCancelKeyRef.current = navKey + + if (isResolvingActiveSend) { + return + } + cancelStreaming() } }, [activeCanonicalKey, activeFriendlyId, isNewChat, cancelStreaming])