From 8f4a7148b01baab448d145c79c8a87a874066ef8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 5 Dec 2025 22:28:05 +0000 Subject: [PATCH 1/3] Initial plan From 1c671c10de39826505f660c2bdd837fa81080ec8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 5 Dec 2025 22:35:08 +0000 Subject: [PATCH 2/3] Add confirmation prompt for non-default branch selection When user is on a non-default branch that exists on the remote with no uncommitted changes, they now get a confirmation prompt to choose between continuing on their current branch or starting from the default branch. This covers the missing case in the buildConfirmation method. Co-authored-by: joshspicer <23246594+joshspicer@users.noreply.github.com> --- .../copilotCloudSessionsProvider.ts | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/extension/chatSessions/vscode-node/copilotCloudSessionsProvider.ts b/src/extension/chatSessions/vscode-node/copilotCloudSessionsProvider.ts index e3a8aa5c98..0cdbd4c863 100644 --- a/src/extension/chatSessions/vscode-node/copilotCloudSessionsProvider.ts +++ b/src/extension/chatSessions/vscode-node/copilotCloudSessionsProvider.ts @@ -151,12 +151,15 @@ export class CopilotCloudSessionsProvider extends Disposable implements vscode.C private readonly PUSH_BRANCH = vscode.l10n.t('Push Branch'); private readonly DELEGATE = vscode.l10n.t('Delegate'); private readonly CANCEL = vscode.l10n.t('Cancel'); + private readonly USE_CURRENT_BRANCH = vscode.l10n.t('Use Current Branch'); + private readonly USE_DEFAULT_BRANCH = vscode.l10n.t('Use Default Branch'); // Messages private readonly BASE_MESSAGE = vscode.l10n.t('Cloud agent works asynchronously to create a pull request with your requested changes. This chat\'s history will be summarized and appended to the pull request as context.'); private readonly AUTHORIZE_MESSAGE = vscode.l10n.t('Cloud agent requires elevated GitHub access to proceed.'); private readonly COMMIT_MESSAGE = vscode.l10n.t('This workspace has uncommitted changes. Should these changes be pushed and included in cloud agent\'s work?'); private readonly PUSH_BRANCH_MESSAGE = (baseRef: string, defaultBranch: string) => vscode.l10n.t('Push your currently checked out branch `{0}`, or start from the default branch `{1}`?', baseRef, defaultBranch); + private readonly CHOOSE_BRANCH_MESSAGE = (baseRef: string, defaultBranch: string) => vscode.l10n.t('Continue on your currently checked out branch `{0}`, or start from the default branch `{1}`?', baseRef, defaultBranch); // Workspace storage keys private readonly WORKSPACE_CONTEXT_PREFIX = 'copilot.cloudAgent'; @@ -892,12 +895,19 @@ export class CopilotCloudSessionsProvider extends Disposable implements vscode.C } } + // Determine if user explicitly chose to use the default branch + const useDefaultBranch = selection.includes(this.USE_DEFAULT_BRANCH.toUpperCase()); + const base_ref: string = await (async () => { const res = await this.checkBaseBranchPresentOnRemote(); if (!res) { // Unexpected throw new Error(vscode.l10n.t('Repo base branch is not detected on remote. Push your branch and try again.')); } + // If user explicitly chose default branch, use it + if (useDefaultBranch) { + return res.repoDefaultBranch; + } return (res?.missingOnRemote || !res?.baseRef) ? res.repoDefaultBranch : res?.baseRef; })(); stream.progress(vscode.l10n.t('Validating branch `{0}` exists on remote', base_ref)); @@ -978,6 +988,7 @@ export class CopilotCloudSessionsProvider extends Disposable implements vscode.C const needsPermissiveAuth = !this._authenticationService.permissiveGitHubSession; const hasUncommittedChanges = await this.detectedUncommittedChanges(); const baseBranchInfo = await this.checkBaseBranchPresentOnRemote(); + const isOnNonDefaultBranch = baseBranchInfo && !baseBranchInfo.missingOnRemote && baseBranchInfo.baseRef !== baseBranchInfo.repoDefaultBranch; if (needsPermissiveAuth && hasUncommittedChanges) { message += '\n\n' + this.AUTHORIZE_MESSAGE; @@ -994,6 +1005,14 @@ export class CopilotCloudSessionsProvider extends Disposable implements vscode.C vscode.l10n.t('{0} and {1}', this.AUTHORIZE, this.PUSH_BRANCH), this.AUTHORIZE, ); + } else if (needsPermissiveAuth && isOnNonDefaultBranch) { + const { baseRef, repoDefaultBranch } = baseBranchInfo; + message += '\n\n' + this.AUTHORIZE_MESSAGE; + message += '\n\n' + this.CHOOSE_BRANCH_MESSAGE(baseRef, repoDefaultBranch); + buttons.unshift( + vscode.l10n.t('{0} and {1}', this.AUTHORIZE, this.USE_CURRENT_BRANCH), + vscode.l10n.t('{0} and {1}', this.AUTHORIZE, this.USE_DEFAULT_BRANCH), + ); } else if (needsPermissiveAuth) { message += '\n\n' + this.AUTHORIZE_MESSAGE; buttons.unshift( @@ -1012,6 +1031,14 @@ export class CopilotCloudSessionsProvider extends Disposable implements vscode.C vscode.l10n.t('{0} and {1}', this.PUSH_BRANCH, this.DELEGATE), this.DELEGATE, ); + } else if (isOnNonDefaultBranch) { + // User is on a non-default branch that exists on remote + const { baseRef, repoDefaultBranch } = baseBranchInfo; + message += '\n\n' + this.CHOOSE_BRANCH_MESSAGE(baseRef, repoDefaultBranch); + buttons.unshift( + this.USE_CURRENT_BRANCH, + this.USE_DEFAULT_BRANCH, + ); } // Check if the message has been modified from the default From 28283227dd3a46c4789b60210d23aad0d99d4f7f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 5 Dec 2025 22:37:35 +0000 Subject: [PATCH 3/3] Add non-null assertions for type safety Add explicit non-null assertions (!) when destructuring baseBranchInfo in the isOnNonDefaultBranch blocks to make the code clearer and address code review feedback about null safety. Co-authored-by: joshspicer <23246594+joshspicer@users.noreply.github.com> --- .../chatSessions/vscode-node/copilotCloudSessionsProvider.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/extension/chatSessions/vscode-node/copilotCloudSessionsProvider.ts b/src/extension/chatSessions/vscode-node/copilotCloudSessionsProvider.ts index 0cdbd4c863..a055aed6f8 100644 --- a/src/extension/chatSessions/vscode-node/copilotCloudSessionsProvider.ts +++ b/src/extension/chatSessions/vscode-node/copilotCloudSessionsProvider.ts @@ -1006,7 +1006,7 @@ export class CopilotCloudSessionsProvider extends Disposable implements vscode.C this.AUTHORIZE, ); } else if (needsPermissiveAuth && isOnNonDefaultBranch) { - const { baseRef, repoDefaultBranch } = baseBranchInfo; + const { baseRef, repoDefaultBranch } = baseBranchInfo!; message += '\n\n' + this.AUTHORIZE_MESSAGE; message += '\n\n' + this.CHOOSE_BRANCH_MESSAGE(baseRef, repoDefaultBranch); buttons.unshift( @@ -1033,7 +1033,7 @@ export class CopilotCloudSessionsProvider extends Disposable implements vscode.C ); } else if (isOnNonDefaultBranch) { // User is on a non-default branch that exists on remote - const { baseRef, repoDefaultBranch } = baseBranchInfo; + const { baseRef, repoDefaultBranch } = baseBranchInfo!; message += '\n\n' + this.CHOOSE_BRANCH_MESSAGE(baseRef, repoDefaultBranch); buttons.unshift( this.USE_CURRENT_BRANCH,