@@ -15,7 +15,7 @@ import { IAccount, ILabel, IMilestone, IProject, isITeam, ITeam, MergeMethod, Re
1515import { BaseBranchMetadata , PullRequestGitHelper } from './pullRequestGitHelper' ;
1616import { PullRequestModel } from './pullRequestModel' ;
1717import { getDefaultMergeMethod } from './pullRequestOverview' ;
18- import { branchPicks , getAssigneesQuickPickItems , getLabelOptions , getMilestoneFromQuickPick , getProjectFromQuickPick , reviewersQuickPick } from './quickPicks' ;
18+ import { branchPicks , cachedBranchPicks , getAssigneesQuickPickItems , getLabelOptions , getMilestoneFromQuickPick , getProjectFromQuickPick , reviewersQuickPick } from './quickPicks' ;
1919import { ISSUE_EXPRESSION , parseIssueExpressionOutput , variableSubstitution } from './utils' ;
2020import { ChangeTemplateReply , DisplayLabel , PreReviewState } from './views' ;
2121import { RemoteInfo } from '../../common/types' ;
@@ -1010,9 +1010,22 @@ Don't forget to commit your template file to the repository so that it can be us
10101010 const params = await super . getCreateParams ( ) ;
10111011 this . model . baseOwner = params . defaultBaseRemote ! . owner ;
10121012 this . model . baseBranch = params . defaultBaseBranch ! ;
1013+ // Pre-fetch branches so they're cached when the user opens the branch picker
1014+ this . prefetchBranches ( params . defaultBaseRemote ! ) ;
10131015 return params ;
10141016 }
10151017
1018+ private prefetchBranches ( baseRemote : RemoteInfo ) : void {
1019+ const githubRepository = this . _folderRepositoryManager . findRepo (
1020+ repo => repo . remote . owner === baseRemote . owner && repo . remote . repositoryName === baseRemote . repositoryName ,
1021+ ) ;
1022+ if ( githubRepository ) {
1023+ githubRepository . listBranches ( baseRemote . owner , baseRemote . repositoryName , undefined ) . catch ( e => {
1024+ Logger . debug ( `Pre-fetching branches failed: ${ e } ` , CreatePullRequestViewProvider . ID ) ;
1025+ } ) ;
1026+ }
1027+ }
1028+
10161029
10171030 private async remotePicks ( isBase : boolean ) : Promise < ( vscode . QuickPickItem & { remote ?: RemoteInfo } ) [ ] > {
10181031 const remotes = isBase ? await this . _folderRepositoryManager . getActiveGitHubRemotes ( await this . _folderRepositoryManager . getGitHubRemotes ( ) ) : this . _folderRepositoryManager . gitHubRepositories . map ( repo => repo . remote ) ;
@@ -1141,6 +1154,13 @@ Don't forget to commit your template file to the repository so that it can be us
11411154 quickPick . show ( ) ;
11421155 quickPick . busy = true ;
11431156 if ( githubRepository ) {
1157+ // Show cached branches immediately if available, then refresh in the background
1158+ const cached = cachedBranchPicks ( githubRepository , this . _folderRepositoryManager , chooseDifferentRemote , isBase ) ;
1159+ if ( cached ) {
1160+ quickPick . items = cached ;
1161+ const activeItem = message . args . currentBranch ? quickPick . items . find ( item => item . branch === message . args . currentBranch ) : undefined ;
1162+ quickPick . activeItems = activeItem ? [ activeItem ] : [ ] ;
1163+ }
11441164 await updateItems ( githubRepository , undefined ) ;
11451165 } else {
11461166 quickPick . items = await this . remotePicks ( isBase ) ;
0 commit comments