Fix/improve load in memory paths - #1448
Conversation
|
This PR changes 651 lines. If it contains multiple concerns, consider splitting it. Large PRs are fine when the changes are mechanical, intentionally grouped, or belong together as part of the same feature. Please make sure the PR description gives reviewers enough context about what matters most to review. |
📝 WalkthroughWalkthroughThe change adds iterative depth-first traversal, bounds filesystem stat and placeholder-loading concurrency, refactors remote-sync path loading to use the traversal helper, and updates virtual-drive traversal to use shared worker-count logic. Tests cover ordering, cancellation, deep trees, metadata propagation, concurrency, and errors. ChangesFilesystem traversal and concurrency
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/backend/features/remote-sync/sync-items-by-checkpoint/load-in-memory-paths.ts (1)
22-72: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueCross-callback state via item mutation is implicit.
loadFoldermutatesitem.uuidin place (Line 52) so thatprocessChildren's latergetFolderUuid(Line 42) can read it. This is correct today only becausetraverseDepthFirsthappens to pass the same object reference to bothprocessNodeandprocessChildrenfor a given stack item — an implicit contract not documented on either side. Works correctly, but worth a comment noting the dependency so a future change to the traversal helper doesn't silently break this.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/backend/features/remote-sync/sync-items-by-checkpoint/load-in-memory-paths.ts` around lines 22 - 72, Document the shared-state dependency between loadFolder and processChildren in loadInMemoryPaths: loadFolder mutates item.uuid for placeholder folders, and processChildren later reads that value through getFolderUuid. Add a concise comment near the mutation or callback wiring noting that traverseDepthFirst must pass the same StackItem reference to both callbacks; do not change the existing behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In
`@src/backend/features/remote-sync/sync-items-by-checkpoint/load-in-memory-paths.ts`:
- Around line 22-72: Document the shared-state dependency between loadFolder and
processChildren in loadInMemoryPaths: loadFolder mutates item.uuid for
placeholder folders, and processChildren later reads that value through
getFolderUuid. Add a concise comment near the mutation or callback wiring noting
that traverseDepthFirst must pass the same StackItem reference to both
callbacks; do not change the existing behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: a1a22b44-b937-4d9d-9e99-e417ac27d47a
📒 Files selected for processing (11)
src/backend/features/remote-sync/sync-items-by-checkpoint/load-file-explorer-files.test.tssrc/backend/features/remote-sync/sync-items-by-checkpoint/load-file-explorer-files.tssrc/backend/features/remote-sync/sync-items-by-checkpoint/load-in-memory-paths.test.tssrc/backend/features/remote-sync/sync-items-by-checkpoint/load-in-memory-paths.tssrc/backend/features/virtual-drive/tree-traversal/traverse-depth-first.test.tssrc/backend/features/virtual-drive/tree-traversal/traverse-depth-first.tssrc/context/virtual-drive/items/application/Traverser.tssrc/core/utils/concurrency.test.tssrc/core/utils/concurrency.tssrc/infra/file-system/services/stat-readdir.test.tssrc/infra/file-system/services/stat-readdir.ts
|
The merge-base changed after approval.



What is Changed / Added
This PR improves the startup placeholder refresh path, especially the local placeholder scan performed by
loadInMemoryPaths.The file placeholder loading was also extracted into its own helper and changed to workers. This avoids creating one promise per file upfront when a folder contains many files.
statReaddirnow follows the same idea for filesystem stats, so a large directory does not launch one stat operation per entry at onceThe recursive folder walk has been replaced with an iterative depth-first traversal helper under
backend/features/virtual-drive/tree-traversal. I have made this function reusable so that we can use it in bothloadInMemoryPathsandtraversekeeping the traversal mechanics in one place while preserving the existing behavior.Why
Users with very large drives have reported startup freezes and long periods where the app appears unresponsive.
loadInMemoryPathsis part of that startup path, and it has to inspect a large local placeholder tree before comparing local state with remote state.Summary by CodeRabbit