From c2c65973f97113820eae8c2cd7be4b7a67726351 Mon Sep 17 00:00:00 2001 From: Dayuan Jiang <34411969+DayuanJiang@users.noreply.github.com> Date: Fri, 12 Dec 2025 14:08:20 +0900 Subject: [PATCH] fix: revert UI and notify user when feedback submission fails (#237) When feedback submission to the API fails, revert the optimistic UI update and show a toast notification to inform the user. Changes: - Add toast import from sonner - Change console.warn to console.error for proper logging - Add toast.error() notification when API call fails - Revert optimistic UI update by removing feedback from state Previously, feedback submission failures were completely silent. Users would see the thumbs-up/down visual feedback but their feedback was never recorded. This creates a false sense that the feedback was successfully submitted. Now users are immediately notified when submission fails and can retry their feedback. --- components/chat-message-display.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/components/chat-message-display.tsx b/components/chat-message-display.tsx index 8b4c92a..f4b2dc7 100644 --- a/components/chat-message-display.tsx +++ b/components/chat-message-display.tsx @@ -270,7 +270,14 @@ export function ChatMessageDisplay({ }), }) } catch (error) { - console.warn("Failed to log feedback:", error) + console.error("Failed to log feedback:", error) + toast.error("Failed to record your feedback. Please try again.") + // Revert optimistic UI update + setFeedback((prev) => { + const next = { ...prev } + delete next[messageId] + return next + }) } }