From 2b96160ab0076c95885f1b7782b591ff3feaf1b9 Mon Sep 17 00:00:00 2001 From: AndyMik90 Date: Sat, 20 Dec 2025 11:24:31 +0100 Subject: [PATCH] fix: display correct merge target branch in worktree UI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The UI was showing "→ main" for all worktree merges because it checked origin/HEAD (the remote's default branch) instead of the user's current local branch. This caused confusion since the actual merge logic in Python correctly merges into the user's current branch (e.g., v2.6.0), but the UI displayed "→ main". Changed baseBranch detection from origin/HEAD to the current local branch (git rev-parse --abbrev-ref HEAD) in three handlers: - TASK_WORKTREE_STATUS - TASK_WORKTREE_DIFF - TASK_LIST_WORKTREES Now the UI accurately reflects where changes will be merged. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- .../ipc-handlers/task/worktree-handlers.ts | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/auto-claude-ui/src/main/ipc-handlers/task/worktree-handlers.ts b/auto-claude-ui/src/main/ipc-handlers/task/worktree-handlers.ts index 742b9621..acb3a821 100644 --- a/auto-claude-ui/src/main/ipc-handlers/task/worktree-handlers.ts +++ b/auto-claude-ui/src/main/ipc-handlers/task/worktree-handlers.ts @@ -49,14 +49,14 @@ export function registerWorktreeHandlers( encoding: 'utf-8' }).trim(); - // Get base branch (usually main or master) + // Get base branch - the current branch in the main project (where changes will be merged) + // This matches the Python merge logic which merges into the user's current branch let baseBranch = 'main'; try { - // Try to get the default branch - baseBranch = execSync('git rev-parse --abbrev-ref origin/HEAD 2>/dev/null || echo main', { + baseBranch = execSync('git rev-parse --abbrev-ref HEAD', { cwd: project.path, encoding: 'utf-8' - }).trim().replace('origin/', ''); + }).trim(); } catch { baseBranch = 'main'; } @@ -145,13 +145,13 @@ export function registerWorktreeHandlers( return { success: false, error: 'No worktree found for this task' }; } - // Get base branch + // Get base branch - the current branch in the main project (where changes will be merged) let baseBranch = 'main'; try { - baseBranch = execSync('git rev-parse --abbrev-ref origin/HEAD 2>/dev/null || echo main', { + baseBranch = execSync('git rev-parse --abbrev-ref HEAD', { cwd: project.path, encoding: 'utf-8' - }).trim().replace('origin/', ''); + }).trim(); } catch { baseBranch = 'main'; } @@ -865,13 +865,13 @@ export function registerWorktreeHandlers( encoding: 'utf-8' }).trim(); - // Get base branch + // Get base branch - the current branch in the main project (where changes will be merged) let baseBranch = 'main'; try { - baseBranch = execSync('git rev-parse --abbrev-ref origin/HEAD 2>/dev/null || echo main', { + baseBranch = execSync('git rev-parse --abbrev-ref HEAD', { cwd: project.path, encoding: 'utf-8' - }).trim().replace('origin/', ''); + }).trim(); } catch { baseBranch = 'main'; }