|
236 | 236 | async submitFeedback(messageIndex, feedbackType) { |
237 | 237 | const message = this.messages[messageIndex] |
238 | 238 |
|
239 | | - if (!message.questionAnswerId) { |
240 | | - console.error('No question_answer_id available for feedback') |
| 239 | + if (message.feedback === feedbackType) { |
241 | 240 | return |
242 | 241 | } |
243 | 242 |
|
244 | | - if (message.feedback === feedbackType) { |
| 243 | + // Clear any previous error |
| 244 | + message.feedbackError = null |
| 245 | +
|
| 246 | + if (!message.questionAnswerId) { |
| 247 | + message.feedbackError = 'Unable to submit feedback' |
| 248 | + console.error('No question_answer_id available for feedback') |
245 | 249 | return |
246 | 250 | } |
247 | 251 |
|
|
258 | 262 | if (response.ok) { |
259 | 263 | message.feedback = feedbackType // $persist auto-saves |
260 | 264 | } else { |
| 265 | + message.feedbackError = 'Unable to submit feedback' |
261 | 266 | console.error('Failed to submit feedback:', response.status, response.statusText) |
262 | 267 | } |
263 | 268 | } catch (err) { |
| 269 | + message.feedbackError = 'Unable to submit feedback' |
264 | 270 | console.error('Error submitting feedback:', err) |
265 | 271 | } |
266 | 272 | }, |
@@ -372,7 +378,7 @@ <h3 class="mb-2 text-xl font-semibold text-gray-900 dark:text-white"> |
372 | 378 | </template> |
373 | 379 | </div> |
374 | 380 | <!-- Feedback buttons for assistant messages --> |
375 | | - <template x-if="message.role === 'assistant' && !message.isStreaming && message.questionAnswerId"> |
| 381 | + <template x-if="message.role === 'assistant' && !message.isStreaming"> |
376 | 382 | <div class="flex items-center gap-2 text-xs"> |
377 | 383 | <div class="flex items-center gap-1"> |
378 | 384 | <!-- Copy button --> |
@@ -414,6 +420,9 @@ <h3 class="mb-2 text-xl font-semibold text-gray-900 dark:text-white"> |
414 | 420 | Thanks for your feedback! |
415 | 421 | </span> |
416 | 422 | </template> |
| 423 | + <template x-if="message.feedbackError"> |
| 424 | + <span class="text-red-600 dark:text-red-400" x-text="message.feedbackError"></span> |
| 425 | + </template> |
417 | 426 | </div> |
418 | 427 | </template> |
419 | 428 | </div> |
|
0 commit comments