@devries-cameron20 / t3code Mirror · read-only / commits / 1a1a57376c
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 23:30 UTC

fix(web): start clone when destination is picked in file manager (#22226)

Co-authored-by: macodev00 <macodev00@users.noreply.github.com> Co-authored-by: Julius Marminge <julius0216@outlook.com>

maco committed Nov 11, 2026 at 20:53 UTC 1a1a57376c4a0930fdcdd8562e786b949303b8cf
3 files changed +70
apps/web/src/components/CommandPalette.tsx
+31
@@ -10,6 +10,7 @@ import {
10 import {
11 canCreateProjectInEnvironment,
12 getCloneDestinationBrowsePath,
13 + getCloneDestinationForPickedFolder,
14 getCloneDestinationPath,
15 getCloneDirectoryLeafName,
16 getCloneDirectoryPath,
@@ -2806,6 +2807,26 @@ function OpenCommandPaletteDialog(props: {
2807 );
2808 return;
2809 }
2810 + if (addProjectCloneFlow?.step === "confirm") {
2811 + if (selection.environmentId !== addProjectCloneFlow.environmentId) {
2812 + toastManager.add(
2813 + stackedThreadToast({
2814 + type: "error",
2815 + title: "Clone failed",
2816 + description: "Choose a folder in the environment the repository is cloned into.",
2817 + }),
2818 + );
2819 + return;
2820 + }
2821 + await submitAddProjectCloneFlow(
2822 + getCloneDestinationForPickedFolder({
2823 + pickedPath: selection.linuxPath,
2824 + cloneDirectoryName: pinnedCloneDirectoryName,
2825 + caseSensitive: true,
2826 + }),
2827 + );
2828 + return;
2829 + }
2830 await handleAddProjectForEnvironment({
2831 environmentId: selection.environmentId,
2832 rawCwd: selection.linuxPath,
@@ -2814,6 +2835,16 @@ function OpenCommandPaletteDialog(props: {
2835 });
2836 return;
2837 }
2838 + if (addProjectCloneFlow?.step === "confirm") {
2839 + await submitAddProjectCloneFlow(
2840 + getCloneDestinationForPickedFolder({
2841 + pickedPath,
2842 + cloneDirectoryName: pinnedCloneDirectoryName,
2843 + caseSensitive: !isWindowsPlatform(browseEnvironmentPlatform),
2844 + }),
2845 + );
2846 + return;
2847 + }
2848 await handleAddProject(pickedPath);
2849 };
2850
packages/client-runtime/src/operations/projects.test.ts
+18
@@ -4,6 +4,7 @@ import { EnvironmentId, ProjectId } from "@t3tools/contracts";
4
5 import {
6 findExistingAddProject,
7 + getCloneDestinationForPickedFolder,
8 getCloneDestinationPath,
9 getCloneDirectoryLeafName,
10 getCloneDirectoryName,
@@ -162,6 +163,23 @@ describe("add project shared logic", () => {
163 expect(getCloneDirectoryName("git@github.com:acme/123.git")).toBe("123");
164 });
165
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 +
183 it("finds existing projects by normalized path in the target environment", () => {
184 const env = EnvironmentId.make("env");
185 const other = EnvironmentId.make("other");
packages/client-runtime/src/operations/projects.ts
+21
@@ -19,6 +19,7 @@ import {
19 appendBrowsePathSegment,
20 ensureBrowseDirectoryPath,
21 findProjectByPath,
22 + getBrowseParentPath,
23 inferProjectTitleFromPath,
24 isExplicitRelativeProjectPath,
25 isUnsupportedWindowsProjectPath,
@@ -299,6 +300,26 @@ export function getCloneDestinationBrowsePath(input: {
300 : getCloneDestinationPath(selectedDirectoryPath, input.cloneDirectoryName);
301 }
302
303 +// The native picker returns a full path, not a name under the browsed directory.
304 +// Split it and reuse the in-app rules so a folder already named after the
305 +// repository stays that folder instead of becoming repo/repo.
306 +export function getCloneDestinationForPickedFolder(input: {
307 + readonly pickedPath: string;
308 + readonly cloneDirectoryName: string;
309 + readonly caseSensitive: boolean;
310 +}): string {
311 + const parentPath = getBrowseParentPath(input.pickedPath);
312 + if (parentPath === null) {
313 + return getCloneDestinationPath(input.pickedPath, input.cloneDirectoryName);
314 + }
315 + return getCloneDestinationBrowsePath({
316 + browseDirectoryPath: parentPath,
317 + selectedDirectoryName: inferProjectTitleFromPath(input.pickedPath),
318 + cloneDirectoryName: input.cloneDirectoryName,
319 + caseSensitive: input.caseSensitive,
320 + });
321 +}
322 +
323 export function resolveAddProjectPath(input: {
324 readonly rawPath: string;
325 readonly currentProjectCwd?: string | null;