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.
This commit is contained in:
Dayuan Jiang
2025-12-12 14:08:20 +09:00
committed by GitHub
parent b5db980f69
commit c2c65973f9

View File

@@ -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
})
}
}