Skip to content

Commit 607c711

Browse files
committed
fix(web): native folder picker starts the clone on the destination step
Open in Finder on the clone destination step added the picked folder as a project and never started cloneRepository. Resolve that folder the same way in-app browse does, then submit the clone flow, including the WSL path.
1 parent 8fc72da commit 607c711

3 files changed

Lines changed: 70 additions & 0 deletions

File tree

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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { scopeProjectRef, scopeThreadRef } from "@t3tools/client-runtime/environ
77
import {
88
canCreateProjectInEnvironment,
99
getCloneDestinationBrowsePath,
10+
getCloneDestinationForPickedFolder,
1011
getCloneDestinationPath,
1112
getCloneDirectoryName,
1213
getDefaultCloneUrl,
@@ -3104,6 +3105,26 @@ function OpenCommandPaletteDialog(props: {
31043105
);
31053106
return;
31063107
}
3108+
if (addProjectCloneFlow?.step === "confirm") {
3109+
if (selection.environmentId !== addProjectCloneFlow.environmentId) {
3110+
toastManager.add(
3111+
stackedThreadToast({
3112+
type: "error",
3113+
title: "Clone failed",
3114+
description: "Choose a folder in the environment the repository is cloned into.",
3115+
}),
3116+
);
3117+
return;
3118+
}
3119+
await submitAddProjectCloneFlow(
3120+
getCloneDestinationForPickedFolder({
3121+
pickedPath: selection.linuxPath,
3122+
cloneDirectoryName: pinnedCloneDirectoryName,
3123+
caseSensitive: true,
3124+
}),
3125+
);
3126+
return;
3127+
}
31073128
await handleAddProjectForEnvironment({
31083129
environmentId: selection.environmentId,
31093130
rawCwd: selection.linuxPath,
@@ -3112,6 +3133,16 @@ function OpenCommandPaletteDialog(props: {
31123133
});
31133134
return;
31143135
}
3136+
if (addProjectCloneFlow?.step === "confirm") {
3137+
await submitAddProjectCloneFlow(
3138+
getCloneDestinationForPickedFolder({
3139+
pickedPath,
3140+
cloneDirectoryName: pinnedCloneDirectoryName,
3141+
caseSensitive: !isWindowsPlatform(browseEnvironmentPlatform),
3142+
}),
3143+
);
3144+
return;
3145+
}
31153146
await handleAddProject(pickedPath);
31163147
};
31173148

‎packages/client-runtime/src/operations/projects.test.ts‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
findExistingAddProject,
1616
getAddProjectInitialQuery,
1717
getCloneDestinationBrowsePath,
18+
getCloneDestinationForPickedFolder,
1819
getCloneDestinationPath,
1920
getCloneDirectoryName,
2021
getDefaultCloneUrl,
@@ -162,6 +163,23 @@ describe("add project shared logic", () => {
162163
).toBe("C:\\Projects\\Repo\\");
163164
});
164165

166+
it("resolves a native-picker folder like an in-app clone selection", () => {
167+
const pick = (pickedPath: string, caseSensitive = true) =>
168+
getCloneDestinationForPickedFolder({
169+
pickedPath,
170+
cloneDirectoryName: "repo",
171+
caseSensitive,
172+
});
173+
174+
expect(pick("/Users/me/code")).toBe("/Users/me/code/repo");
175+
expect(pick("/Users/me/code/")).toBe("/Users/me/code/repo");
176+
expect(pick("/Users/me/repo")).toBe("/Users/me/repo/");
177+
expect(pick("/Users/me/Repo")).toBe("/Users/me/Repo/repo");
178+
expect(pick("C:\\Projects\\Repo", false)).toBe("C:\\Projects\\Repo\\");
179+
expect(pick("C:\\Projects", false)).toBe("C:\\Projects\\repo");
180+
expect(pick("/")).toBe("/repo");
181+
});
182+
165183
it("rejects unsupported windows paths on non-windows environments", () => {
166184
expect(
167185
resolveAddProjectPath({

‎packages/client-runtime/src/operations/projects.ts‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
appendBrowsePathSegment,
1919
ensureBrowseDirectoryPath,
2020
findProjectByPath,
21+
getBrowseParentPath,
2122
inferProjectTitleFromPath,
2223
isExplicitRelativeProjectPath,
2324
isUnsupportedWindowsProjectPath,
@@ -247,6 +248,26 @@ export function getCloneDestinationBrowsePath(input: {
247248
: getCloneDestinationPath(selectedDirectoryPath, input.cloneDirectoryName);
248249
}
249250

251+
// The native picker returns a full path, not a name under the browsed directory.
252+
// Split it and reuse the in-app rules so a folder already named after the
253+
// repository stays that folder instead of becoming repo/repo.
254+
export function getCloneDestinationForPickedFolder(input: {
255+
readonly pickedPath: string;
256+
readonly cloneDirectoryName: string;
257+
readonly caseSensitive: boolean;
258+
}): string {
259+
const parentPath = getBrowseParentPath(input.pickedPath);
260+
if (parentPath === null) {
261+
return getCloneDestinationPath(input.pickedPath, input.cloneDirectoryName);
262+
}
263+
return getCloneDestinationBrowsePath({
264+
browseDirectoryPath: parentPath,
265+
selectedDirectoryName: inferProjectTitleFromPath(input.pickedPath),
266+
cloneDirectoryName: input.cloneDirectoryName,
267+
caseSensitive: input.caseSensitive,
268+
});
269+
}
270+
250271
export function resolveAddProjectPath(input: {
251272
readonly rawPath: string;
252273
readonly currentProjectCwd?: string | null;

0 commit comments

Comments
 (0)