From c283313bb8576a44aa8043341dc18563b7ddb3e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20G=C3=B3mez?= Date: Tue, 17 Mar 2026 09:22:02 +0100 Subject: [PATCH] fix: clean reply state synchronously and cleanly --- src/components/ChatViewer.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/components/ChatViewer.tsx b/src/components/ChatViewer.tsx index baa7190..9ad0914 100644 --- a/src/components/ChatViewer.tsx +++ b/src/components/ChatViewer.tsx @@ -742,6 +742,9 @@ export function ChatViewer({ toast.error(errorMessage); } finally { setIsSending(false); + // Clear reply context after slash command execution + replyToRef.current = undefined; + setReplyTo(undefined); } return; } @@ -754,7 +757,10 @@ export function ChatViewer({ emojiTags, blobAttachments, }); - setReplyTo(undefined); // Clear reply context only on success + // Clear reply context immediately (ref + state) so the next send + // cannot read a stale value before React re-renders. + replyToRef.current = undefined; + setReplyTo(undefined); } catch (error) { console.error("[Chat] Failed to send message:", error); const errorMessage =