Skip to content

Commit 20892ae

Browse files
authored
docs: add a copy button to AI assistant answers (#14052)
1 parent 178b1e2 commit 20892ae

File tree

1 file changed

+10
-3
lines changed
  • www/packages/docs-ui/src/components/AiAssistant/ThreadItem/Actions

1 file changed

+10
-3
lines changed

www/packages/docs-ui/src/components/AiAssistant/ThreadItem/Actions/index.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
ThumbUp,
77
Link as LinkIcon,
88
CheckCircle,
9+
SquareTwoStack,
910
} from "@medusajs/icons"
1011
import {
1112
AiAssistantThreadItem as AiAssistantThreadItemType,
@@ -26,9 +27,12 @@ export const AiAssistantThreadItemActions = ({
2627
const {
2728
config: { baseUrl },
2829
} = useSiteConfig()
29-
const { handleCopy, isCopied } = useCopy(
30+
const { handleCopy: handleLinkCopy, isCopied: isLinkCopied } = useCopy(
3031
`${baseUrl}?query=${encodeURI(item.content)}`
3132
)
33+
const { handleCopy: handleAnswerCopy, isCopied: isAnswerCopied } = useCopy(
34+
item.content
35+
)
3236

3337
const handleFeedback = async (
3438
reaction: Reaction,
@@ -55,8 +59,8 @@ export const AiAssistantThreadItemActions = ({
5559
>
5660
{item.type === "question" && (
5761
<div className="flex gap-docs_0.25 items-center text-medusa-fg-muted">
58-
<ActionButton onClick={handleCopy}>
59-
{isCopied ? <CheckCircle /> : <LinkIcon />}
62+
<ActionButton onClick={handleLinkCopy}>
63+
{isLinkCopied ? <CheckCircle /> : <LinkIcon />}
6064
</ActionButton>
6165
</div>
6266
)}
@@ -74,6 +78,9 @@ export const AiAssistantThreadItemActions = ({
7478
</div>
7579
)}
7680
<div className="flex gap-docs_0.25 items-center text-medusa-fg-muted">
81+
<ActionButton onClick={handleAnswerCopy}>
82+
{isAnswerCopied ? <CheckCircle /> : <SquareTwoStack />}
83+
</ActionButton>
7784
{(feedback === null || feedback === "upvote") && (
7885
<ActionButton
7986
onClick={async () => handleFeedback("upvote", item.question_id)}

0 commit comments

Comments
 (0)