Skip to content

Commit 4180de7

Browse files
PR Batch Testerclaude
andcommitted
fix(client): folder browsing keeps the ghq clone folder it suggested
With the ghq layout on, browsing pinned the repository's display name while the default ended in the URL's folder, so selecting an existing Azure folder gave .../My%20Repo/My Repo. Web and mobile now pin the default's last folder. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent bf07b0a commit 4180de7

4 files changed

Lines changed: 31 additions & 5 deletions

File tree

‎apps/mobile/src/features/projects/AddProjectScreen.tsx‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
getAddProjectInitialQuery,
1818
getCloneDestinationBrowsePath,
1919
getCloneDestinationPath,
20+
getCloneDirectoryLeafName,
2021
getCloneDirectoryPath,
2122
getCloneDirectoryName,
2223
getDefaultCloneUrl,
@@ -304,7 +305,7 @@ function useBrowsePathInput(
304305
const seedPath = getCloneDestinationPath(
305306
getAddProjectInitialQuery(environmentBaseDirectory),
306307
remoteUrl && environment?.ghqCloneLayout
307-
? getCloneDirectoryPath(remoteUrl, true)
308+
? getCloneDirectoryPath(remoteUrl, true, pinnedDirectoryName)
308309
: pinnedDirectoryName,
309310
);
310311
// Each host keeps the path last typed or browsed for it, and shows its own default until then,
@@ -1367,9 +1368,13 @@ export function AddProjectDestinationScreen(props: {
13671368
const repositoryTitle = stringParam(props.repositoryTitle);
13681369
const prompt = stringParam(props.prompt);
13691370
const repositoryName = stringParam(props.repositoryName)?.trim() ?? "";
1371+
const cloneDirectoryName =
1372+
remoteUrl && environment?.ghqCloneLayout
1373+
? getCloneDirectoryLeafName(remoteUrl, true, repositoryName)
1374+
: repositoryName;
13701375
const { isBrowseNavigating, navigateToBrowsePath, pathInput, setPathInput } = useBrowsePathInput(
13711376
environment,
1372-
repositoryName,
1377+
cloneDirectoryName,
13731378
remoteUrl,
13741379
);
13751380
const [isSubmitting, setIsSubmitting] = useState(false);
@@ -1475,7 +1480,7 @@ export function AddProjectDestinationScreen(props: {
14751480
navigateToBrowsePath={navigateToBrowsePath}
14761481
pathInput={pathInput}
14771482
setPathInput={setPathInput}
1478-
pinnedDirectoryName={repositoryName}
1483+
pinnedDirectoryName={cloneDirectoryName}
14791484
cloning={Boolean(remoteUrl)}
14801485
/>
14811486
</>

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
canCreateProjectInEnvironment,
1111
getCloneDestinationBrowsePath,
1212
getCloneDestinationPath,
13-
getCloneDirectoryName,
13+
getCloneDirectoryLeafName,
1414
getCloneDirectoryPath,
1515
getDefaultCloneUrl,
1616
getNewProjectPathPreview,
@@ -590,7 +590,11 @@ function OpenCommandPaletteDialog(props: {
590590
const isRemoteProjectRepositoryStep = addProjectCloneFlow?.step === "repository";
591591
const pinnedCloneDirectoryName =
592592
addProjectCloneFlow?.step === "confirm"
593-
? getCloneDirectoryName(
593+
? getCloneDirectoryLeafName(
594+
addProjectCloneFlow.remoteUrl,
595+
environments.find(
596+
(candidate) => candidate.environmentId === addProjectCloneFlow.environmentId,
597+
)?.serverConfig?.settings.ghqCloneLayout === true,
594598
addProjectCloneFlow.repository?.nameWithOwner ?? addProjectCloneFlow.remoteUrl,
595599
)
596600
: "";

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { EnvironmentId, ProjectId } from "@t3tools/contracts";
55
import {
66
findExistingAddProject,
77
getCloneDestinationPath,
8+
getCloneDirectoryLeafName,
89
getCloneDirectoryName,
910
getCloneDirectoryPath,
1011
getDefaultCloneUrl,
@@ -82,6 +83,13 @@ describe("add project shared logic", () => {
8283
"Project/My Repo",
8384
),
8485
).toBe("My Repo");
86+
expect(
87+
getCloneDirectoryLeafName(
88+
"[email protected]:v3/org/Project/My%20Repo",
89+
true,
90+
"Project/My Repo",
91+
),
92+
).toBe("My%20Repo");
8593
expect(
8694
getCloneDestinationPath(
8795
"C:\\Users\\me\\ghq",

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,15 @@ export function getCloneDirectoryPath(
200200
);
201201
}
202202

203+
/** The clone's own folder, which folder browsing keeps at the end of the destination. */
204+
export function getCloneDirectoryLeafName(
205+
remoteUrl: string,
206+
ghqCloneLayout: boolean,
207+
repository = remoteUrl,
208+
): string {
209+
return getCloneDirectoryPath(remoteUrl, ghqCloneLayout, repository).split("/").at(-1) ?? "";
210+
}
211+
203212
export function getCloneDestinationPath(
204213
directoryPath: string,
205214
directoryName: string | null | undefined,

0 commit comments

Comments
 (0)