@@ -157,6 +157,46 @@ const ToolCodeBlock = ({ name, code, isExpanded, onToggle }) => {
157157 )
158158}
159159
160+ /**
161+ * A dedicated component to render tool result blocks neatly.
162+ * NOTE: This component is now being used to display the tool result.
163+ */
164+ const ToolResultBlock = ( { name, result, isExpanded, onToggle } ) => {
165+ let formattedResult = result
166+ try {
167+ // Pretty-print if it's a JSON string
168+ const parsed = JSON . parse ( result )
169+ formattedResult = JSON . stringify ( parsed , null , 2 )
170+ } catch ( e ) {
171+ // Not a valid JSON, leave as is
172+ }
173+
174+ return (
175+ < div className = "mb-4 border-l-2 border-purple-500 pl-3" >
176+ < button
177+ onClick = { onToggle }
178+ className = "flex items-center gap-2 text-purple-400 hover:text-purple-300 text-sm font-semibold"
179+ data-tooltip-id = "chat-bubble-tooltip"
180+ data-tooltip-content = "Click to see the result from the tool."
181+ >
182+ { isExpanded ? (
183+ < IconChevronUp size = { 16 } />
184+ ) : (
185+ < IconChevronDown size = { 16 } />
186+ ) }
187+ Tool Result: { name }
188+ </ button >
189+ { isExpanded && (
190+ < div className = "mt-2 p-3 bg-neutral-800/50 rounded-md" >
191+ < pre className = "text-xs text-gray-300 whitespace-pre-wrap font-mono" >
192+ < code > { formattedResult } </ code >
193+ </ pre >
194+ </ div >
195+ ) }
196+ </ div >
197+ )
198+ }
199+
160200/**
161201 * ChatBubble Component - Displays a single chat message bubble.
162202 *
@@ -292,7 +332,13 @@ const ChatBubble = ({
292332 / < t o o l _ r e s u l t t o o l _ n a m e = " ( [ ^ " ] + ) " > ( [ \s \S ] * ?) < \/ t o o l _ r e s u l t > /
293333 ) )
294334 ) {
295- // We correctly parse and then ignore/hide tool_result
335+ const toolName = subMatch [ 1 ]
336+ const toolResult = subMatch [ 2 ] ? subMatch [ 2 ] . trim ( ) : "{}"
337+ contentParts . push ( {
338+ type : "tool_result" ,
339+ name : toolName ,
340+ result : toolResult
341+ } )
296342 } else if ( ( subMatch = tag . match ( / < t h i n k > ( [ \s \S ] * ?) < \/ t h i n k > / ) ) ) {
297343 const thinkContent = subMatch [ 1 ] . trim ( )
298344 if ( thinkContent ) {
@@ -363,6 +409,18 @@ const ChatBubble = ({
363409 />
364410 )
365411 }
412+ // ADDED THIS BLOCK TO RENDER THE TOOL RESULT
413+ if ( part . type === "tool_result" ) {
414+ return (
415+ < ToolResultBlock
416+ key = { partId }
417+ name = { part . name }
418+ result = { part . result }
419+ isExpanded = { ! ! expandedStates [ partId ] }
420+ onToggle = { ( ) => toggleExpansion ( partId ) }
421+ />
422+ )
423+ }
366424 if ( part . type === "text" && part . content . trim ( ) ) {
367425 return (
368426 < ReactMarkdown
0 commit comments