11import { memo , useCallback } from 'react' ;
22import { useRecoilValue } from 'recoil' ;
33import { useForm } from 'react-hook-form' ;
4- import { useParams } from 'react-router-dom' ;
4+ import { useParams , useSearchParams } from 'react-router-dom' ;
55import { useGetMessagesByConvoId } from 'librechat-data-provider/react-query' ;
66import type { TMessage } from 'librechat-data-provider' ;
77import type { ChatFormValues } from '~/common' ;
@@ -19,10 +19,12 @@ import store from '~/store';
1919
2020function ChatView ( { index = 0 } : { index ?: number } ) {
2121 const { conversationId } = useParams ( ) ;
22+ const [ searchParams ] = useSearchParams ( ) ;
2223 const rootSubmission = useRecoilValue ( store . submissionByIndex ( index ) ) ;
2324 const addedSubmission = useRecoilValue ( store . submissionByIndex ( index + 1 ) ) ;
2425
2526 const fileMap = useFileMapContext ( ) ;
27+ const initialMessage = searchParams . get ( 'initialMessage' ) ;
2628
2729 const { data : messagesTree = null , isLoading } = useGetMessagesByConvoId ( conversationId ?? '' , {
2830 select : useCallback (
@@ -65,7 +67,7 @@ function ChatView({ index = 0 }: { index?: number }) {
6567 < Presentation >
6668 { content }
6769 < div className = "w-full border-t-0 pl-0 pt-2 dark:border-white/20 md:w-[calc(100%-.5rem)] md:border-t-0 md:border-transparent md:pl-0 md:pt-0 md:dark:border-transparent" >
68- < ChatForm index = { index } />
70+ < ChatForm index = { index } initialMessage = { initialMessage } />
6971 < Footer />
7072 </ div >
7173 </ Presentation >
0 commit comments