Skip to content

Commit d10dd51

Browse files
PR Batch Testerclaude
andcommitted
fix(mobile): let a typed or picked clone folder skip the pending suggestion
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 8cd4eec commit d10dd51

3 files changed

Lines changed: 42 additions & 14 deletions

File tree

‎apps/mobile/src/features/projects/AddProjectScreen.logic.test.ts‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,22 @@ describe("createDestinationPathOwner", () => {
103103
expect(committed).toEqual(["~/repo"]);
104104
});
105105

106+
it("marks typed and picked destinations as explicit so they skip a pending suggestion", async () => {
107+
const commits: Array<[string, boolean]> = [];
108+
const paths = createDestinationPathOwner((path, explicit) => commits.push([path, explicit]));
109+
paths.suggest("/ghq/github.com/acme/repo");
110+
paths.edit("~/typed");
111+
await paths.navigate("/work/repo", async () => {});
112+
paths.suggest("/ghq/github.com/acme/late");
113+
paths.reset("~/repo");
114+
expect(commits).toEqual([
115+
["/ghq/github.com/acme/repo", false],
116+
["~/typed", true],
117+
["/work/repo", true],
118+
["~/repo", false],
119+
]);
120+
});
121+
106122
it("lets a new environment's default take suggestions again", () => {
107123
const { committed, paths } = owner();
108124
paths.edit("/work/repo");

‎apps/mobile/src/features/projects/AddProjectScreen.logic.ts‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,29 @@ const isFilesystemBrowseError = Schema.is(FilesystemBrowseError);
99
/**
1010
* A destination field that automatic suggestions may fill until the user types or picks a
1111
* folder. A pick claims the field before its preload, so a late suggestion cannot replace it.
12+
* `explicit` commits are the user's choice and need not wait for a pending suggestion.
1213
*/
13-
export function createDestinationPathOwner(commit: (path: string) => void) {
14+
export function createDestinationPathOwner(commit: (path: string, explicit: boolean) => void) {
1415
const navigation = createBrowseNavigationCoordinator();
1516
let userOwned = false;
1617
return {
1718
/** An automatic default, such as a new environment's; suggestions may replace it again. */
1819
reset: (path: string) => {
1920
navigation.invalidate();
2021
userOwned = false;
21-
commit(path);
22+
commit(path, false);
2223
},
2324
edit: (path: string) => {
2425
navigation.invalidate();
2526
userOwned = true;
26-
commit(path);
27+
commit(path, true);
2728
},
2829
navigate: (path: string, load: () => Promise<void>) => {
2930
userOwned = true;
30-
return navigation.run(load, () => commit(path));
31+
return navigation.run(load, () => commit(path, true));
3132
},
3233
suggest: (path: string) => {
33-
if (!userOwned) commit(path);
34+
if (!userOwned) commit(path, false);
3435
},
3536
dispose: navigation.invalidate,
3637
};

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

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -295,19 +295,22 @@ function useBrowsePathInput(environment: EnvironmentOption | null, pinnedDirecto
295295
const environmentId = environment?.environmentId ?? null;
296296
const environmentBaseDirectory = environment?.baseDirectory ?? null;
297297
const clonePathCaseSensitive = !isWindowsPlatform(environment?.platform ?? "");
298-
const [pathInput, commitPathInput] = useState(() =>
299-
getCloneDestinationPath(
298+
const [destination, setDestination] = useState(() => ({
299+
path: getCloneDestinationPath(
300300
getAddProjectInitialQuery(environmentBaseDirectory),
301301
pinnedDirectoryName,
302302
),
303-
);
303+
explicit: false,
304+
}));
304305
const previousEnvironmentIdRef = useRef(environmentId);
305306
const environmentRuntime = useRemoteEnvironmentRuntime(environmentId);
306307
const loadBrowsePath = useAtomQueryRunner(filesystemEnvironment.browse, {
307308
reportFailure: false,
308309
reportDefect: false,
309310
});
310-
const [pathOwner] = useState(() => createDestinationPathOwner(commitPathInput));
311+
const [pathOwner] = useState(() =>
312+
createDestinationPathOwner((path, explicit) => setDestination({ path, explicit })),
313+
);
311314
const [isBrowseNavigating, setIsBrowseNavigating] = useState(false);
312315
const setPathInput = (path: string) => {
313316
setIsBrowseNavigating(false);
@@ -365,7 +368,8 @@ function useBrowsePathInput(environment: EnvironmentOption | null, pinnedDirecto
365368

366369
return {
367370
isBrowseNavigating,
368-
pathInput,
371+
pathInput: destination.path,
372+
pathIsExplicit: destination.explicit,
369373
setPathInput,
370374
navigateToBrowsePath,
371375
suggestPath: pathOwner.suggest,
@@ -1296,8 +1300,14 @@ export function AddProjectDestinationScreen(props: {
12961300
const repositoryTitle = stringParam(props.repositoryTitle);
12971301
const prompt = stringParam(props.prompt);
12981302
const repositoryName = stringParam(props.repositoryName)?.trim() ?? "";
1299-
const { isBrowseNavigating, navigateToBrowsePath, pathInput, setPathInput, suggestPath } =
1300-
useBrowsePathInput(environment, repositoryName);
1303+
const {
1304+
isBrowseNavigating,
1305+
navigateToBrowsePath,
1306+
pathInput,
1307+
pathIsExplicit,
1308+
setPathInput,
1309+
suggestPath,
1310+
} = useBrowsePathInput(environment, repositoryName);
13011311
const suggestedDestination = useEnvironmentQuery(
13021312
environment?.ghqCloneLayout && remoteUrl
13031313
? sourceControlEnvironment.suggestCloneDestination({
@@ -1311,6 +1321,7 @@ export function AddProjectDestinationScreen(props: {
13111321
useEffect(() => {
13121322
if (suggestion?.destinationPath) suggestPath(suggestion.destinationPath);
13131323
}, [suggestPath, suggestion]);
1324+
const awaitingSuggestion = suggestedDestination.isPending && !pathIsExplicit;
13141325
const [isSubmitting, setIsSubmitting] = useState(false);
13151326
const [error, setError] = useState<string | null>(null);
13161327

@@ -1321,7 +1332,7 @@ export function AddProjectDestinationScreen(props: {
13211332
!readEnvironmentScope(environment.environmentId, AuthOrchestrationOperateScope) ||
13221333
!remoteUrl ||
13231334
isBrowseNavigating ||
1324-
suggestedDestination.isPending ||
1335+
awaitingSuggestion ||
13251336
isSubmitting
13261337
) {
13271338
return;
@@ -1418,7 +1429,7 @@ export function AddProjectDestinationScreen(props: {
14181429
disabled={
14191430
!canCloneProject ||
14201431
isBrowseNavigating ||
1421-
suggestedDestination.isPending ||
1432+
awaitingSuggestion ||
14221433
isSubmitting ||
14231434
!remoteUrl
14241435
}

0 commit comments

Comments
 (0)