11import { Show , createSignal } from 'solid-js'
2+ import { JsonTree } from '@tanstack/devtools-ui'
23import { useStyles } from '../../styles/use-styles'
3- import { formatTimestamp , getChunkTypeColor } from '../utils'
4+ import { formatDuration , formatTimestamp , getChunkTypeColor } from '../utils'
45import type { Component } from 'solid-js'
56import type { Chunk } from '../../store/ai-store'
67
@@ -16,6 +17,28 @@ export const ChunkItem: Component<ChunkItemProps> = (props) => {
1617 const isLarge = ( ) => props . variant === 'large'
1718 const chunkCount = ( ) => props . chunk . chunkCount || 1
1819
20+ const parseToolArguments = ( ) : Record < string , unknown > => {
21+ try {
22+ return JSON . parse ( props . chunk . arguments || '{}' ) as Record <
23+ string ,
24+ unknown
25+ >
26+ } catch {
27+ return { raw : props . chunk . arguments }
28+ }
29+ }
30+
31+ const parseToolResult = ( ) : Record < string , unknown > => {
32+ try {
33+ if ( typeof props . chunk . result === 'string' ) {
34+ return JSON . parse ( props . chunk . result ) as Record < string , unknown >
35+ }
36+ return props . chunk . result as Record < string , unknown >
37+ } catch {
38+ return { raw : props . chunk . result }
39+ }
40+ }
41+
1942 return (
2043 < div
2144 class = {
@@ -185,6 +208,52 @@ export const ChunkItem: Component<ChunkItemProps> = (props) => {
185208 </ Show >
186209 </ div >
187210 </ Show >
211+ < Show when = { props . chunk . type === 'tool_call' && props . chunk . arguments } >
212+ < div class = { styles ( ) . conversationDetails . chunkToolCall } >
213+ < div class = { styles ( ) . conversationDetails . chunkToolCallHeader } >
214+ < span class = { styles ( ) . conversationDetails . chunkToolCallTitle } >
215+ 📤 Tool Arguments
216+ </ span >
217+ </ div >
218+ < div class = { styles ( ) . conversationDetails . toolJsonContainer } >
219+ < JsonTree
220+ value = { parseToolArguments ( ) }
221+ defaultExpansionDepth = { 2 }
222+ copyable
223+ />
224+ </ div >
225+ </ div >
226+ </ Show >
227+ < Show
228+ when = {
229+ props . chunk . type === 'tool_result' &&
230+ props . chunk . result !== undefined
231+ }
232+ >
233+ < div class = { styles ( ) . conversationDetails . chunkToolResult } >
234+ < div class = { styles ( ) . conversationDetails . chunkToolResultHeader } >
235+ < span class = { styles ( ) . conversationDetails . chunkToolResultTitle } >
236+ ✓ Tool Result
237+ </ span >
238+ < Show
239+ when = {
240+ props . chunk . duration !== undefined && props . chunk . duration > 0
241+ }
242+ >
243+ < span class = { styles ( ) . conversationDetails . durationBadge } >
244+ ⏱️ { formatDuration ( props . chunk . duration ) }
245+ </ span >
246+ </ Show >
247+ </ div >
248+ < div class = { styles ( ) . conversationDetails . toolJsonContainer } >
249+ < JsonTree
250+ value = { parseToolResult ( ) }
251+ defaultExpansionDepth = { 2 }
252+ copyable
253+ />
254+ </ div >
255+ </ div >
256+ </ Show >
188257 </ Show >
189258
190259 { /* Raw JSON View */ }
0 commit comments