diff --git a/backend/src/models/task_attempt.rs b/backend/src/models/task_attempt.rs index 96527dd6..e24074d5 100644 --- a/backend/src/models/task_attempt.rs +++ b/backend/src/models/task_attempt.rs @@ -127,6 +127,7 @@ pub struct BranchStatus { pub up_to_date: bool, pub merged: bool, pub has_uncommitted_changes: bool, + pub base_branch_name: String, } impl TaskAttempt { @@ -252,7 +253,7 @@ impl TaskAttempt { // Now we need to merge the worktree branch into the main repository let branch_name = format!("attempt-{}", attempt_id); - // Get the main branch (usually "main" or "master") + // Get the current base branch name (e.g., "main", "master", "develop", etc.) let main_branch = main_repo.head()?.shorthand().unwrap_or("main").to_string(); // Fetch the worktree branch into the main repository @@ -273,7 +274,7 @@ impl TaskAttempt { "Import worktree changes", )?; - // Now merge the branch into main + // Now merge the branch into the base branch let main_branch_commit = main_repo .reference_to_annotated_commit(&main_repo.find_reference(&main_branch_ref)?)?; let worktree_branch_commit = main_repo @@ -1222,7 +1223,10 @@ impl TaskAttempt { // Open the worktree repository let worktree_repo = Repository::open(&attempt.worktree_path)?; - // Get the current HEAD of main branch in the main repo + // Get the base branch name from the main repository + let base_branch_name = main_repo.head()?.shorthand().unwrap_or("main").to_string(); + + // Get the current HEAD of base branch in the main repo let main_head = main_repo.head()?.peel_to_commit()?; let main_oid = main_head.id(); @@ -1250,6 +1254,7 @@ impl TaskAttempt { up_to_date: true, merged: attempt.merge_commit.is_some(), has_uncommitted_changes, + base_branch_name, }); } @@ -1274,6 +1279,7 @@ impl TaskAttempt { up_to_date: commits_behind == 0 && commits_ahead == 0, merged: attempt.merge_commit.is_some(), has_uncommitted_changes, + base_branch_name, }) } diff --git a/frontend/src/pages/task-attempt-compare.tsx b/frontend/src/pages/task-attempt-compare.tsx index d17d004a..8649a5d9 100644 --- a/frontend/src/pages/task-attempt-compare.tsx +++ b/frontend/src/pages/task-attempt-compare.tsx @@ -50,7 +50,6 @@ export function TaskAttemptComparePage() { const [error, setError] = useState(null); const [merging, setMerging] = useState(false); const [rebasing, setRebasing] = useState(false); - const [mergeSuccess, setMergeSuccess] = useState(false); const [rebaseSuccess, setRebaseSuccess] = useState(false); const [expandedSections, setExpandedSections] = useState>( new Set() @@ -150,7 +149,6 @@ export function TaskAttemptComparePage() { if (response.ok) { const result: ApiResponse = await response.json(); if (result.success) { - setMergeSuccess(true); // Refetch both diff and branch status to show updated state fetchDiff(); fetchBranchStatus(); @@ -493,15 +491,15 @@ export function TaskAttemptComparePage() { {branchStatus.up_to_date ? ( Up to date ) : branchStatus.is_behind === true ? ( - - {branchStatus.commits_behind} commit - {branchStatus.commits_behind !== 1 ? "s" : ""} behind main - + + {branchStatus.commits_behind} commit + {branchStatus.commits_behind !== 1 ? "s" : ""} behind {branchStatus.base_branch_name} + ) : ( - - {branchStatus.commits_ahead} commit - {branchStatus.commits_ahead !== 1 ? "s" : ""} ahead of main - + + {branchStatus.commits_ahead} commit + {branchStatus.commits_ahead !== 1 ? "s" : ""} ahead of {branchStatus.base_branch_name} + )} {branchStatus.has_uncommitted_changes && ( @@ -524,11 +522,6 @@ export function TaskAttemptComparePage() { Branch rebased successfully! )} - {mergeSuccess && ( -
- Changes merged successfully! -
- )} {/* Action Buttons */}
@@ -544,7 +537,7 @@ export function TaskAttemptComparePage() { - {rebasing ? "Rebasing..." : "Rebase onto Main"} + {rebasing ? "Rebasing..." : `Rebase onto ${branchStatus.base_branch_name}`} )} {!branchStatus?.merged && ( @@ -762,7 +755,7 @@ export function TaskAttemptComparePage() {

Warning: The worktree contains uncommitted changes (modified, added, or deleted files) - that have not been committed to git. These changes will be permanently merged into the main branch. + that have not been committed to git. These changes will be permanently merged into the {branchStatus?.base_branch_name || 'base'} branch.

diff --git a/shared/types.ts b/shared/types.ts index 26ca899a..e1c26565 100644 --- a/shared/types.ts +++ b/shared/types.ts @@ -70,7 +70,7 @@ export type FileDiff = { path: string, chunks: Array, }; export type WorktreeDiff = { files: Array, }; -export type BranchStatus = { is_behind: boolean, commits_behind: number, commits_ahead: number, up_to_date: boolean, merged: boolean, has_uncommitted_changes: boolean, }; +export type BranchStatus = { is_behind: boolean, commits_behind: number, commits_ahead: number, up_to_date: boolean, merged: boolean, has_uncommitted_changes: boolean, base_branch_name: string, }; export type ExecutionProcess = { id: string, task_attempt_id: string, process_type: ExecutionProcessType, executor_type: string | null, status: ExecutionProcessStatus, command: string, args: string | null, working_directory: string, stdout: string | null, stderr: string | null, exit_code: bigint | null, started_at: string, completed_at: string | null, created_at: string, updated_at: string, };