Skip to content

Commit 0cfb8e8

Browse files
authored
Prompt for sign in from the coding agent tool (#7626)
Part of #7614
1 parent 8327743 commit 0cfb8e8

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

src/github/copilotRemoteAgent.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,9 +263,9 @@ export class CopilotRemoteAgentManager extends Disposable {
263263
}
264264
}
265265

266-
private async tryAcquireAuth(): Promise<FolderRepositoryManager | undefined> {
266+
async tryAcquireAuth(): Promise<FolderRepositoryManager | undefined> {
267267
if (this.credentialStore.isAnyAuthenticated()) {
268-
return undefined;
268+
return this.chooseFolderManager();
269269
}
270270

271271
const result = await this.credentialStore.create({ createIfNone: { detail: vscode.l10n.t('Sign in to start delegating tasks to the GitHub coding agent.') } });
@@ -294,6 +294,9 @@ export class CopilotRemoteAgentManager extends Disposable {
294294
}
295295
const { userPrompt, summary, source, followup, _version } = args;
296296
const fm = await this.tryAcquireAuth();
297+
if (!fm) {
298+
return;
299+
}
297300

298301
/* __GDPR__
299302
"remoteAgent.command.args" : {

src/lm/tools/copilotRemoteAgentTool.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,15 @@ export class CopilotRemoteAgentTool implements vscode.LanguageModelTool<CopilotR
3030

3131
async prepareInvocation(options: vscode.LanguageModelToolInvocationPrepareOptions<CopilotRemoteAgentToolParameters>): Promise<vscode.PreparedToolInvocation> {
3232
const { title, existingPullRequest } = options.input;
33+
const folderManager = existingPullRequest ? undefined : await this.manager.tryAcquireAuth();
3334

3435
// Check if the coding agent is available (enabled and assignable)
3536
const isAvailable = await this.manager.isAvailable();
3637
if (!isAvailable) {
3738
throw new Error(vscode.l10n.t('Copilot coding agent is not available for this repository. Make sure the agent is enabled and assignable to this repository.'));
3839
}
3940

40-
const targetRepo = await this.manager.repoInfo();
41+
const targetRepo = await this.manager.repoInfo(folderManager);
4142
const autoPushEnabled = this.manager.autoCommitAndPushEnabled;
4243
const openPR = existingPullRequest || await this.getActivePullRequestWithSession(targetRepo);
4344

@@ -67,7 +68,9 @@ export class CopilotRemoteAgentTool implements vscode.LanguageModelTool<CopilotR
6768
const title = options.input.title;
6869
const body = options.input.body || '';
6970
const existingPullRequest = options.input.existingPullRequest || '';
70-
const targetRepo = await this.manager.repoInfo();
71+
const folderManager = existingPullRequest ? undefined : await this.manager.tryAcquireAuth();
72+
73+
const targetRepo = await this.manager.repoInfo(folderManager);
7174
if (!targetRepo) {
7275
return new vscode.LanguageModelToolResult([
7376
new vscode.LanguageModelTextPart(vscode.l10n.t('No repository information found. Please open a workspace with a Git repository.'))

0 commit comments

Comments
 (0)