From 20b8379fc45583d0b184a7ed87bcc61ef0a77d75 Mon Sep 17 00:00:00 2001 From: Kiet Ho Date: Fri, 6 Feb 2026 14:38:03 -0800 Subject: [PATCH] fix(desktop): don't use --delete-branch when merging PR from changes sidebar gh pr merge --delete-branch checks out the default branch locally after merging, causing the worktree to unexpectedly switch to main. Remove the --delete-branch flag and the deleteBranch parameter entirely so the local checkout stays on the current branch. --- apps/desktop/src/lib/trpc/routers/changes/git-operations.ts | 4 ---- .../components/ChangesHeader/components/PRButton/PRButton.tsx | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/apps/desktop/src/lib/trpc/routers/changes/git-operations.ts b/apps/desktop/src/lib/trpc/routers/changes/git-operations.ts index 6b29651a438..0a9ef07af66 100644 --- a/apps/desktop/src/lib/trpc/routers/changes/git-operations.ts +++ b/apps/desktop/src/lib/trpc/routers/changes/git-operations.ts @@ -263,7 +263,6 @@ export const createGitOperationsRouter = () => { z.object({ worktreePath: z.string(), strategy: z.enum(["merge", "squash", "rebase"]).default("squash"), - deleteBranch: z.boolean().default(true), }), ) .mutation( @@ -271,9 +270,6 @@ export const createGitOperationsRouter = () => { assertRegisteredWorktree(input.worktreePath); const args = ["pr", "merge", `--${input.strategy}`]; - if (input.deleteBranch) { - args.push("--delete-branch"); - } try { await execWithShellEnv("gh", args, { cwd: input.worktreePath }); diff --git a/apps/desktop/src/renderer/screens/main/components/WorkspaceView/RightSidebar/ChangesView/components/ChangesHeader/components/PRButton/PRButton.tsx b/apps/desktop/src/renderer/screens/main/components/WorkspaceView/RightSidebar/ChangesView/components/ChangesHeader/components/PRButton/PRButton.tsx index 3d5e8d9e2f0..8ca6379cc0e 100644 --- a/apps/desktop/src/renderer/screens/main/components/WorkspaceView/RightSidebar/ChangesView/components/ChangesHeader/components/PRButton/PRButton.tsx +++ b/apps/desktop/src/renderer/screens/main/components/WorkspaceView/RightSidebar/ChangesView/components/ChangesHeader/components/PRButton/PRButton.tsx @@ -47,7 +47,7 @@ export function PRButton({ }); const handleMergePR = (strategy: "merge" | "squash" | "rebase") => - mergePRMutation.mutate({ worktreePath, strategy, deleteBranch: true }); + mergePRMutation.mutate({ worktreePath, strategy }); if (isLoading) { return (