From 7d82ef1acfa2cf6a9018b0be328e57c62931e54b Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Fri, 17 Apr 2026 13:06:02 +0200 Subject: [PATCH] Handle client-side errors in message sending and update UI accordingly --- src/App.jsx | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/App.jsx b/src/App.jsx index 45f2d51..a94da06 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -2573,6 +2573,23 @@ async function sendMessage() { } console.error('Failed to send message:', error) + if (Number(error?.status) >= 400 && Number(error?.status) < 500) { + setAssistantMessageContent(targetSessionId, assistantMsgId, fullReply, { removeIfEmpty: true }) + setChatSessions(prevSessions => + prevSessions.map(session => + session.session_id === targetSessionId + ? { + ...session, + messages: (session.messages || []).filter(message => message.id !== userMsg.id), + } + : session + ) + ) + setInput(composerSnapshot) + setComposerAttachments(attachmentSnapshot) + window.alert(getErrorText(error)) + return + } setAssistantMessageContent(targetSessionId, assistantMsgId, 'Error: ' + getErrorText(error), { removeIfEmpty: true }) return }