@@ -28,6 +28,7 @@ import type {
2828 RequestBody ,
2929 ToolCallResult ,
3030} from "./_types/types" ;
31+ import { INITIAL_ASSISTANT_MESSAGE } from "./_types/types" ;
3132
3233function ChatPage ( ) {
3334 const isDebugMode = process . env . NEXT_PUBLIC_OPENRAG_DEBUG === "true" ;
@@ -52,11 +53,7 @@ function ChatPage() {
5253 setLoading,
5354 } = useChat ( ) ;
5455 const [ messages , setMessages ] = useState < Message [ ] > ( [
55- {
56- role : "assistant" ,
57- content : "How can I assist?" ,
58- timestamp : new Date ( ) ,
59- } ,
56+ INITIAL_ASSISTANT_MESSAGE ,
6057 ] ) ;
6158 const [ input , setInput ] = useState ( "" ) ;
6259 const { setChatError } = useChat ( ) ;
@@ -327,13 +324,7 @@ function ChatPage() {
327324 // Abort any in-flight streaming so it doesn't bleed into new chat
328325 abortStream ( ) ;
329326 // Reset chat UI even if context state was already 'new'
330- setMessages ( [
331- {
332- role : "assistant" ,
333- content : "How can I assist?" ,
334- timestamp : new Date ( ) ,
335- } ,
336- ] ) ;
327+ setMessages ( [ INITIAL_ASSISTANT_MESSAGE ] ) ;
337328 setInput ( "" ) ;
338329 setExpandedFunctionCalls ( new Set ( ) ) ;
339330 setIsFilterHighlighted ( false ) ;
@@ -571,13 +562,7 @@ function ChatPage() {
571562 useEffect ( ( ) => {
572563 if ( placeholderConversation && currentConversationId === null ) {
573564 console . log ( "Starting new conversation" ) ;
574- setMessages ( [
575- {
576- role : "assistant" ,
577- content : "How can I assist?" ,
578- timestamp : new Date ( ) ,
579- } ,
580- ] ) ;
565+ setMessages ( [ INITIAL_ASSISTANT_MESSAGE ] ) ;
581566 lastLoadedConversationRef . current = null ;
582567
583568 // Focus input when starting a new conversation
@@ -1054,9 +1039,11 @@ function ChatPage() {
10541039 isInitialGreeting = {
10551040 index === 0 &&
10561041 messages . length === 1 &&
1057- message . content === "How can I assist?"
1042+ message . content ===
1043+ INITIAL_ASSISTANT_MESSAGE . content
10581044 }
10591045 usage = { message . usage }
1046+ timestamp = { message . timestamp }
10601047 />
10611048 ) }
10621049 </ div >
0 commit comments