diff --git a/client/src/components/Chat/ChatView.tsx b/client/src/components/Chat/ChatView.tsx
index dbf39ee84535..0ed1eeb592c6 100644
--- a/client/src/components/Chat/ChatView.tsx
+++ b/client/src/components/Chat/ChatView.tsx
@@ -1,7 +1,7 @@
import { memo, useCallback } from 'react';
import { useRecoilValue } from 'recoil';
import { useForm } from 'react-hook-form';
-import { useParams } from 'react-router-dom';
+import { useParams, useSearchParams } from 'react-router-dom';
import { useGetMessagesByConvoId } from 'librechat-data-provider/react-query';
import type { TMessage } from 'librechat-data-provider';
import type { ChatFormValues } from '~/common';
@@ -19,10 +19,12 @@ import store from '~/store';
function ChatView({ index = 0 }: { index?: number }) {
const { conversationId } = useParams();
+ const [searchParams] = useSearchParams();
const rootSubmission = useRecoilValue(store.submissionByIndex(index));
const addedSubmission = useRecoilValue(store.submissionByIndex(index + 1));
const fileMap = useFileMapContext();
+ const initialMessage = searchParams.get('initialMessage');
const { data: messagesTree = null, isLoading } = useGetMessagesByConvoId(conversationId ?? '', {
select: useCallback(
@@ -65,7 +67,7 @@ function ChatView({ index = 0 }: { index?: number }) {
{content}
-
+
diff --git a/client/src/components/Chat/Input/ChatForm.tsx b/client/src/components/Chat/Input/ChatForm.tsx
index 442d32a45e2a..783eceeefb01 100644
--- a/client/src/components/Chat/Input/ChatForm.tsx
+++ b/client/src/components/Chat/Input/ChatForm.tsx
@@ -36,7 +36,7 @@ import SendButton from './SendButton';
import Mention from './Mention';
import store from '~/store';
-const ChatForm = ({ index = 0 }) => {
+const ChatForm = ({ index = 0, initialMessage = '' }: { index?: number; initialMessage?: string | null }) => {
const submitButtonRef = useRef(null);
const textAreaRef = useRef(null);
useQueryParams({ textAreaRef });
@@ -130,6 +130,12 @@ const ChatForm = ({ index = 0 }) => {
},
});
+ useEffect(() => {
+ if (initialMessage) {
+ methods.setValue('text', initialMessage);
+ }
+ }, [initialMessage, methods]);
+
useEffect(() => {
if (!isSearching && textAreaRef.current && !disableInputs) {
textAreaRef.current.focus();