Skip to content

Commit 656da45

Browse files
committed
fix(web): seed the open folder picker without stalling the hotkey
44d39ed held the open-folder intent until the add-project browse view committed. If that browse was invalidated first, or the committed query was not a browse path, the intent stuck and later mod+alt+o presses did nothing until the palette was closed. Drop the wait. fileManagerInitialPath now falls back to the environment's configured add-project directory when there is no browse query yet, which is the only thing the wait was buying. The desktop already expands a leading ~ against the target's home, including over WSL, so the hotkey gets the right starting directory on the first render and the intent clears immediately.
1 parent 44d39ed commit 656da45

1 file changed

Lines changed: 25 additions & 22 deletions

File tree

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

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2140,10 +2140,18 @@ function OpenCommandPaletteDialog(props: {
21402140
window.desktopBridge !== undefined;
21412141
const canOpenProjectFromFileManager = isBrowsing && canPickProjectFolder;
21422142
const fileManagerInitialPath = useMemo(() => {
2143-
if (!canOpenProjectFromFileManager) {
2143+
if (!canPickProjectFolder) {
21442144
return undefined;
21452145
}
21462146

2147+
// The `project.openFolder` hotkey opens the picker before a browse view
2148+
// exists, so there is no query to derive a directory from. Start at the
2149+
// environment's configured add-project directory instead; the desktop
2150+
// expands a leading `~` against the target's home, including over WSL.
2151+
if (!isBrowsing) {
2152+
return getAddProjectInitialQueryForEnvironment(browseEnvironmentId);
2153+
}
2154+
21472155
const trimmedQuery = query.trim();
21482156
if (trimmedQuery.length === 0) {
21492157
return undefined;
@@ -2157,9 +2165,12 @@ function OpenCommandPaletteDialog(props: {
21572165
return resolvedPath.length > 0 ? resolvedPath : undefined;
21582166
}, [
21592167
browseDirectoryPath,
2168+
browseEnvironmentId,
21602169
browseResult?.parentPath,
2161-
canOpenProjectFromFileManager,
2170+
canPickProjectFolder,
21622171
currentProjectCwdForBrowse,
2172+
getAddProjectInitialQueryForEnvironment,
2173+
isBrowsing,
21632174
query,
21642175
]);
21652176

@@ -2347,36 +2358,28 @@ function OpenCommandPaletteDialog(props: {
23472358
primaryEnvironmentId,
23482359
]);
23492360

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.
2361+
// `project.openFolder` routes here: jump straight to the native folder
2362+
// picker against the environment browsing would target, opening the
2363+
// add-project browse view behind it so cancelling lands somewhere useful.
2364+
// Falls back to the regular add-project flow when the picker can't run (web
2365+
// client, WSL instance not yet resolved) or environment selection is needed.
23572366
useLayoutEffect(() => {
23582367
if (openIntent?.kind !== "open-folder") {
2359-
openFolderBrowseStartedRef.current = false;
23602368
return;
23612369
}
2370+
clearOpenIntent();
23622371
if (
2363-
browseEnvironmentId === null ||
2364-
!canPickProjectFolder ||
2365-
addProjectEnvironmentOptions.length > 1
2372+
browseEnvironmentId !== null &&
2373+
canPickProjectFolder &&
2374+
addProjectEnvironmentOptions.length <= 1
23662375
) {
2367-
clearOpenIntent();
2368-
openAddProjectFlow();
2369-
return;
2370-
}
2371-
if (!isBrowsing) {
2372-
if (!openFolderBrowseStartedRef.current) {
2373-
openFolderBrowseStartedRef.current = true;
2376+
if (!isBrowsing) {
23742377
void startAddProjectBrowse(browseEnvironmentId);
23752378
}
2379+
void handleOpenProjectFromFileManager();
23762380
return;
23772381
}
2378-
clearOpenIntent();
2379-
void handleOpenProjectFromFileManager();
2382+
openAddProjectFlow();
23802383
}, [
23812384
addProjectEnvironmentOptions.length,
23822385
browseEnvironmentId,

0 commit comments

Comments
 (0)