@@ -13,8 +13,29 @@ interface ToolResultsProps {
1313 resourceContent : Record < string , string > ;
1414 onReadResource ?: ( uri : string ) => void ;
1515 isPollingTask ?: boolean ;
16+ toolRunDurationMs ?: number | null ;
1617}
1718
19+ const formatToolRunDuration = ( durationMs : number ) : string => {
20+ const roundedMs = Math . max ( 0 , Math . round ( durationMs ) ) ;
21+ if ( roundedMs < 1000 ) {
22+ return `${ roundedMs } ms` ;
23+ }
24+ return `${ ( roundedMs / 1000 ) . toFixed ( 2 ) } s` ;
25+ } ;
26+
27+ const ToolRunDuration = ( { durationMs } : { durationMs ?: number | null } ) => {
28+ if ( typeof durationMs !== "number" || ! Number . isFinite ( durationMs ) ) {
29+ return null ;
30+ }
31+
32+ return (
33+ < span className = "ml-2 text-xs font-medium text-muted-foreground" >
34+ Took { formatToolRunDuration ( durationMs ) }
35+ </ span >
36+ ) ;
37+ } ;
38+
1839const checkContentCompatibility = (
1940 structuredContent : unknown ,
2041 unstructuredContent : Array < {
@@ -65,6 +86,7 @@ const ToolResults = ({
6586 resourceContent,
6687 onReadResource,
6788 isPollingTask,
89+ toolRunDurationMs,
6890} : ToolResultsProps ) => {
6991 if ( ! toolResult ) return null ;
7092
@@ -73,7 +95,10 @@ const ToolResults = ({
7395 if ( ! parsedResult . success ) {
7496 return (
7597 < >
76- < h4 className = "font-semibold mb-2" > Invalid Tool Result:</ h4 >
98+ < h4 className = "font-semibold mb-2" >
99+ Invalid Tool Result:
100+ < ToolRunDuration durationMs = { toolRunDurationMs } />
101+ </ h4 >
77102 < JsonView data = { toolResult } />
78103 < h4 className = "font-semibold mb-2" > Errors:</ h4 >
79104 { parsedResult . error . issues . map ( ( issue , idx ) => (
@@ -141,6 +166,7 @@ const ToolResults = ({
141166 ) : (
142167 < span className = "text-green-600 font-semibold" > Success</ span >
143168 ) }
169+ < ToolRunDuration durationMs = { toolRunDurationMs } />
144170 </ h4 >
145171 { structuredResult . structuredContent && (
146172 < div className = "mb-4" >
@@ -240,7 +266,10 @@ const ToolResults = ({
240266 } else if ( "toolResult" in toolResult ) {
241267 return (
242268 < >
243- < h4 className = "font-semibold mb-2" > Tool Result (Legacy):</ h4 >
269+ < h4 className = "font-semibold mb-2" >
270+ Tool Result (Legacy):
271+ < ToolRunDuration durationMs = { toolRunDurationMs } />
272+ </ h4 >
244273 < JsonView data = { toolResult . toolResult } />
245274 </ >
246275 ) ;
0 commit comments