feat(web): allow "Open from file manager" against desktop-local envs
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.
This commit is contained in:
1 parent
1c7e78733f
commit
38e8477a45
1 file changed
+21
-3
@@ -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 (
|
||||
|
||||
Reference in new issue
Block a user