@@ -78,13 +78,29 @@ function getTitle(part: ToolUIPart): React.ReactNode {
7878 return 'Select data from ...'
7979 }
8080 if ( part . type === 'tool-webSearch' ) {
81- if ( part . input && typeof part . input === 'object' && 'query' in part . input ) {
82- const query = typeof part . input . query === 'string' ? part . input . query : ''
83-
81+ const query = typeof part . input ?. query === 'string' ? part . input ?. query : ''
82+ if ( query ) {
8483 return `Searching the web for "${ query } "`
8584 }
8685 return 'Searching the web...'
8786 }
87+ if ( part . type === 'tool-resolveLibraryId' ) {
88+ const libraryName = part . input && typeof part . input . libraryName === 'string' ? part . input . libraryName : ''
89+
90+ if ( libraryName ) {
91+ return `Resolved library "${ libraryName } "`
92+ }
93+
94+ return 'Resolving library name...'
95+ }
96+ if ( part . type === 'tool-queryDocs' ) {
97+ const query = typeof part . input ?. query === 'string' ? part . input ?. query : ''
98+
99+ if ( query ) {
100+ return `Querying docs for "${ query } "`
101+ }
102+ return 'Querying docs...'
103+ }
88104
89105 return 'Unknown tool'
90106}
@@ -97,21 +113,6 @@ const monacoOptions = {
97113 folding : false ,
98114} as const satisfies editor . IStandaloneEditorConstructionOptions
99115
100- function extractErrorMessage ( output : unknown ) : string | null {
101- if ( typeof output !== 'object' || output === null || ! ( 'error' in output ) )
102- return null
103-
104- const { error } = output
105-
106- if ( typeof error === 'string' )
107- return error
108-
109- if ( error instanceof Error )
110- return error . message
111-
112- return JSON . stringify ( error )
113- }
114-
115116function MonacoOutput ( { value } : { value : string } ) {
116117 return (
117118 < Monaco
@@ -233,7 +234,22 @@ function ChatMessageToolContent({ part }: { part: ToolUIPart }): ReactNode {
233234 )
234235 }
235236
236- return null
237+ return < MonacoOutput value = { JSON . stringify ( part . output ) } />
238+ }
239+
240+ function extractErrorMessage ( output : unknown ) : string | null {
241+ if ( typeof output !== 'object' || output === null || ! ( 'error' in output ) )
242+ return null
243+
244+ const { error } = output
245+
246+ if ( typeof error === 'string' )
247+ return error
248+
249+ if ( error instanceof Error )
250+ return error . message
251+
252+ return JSON . stringify ( error )
237253}
238254
239255export function ChatMessageTool ( { part, className } : { part : ToolUIPart , className ?: string } ) {
@@ -249,38 +265,25 @@ export function ChatMessageTool({ part, className }: { part: ToolUIPart, classNa
249265 setOpen ( true )
250266 }
251267
252- if ( loading ) {
253- return (
254- < div className = { cn ( 'my-2 flex items-center gap-2 text-sm' , className ) } >
255- < Icon
256- className = { cn ( 'size-4 shrink-0' , loading && `
257- animate-spin text-primary
258- ` ) }
259- part = { part }
260- />
261- < span className = { cn ( loading && 'text-muted-foreground' ) } >
262- { title }
263- </ span >
264- </ div >
265- )
266- }
267-
268268 return (
269269 < SingleAccordion
270- className = { cn ( 'my-2' , className ) }
270+ className = { cn ( 'my-2 rounded-sm ' , className ) }
271271 open = { open }
272272 onOpenChange = { error ? undefined : setOpen }
273+ disabled = { ! ! error || loading }
273274 >
274- < SingleAccordionTrigger className = "gap-2 py-2" disabled = { ! ! error } >
275- < div className = "flex min-w-0 flex-1 items-center gap-2" >
275+ < SingleAccordionTrigger
276+ className = "min-w-0 gap-2 overflow-hidden py-1 text-xs"
277+ disabled = { ! ! error }
278+ >
279+ < div className = "flex flex-1 items-center gap-2 overflow-hidden" >
276280 < Icon className = { cn ( 'size-4 shrink-0' , ! ! error && 'text-red-600' ) } part = { part } />
277281 < span className = "truncate text-sm" >
278282 { title }
279283 </ span >
280284 </ div >
281- { ! error && < SingleAccordionTriggerArrow /> }
285+ { ! error && < SingleAccordionTriggerArrow className = "ml-auto shrink-0" /> }
282286 </ SingleAccordionTrigger >
283-
284287 < SingleAccordionContent >
285288 { error
286289 ? (
0 commit comments