Upload into the selected file-tree folder (not just the project root)#876
Upload into the selected file-tree folder (not just the project root)#876rhueller wants to merge 3 commits into
Conversation
Clicking a directory in the file tree now sets it as the upload target, so File Explorer uploads land in that folder instead of always going to the project root. An "Upload target" indicator shows the active folder and offers a clear (X) button to reset the target back to the project root. The server already accepts and validates a targetPath (validatePathInProject); this wires the frontend to pass the last-clicked directory through handleFileSelect, defaulting to '' (root).
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthrough
ChangesDirectory-targeted upload flow
Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 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/components/file-tree/view/FileTree.tsx (1)
95-95: ⚡ Quick winClear
selectedUploadDirwhenselectedProjectchanges.When the user switches projects,
selectedUploadDirretains the path from the previous project, leading to a stale upload target. The UI indicator will display a path that doesn't exist in the new project, and uploads will fail with a server error.🔄 Proposed fix to reset upload target on project change
Add this effect after line 95:
const [selectedUploadDir, setSelectedUploadDir] = useState<string>(''); + + useEffect(() => { + setSelectedUploadDir(''); + }, [selectedProject]);🤖 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/components/file-tree/view/FileTree.tsx` at line 95, The selectedUploadDir state variable retains its value from the previous project when the user switches projects, causing stale upload paths and server errors. Add a useEffect hook that monitors the selectedProject dependency and clears the selectedUploadDir by calling setSelectedUploadDir with an empty string whenever selectedProject changes. This effect should be added immediately after the useState declaration for selectedUploadDir to ensure the upload target is reset whenever a different project is selected.
🤖 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/components/file-tree/view/FileTree.tsx`:
- Line 95: The selectedUploadDir state variable retains its value from the
previous project when the user switches projects, causing stale upload paths and
server errors. Add a useEffect hook that monitors the selectedProject dependency
and clears the selectedUploadDir by calling setSelectedUploadDir with an empty
string whenever selectedProject changes. This effect should be added immediately
after the useState declaration for selectedUploadDir to ensure the upload target
is reset whenever a different project is selected.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 5fe979ae-ac8e-42e7-af5a-858d42dee5e8
📒 Files selected for processing (2)
src/components/file-tree/hooks/useFileTreeUpload.tssrc/components/file-tree/view/FileTree.tsx
|
Thank you! It's an important feature! |
Document handleFileSelect's targetPath parameter and handleItemClick's upload-target side effect to satisfy the docstring-coverage pre-merge check.
|
Hey @rhueller, thanks for the feature! I tested this and it's still uploading it to the root even after changing the upload target. I used Windows OS. Can you test it again? |
What
Lets a file upload target a selected subfolder of the file tree, instead of
always landing in the project root.
clear (×) button to reset back to the project root.
project root exactly as before.
Why
Follow-up to #680. Uploads currently always land in the project root because the
frontend hardcodes the upload
targetPathto''. The server already acceptsand validates a per-upload
targetPath(validatePathInProject, recursivemkdir, traversal guard), so this is a frontend-only wiring change - noserver changes required.
Changes
useFileTreeUpload.ts:handleFileSelecttakes an optionaltargetPath(default
'') and forwards it touploadFiles.FileTree.tsx: newselectedUploadDirstate, set when a directory is clicked;passed as the upload target; small i18n indicator + reset button. Labels use
t(key, fallback), so no locale-file changes are needed (English fallbackrenders out of the box).
~23 lines added, two files, frontend only, fully backward-compatible.
Testing
npm run buildpasses (client + server).the target to the project root; with no selection, uploads still go to the root.
Screenshots
Upload target indicator + reset: clicking a folder sets it as the upload
target; the (×) resets to the project root.
Result: the uploaded file lands in the selected subfolder, not the root.
Summary by CodeRabbit
Summary by CodeRabbit