mirror of
https://github.com/DayuanJiang/next-ai-draw-io.git
synced 2026-01-02 22:32:27 +08:00
fix: add user feedback for clipboard copy failures (#236)
Add toast notification when clipboard copy operation fails, so users know when their copy attempt was unsuccessful. Changes: - Add toast import from sonner - Add toast.error() notification when clipboard copy fails - Show clear message: "Failed to copy message. Please copy manually or check clipboard permissions." Previously, clipboard copy failures were only indicated by a brief visual state change (setCopyFailedMessageId), which users might miss. Now users receive persistent feedback when copy operations fail.
This commit is contained in:
@@ -22,6 +22,7 @@ import Image from "next/image"
|
||||
import type { MutableRefObject } from "react"
|
||||
import { useCallback, useEffect, useRef, useState } from "react"
|
||||
import ReactMarkdown from "react-markdown"
|
||||
import { toast } from "sonner"
|
||||
import {
|
||||
Reasoning,
|
||||
ReasoningContent,
|
||||
@@ -234,6 +235,9 @@ export function ChatMessageDisplay({
|
||||
setTimeout(() => setCopiedMessageId(null), 2000)
|
||||
} catch (fallbackErr) {
|
||||
console.error("Failed to copy message:", fallbackErr)
|
||||
toast.error(
|
||||
"Failed to copy message. Please copy manually or check clipboard permissions.",
|
||||
)
|
||||
setCopyFailedMessageId(messageId)
|
||||
setTimeout(() => setCopyFailedMessageId(null), 2000)
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user