Skip to content

SmythOS Studio: Open-Source Visual AI Agent Builder and deployable runtime stack from SmythOS. Start with an intuitive drag-and-drop workspace, extend with custom code, and deploy your agents anywhere — local, cloud, or edge — with full governance and control.

Refactor SystemMessage Component to Remove Copy Button Functionality

Salman-Ahamed106505a9542e
diff --git a/packages/app/src/react/features/ai-chat/components/system-message.tsx b/packages/app/src/react/features/ai-chat/components/system-message.tsx
index 3f7f2e25..82cb434a 100644
--- a/packages/app/src/react/features/ai-chat/components/system-message.tsx
+++ b/packages/app/src/react/features/ai-chat/components/system-message.tsx
@@ -1,6 +1,4 @@
-import { Tooltip } from 'flowbite-react';
-import { FC, useRef, useState } from 'react';
-import { FaCheck, FaRegCopy } from 'react-icons/fa6';
+import { FC, useRef } from 'react';
import {
ErrorMessage,
@@ -19,7 +17,6 @@ interface ISystemMessageProps {
typingAnimation?: boolean;
onTypingComplete?: () => void;
onTypingProgress?: () => void;
- showCopyButton?: boolean; // Control copy button visibility (default: true)
}
export const SystemMessage: FC<ISystemMessageProps> = (props) => {
@@ -33,30 +30,9 @@ export const SystemMessage: FC<ISystemMessageProps> = (props) => {
onTypingComplete,
onTypingProgress,
typingAnimation = true,
- showCopyButton = true, // Default to true for backward compatibility
} = props;
- const [copied, setCopied] = useState(false);
- const contentRef = useRef<HTMLDivElement>(null);
-
- const handleCopy = () => {
- if (contentRef.current) {
- const range = document.createRange();
- range.selectNodeContents(contentRef.current);
- const selection = window.getSelection();
- selection?.removeAllRanges();
- selection?.addRange(range);
-
- try {
- document.execCommand('copy');
- setCopied(true);
- setTimeout(() => setCopied(false), 2000);
- } catch (err) {
- console.error('Failed to copy text: ', err); // eslint-disable-line no-console
- }
- selection?.removeAllRanges();
- }
- };
+ const contentRef = useRef<HTMLDivElement>(null);
return (
<div className="system-message-bubble relative">
@@ -81,19 +57,6 @@ export const SystemMessage: FC<ISystemMessageProps> = (props) => {
{/* Display thinking message inline if present */}
{thinkingMessage && <ThinkingMessage message={thinkingMessage} avatar={avatar} />}
-
- {!isError && !thinkingMessage && showCopyButton && (
- <div className="pt-2.5">
- <Tooltip content={copied ? 'Copied!' : 'Copy'} placement="bottom">
- <button
- onClick={handleCopy}
- className="text-gray-500 hover:text-gray-700 transition-colors"
- >
- {copied ? <FaCheck /> : <FaRegCopy />}
- </button>
- </Tooltip>
- </div>
- )}
</div>
)}
</div>