fix: display correct merge target branch in worktree UI

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 <noreply@anthropic.com>
This commit is contained in:
AndyMik90
2025-12-20 11:24:31 +01:00
parent 7171589002
commit 2b96160ab0
@@ -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';
}