Skip to content

Commit 074eaae

Browse files
jon-bellclaude
andauthored
Preserve message content when chat send fails (#605)
When users try to send a message while disconnected from the chat, the message was being cleared even though it failed to send. This was because handleSendMessage returned early without throwing an error, so the .then() block in MessageInput executed and cleared the input. Now handleSendMessage throws an error when not connected, which is caught by MessageInput's error handler, preserving the user's message in the input box so they don't lose their typed content. https://claude.ai/code/session_012EqUZa3tCdhg3hHkBQkDdg Co-authored-by: Claude <noreply@anthropic.com>
1 parent 44dd4ea commit 074eaae

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

components/realtime-chat.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,7 @@ export const RealtimeChat = ({
244244
const handleSendMessage = useCallback(
245245
async (message: string) => {
246246
if (!isConnected) {
247-
toaster.error({
248-
title: "Not connected to chat",
249-
description: "Please wait for the chat to connect before sending messages."
250-
});
251-
return;
247+
throw new Error("Please wait for the chat to connect before sending messages.");
252248
}
253249
if (!message.trim() || !sendMessage || moderationStatus.isBanned) return;
254250

0 commit comments

Comments
 (0)