fix(web): set correct intermediate directory paths in buildFileTree - #1708
riteshvish02 wants to merge 1 commit into
Conversation
When constructing the file tree from a flat list in buildFileTree, new intermediate directory nodes were assigned item.path (the path of the leaf item being processed) instead of their actual directory path.
This caused intermediate directory nodes to have full file paths instead of their directory path (e.g. directory 'src' receiving path 'src/components/Button.tsx'), breaking folder expansion state tracking (openPaths.has(node.path)) and corrupting directory paths returned by getTree.
Reconstruct the node path using parts.slice(0, i + 1).join('/') so both directories and leaves have the correct path.
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review. Walkthrough
ChangesFile tree path correction
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~5 minutes Change: Bug fix · Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to This change corrects directory paths in file trees and adds focused nested-path coverage. No remaining merge-blocking risk is evident. Security Architecture ReviewSecurity architecture risk: ⚪ Minimal · up to The corrected directory paths preserve the existing repository-access boundary. No material security risk was identified in the reviewed change. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Fixes #1707
Summary
Fixes an issue where
buildFileTreeassigned leaf item paths to newly created intermediate directory nodes instead of their actual reconstructed directory path.Root Cause
In
packages/web/src/features/git/utils.ts, lines 68-74:When processing a flat list containing nested paths like
src/components/buttons/PrimaryButton.tsx, intermediate directory nodessrcandcomponentshadpath: "src/components/buttons/PrimaryButton.tsx"instead of"src"and"src/components".Impact
fileTreePanel.tsx, folder expand/collapse state trackingopenPaths.has(node.path)and route sync failed for intermediate directories.getTree), consumers received corruptedFileTreeNodepaths for directory nodes.Changes
pathinbuildFileTreetoparts.slice(0, i + 1).join('/').packages/web/src/features/git/utils.test.tsverifying that intermediate directory nodes retain their correct parent paths.Note
Low Risk
Small path-construction bugfix in git file-tree utilities with added regression test; no auth or data-handling changes.
Overview
Fixes
buildFileTreeso newly created intermediate directory nodes getpathvalues built from the path segments walked so far (parts.slice(0, i + 1).join('/')), instead of inheriting the leaf file’s full path.That restores correct folder keys for browse UI expand/collapse (
openPaths.has(node.path)) and forgetTreeconsumers that rely on directoryFileTreeNode.path. A focused unit test covers nested paths likesrc/components/buttons/….Reviewed by Cursor Bugbot for commit 2cdd153. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by CodeRabbit