diff --git a/frontend/src/components/dialogs/tasks/CreatePRDialog.tsx b/frontend/src/components/dialogs/tasks/CreatePRDialog.tsx index 2e5a4c26..bd38aeaa 100644 --- a/frontend/src/components/dialogs/tasks/CreatePRDialog.tsx +++ b/frontend/src/components/dialogs/tasks/CreatePRDialog.tsx @@ -38,10 +38,11 @@ interface CreatePRDialogProps { attempt: TaskAttempt; task: TaskWithAttemptStatus; repoId: string; + targetBranch?: string; } const CreatePRDialogImpl = NiceModal.create( - ({ attempt, task, repoId }) => { + ({ attempt, task, repoId, targetBranch }) => { const modal = useModal(); const { t } = useTranslation('tasks'); const { isLoaded } = useAuth(); @@ -84,12 +85,18 @@ const CreatePRDialogImpl = NiceModal.create( // Set default base branch when branches are loaded useEffect(() => { 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); if (currentBranch) { setPrBaseBranch(currentBranch.name); } } - }, [branches, prBaseBranch]); + }, [branches, prBaseBranch, targetBranch]); const isMacEnvironment = useMemo( () => environment?.os_type?.toLowerCase().includes('mac'), diff --git a/frontend/src/components/tasks/Toolbar/GitOperations.tsx b/frontend/src/components/tasks/Toolbar/GitOperations.tsx index ac2803a1..ab6dc2ca 100644 --- a/frontend/src/components/tasks/Toolbar/GitOperations.tsx +++ b/frontend/src/components/tasks/Toolbar/GitOperations.tsx @@ -254,6 +254,7 @@ function GitOperations({ attempt: selectedAttempt, task, repoId: getSelectedRepoId(), + targetBranch: getSelectedRepoStatus()?.target_branch_name, }); };