@@ -48,7 +48,7 @@ function formatToolArgs(input: unknown): string {
4848 . slice ( 0 , 4 )
4949 . map ( ( [ k , v ] ) => {
5050 const val = typeof v === 'string' ? v : JSON . stringify ( v ) ;
51- const display = typeof val === 'string' && val . length > 30 ? val . slice ( 0 , 30 ) + '…' : val ;
51+ const display = val . length > 30 ? val . slice ( 0 , 30 ) + '…' : val ;
5252 return `${ k } : ${ display } ` ;
5353 } )
5454 . join ( ', ' ) ;
@@ -61,6 +61,14 @@ function isToolPart(part: UIMessage['parts'][number]): part is Extract<UIMessage
6161 return part . type === 'dynamic-tool' ;
6262}
6363
64+ /**
65+ * Format tool output for display, truncating to a max length.
66+ */
67+ function formatToolOutput ( output : unknown , maxLen = 80 ) : string {
68+ const raw = typeof output === 'string' ? output : JSON . stringify ( output ) ;
69+ return raw . length > maxLen ? raw . slice ( 0 , maxLen ) + '…' : raw ;
70+ }
71+
6472// ── Tool Invocation State Labels ────────────────────────────────────
6573
6674interface ToolInvocationDisplayProps {
@@ -144,9 +152,7 @@ function ToolInvocationDisplay({ part, onApprove, onDeny }: ToolInvocationDispla
144152 < div className = "min-w-0" >
145153 < span className = "font-medium" > { toolLabel } </ span >
146154 < p className = "mt-0.5 text-muted-foreground truncate" >
147- { typeof part . output === 'string'
148- ? part . output . length > 80 ? part . output . slice ( 0 , 80 ) + '…' : part . output
149- : JSON . stringify ( part . output ) . slice ( 0 , 80 ) }
155+ { formatToolOutput ( part . output ) }
150156 </ p >
151157 </ div >
152158 </ div >
0 commit comments