Skip to content

Commit b9ba6e3

Browse files
Reintroduce copy button for AI text output (#615)
1 parent 4cd3cda commit b9ba6e3

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

lib/user-interface/react-app/src/components/chatbot/chat-message.tsx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import {
33
Container,
44
Spinner,
55
TextContent,
6+
Button,
7+
Popover,
8+
StatusIndicator,
69
} from "@cloudscape-design/components";
710
import { useContext, useEffect, useState, useCallback } from "react";
811
import ReactMarkdown from "react-markdown";
@@ -212,6 +215,30 @@ export default function ChatMessage(props: ChatMessageProps) {
212215
)
213216
}
214217
>
218+
{props.message.content.length > 0 && (
219+
<div className={styles.btn_chabot_message_copy}>
220+
<Popover
221+
data-locator="copy-clipboard"
222+
size="medium"
223+
position="top"
224+
triggerType="custom"
225+
dismissButton={false}
226+
content={
227+
<StatusIndicator type="success">
228+
Copied to clipboard
229+
</StatusIndicator>
230+
}
231+
>
232+
<Button
233+
variant="inline-icon"
234+
iconName="copy"
235+
onClick={() => {
236+
navigator.clipboard.writeText(props.message.content);
237+
}}
238+
/>
239+
</Popover>
240+
</div>
241+
)}
215242
{loading ||
216243
(content.length === 0 && !processingAsyncFiles && !files.length) ? (
217244
<Box>

0 commit comments

Comments
 (0)