From 38ca38e3cbd99294779476c32d244de2323d9f9e Mon Sep 17 00:00:00 2001 From: 7418 <7418@openclaw.ai> Date: Thu, 12 Feb 2026 01:31:48 +0800 Subject: [PATCH] fix: auto-refresh file tree after AI finishes streaming Co-Authored-By: Claude Opus 4.6 --- src/components/chat/ChatView.tsx | 2 ++ src/components/project/FileTree.tsx | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/src/components/chat/ChatView.tsx b/src/components/chat/ChatView.tsx index d5a33e8..d7e670f 100644 --- a/src/components/chat/ChatView.tsx +++ b/src/components/chat/ChatView.tsx @@ -443,6 +443,8 @@ export function ChatView({ sessionId, initialMessages = [], modelName, initialMo setPermissionResolved(null); setPendingApprovalSessionId(''); abortControllerRef.current = null; + // Notify file tree to refresh after AI finishes + window.dispatchEvent(new CustomEvent('refresh-file-tree')); } }, [sessionId, isStreaming, setStreamingSessionId, setPendingApprovalSessionId, mode, currentModel] diff --git a/src/components/project/FileTree.tsx b/src/components/project/FileTree.tsx index a50626f..75293f0 100644 --- a/src/components/project/FileTree.tsx +++ b/src/components/project/FileTree.tsx @@ -137,6 +137,13 @@ export function FileTree({ workingDirectory, onFileSelect, onFileAdd }: FileTree fetchTree(); }, [fetchTree]); + // Auto-refresh when AI finishes streaming + useEffect(() => { + const handler = () => fetchTree(); + window.addEventListener('refresh-file-tree', handler); + return () => window.removeEventListener('refresh-file-tree', handler); + }, [fetchTree]); + // Build default expanded set from first-level directories const defaultExpanded = new Set( tree.filter((n) => n.type === "directory").map((n) => n.path)