@@ -59,6 +59,8 @@ export default function ChatMessage({
5959 const nextSibling = siblingLeafNodeIds [ siblingCurrIdx + 1 ] ;
6060 const prevSibling = siblingLeafNodeIds [ siblingCurrIdx - 1 ] ;
6161
62+ // for reasoning model, we split the message into content and thought
63+ // TODO: implement this as remark/rehype plugin in the future
6264 const {
6365 content : mainDisplayableContent ,
6466 thought,
@@ -79,10 +81,12 @@ export default function ChatMessage({
7981 actualContent += thinkSplit [ 0 ] ;
8082
8183 while ( thinkSplit [ 1 ] !== undefined ) {
84+ // <think> tag found
8285 thinkSplit = thinkSplit [ 1 ] . split ( '</think>' , 2 ) ;
8386 thought += thinkSplit [ 0 ] ;
8487 isThinking = true ;
8588 if ( thinkSplit [ 1 ] !== undefined ) {
89+ // </think> closing tag found
8690 isThinking = false ;
8791 thinkSplit = thinkSplit [ 1 ] . split ( '<think>' , 2 ) ;
8892 actualContent += thinkSplit [ 0 ] ;
@@ -129,6 +133,7 @@ export default function ChatMessage({
129133 'chat-bubble bg-transparent' : ! isUser ,
130134 } ) }
131135 >
136+ { /* textarea for editing message */ }
132137 { editingContent !== null && (
133138 < >
134139 < textarea
@@ -157,12 +162,14 @@ export default function ChatMessage({
157162 </ button >
158163 </ >
159164 ) }
165+ { /* not editing content, render message */ }
160166 { editingContent === null && (
161167 < >
162168 { mainDisplayableContent === null &&
163169 ! toolCalls &&
164170 ! chainedParts ?. length ? (
165171 < >
172+ { /* show loading dots for pending message */ }
166173 < span className = "loading loading-dots loading-md" > </ span >
167174 </ >
168175 ) : (
@@ -224,6 +231,7 @@ export default function ChatMessage({
224231 ) ) }
225232 </ React . Fragment >
226233 ) ) }
234+ { /* render timings if enabled */ }
227235 { timings && config . showTokensPerSecond && (
228236 < div className = "dropdown dropdown-hover dropdown-top mt-2" >
229237 < div
@@ -252,6 +260,7 @@ export default function ChatMessage({
252260 </ div >
253261 </ div >
254262
263+ { /* actions for each message */ }
255264 { ( entireTurnHasSomeDisplayableContent || msg . role === 'user' ) && (
256265 < div
257266 className = { classNames ( {
@@ -290,6 +299,7 @@ export default function ChatMessage({
290299 </ button >
291300 </ div >
292301 ) }
302+ { /* user message */ }
293303 { msg . role === 'user' && (
294304 < BtnWithTooltips
295305 className = "btn-mini w-8 h-8"
@@ -300,6 +310,7 @@ export default function ChatMessage({
300310 < PencilSquareIcon className = "h-4 w-4" />
301311 </ BtnWithTooltips >
302312 ) }
313+ { /* assistant message */ }
303314 { msg . role === 'assistant' && (
304315 < >
305316 { ! isPending && (
0 commit comments