feat(web): create folders from the add-project path picker#3723
Conversation
Add a filesystem.createDirectory RPC and surface it in the browse picker so users can create a missing folder and keep browsing without immediately adding it as a project. The picker shows a Create folder action when the typed leaf name has no exact match, Shift+Enter creates and navigates into the folder, and Enter still adds or clones the project as before.
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ 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.
Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit bcccbf6. Configure here.
| partialPath: input.partialPath, | ||
| directoryPath: resolvedDirectoryPath, | ||
| }), | ||
| ), |
There was a problem hiding this comment.
EEXIST breaks directory idempotency
Medium Severity
The createDirectory function can incorrectly fail with path_already_exists when a directory is created by another process between its initial stat check and the mkdir call. This breaks its intended idempotent behavior, causing RPC failures even when the directory exists.
Reviewed by Cursor Bugbot for commit bcccbf6. Configure here.
| ? { | ||
| emptyStateMessage: | ||
| "Press Enter to create this folder and add it as a project.", | ||
| } |
There was a problem hiding this comment.
Clone step hides folder hint
Medium Severity
During the clone destination step, the empty-state copy always says to press Enter to clone, even when a new folder name is typed and the footer shows Shift+Enter to create a folder. The browseCreateFolderName branch never runs because the confirm-step branch is checked first, so clone browsing never gets the Shift+Enter vs Enter guidance this PR added elsewhere.
Reviewed by Cursor Bugbot for commit bcccbf6. Configure here.
|
Doing some further testing, it seems fine so far |
| if ( | ||
| folderName.length === 0 || | ||
| input.exactEntry !== null || | ||
| input.isBrowsePending || | ||
| input.relativePathNeedsActiveProject || | ||
| input.browseParentPath === null || | ||
| input.browseParentPath === undefined || | ||
| input.browseParentPath.length === 0 | ||
| ) { |
There was a problem hiding this comment.
🟡 Medium components/CommandPalette.logic.ts:65
getBrowseCreateFolderName returns "." and ".." as valid folder names. When the user types .. (or a query whose leaf is ..), the create-folder action navigates to the parent directory via appendBrowsePathSegment(..., "..") instead of creating a new folder — it performs the wrong operation and succeeds without creating anything. Consider rejecting ".", "..", and empty segments so these inputs do not produce a create-folder item.
| if ( | |
| folderName.length === 0 || | |
| input.exactEntry !== null || | |
| input.isBrowsePending || | |
| input.relativePathNeedsActiveProject || | |
| input.browseParentPath === null || | |
| input.browseParentPath === undefined || | |
| input.browseParentPath.length === 0 | |
| ) { | |
| const folderName = input.browseFilterQuery.trim(); | |
| if ( | |
| folderName.length === 0 || | |
| folderName === "." || | |
| folderName === ".." || | |
| input.exactEntry !== null || | |
| input.isBrowsePending || | |
| input.relativePathNeedsActiveProject || | |
| input.browseParentPath === null || | |
| input.browseParentPath === undefined || | |
| input.browseParentPath.length === 0 | |
| ) { |
🤖 Copy this AI Prompt to have your agent fix this:
In file @apps/web/src/components/CommandPalette.logic.ts around lines 65-73:
`getBrowseCreateFolderName` returns `"."` and `".."` as valid folder names. When the user types `..` (or a query whose leaf is `..`), the create-folder action navigates to the parent directory via `appendBrowsePathSegment(..., "..")` instead of creating a new folder — it performs the wrong operation and succeeds without creating anything. Consider rejecting `"."`, `".."`, and empty segments so these inputs do not produce a create-folder item.
ApprovabilityVerdict: Needs human review 1 blocking correctness issue found. This PR introduces a new feature (folder creation in path picker) with ~550 lines of new logic across server and client. Three unresolved medium-severity bugs have been identified: a race condition in directory creation, missing UI hints during clone, and acceptance of You can customize Macroscope's approvability policy. Learn more. |


Summary
Adds the ability to create folders while browsing in the add-project path picker, without immediately adding them as a project.
Previously, typing a non-existent path and pressing Enter always created the directory and added it as a project. There was no way to create intermediate folders and keep browsing.
What's included
filesystem.createDirectoryRPC (contracts, server, client-runtime)Design notes
WorkspaceEntries.createDirectory(parent must exist; idempotent if the folder already exists)AuthOrchestrationOperateScopefor the new RPCTesting
vp check— passvp run typecheck— passfilesystem.test.ts,WorkspaceEntries.test.ts,CommandPalette.logic.test.tsbun run dev:desktop) — create folder via Shift+Enter, navigate in, then add project with EnterNote
Medium Risk
Adds an authenticated but operate-scoped RPC that performs real
mkdiron the host filesystem; path rules mirror browse, but misuse or bugs could still create directories outside user intent.Overview
Introduces
filesystem.createDirectorythrough contracts, client-runtime,WorkspaceEntries, and WebSocket RPC (AuthOrchestrationOperateScope), with typed failures mapped to client-facing errors.The add-project path browser can show Create folder "name" when the typed leaf has no exact match; Shift+Enter (or the list action) creates the directory and refreshes browse into it, while Enter still adds the path as a project or clone destination. Footer and empty-state copy document the shortcut.
Server
createDirectoryreuses browse path resolution, requires an existing parent directory, is idempotent when the target is already a directory, and rejects files / missing parents / races (EEXIST).Reviewed by Cursor Bugbot for commit bcccbf6. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Add folder creation to the add-project path picker in the command palette
filesystem.createDirectoryRPC across contracts, server, and client, with typed input/result schemas and structured failure codes in filesystem.ts.WorkspaceEntries.createDirectoryon the server, resolving paths, checking parent existence, and mappingmkdirerrors to tagged error types.📊 Macroscope summarized bcccbf6. 7 files reviewed, 0 issues evaluated, 0 issues filtered, 0 comments posted
🗂️ Filtered Issues
No issues evaluated.