11import { Tool , ToolCallState } from "core" ;
2+ import { useContext , useMemo } from "react" ;
3+ import { openContextItem } from "../../../components/mainInput/belowMainInput/ContextItemsPeek" ;
4+ import { IdeMessengerContext } from "../../../context/IdeMessenger" ;
25import { ToolCallStatusMessage } from "./ToolCallStatusMessage" ;
6+ import { toolCallStateToContextItems } from "./utils" ;
37
48interface ToolCallDisplayProps {
59 children : React . ReactNode ;
@@ -16,11 +20,29 @@ export function ToolCallDisplay({
1620 icon,
1721 historyIndex,
1822} : ToolCallDisplayProps ) {
23+ const ideMessenger = useContext ( IdeMessengerContext ) ;
24+ const shownContextItems = useMemo ( ( ) => {
25+ const contextItems = toolCallStateToContextItems ( toolCallState ) ;
26+ return contextItems . filter ( ( item ) => ! item . hidden ) ;
27+ } , [ toolCallState ] ) ;
28+
29+ const isClickable = shownContextItems . length > 0 ;
30+
31+ function handleClick ( ) {
32+ if ( shownContextItems . length > 0 ) {
33+ openContextItem ( shownContextItems [ 0 ] , ideMessenger ) ;
34+ }
35+ }
1936 return (
2037 < div className = "flex flex-col justify-center px-4" >
2138 < div className = "mb-2 flex flex-col" >
2239 < div className = "flex flex-row items-center justify-between gap-1.5" >
23- < div className = "flex min-w-0 flex-row items-center gap-2" >
40+ < div
41+ className = { `flex min-w-0 flex-row items-center gap-2 transition-colors duration-200 ease-in-out ${
42+ isClickable ? "cursor-pointer hover:brightness-125" : ""
43+ } `}
44+ onClick = { isClickable ? handleClick : undefined }
45+ >
2446 < div className = "mt-[1px] h-4 w-4 flex-shrink-0 font-semibold" >
2547 { icon }
2648 </ div >
0 commit comments