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)