Skip to content

Commit 0e9c343

Browse files
test(mobile): a carried PR selection drops the old machine's worktree path
AI-assisted; verified with the tests and tools listed above.
1 parent 4bcca68 commit 0e9c343

2 files changed

Lines changed: 7 additions & 6 deletions

File tree

‎apps/mobile/src/state/use-composer-drafts.test.ts‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1935,16 +1935,17 @@ describe("mobile composer drafts", () => {
19351935
const pullRequestSelection = {
19361936
mode: "worktree" as const,
19371937
branch: "feature/pr-head",
1938-
worktreePath: null,
1938+
worktreePath: "/old-machine/worktrees/pr-42",
19391939
startFromOrigin: false,
19401940
pullRequestReference: "https://github.com/acme/repo/pull/42",
19411941
};
19421942
updateComposerDraftSettings(key, { workspaceSelection: pullRequestSelection });
19431943
retargetNewTaskDraft(key, from, { keepPullRequestWorkspace: true });
1944-
expect(getComposerDraftSnapshot(key).workspaceSelection).toEqual(pullRequestSelection);
1945-
retargetNewTaskDraft(key, to, { keepPullRequestWorkspace: true });
1946-
expect(getComposerDraftSnapshot(key).workspaceSelection).toEqual(pullRequestSelection);
1947-
retargetNewTaskDraft(key, from);
1944+
expect(getComposerDraftSnapshot(key).workspaceSelection).toEqual({
1945+
...pullRequestSelection,
1946+
worktreePath: null,
1947+
});
1948+
retargetNewTaskDraft(key, to);
19481949
expect(getComposerDraftSnapshot(key).workspaceSelection).toBeUndefined();
19491950
});
19501951

‎apps/mobile/src/state/use-composer-drafts.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1978,7 +1978,7 @@ export function retargetNewTaskDraft(
19781978
return current;
19791979
}
19801980
const { workspaceSelection, ...retained } = normalizeDraft(existing);
1981-
// A PR worktree names no local path, so it carries to the same repository on another machine.
1981+
// The PR checkout is recreated on the target machine, so only the old local path is dropped.
19821982
const keptWorkspaceSelection =
19831983
options?.keepPullRequestWorkspace && workspaceSelection?.pullRequestReference !== undefined
19841984
? { ...workspaceSelection, worktreePath: null }

0 commit comments

Comments
 (0)