@@ -344,6 +344,17 @@ function urls(text: string | undefined) {
344344 } )
345345}
346346
347+ function sessionLink ( id : string | undefined , path : string , href ?: ( id : string ) => string | undefined ) {
348+ if ( ! id ) return
349+
350+ const direct = href ?.( id )
351+ if ( direct ) return direct
352+
353+ const idx = path . indexOf ( "/session" )
354+ if ( idx === - 1 ) return
355+ return `${ path . slice ( 0 , idx ) } /session/${ id } `
356+ }
357+
347358const CONTEXT_GROUP_TOOLS = new Set ( [ "read" , "glob" , "grep" , "list" ] )
348359const HIDDEN_TOOLS = new Set ( [ "todowrite" , "todoread" ] )
349360
@@ -1215,6 +1226,7 @@ function ToolFileAccordion(props: { path: string; actions?: JSX.Element; childre
12151226}
12161227
12171228PART_MAPPING [ "tool" ] = function ToolPartDisplay ( props ) {
1229+ const data = useData ( )
12181230 const i18n = useI18n ( )
12191231 const part = ( ) => props . part as ToolPart
12201232 if ( part ( ) . tool === "todowrite" || part ( ) . tool === "todoread" ) return null
@@ -1229,6 +1241,21 @@ PART_MAPPING["tool"] = function ToolPartDisplay(props) {
12291241 const input = ( ) => part ( ) . state ?. input ?? emptyInput
12301242 // @ts -expect-error
12311243 const partMetadata = ( ) => part ( ) . state ?. metadata ?? emptyMetadata
1244+ const taskId = createMemo ( ( ) => {
1245+ if ( part ( ) . tool !== "task" ) return
1246+ const value = partMetadata ( ) . sessionId
1247+ if ( typeof value === "string" && value ) return value
1248+ } )
1249+ const taskHref = createMemo ( ( ) => {
1250+ if ( part ( ) . tool !== "task" ) return
1251+ return sessionLink ( taskId ( ) , useLocation ( ) . pathname , data . sessionHref )
1252+ } )
1253+ const taskSubtitle = createMemo ( ( ) => {
1254+ if ( part ( ) . tool !== "task" ) return undefined
1255+ const value = input ( ) . description
1256+ if ( typeof value === "string" && value ) return value
1257+ return taskId ( )
1258+ } )
12321259
12331260 const render = createMemo ( ( ) => ToolRegistry . render ( part ( ) . tool ) ?? GenericTool )
12341261
@@ -1248,7 +1275,15 @@ PART_MAPPING["tool"] = function ToolPartDisplay(props) {
12481275 </ div >
12491276 )
12501277 }
1251- return < ToolErrorCard tool = { part ( ) . tool } error = { error ( ) } defaultOpen = { props . defaultOpen } />
1278+ return (
1279+ < ToolErrorCard
1280+ tool = { part ( ) . tool }
1281+ error = { error ( ) }
1282+ defaultOpen = { props . defaultOpen }
1283+ subtitle = { taskSubtitle ( ) }
1284+ href = { taskHref ( ) }
1285+ />
1286+ )
12521287 } }
12531288 </ Match >
12541289 < Match when = { true } >
@@ -1625,25 +1660,14 @@ ToolRegistry.register({
16251660 return raw [ 0 ] ! . toUpperCase ( ) + raw . slice ( 1 )
16261661 } )
16271662 const title = createMemo ( ( ) => agentTitle ( i18n , type ( ) ) )
1628- const description = createMemo ( ( ) => {
1663+ const subtitle = createMemo ( ( ) => {
16291664 const value = props . input . description
1630- if ( typeof value === "string" ) return value
1631- return undefined
1665+ if ( typeof value === "string" && value ) return value
1666+ return childSessionId ( )
16321667 } )
16331668 const running = createMemo ( ( ) => props . status === "pending" || props . status === "running" )
16341669
1635- const href = createMemo ( ( ) => {
1636- const sessionId = childSessionId ( )
1637- if ( ! sessionId ) return
1638-
1639- const direct = data . sessionHref ?.( sessionId )
1640- if ( direct ) return direct
1641-
1642- const path = location . pathname
1643- const idx = path . indexOf ( "/session" )
1644- if ( idx === - 1 ) return
1645- return `${ path . slice ( 0 , idx ) } /session/${ sessionId } `
1646- } )
1670+ const href = createMemo ( ( ) => sessionLink ( childSessionId ( ) , location . pathname , data . sessionHref ) )
16471671
16481672 const titleContent = ( ) => < TextShimmer text = { title ( ) } active = { running ( ) } />
16491673
@@ -1653,7 +1677,7 @@ ToolRegistry.register({
16531677 < span data-slot = "basic-tool-tool-title" class = "capitalize agent-title" >
16541678 { titleContent ( ) }
16551679 </ span >
1656- < Show when = { description ( ) } >
1680+ < Show when = { subtitle ( ) } >
16571681 < Switch >
16581682 < Match when = { href ( ) } >
16591683 < a
@@ -1662,11 +1686,11 @@ ToolRegistry.register({
16621686 href = { href ( ) ! }
16631687 onClick = { ( e ) => e . stopPropagation ( ) }
16641688 >
1665- { description ( ) }
1689+ { subtitle ( ) }
16661690 </ a >
16671691 </ Match >
16681692 < Match when = { true } >
1669- < span data-slot = "basic-tool-tool-subtitle" > { description ( ) } </ span >
1693+ < span data-slot = "basic-tool-tool-subtitle" > { subtitle ( ) } </ span >
16701694 </ Match >
16711695 </ Switch >
16721696 </ Show >
0 commit comments