diff --git a/surfsense_web/components/public-chat-snapshots/public-chat-snapshot-row.tsx b/surfsense_web/components/public-chat-snapshots/public-chat-snapshot-row.tsx index e1fdb5605..1e7de9f23 100644 --- a/surfsense_web/components/public-chat-snapshots/public-chat-snapshot-row.tsx +++ b/surfsense_web/components/public-chat-snapshots/public-chat-snapshot-row.tsx @@ -1,7 +1,8 @@ "use client"; -import { Copy, ExternalLink, MessageSquare, Trash2 } from "lucide-react"; +import { Check, Copy, ExternalLink, MessageSquare, Trash2 } from "lucide-react"; import Image from "next/image"; +import { useCallback, useRef, useState } from "react"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { Card, CardContent } from "@/components/ui/card"; @@ -33,6 +34,16 @@ export function PublicChatSnapshotRow({ isDeleting = false, memberMap, }: PublicChatSnapshotRowProps) { + const [copied, setCopied] = useState(false); + const copyTimeoutRef = useRef>(); + + const handleCopyClick = useCallback(() => { + onCopy(snapshot); + setCopied(true); + clearTimeout(copyTimeoutRef.current); + copyTimeoutRef.current = setTimeout(() => setCopied(false), 2000); + }, [onCopy, snapshot]); + const formattedDate = new Date(snapshot.created_at).toLocaleDateString(undefined, { year: "numeric", month: "short", @@ -63,27 +74,18 @@ export function PublicChatSnapshotRow({ - Copy link - - - - - - - - - Open link @@ -108,18 +110,47 @@ export function PublicChatSnapshotRow({ - {/* Message count badge */} -
- - - {snapshot.message_count} messages - -
+ {/* Message count badge */} +
+ + + {snapshot.message_count} messages + +
- {/* Footer: Date + Creator */} + {/* Public URL – selectable fallback for manual copy */} +
+

+ {snapshot.public_url} +

+ + + + + + {copied ? "Copied!" : "Copy link"} + + +
+ + {/* Footer: Date + Creator */}
{formattedDate} diff --git a/surfsense_web/components/public-chat-snapshots/public-chat-snapshots-list.tsx b/surfsense_web/components/public-chat-snapshots/public-chat-snapshots-list.tsx index 8daf9a07f..7a07c62ee 100644 --- a/surfsense_web/components/public-chat-snapshots/public-chat-snapshots-list.tsx +++ b/surfsense_web/components/public-chat-snapshots/public-chat-snapshots-list.tsx @@ -26,7 +26,7 @@ export function PublicChatSnapshotsList({ } return ( -
+
{snapshots.map((snapshot) => ( { const publicUrl = `${window.location.origin}/public/${snapshot.share_token}`; navigator.clipboard.writeText(publicUrl); - toast.success("Link copied to clipboard"); }, []); const handleDelete = useCallback( @@ -90,7 +89,7 @@ export function PublicChatSnapshotsManager({ {/* Cards grid skeleton */} -
+
{["skeleton-a", "skeleton-b", "skeleton-c"].map((key) => ( @@ -98,11 +97,13 @@ export function PublicChatSnapshotsManager({
- {/* Message count badge */} -
- -
- {/* Footer: Date + Creator */} + {/* Message count badge */} +
+ +
+ {/* URL skeleton */} + + {/* Footer: Date + Creator */}