11import { clipboard , invoke } from "@tauri-apps/api" ;
2- import { useRef , useState } from "react" ;
3- import { useRecoilState } from "recoil" ;
2+ import { useEffect , useRef , useState } from "react" ;
43import { toast } from "react-toastify" ;
54
65import DB from "../../lib/sqlite" ;
7- import { showExecutedToolsState } from "../../store/atoms/showExecutedToolsState" ;
86import { ArrowPath } from "../atoms/ArrowPath" ;
97import { Check } from "../atoms/Check" ;
108import { CheckBadge } from "../atoms/CheckBadge" ;
@@ -28,7 +26,10 @@ const ToolCard = ({ id, tool_results, note_id, note_title, clear, updateToolResu
2826 const [ dialogName , setDialogName ] = useState < string > ( "" ) ;
2927 const [ dialogMethod , setDialogMethod ] = useState < string > ( "" ) ;
3028 const [ dialogDescription , setDialogDescription ] = useState < string > ( "" ) ;
31- const [ showExecuted , setShowExecuted ] = useRecoilState ( showExecutedToolsState ) ;
29+ const [ showExecutedTool , setShowExecutedTool ] = useState ( false ) ;
30+ useEffect ( ( ) => {
31+ setShowExecutedTool ( false ) ;
32+ } , [ id ] ) ;
3233 const obj = ( ( ) => {
3334 try {
3435 return JSON . parse ( tool_results ) as { "is_required_user_permission" : boolean , "content" : string | null , "cmds" : { "call_id" : string , "args" : Object , "name" : string , "method" : string , "description" : string , "result" : string | null } [ ] }
@@ -90,14 +91,14 @@ const ToolCard = ({ id, tool_results, note_id, note_title, clear, updateToolResu
9091 < div >
9192 { hasExecutedTools &&
9293 < button className = "mt-4 mb-2 cursor-pointer flex items-center"
93- onClick = { ( ) => setShowExecuted ( ! showExecuted ) } >
94- { showExecuted ?
94+ onClick = { ( ) => setShowExecutedTool ( ! showExecutedTool ) } >
95+ { showExecutedTool ?
9596 < ChevronDown /> :
9697 < ChevronRight />
9798 }
9899 < span > 実行済みのツール({ executedTools } )</ span >
99100 </ button > }
100- { showExecuted && (
101+ { showExecutedTool && (
101102 cmds . filter ( cmd => cmd . result !== null ) . reverse ( ) . map ( ( { call_id, args, name, method, description, result } ) => {
102103 return (
103104 < div key = { call_id } className = "cursor-default h-full py-3 px-6 border border-neutral-300 rounded-md shadow mb-2" >
@@ -152,14 +153,14 @@ const ToolCard = ({ id, tool_results, note_id, note_title, clear, updateToolResu
152153 < div >
153154 { hasExecutedTools &&
154155 < button className = "mt-4 mb-2 cursor-pointer flex items-center"
155- onClick = { ( ) => setShowExecuted ( ! showExecuted ) } >
156- { showExecuted ?
156+ onClick = { ( ) => setShowExecutedTool ( ! showExecutedTool ) } >
157+ { showExecutedTool ?
157158 < ChevronDown /> :
158159 < ChevronRight />
159160 }
160161 < span > 実行済みのツール({ executedTools } )</ span >
161162 </ button > }
162- { showExecuted && (
163+ { showExecutedTool && (
163164 cmds . filter ( cmd => cmd . result !== null ) . reverse ( ) . map ( ( { call_id, args, name, method, description, result } ) => {
164165 return (
165166 < div key = { call_id } className = "cursor-default h-full py-3 px-6 border border-neutral-300 rounded-md shadow mb-2" >
0 commit comments