diff --git a/ui/components/EmptyChatMessageInput.tsx b/ui/components/EmptyChatMessageInput.tsx index 39d3f16..f509d3d 100644 --- a/ui/components/EmptyChatMessageInput.tsx +++ b/ui/components/EmptyChatMessageInput.tsx @@ -18,6 +18,12 @@ const EmptyChatMessageInput = ({ const inputRef = useRef(null); + // Function to extract query parameter from URL + const getQueryFromURL = () => { + const urlParams = new URLSearchParams(window.location.search); + return urlParams.get('query') || ''; + }; + useEffect(() => { const handleKeyDown = (e: KeyboardEvent) => { const activeElement = document.activeElement; @@ -33,12 +39,19 @@ const EmptyChatMessageInput = ({ } }; + // Handle query parameter on initial load + const initialQuery = getQueryFromURL(); + if (initialQuery) { + setMessage(initialQuery); // Set the query to the message input + sendMessage(initialQuery); // Automatically send the message + } + document.addEventListener('keydown', handleKeyDown); return () => { document.removeEventListener('keydown', handleKeyDown); }; - }, []); + }, [sendMessage]); return (
- {/* */}