Skip to content

Upload into the selected file-tree folder (not just the project root)#876

Draft
rhueller wants to merge 3 commits into
siteboon:mainfrom
hit-services:upstream-pr/upload-target-selected-folder
Draft

Upload into the selected file-tree folder (not just the project root)#876
rhueller wants to merge 3 commits into
siteboon:mainfrom
hit-services:upstream-pr/upload-target-selected-folder

Conversation

@rhueller

@rhueller rhueller commented Jun 14, 2026

Copy link
Copy Markdown

What

Lets a file upload target a selected subfolder of the file tree, instead of
always landing in the project root.

  • Clicking a directory in the file tree sets it as the active upload target.
  • A small "Upload target: " indicator shows the active folder, with a
    clear (×) button to reset back to the project root.
  • Default behaviour is unchanged: with nothing selected, uploads go to the
    project root exactly as before.

Why

Follow-up to #680. Uploads currently always land in the project root because the
frontend hardcodes the upload targetPath to ''. The server already accepts
and validates a per-upload targetPath (validatePathInProject, recursive
mkdir, traversal guard), so this is a frontend-only wiring change - no
server changes required.

Changes

  • useFileTreeUpload.ts: handleFileSelect takes an optional targetPath
    (default '') and forwards it to uploadFiles.
  • FileTree.tsx: new selectedUploadDir state, 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 fallback
    renders out of the box).

~23 lines added, two files, frontend only, fully backward-compatible.

Testing

  • npm run build passes (client + server).
  • Manually verified: selecting a subfolder uploads into it; the (×) reset returns
    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.

image

Result: the uploaded file lands in the selected subfolder, not the root.

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features
    • Uploads can now be directed to a specific directory within your project (instead of only uploading to the default root).
    • The File Tree UI now shows an “Upload target” indicator for the currently selected destination.
    • You can clear the selection to return uploads to the project root.

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).
@coderabbitai

coderabbitai Bot commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 46cc2e17-8f93-43ce-ad34-1f4caf17a73a

📥 Commits

Reviewing files that changed from the base of the PR and between 2d99591 and 4888ee2.

📒 Files selected for processing (2)
  • src/components/file-tree/hooks/useFileTreeUpload.ts
  • src/components/file-tree/view/FileTree.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/components/file-tree/view/FileTree.tsx

📝 Walkthrough

Walkthrough

useFileTreeUpload's handleFileSelect gains an optional targetPath parameter forwarded to uploadFiles. FileTree adds selectedUploadDir state, sets it when a directory is clicked, passes it to handleFileSelect, and renders a dismissible upload-target indicator bar.

Changes

Directory-targeted upload flow

Layer / File(s) Summary
handleFileSelect targetPath parameter
src/components/file-tree/hooks/useFileTreeUpload.ts
handleFileSelect signature updated to accept targetPath?: string (defaulting to '') with JSDoc documenting the parameter, and forwards it to uploadFiles alongside the converted files array.
selectedUploadDir state, wiring, and indicator UI
src/components/file-tree/view/FileTree.tsx
FileTree adds selectedUploadDir state initialized to '', sets it on directory click, passes it as the second argument to upload.handleFileSelect in the header upload handler, and conditionally renders an "Upload target" bar showing the selected path with a reset button.

Possibly related PRs

  • siteboon/claudecodeui#847: Refactored the XHR/progress-based upload implementation in useFileTreeUpload and FileTree, which is the same upload flow this PR extends with directory targeting.

Suggested reviewers

  • viper151

Poem

🐇 Hippity-hop, I pick the right spot,
No more uploading to wherever, or not!
Click a folder, the target is set,
A little bar shows — the best UI yet.
Reset with a click, back to the root we go,
Uploads land where you want them — put on a show! 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Upload into the selected file-tree folder (not just the project root)' directly and clearly describes the main feature—enabling uploads to target a selected subfolder instead of always the project root.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/components/file-tree/view/FileTree.tsx (1)

95-95: ⚡ Quick win

Clear selectedUploadDir when selectedProject changes.

When the user switches projects, selectedUploadDir retains 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

📥 Commits

Reviewing files that changed from the base of the PR and between 86f6479 and 2d99591.

📒 Files selected for processing (2)
  • src/components/file-tree/hooks/useFileTreeUpload.ts
  • src/components/file-tree/view/FileTree.tsx

@artemkrotov

Copy link
Copy Markdown

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.
@blackmammoth blackmammoth linked an issue Jun 18, 2026 that may be closed by this pull request
@blackmammoth

Copy link
Copy Markdown
Member

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?

@blackmammoth blackmammoth marked this pull request as draft June 18, 2026 11:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Enable file uploads in file view inside projects

3 participants