diff --git a/apps/web/src/components/BranchToolbar.logic.test.ts b/apps/web/src/components/BranchToolbar.logic.test.ts index 3db5237373a..94e61c43735 100644 --- a/apps/web/src/components/BranchToolbar.logic.test.ts +++ b/apps/web/src/components/BranchToolbar.logic.test.ts @@ -298,7 +298,6 @@ describe("resolveBranchSelectionTarget", () => { activeProjectCwd: "/repo", activeWorktreePath: "/repo/.t3/worktrees/feature-a", refName: { - isDefault: false, worktreePath: "/repo/.t3/worktrees/feature-b", }, }), @@ -315,7 +314,6 @@ describe("resolveBranchSelectionTarget", () => { activeProjectCwd: "/repo", activeWorktreePath: "/repo/.t3/worktrees/feature-a", refName: { - isDefault: true, worktreePath: "/repo", }, }), @@ -326,30 +324,12 @@ describe("resolveBranchSelectionTarget", () => { }); }); - it("checks out the default ref in the main repo when leaving a secondary worktree", () => { + it("keeps checkout in the current worktree when the selected ref has no existing worktree", () => { expect( resolveBranchSelectionTarget({ activeProjectCwd: "/repo", activeWorktreePath: "/repo/.t3/worktrees/feature-a", refName: { - isDefault: true, - worktreePath: null, - }, - }), - ).toEqual({ - checkoutCwd: "/repo", - nextWorktreePath: null, - reuseExistingWorktree: false, - }); - }); - - it("keeps checkout in the current worktree for non-default refs", () => { - expect( - resolveBranchSelectionTarget({ - activeProjectCwd: "/repo", - activeWorktreePath: "/repo/.t3/worktrees/feature-a", - refName: { - isDefault: false, worktreePath: null, }, }), diff --git a/apps/web/src/components/BranchToolbar.logic.ts b/apps/web/src/components/BranchToolbar.logic.ts index 65388962c08..36587219419 100644 --- a/apps/web/src/components/BranchToolbar.logic.ts +++ b/apps/web/src/components/BranchToolbar.logic.ts @@ -100,7 +100,7 @@ export function resolveBranchToolbarValue(input: { export function resolveBranchSelectionTarget(input: { activeProjectCwd: string; activeWorktreePath: string | null; - refName: Pick; + refName: Pick; }): { checkoutCwd: string; nextWorktreePath: string | null; @@ -116,12 +116,9 @@ export function resolveBranchSelectionTarget(input: { }; } - const nextWorktreePath = - activeWorktreePath !== null && refName.isDefault ? null : activeWorktreePath; - return { - checkoutCwd: nextWorktreePath ?? activeProjectCwd, - nextWorktreePath, + checkoutCwd: activeWorktreePath ?? activeProjectCwd, + nextWorktreePath: activeWorktreePath, reuseExistingWorktree: false, }; }