From 84f68907da2221bef2cd95bfcee7f7212bdfeba8 Mon Sep 17 00:00:00 2001 From: Rob Colbert Date: Tue, 12 May 2026 16:32:27 -0400 Subject: [PATCH] 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. --- gadget-drone/src/gadget-drone.ts | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/gadget-drone/src/gadget-drone.ts b/gadget-drone/src/gadget-drone.ts index 941bbf7..47c3fcc 100644 --- a/gadget-drone/src/gadget-drone.ts +++ b/gadget-drone/src/gadget-drone.ts @@ -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;