From c591e82d8d08d921dcfc3a282a7b11522f1ba675 Mon Sep 17 00:00:00 2001 From: Mahesh Sanikommu Date: Fri, 5 Jun 2026 13:57:17 -0700 Subject: [PATCH] fix(nova): keep user message when stopping generation early Clicking stop before the first assistant token streamed in deleted the triggering user message: handleStop unconditionally sliced off a trailing user message, which during the submitted/thinking window is the user's own message. Drop the slice so the message is preserved on stop. ENG-732 --- apps/web/components/chat/index.tsx | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/apps/web/components/chat/index.tsx b/apps/web/components/chat/index.tsx index 80e933bb7..ae02e2c18 100644 --- a/apps/web/components/chat/index.tsx +++ b/apps/web/components/chat/index.tsx @@ -549,16 +549,11 @@ export function ChatSidebar({ } } - // When the user stops generation before any assistant response arrives, - // remove the dangling user message so it isn't duplicated on the next send. + // Keep the user message on stop so it isn't lost when generation is halted + // before any assistant response arrives (ENG-732). const handleStop = useCallback(() => { stop() - setMessages((prev) => { - const last = prev[prev.length - 1] - if (last?.role === "user") return prev.slice(0, -1) - return prev - }) - }, [stop, setMessages]) + }, [stop]) const handleCopyMessage = useCallback((messageId: string, text: string) => { analytics.chatMessageCopied({ message_id: messageId })