diff --git a/apps/web/src/components/CommandPalette.tsx b/apps/web/src/components/CommandPalette.tsx
index 3349902aeea05..cc839c6d92c3c 100644
--- a/apps/web/src/components/CommandPalette.tsx
+++ b/apps/web/src/components/CommandPalette.tsx
@@ -2379,7 +2379,7 @@ function OpenCommandPaletteDialog(props: {
cloneDirectoryName: pinnedCloneDirectoryName,
caseSensitive: !isWindowsPlatform(browseEnvironmentPlatform),
})
- : appendBrowsePathSegment(query, name);
+ : appendBrowsePathSegment(browsePath.directoryPath, name);
await browseNavigation.run(
() => prefetchBrowsePath(getBrowseDirectoryPath(nextQuery)),
() => {
@@ -2797,7 +2797,7 @@ function OpenCommandPaletteDialog(props: {
void browseTo(completion.name);
} else if (completion && !pinnedCloneDirectoryName) {
setHighlightedItemValue(null);
- setQuery(`${getBrowseDirectoryPath(query)}${completion.name}`);
+ setQuery(`${browsePath.directoryPath}${completion.name}`);
}
return;
}
diff --git a/apps/web/src/components/settings/ProjectRepositoriesSettings.tsx b/apps/web/src/components/settings/ProjectRepositoriesSettings.tsx
index ea6868ed3dc93..6ea4694620c23 100644
--- a/apps/web/src/components/settings/ProjectRepositoriesSettings.tsx
+++ b/apps/web/src/components/settings/ProjectRepositoriesSettings.tsx
@@ -338,7 +338,9 @@ function AddTrackedFolderDialog(props: {
key={entry.fullPath}
type="button"
className={rowClassName}
- onClick={() => setQuery(appendBrowsePathSegment(query, entry.name))}
+ onClick={() =>
+ setQuery(appendBrowsePathSegment(browsePath.directoryPath, entry.name))
+ }
>
{entry.name}
diff --git a/packages/client-runtime/src/state/filesystem.test.ts b/packages/client-runtime/src/state/filesystem.test.ts
index f0c87f7c7f447..4b4547490f41c 100644
--- a/packages/client-runtime/src/state/filesystem.test.ts
+++ b/packages/client-runtime/src/state/filesystem.test.ts
@@ -78,6 +78,13 @@ describe("filesystem browse model", () => {
parentPath: "~/",
canBrowseUp: true,
});
+ expect(getFilesystemBrowsePath("D:", "Win32")).toEqual({
+ isBrowsing: true,
+ directoryPath: "D:\\",
+ filterQuery: "",
+ parentPath: null,
+ canBrowseUp: false,
+ });
expect(getFilesystemBrowsePath("C:\\Users\\test", "MacIntel").isBrowsing).toBe(false);
expect(getFilesystemBrowsePath("~/projects/", "", false).isBrowsing).toBe(false);
});
diff --git a/packages/client-runtime/src/state/filesystem.ts b/packages/client-runtime/src/state/filesystem.ts
index 1ee87c85d5507..d2bddeeb75ad4 100644
--- a/packages/client-runtime/src/state/filesystem.ts
+++ b/packages/client-runtime/src/state/filesystem.ts
@@ -70,9 +70,13 @@ export function resolveFilesystemReadAccess(
export function getFilesystemBrowsePath(query: string, platform = "", enabled = true) {
const isBrowsing = enabled && isFilesystemBrowseQuery(query, platform);
- const directoryPath = isBrowsing ? getBrowseDirectoryPath(query) : "";
+ // A bare drive has no separator, so it would otherwise filter its own listing by "D:".
+ const browseQuery = /^[a-zA-Z]:$/.test(query) ? `${query}\\` : query;
+ const directoryPath = isBrowsing ? getBrowseDirectoryPath(browseQuery) : "";
const filterQuery =
- isBrowsing && !hasTrailingPathSeparator(query) ? getBrowseLeafPathSegment(query) : "";
+ isBrowsing && !hasTrailingPathSeparator(browseQuery)
+ ? getBrowseLeafPathSegment(browseQuery)
+ : "";
const parentPath = isBrowsing ? getBrowseParentPath(directoryPath) : null;
return {