From 38e8477a45d863be92c64df86e5f2f0284e2e70c Mon Sep 17 00:00:00 2001 From: Josh Gratton Date: Sun, 17 May 2026 13:57:48 -0400 Subject: [PATCH] feat(web): allow "Open from file manager" against desktop-local envs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The command-palette's add-project flow gated the "Open project from File Manager" affordance on browseEnvironmentId === primary. That held for the swap-mode world where the desktop only managed one local backend. With the WSL backend now registered as a saved-env with a desktopLocal marker, the file-manager picker should be available there too — and the desktop side already knows how to route a pickFolder call into the right WSL distro's filesystem when the renderer passes targetEnvironmentId. Open the gate to "primary OR desktopLocal" and forward browseEnvironmentId as targetEnvironmentId on the pickFolder call. Remote saved environments stay browse-only because the desktop side has no way to spawn an OS file dialog over there. --- apps/web/src/components/CommandPalette.tsx | 24 +++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/apps/web/src/components/CommandPalette.tsx b/apps/web/src/components/CommandPalette.tsx index 7862191d40..62e6d732e4 100644 --- a/apps/web/src/components/CommandPalette.tsx +++ b/apps/web/src/components/CommandPalette.tsx @@ -1404,11 +1404,18 @@ function OpenCommandPaletteDialog() { query.trim().length > 0 && !isRemoteProjectPending; const fileManagerName = getLocalFileManagerName(navigator.platform); + // The file-manager picker comes from the desktop. We allow it for + // the primary backend (its native fs) and for any desktop-local + // secondary (today: the WSL backend — pickFolder dispatches to the + // WSL distro's home when routed by env id). Remote saved envs + // stay browse-only. + const browseSavedEnvironmentRecord = + browseEnvironmentId !== null ? (savedEnvironmentRegistry[browseEnvironmentId] ?? null) : null; + const browseEnvironmentIsDesktopLocal = browseSavedEnvironmentRecord?.desktopLocal !== undefined; const canOpenProjectFromFileManager = isBrowsing && browseEnvironmentId !== null && - primaryEnvironmentId !== null && - browseEnvironmentId === primaryEnvironmentId && + (browseEnvironmentId === primaryEnvironmentId || browseEnvironmentIsDesktopLocal) && typeof window !== "undefined" && window.desktopBridge !== undefined; const fileManagerInitialPath = useMemo(() => { @@ -1504,8 +1511,17 @@ function OpenCommandPaletteDialog() { setIsPickingProjectFolder(true); let pickedPath: string | null = null; try { + // Route the picker to the env id the user is browsing in so the + // dialog opens against the right backend's filesystem (desktop + // side resolves wsl:* ids to their distro's home dir). + const pickerOptions = { + ...(fileManagerInitialPath ? { initialPath: fileManagerInitialPath } : {}), + ...(browseEnvironmentId && browseEnvironmentId !== primaryEnvironmentId + ? { targetEnvironmentId: browseEnvironmentId } + : {}), + }; pickedPath = await api.dialogs.pickFolder( - fileManagerInitialPath ? { initialPath: fileManagerInitialPath } : undefined, + Object.keys(pickerOptions).length > 0 ? pickerOptions : undefined, ); } catch { // Ignore picker failures and leave the palette open. @@ -1518,10 +1534,12 @@ function OpenCommandPaletteDialog() { } await handleAddProject(pickedPath); }, [ + browseEnvironmentId, canOpenProjectFromFileManager, fileManagerInitialPath, handleAddProject, isPickingProjectFolder, + primaryEnvironmentId, ]); return (