Skip to content

Commit 6fd3ee2

Browse files
authored
fix promptAndUpdatePreferredGitHubRemote() (#7656)
1 parent 88c6233 commit 6fd3ee2

2 files changed

Lines changed: 5 additions & 6 deletions

File tree

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1744,6 +1744,7 @@
17441744
"command": "pr.preferredCodingAgentGitHubRemote",
17451745
"title": "%command.pr.preferredCodingAgentGitHubRemote.title%",
17461746
"icon": "$(gear)",
1747+
"enablement": "github:hasMultipleGitHubRemotes",
17471748
"category": "%command.pull.request.category%"
17481749
},
17491750
{

src/github/copilotRemoteAgent.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ export class CopilotRemoteAgentManager extends Disposable {
218218
await this.context.workspaceState.update(PREFERRED_GITHUB_CODING_AGENT_REMOTE_WORKSPACE_KEY, undefined);
219219
}
220220

221-
public async promptAndUpdatePreferredGitHubRemote(skipIfValueAlreadyCached = false): Promise<GitHubRemote | undefined> {
221+
public async promptAndUpdatePreferredGitHubRemote(skipIfValueAlreadyCached = false): Promise<void> {
222222
if (skipIfValueAlreadyCached) {
223223
const cachedValue = await this.context.workspaceState.get(PREFERRED_GITHUB_CODING_AGENT_REMOTE_WORKSPACE_KEY);
224224
if (cachedValue) {
@@ -233,7 +233,8 @@ export class CopilotRemoteAgentManager extends Disposable {
233233

234234
const ghRemotes = await fm.getAllGitHubRemotes();
235235
Logger.trace(`There are ${ghRemotes.length} GitHub remotes available to select from`, CopilotRemoteAgentManager.ID);
236-
if (!ghRemotes || ghRemotes.length === 0) {
236+
if (!ghRemotes || ghRemotes.length <= 1) {
237+
Logger.trace('No need to select a coding agent GitHub remote, skipping prompt', CopilotRemoteAgentManager.ID);
237238
return;
238239
}
239240

@@ -252,7 +253,6 @@ export class CopilotRemoteAgentManager extends Disposable {
252253

253254
Logger.appendLine(`Updated '${result.remoteName}' as preferred coding agent remote`, CopilotRemoteAgentManager.ID);
254255
await this.context.workspaceState.update(PREFERRED_GITHUB_CODING_AGENT_REMOTE_WORKSPACE_KEY, result.remoteName);
255-
return result;
256256
}
257257

258258
async repoInfo(fm?: FolderRepositoryManager): Promise<RepoInfo | undefined> {
@@ -518,9 +518,7 @@ export class CopilotRemoteAgentManager extends Disposable {
518518
return { error: vscode.l10n.t('Failed to initialize Copilot API'), state: 'error' };
519519
}
520520

521-
if (!await this.promptAndUpdatePreferredGitHubRemote(true)) {
522-
return { error: vscode.l10n.t('Cancelled setting preferred GitHub remote'), state: 'error' };
523-
}
521+
await this.promptAndUpdatePreferredGitHubRemote(true);
524522

525523
const repoInfo = await this.repoInfo();
526524
if (!repoInfo) {

0 commit comments

Comments
 (0)