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 paste handling in ChatInput component

Salman-Ahamedf828de05da45
diff --git a/packages/app/src/react/features/ai-chat/components/input.tsx b/packages/app/src/react/features/ai-chat/components/input.tsx
index 4ffd7067..7ac9980d 100644
--- a/packages/app/src/react/features/ai-chat/components/input.tsx
+++ b/packages/app/src/react/features/ai-chat/components/input.tsx
@@ -167,17 +167,17 @@ export const ChatInput = forwardRef<ChatInputRef, ChatInputProps>(
const handlePaste = (e: ClipboardEvent<HTMLTextAreaElement>) => {
e.preventDefault();
const pasted = e.clipboardData.getData('text/plain');
- const text = message ? `${message} ${pasted}` : pasted;
+
if (pasted.length >= LARGE_TEXT_THRESHOLD) {
- const file = createFileFromText(text);
+ const file = createFileFromText(pasted);
handleFileDrop([file.file]);
setMessage('');
- } else setMessage(text);
+ } else setMessage(pasted);
setTimeout(() => {
if (inputRef.current) {
inputRef.current.scrollTop = inputRef.current.scrollHeight;
inputRef.current.selectionStart = inputRef.current.selectionEnd =
- pasted.length >= LARGE_TEXT_THRESHOLD ? 0 : text.length;
+ pasted.length >= LARGE_TEXT_THRESHOLD ? 0 : pasted.length;
}
}, 0);
};