From 6cb00c28d7cd0b1a822bf88f405674392bfb3bfa Mon Sep 17 00:00:00 2001 From: Aaron Nelson Date: Sun, 26 Apr 2026 17:33:33 -0400 Subject: [PATCH] =?UTF-8?q?Copy=20button=20=E2=80=94=20on=20all=20messages?= =?UTF-8?q?,=20Copied!=20feedback,=20checkmark=20icon?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/MessageList.tsx | 84 +++++++++++++++++++++++--------------- 1 file changed, 50 insertions(+), 34 deletions(-) diff --git a/components/MessageList.tsx b/components/MessageList.tsx index 4a587aa..0f25af2 100644 --- a/components/MessageList.tsx +++ b/components/MessageList.tsx @@ -1,9 +1,57 @@ 'use client'; -import { useEffect, useRef } from 'react'; +import { useEffect, useRef, useState } from 'react'; import { useStore } from '@/lib/store'; import { renderMarkdown } from '@/lib/markdown'; +function CopyRow({ content, sources }: { content: string; sources: string[] }) { + const [copied, setCopied] = useState(false); + function copy() { + navigator.clipboard.writeText(content).then(() => { + setCopied(true); + setTimeout(() => setCopied(false), 2000); + }); + } + return ( +
+ + {sources && sources.length > 0 && ( +
+ Sources: {[...new Set(sources)].join(', ')} +
+ )} +
+ ); +} + export default function MessageList() { const { messages, isLoading } = useStore(); const bottomRef = useRef(null); @@ -60,39 +108,7 @@ export default function MessageList() { {m.content} )} -
- {m.role === 'assistant' && ( - - )} - {m.sources && m.sources.length > 0 && ( -
- Sources: {[...new Set(m.sources)].join(', ')} -
- )} -
+ ))}