44 ArrowsLeftRight ,
55 Brain ,
66 ChatCircle ,
7+ Command ,
78 FileText ,
89 Globe ,
910 type Icon ,
@@ -17,11 +18,14 @@ import { Box, Flex } from "@radix-ui/themes";
1718import { compactHomePath } from "@utils/path" ;
1819import { useState } from "react" ;
1920import {
21+ compactInput ,
2022 ExpandableIcon ,
2123 ExpandedContentBox ,
24+ formatInput ,
2225 getContentText ,
2326 getFilename ,
2427 StatusIndicators ,
28+ stripCodeFences ,
2529 ToolTitle ,
2630 type ToolViewProps ,
2731 useToolCallStatus ,
@@ -41,20 +45,33 @@ const kindIcons: Record<TwigToolKind, Icon> = {
4145 other : Wrench ,
4246} ;
4347
48+ const toolNameIcons : Record < string , Icon > = {
49+ ToolSearch : MagnifyingGlass ,
50+ Skill : Command ,
51+ } ;
52+
53+ interface ToolCallViewProps extends ToolViewProps {
54+ agentToolName ?: string ;
55+ }
56+
4457export function ToolCallView ( {
4558 toolCall,
4659 turnCancelled,
4760 turnComplete,
61+ agentToolName,
4862 expanded = false ,
49- } : ToolViewProps ) {
63+ } : ToolCallViewProps ) {
5064 const [ isExpanded , setIsExpanded ] = useState ( expanded ) ;
51- const { title, kind, status, locations, content } = toolCall ;
52- const { isLoading, isFailed, wasCancelled } = useToolCallStatus (
65+ const { title, kind, status, locations, content, rawInput } = toolCall ;
66+ const { isLoading, isFailed, wasCancelled, isComplete } = useToolCallStatus (
5367 status ,
5468 turnCancelled ,
5569 turnComplete ,
5670 ) ;
57- const KindIcon = ( kind && kindIcons [ kind ] ) || Wrench ;
71+ const KindIcon =
72+ ( agentToolName && toolNameIcons [ agentToolName ] ) ||
73+ ( kind && kindIcons [ kind ] ) ||
74+ Wrench ;
5875
5976 const filePath = kind === "read" && locations ?. [ 0 ] ?. path ;
6077 const displayText = filePath
@@ -63,9 +80,12 @@ export function ToolCallView({
6380 ? compactHomePath ( title )
6481 : undefined ;
6582
83+ const inputPreview = compactInput ( rawInput ) ;
84+ const fullInput = formatInput ( rawInput ) ;
85+
6686 const output = stripCodeFences ( getContentText ( content ) ?? "" ) ;
6787 const hasOutput = output . trim ( ) . length > 0 ;
68- const isExpandable = hasOutput ;
88+ const isExpandable = ! ! fullInput || hasOutput ;
6989
7090 const handleClick = ( ) => {
7191 if ( isExpandable ) {
@@ -87,19 +107,25 @@ export function ToolCallView({
87107 isExpanded = { isExpanded }
88108 />
89109 </ Box >
90- < Flex align = "center" gap = "2 " wrap = "wrap" >
110+ < Flex align = "center" gap = "1 " wrap = "wrap" className = "min-w-0 ">
91111 < ToolTitle > { displayText } </ ToolTitle >
112+ { inputPreview && (
113+ < ToolTitle >
114+ < span className = "font-mono text-accent-11" > { inputPreview } </ span >
115+ </ ToolTitle >
116+ ) }
92117 < StatusIndicators isFailed = { isFailed } wasCancelled = { wasCancelled } />
93118 </ Flex >
94119 </ Flex >
95120
96- { isExpanded && hasOutput && (
97- < ExpandedContentBox > { output } </ ExpandedContentBox >
121+ { isExpanded && (
122+ < >
123+ { fullInput && < ExpandedContentBox > { fullInput } </ ExpandedContentBox > }
124+ { isComplete && hasOutput && (
125+ < ExpandedContentBox > { output } </ ExpandedContentBox >
126+ ) }
127+ </ >
98128 ) }
99129 </ Box >
100130 ) ;
101131}
102-
103- function stripCodeFences ( text : string ) : string {
104- return text . replace ( / ^ ` ` ` \w * \n ? / , "" ) . replace ( / \n ? ` ` ` \s * $ / , "" ) ;
105- }
0 commit comments