@@ -14,6 +14,7 @@ import "../../styles/prism-material-oceanic.css"
1414import InlineToaster from "../toast/InlineToaster" ;
1515const PlanChat : React . FC < PlanChatProps > = ( {
1616 planData,
17+ loading,
1718 OnChatSubmit
1819} ) => {
1920 // const [messages, setMessages] = useState<{ role: string; content: string }[]>([]);
@@ -25,7 +26,7 @@ const PlanChat: React.FC<PlanChatProps> = ({
2526
2627 const messagesContainerRef = useRef < HTMLDivElement > ( null ) ;
2728 const inputContainerRef = useRef < HTMLDivElement > ( null ) ;
28- const messages = planData . messages || [ ] ;
29+ const messages = planData ? .messages || [ ] ;
2930 const scrollToBottom = ( ) => {
3031 } ;
3132 const clearChat = async ( ) => {
@@ -34,15 +35,18 @@ const PlanChat: React.FC<PlanChatProps> = ({
3435 } ;
3536 return (
3637 < div className = "chat-container" >
37- < div className = "messages" ref = { messagesContainerRef } >
38- < div className = "message-wrapper" >
39- { messages . map ( ( msg , index ) => ( < div key = { index } className = { `message ${ msg . source !== "human" ? "assistant" : "user" } ` } >
40- < Body1 >
41- < div className = "plan-chat-message-content" >
42- < ReactMarkdown remarkPlugins = { [ remarkGfm ] } rehypePlugins = { [ rehypePrism ] } >
43- { msg . content }
44- </ ReactMarkdown >
45- { /* {msg.role === "assistant" && (
38+ { planData && (
39+ < >
40+ < div className = "messages" ref = { messagesContainerRef } >
41+ < div className = "message-wrapper" >
42+
43+ { messages . map ( ( msg , index ) => ( < div key = { index } className = { `message ${ msg . source !== "human" ? "assistant" : "user" } ` } >
44+ < Body1 >
45+ < div className = "plan-chat-message-content" >
46+ < ReactMarkdown remarkPlugins = { [ remarkGfm ] } rehypePlugins = { [ rehypePrism ] } >
47+ { msg . content }
48+ </ ReactMarkdown >
49+ { /* {msg.role === "assistant" && (
4650 <div className="assistant-footer">
4751 <div className="assistant-actions">
4852 <Button
@@ -62,44 +66,43 @@ const PlanChat: React.FC<PlanChatProps> = ({
6266 </div>
6367 </div>
6468 )} */ }
69+ </ div >
70+ </ Body1 >
6571 </ div >
66- </ Body1 >
72+ ) ) } </ div >
6773 </ div >
68- ) ) } </ div >
69- </ div >
70- { showScrollButton && (
71- < Tag
72- onClick = { scrollToBottom }
73- className = "scroll-to-bottom plan-chat-scroll-button"
74- shape = "circular"
75- style = { { bottom : inputHeight } }
76- >
77- Back to bottom
78- </ Tag >
79- ) }
80-
81- < InlineToaster />
82- < div ref = { inputContainerRef } className = "plan-chat-input-container" >
83- < div className = "plan-chat-input-wrapper" >
84- < ChatInput
85- value = { input }
86- onChange = { setInput }
87- onEnter = { ( ) => OnChatSubmit ( input ) }
88- disabledChat = { ! planData . hasHumanClarificationRequest }
89- >
90- < Button
91- appearance = "transparent"
92- onClick = { ( ) => OnChatSubmit ( input ) }
93- icon = { < Send /> }
94- disabled = { ! planData . hasHumanClarificationRequest && ( ! input . trim ( ) ) }
95- />
74+ { showScrollButton && (
75+ < Tag
76+ onClick = { scrollToBottom }
77+ className = "scroll-to-bottom plan-chat-scroll-button"
78+ shape = "circular"
79+ style = { { bottom : inputHeight } }
80+ >
81+ Back to bottom
82+ </ Tag >
83+ ) }
9684
97- </ ChatInput >
98- </ div >
99-
100- </ div >
85+ < InlineToaster />
86+ < div ref = { inputContainerRef } className = "plan-chat-input-container" >
87+ < div className = "plan-chat-input-wrapper" >
88+ < ChatInput
89+ value = { input }
90+ onChange = { setInput }
91+ onEnter = { ( ) => OnChatSubmit ( input ) }
92+ disabledChat = { ! planData . hasHumanClarificationRequest }
93+ >
94+ < Button
95+ appearance = "transparent"
96+ onClick = { ( ) => OnChatSubmit ( input ) }
97+ icon = { < Send /> }
98+ disabled = { ! planData ?. hasHumanClarificationRequest && ( ! input . trim ( ) ) }
99+ />
101100
101+ </ ChatInput >
102+ </ div >
102103
104+ </ div >
105+ </ > ) }
103106 </ div >
104107 ) ;
105108} ;
0 commit comments