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'; }