fix: FileTree backend recursion breaking lazy loading

CRITICAL FIX: Remove recursion from listDirectoryForTree function.

The backend was recursively fetching ALL subdirectories and returning
them as a flat list, which completely broke the lazy-loading model.

Changes:
- Remove recursive call in listDirectoryForTree
- Backend now returns ONLY immediate children
- Frontend handles lazy loading by requesting children on expand
- This matches the intended architecture where frontend controls tree

This fixes the issue where directory contents were duplicated and
the tree structure was corrupted when expanding/collapsing.
This commit is contained in:
Rob Colbert 2026-05-12 16:32:27 -04:00
parent 2b029ebf2e
commit 84f68907da

View File

@ -835,17 +835,8 @@ class GadgetDrone extends GadgetProcess {
results.push(fileTreeEntry);
// Recurse if directory and within depth limit
if (entry.isDirectory() && depth < maxDepth) {
const subResults = await this.listDirectoryForTree(
fullPath,
showHidden,
depth + 1,
maxDepth,
projectRoot,
);
results.push(...subResults);
}
// NO RECURSION - lazy loading is handled by frontend
// The frontend will request children when directories are expanded
}
return results;