From e77ffb42b01d8ef65651d649fa8462da30e7858e Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Mon, 2 Feb 2026 19:51:05 +0000 Subject: [PATCH] Clear queued message input Co-authored-by: me --- .../_app+/recipients+/$recipientId.index.tsx | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/app/routes/_app+/recipients+/$recipientId.index.tsx b/app/routes/_app+/recipients+/$recipientId.index.tsx index 042c5c87..f3877b83 100644 --- a/app/routes/_app+/recipients+/$recipientId.index.tsx +++ b/app/routes/_app+/recipients+/$recipientId.index.tsx @@ -300,6 +300,22 @@ export default function RecipientRoute() { const data = useLoaderData() const newMessageFetcher = useFetcher() const isCreating = newMessageFetcher.state !== 'idle' + const newMessageInputRef = useRef(null) + const shouldClearMessageInput = useRef(false) + + useEffect(() => { + if (newMessageFetcher.state !== 'idle') { + shouldClearMessageInput.current = true + return + } + if (!shouldClearMessageInput.current) return + + const hasErrors = Boolean(newMessageFetcher.data?.result?.error) + if (!hasErrors && newMessageInputRef.current) { + newMessageInputRef.current.value = '' + } + shouldClearMessageInput.current = false + }, [newMessageFetcher.state, newMessageFetcher.data]) return (
@@ -341,6 +357,7 @@ export default function RecipientRoute() {