Open desktop folder picker immediately when adding projects in Electron#697
Open desktop folder picker immediately when adding projects in Electron#697juliusmarminge merged 4 commits intomainfrom
Conversation
- add `shouldOpenProjectFolderPickerImmediately` to centralize Sidebar behavior - trigger folder browse directly when adding a project in desktop Electron - keep manual path entry for mobile layouts and non-Electron, with tests for all cases
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Autofix Details
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Project creation errors invisible in desktop Electron mode
- In the catch block of addProjectFromPath, errors now show a toast via toastManager when shouldBrowseForProjectImmediately is true (desktop Electron), since the inline error display is inside a conditional block that is always false in that mode.
Or push these changes by commenting:
@cursor push f0ba5fcc2e
Preview (f0ba5fcc2e)
diff --git a/apps/web/src/components/Sidebar.tsx b/apps/web/src/components/Sidebar.tsx
--- a/apps/web/src/components/Sidebar.tsx
+++ b/apps/web/src/components/Sidebar.tsx
@@ -531,15 +531,29 @@
});
await handleNewThread(projectId).catch(() => undefined);
} catch (error) {
+ const message =
+ error instanceof Error ? error.message : "An error occurred while adding the project.";
setIsAddingProject(false);
- setAddProjectError(
- error instanceof Error ? error.message : "An error occurred while adding the project.",
- );
+ if (shouldBrowseForProjectImmediately) {
+ toastManager.add({
+ type: "error",
+ title: "Could not add project",
+ description: message,
+ });
+ } else {
+ setAddProjectError(message);
+ }
return;
}
finishAddingProject();
},
- [focusMostRecentThreadForProject, handleNewThread, isAddingProject, projects],
+ [
+ focusMostRecentThreadForProject,
+ handleNewThread,
+ isAddingProject,
+ projects,
+ shouldBrowseForProjectImmediately,
+ ],
);
const handleAddProject = () => {- remove mobile-width gating from sidebar project picker behavior - simplify picker logic/tests to depend only on Electron runtime
|
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)
Comment |
- Replace `shouldOpenProjectFolderPickerImmediately` with direct `isElectron` usage - Remove obsolete `Sidebar.logic.ts` and its tests
| isElectron: boolean; | ||
| }): boolean { | ||
| return input.isElectron; | ||
| } |
There was a problem hiding this comment.
Missing isMobile check opens picker on mobile Electron
Medium Severity
The PR description specifies the folder picker opens only for desktop Electron (isElectron && !isMobile), keeping manual path-entry for mobile Electron layouts. However, shouldOpenProjectFolderPickerImmediately only checks isElectron and doesn't accept or evaluate an isMobile parameter. This means mobile Electron users get the native folder picker instead of the intended manual path-entry UI. The isMobile value is available via useSidebar() in the sidebar context but is never passed to or checked by this function.
Additional Locations (1)
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Missing
!isMobilecheck for folder picker condition- Added
useSidebar()hook to getisMobileand updated the condition fromisElectrontoisElectron && !isMobileso mobile Electron layouts preserve the manual path-entry UI.
- Added
Or push these changes by commenting:
@cursor push 95ebece7ed
| const renamingCommittedRef = useRef(false); | ||
| const renamingInputRef = useRef<HTMLInputElement | null>(null); | ||
| const [desktopUpdateState, setDesktopUpdateState] = useState<DesktopUpdateState | null>(null); | ||
| const shouldBrowseForProjectImmediately = isElectron; |
There was a problem hiding this comment.
Missing !isMobile check for folder picker condition
High Severity
shouldBrowseForProjectImmediately is set to just isElectron, but the PR description explicitly specifies the condition as isElectron && !isMobile. Mobile Electron layouts will incorrectly skip the manual path-entry UI and immediately open the native folder picker, breaking the intended behavior of preserving manual entry for mobile Electron environments.
- Use a toast error for add-project failures during immediate folder browse - Keep inline add-project error state for non-immediate flows - Include `shouldBrowseForProjectImmediately` in callback dependencies
|
weird change. I remember Theo on stream specified this as a pro-dev feature that he insisted on and it was actually useful to many, and now it basically gone |
|
We need to have a chat Julius |



Summary
isElectron && !isMobile).Sidebar.logic.tsto isolate the picker decision logic for easier testing and reuse.shouldOpenProjectFolderPickerImmediatelycovering desktop Electron, mobile Electron, and non-Electron cases.Testing
apps/web/src/components/Sidebar.logic.test.tsadded with 3 Vitest cases for the new decision logic.bun lint— Not run.bun typecheck— Not run.bun run test— Not run.Note
Medium Risk
Changes the project-creation UX and error surfacing in
Sidebar, which could affect Electron users’ ability to add projects if the picker flow or state transitions misbehave.Overview
Clicking Add project in
Sidebarnow immediately opens the native folder picker on Electron, instead of toggling the inline path-entry UI.The inline path entry (and related empty-state text) is now gated behind
shouldShowProjectPathEntry, while failures during add-project in the immediate-picker flow are surfaced via an error toast rather than inline form error state; the add button also reflects state viaaria-pressedand a rotatingPlusIcon.Written by Cursor Bugbot for commit 2b6e011. This will update automatically on new commits. Configure here.
Note
Open the native folder picker immediately in Electron when clicking Add project in
Sidebarand adjust web UX in Sidebar.tsxIntroduce
shouldBrowseForProjectImmediatelyandshouldShowProjectPathEntry, addhandleStartAddProject, route errors to toasts in Electron, skip refocus after canceled pick in Electron, and update Projects section JSX and button state.📍Where to Start
Start with the
handleStartAddProjecthandler and related state logic in Sidebar.tsx.Macroscope summarized 2b6e011.