Skip to content

Commit 44d39ed

Browse files
committed
fix(web): open folder hotkey starts at the configured add-project directory
The hotkey opened the native picker in the same tick that it started the add-project browse, so isBrowsing was still false and fileManagerInitialPath resolved to undefined. The picker opened wherever the OS last left it instead of the environment's addProjectBaseDirectory. Split the effect in two: start the browse and keep the open-folder intent, then open the picker on the render after the browse view commits, when the resolved directory is available. This also removes the in-flight browse commit that could land after the palette closed.
1 parent e8473d9 commit 44d39ed

1 file changed

Lines changed: 20 additions & 11 deletions

File tree

‎apps/web/src/components/CommandPalette.tsx‎

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2347,27 +2347,36 @@ function OpenCommandPaletteDialog(props: {
23472347
primaryEnvironmentId,
23482348
]);
23492349

2350-
// `project.openFolder` routes here: jump straight to the native folder
2351-
// picker against the environment browsing would target, falling back to the
2352-
// regular add-project flow when the picker can't run (web client, WSL
2353-
// instance not yet resolved) or environment selection is needed first.
2350+
const openFolderBrowseStartedRef = useRef(false);
2351+
// `project.openFolder` routes here: open the add-project browse view for the
2352+
// environment browsing would target, then hand off to the native picker once
2353+
// that view has committed so the picker starts at the environment's
2354+
// configured add-project directory. Falls back to the regular add-project
2355+
// flow when the picker can't run (web client, WSL instance not yet resolved)
2356+
// or environment selection is needed first.
23542357
useLayoutEffect(() => {
23552358
if (openIntent?.kind !== "open-folder") {
2359+
openFolderBrowseStartedRef.current = false;
23562360
return;
23572361
}
2358-
clearOpenIntent();
23592362
if (
2360-
browseEnvironmentId !== null &&
2361-
canPickProjectFolder &&
2362-
addProjectEnvironmentOptions.length <= 1
2363+
browseEnvironmentId === null ||
2364+
!canPickProjectFolder ||
2365+
addProjectEnvironmentOptions.length > 1
23632366
) {
2364-
if (!isBrowsing) {
2367+
clearOpenIntent();
2368+
openAddProjectFlow();
2369+
return;
2370+
}
2371+
if (!isBrowsing) {
2372+
if (!openFolderBrowseStartedRef.current) {
2373+
openFolderBrowseStartedRef.current = true;
23652374
void startAddProjectBrowse(browseEnvironmentId);
23662375
}
2367-
void handleOpenProjectFromFileManager();
23682376
return;
23692377
}
2370-
openAddProjectFlow();
2378+
clearOpenIntent();
2379+
void handleOpenProjectFromFileManager();
23712380
}, [
23722381
addProjectEnvironmentOptions.length,
23732382
browseEnvironmentId,

0 commit comments

Comments
 (0)