From 5810c7cccf7f9afc9fd8dd1d347880bffc0dbc63 Mon Sep 17 00:00:00 2001 From: Louis Knight-Webb Date: Thu, 18 Dec 2025 09:53:13 +0000 Subject: [PATCH] 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 --- .../src/components/dialogs/tasks/CreatePRDialog.tsx | 11 +++++++++-- .../src/components/tasks/Toolbar/GitOperations.tsx | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) 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, }); };