@@ -21,7 +21,13 @@ interface ChatFormProps {
2121 execResults : Record < string , ReplOutput [ ] > ;
2222}
2323
24- export function ChatForm ( { documentContent, sectionId, replOutputs, fileContents, execResults } : ChatFormProps ) {
24+ export function ChatForm ( {
25+ documentContent,
26+ sectionId,
27+ replOutputs,
28+ fileContents,
29+ execResults,
30+ } : ChatFormProps ) {
2531 const [ messages , updateChatHistory ] = useChatHistory ( sectionId ) ;
2632 const [ inputValue , setInputValue ] = useState ( "" ) ;
2733 const [ isLoading , setIsLoading ] = useState ( false ) ;
@@ -54,9 +60,10 @@ export function ChatForm({ documentContent, sectionId, replOutputs, fileContents
5460 updateChatHistory ( [ userMessage ] ) ;
5561
5662 let userQuestion = inputValue ;
57- if ( ! userQuestion && exampleData ) {
63+ if ( ! userQuestion && exampleData ) {
5864 // 質問が空欄なら、質問例を使用
59- userQuestion = exampleData [ Math . floor ( exampleChoice * exampleData . length ) ] ;
65+ userQuestion =
66+ exampleData [ Math . floor ( exampleChoice * exampleData . length ) ] ;
6067 setInputValue ( userQuestion ) ;
6168 }
6269
@@ -69,7 +76,11 @@ export function ChatForm({ documentContent, sectionId, replOutputs, fileContents
6976 } ) ;
7077
7178 if ( result . error ) {
72- const errorMessage : Message = { sender : "ai" , text : `エラー: ${ result . error } ` , isError : true } ;
79+ const errorMessage : Message = {
80+ sender : "ai" ,
81+ text : `エラー: ${ result . error } ` ,
82+ isError : true ,
83+ } ;
7384 updateChatHistory ( [ userMessage , errorMessage ] ) ;
7485 } else {
7586 const aiMessage : Message = { sender : "ai" , text : result . response } ;
@@ -83,12 +94,20 @@ export function ChatForm({ documentContent, sectionId, replOutputs, fileContents
8394 const handleClearHistory = ( ) => {
8495 updateChatHistory ( [ ] ) ;
8596 } ;
86-
97+
8798 return (
8899 < >
89100 { isFormVisible && (
90- < form className = "border border-2 border-secondary shadow-md rounded-lg bg-base-100" style = { { width :"100%" , textAlign :"center" , boxShadow :"-moz-initial" } } onSubmit = { handleSubmit } >
91- < div className = "input-area" >
101+ < form
102+ className = "border border-2 border-secondary shadow-md rounded-lg bg-base-100"
103+ style = { {
104+ width : "100%" ,
105+ textAlign : "center" ,
106+ boxShadow : "-moz-initial" ,
107+ } }
108+ onSubmit = { handleSubmit }
109+ >
110+ < div className = "input-area" >
92111 < textarea
93112 className = "textarea textarea-ghost textarea-md rounded-lg"
94113 placeholder = {
@@ -108,7 +127,15 @@ export function ChatForm({ documentContent, sectionId, replOutputs, fileContents
108127 disabled = { isLoading }
109128 > </ textarea >
110129 </ div >
111- < div className = "controls" style = { { margin :"10px" , display :"flex" , alignItems :"center" , justifyContent :"space-between" } } >
130+ < div
131+ className = "controls"
132+ style = { {
133+ margin : "10px" ,
134+ display : "flex" ,
135+ alignItems : "center" ,
136+ justifyContent : "space-between" ,
137+ } }
138+ >
112139 < div className = "left-icons" >
113140 < button
114141 className = "btn btn-soft btn-secondary rounded-full"
@@ -156,15 +183,21 @@ export function ChatForm({ documentContent, sectionId, replOutputs, fileContents
156183 </ button >
157184 </ div >
158185 { messages . map ( ( msg , index ) => (
159- < div key = { index } className = { `chat ${ msg . sender === 'user' ? 'chat-end' : 'chat-start' } ` } >
160- < div
186+ < div
187+ key = { index }
188+ className = { `chat ${ msg . sender === "user" ? "chat-end" : "chat-start" } ` }
189+ >
190+ < div
161191 className = { clsx (
162192 "chat-bubble" ,
163- { "bg-primary text-primary-content" : msg . sender === 'user' } ,
164- { "bg-secondary-content dark:bg-neutral text-black dark:text-white" : msg . sender === 'ai' && ! msg . isError } ,
193+ { "bg-primary text-primary-content" : msg . sender === "user" } ,
194+ {
195+ "bg-secondary-content dark:bg-neutral text-black dark:text-white" :
196+ msg . sender === "ai" && ! msg . isError ,
197+ } ,
165198 { "chat-bubble-error" : msg . isError }
166- ) }
167- style = { { maxWidth : "100%" , wordBreak : "break-word" } }
199+ ) }
200+ style = { { maxWidth : "100%" , wordBreak : "break-word" } }
168201 >
169202 < StyledMarkdown content = { msg . text } />
170203 </ div >
@@ -178,7 +211,6 @@ export function ChatForm({ documentContent, sectionId, replOutputs, fileContents
178211 AIが考え中です…
179212 </ div >
180213 ) }
181-
182214 </ >
183215 ) ;
184- }
216+ }
0 commit comments