All checks pass. Here's a summary of the changes made: (#1595)

## Summary

Fixed the regression where the Create PR dialog was defaulting to the repository's current checked-out branch (`is_current`) instead of the task attempt's configured target branch.

### Changes Made

1. **`frontend/src/components/dialogs/tasks/CreatePRDialog.tsx`**:
   - Added `targetBranch?: string` to the props interface
   - Destructured `targetBranch` in the component
   - Updated the default branch selection logic to prioritize `targetBranch` over `is_current`

2. **`frontend/src/components/tasks/Toolbar/GitOperations.tsx`**:
   - Pass `targetBranch: getSelectedRepoStatus()?.target_branch_name` when showing the dialog

### Behavior

- When opening the Create PR dialog, it now defaults to the attempt's target branch (from `RepoBranchStatus.target_branch_name`)
- Falls back to the current branch (`is_current`) only if the target branch is not set or not found in the branch list
- This restores the original intended behavior that was lost during the multi-repo refactor
This commit is contained in:
Louis Knight-Webb
2025-12-18 09:53:13 +00:00
committed by GitHub
parent adf759fbbe
commit 5810c7cccf
2 changed files with 10 additions and 2 deletions

View File

@@ -38,10 +38,11 @@ interface CreatePRDialogProps {
attempt: TaskAttempt; attempt: TaskAttempt;
task: TaskWithAttemptStatus; task: TaskWithAttemptStatus;
repoId: string; repoId: string;
targetBranch?: string;
} }
const CreatePRDialogImpl = NiceModal.create<CreatePRDialogProps>( const CreatePRDialogImpl = NiceModal.create<CreatePRDialogProps>(
({ attempt, task, repoId }) => { ({ attempt, task, repoId, targetBranch }) => {
const modal = useModal(); const modal = useModal();
const { t } = useTranslation('tasks'); const { t } = useTranslation('tasks');
const { isLoaded } = useAuth(); const { isLoaded } = useAuth();
@@ -84,12 +85,18 @@ const CreatePRDialogImpl = NiceModal.create<CreatePRDialogProps>(
// Set default base branch when branches are loaded // Set default base branch when branches are loaded
useEffect(() => { useEffect(() => {
if (branches.length > 0 && !prBaseBranch) { if (branches.length > 0 && !prBaseBranch) {
// First priority: use the target branch from attempt config
if (targetBranch && branches.some((b) => b.name === targetBranch)) {
setPrBaseBranch(targetBranch);
return;
}
// Fallback: use the current branch
const currentBranch = branches.find((b) => b.is_current); const currentBranch = branches.find((b) => b.is_current);
if (currentBranch) { if (currentBranch) {
setPrBaseBranch(currentBranch.name); setPrBaseBranch(currentBranch.name);
} }
} }
}, [branches, prBaseBranch]); }, [branches, prBaseBranch, targetBranch]);
const isMacEnvironment = useMemo( const isMacEnvironment = useMemo(
() => environment?.os_type?.toLowerCase().includes('mac'), () => environment?.os_type?.toLowerCase().includes('mac'),

View File

@@ -254,6 +254,7 @@ function GitOperations({
attempt: selectedAttempt, attempt: selectedAttempt,
task, task,
repoId: getSelectedRepoId(), repoId: getSelectedRepoId(),
targetBranch: getSelectedRepoStatus()?.target_branch_name,
}); });
}; };