From dfbf3a2439b87d0274985be02255d4cdde815b61 Mon Sep 17 00:00:00 2001 From: Shahed Nasser Date: Thu, 13 Nov 2025 16:26:57 +0200 Subject: [PATCH] docs: add a copy button to AI assistant answers --- .../AiAssistant/ThreadItem/Actions/index.tsx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/www/packages/docs-ui/src/components/AiAssistant/ThreadItem/Actions/index.tsx b/www/packages/docs-ui/src/components/AiAssistant/ThreadItem/Actions/index.tsx index bbd494d2723f0..2c5da51ba6aba 100644 --- a/www/packages/docs-ui/src/components/AiAssistant/ThreadItem/Actions/index.tsx +++ b/www/packages/docs-ui/src/components/AiAssistant/ThreadItem/Actions/index.tsx @@ -6,6 +6,7 @@ import { ThumbUp, Link as LinkIcon, CheckCircle, + SquareTwoStack, } from "@medusajs/icons" import { AiAssistantThreadItem as AiAssistantThreadItemType, @@ -26,9 +27,12 @@ export const AiAssistantThreadItemActions = ({ const { config: { baseUrl }, } = useSiteConfig() - const { handleCopy, isCopied } = useCopy( + const { handleCopy: handleLinkCopy, isCopied: isLinkCopied } = useCopy( `${baseUrl}?query=${encodeURI(item.content)}` ) + const { handleCopy: handleAnswerCopy, isCopied: isAnswerCopied } = useCopy( + item.content + ) const handleFeedback = async ( reaction: Reaction, @@ -55,8 +59,8 @@ export const AiAssistantThreadItemActions = ({ > {item.type === "question" && (
- - {isCopied ? : } + + {isLinkCopied ? : }
)} @@ -74,6 +78,9 @@ export const AiAssistantThreadItemActions = ({ )}
+ + {isAnswerCopied ? : } + {(feedback === null || feedback === "upvote") && ( handleFeedback("upvote", item.question_id)}