Skip to content

Commit d818e52

Browse files
authored
return string for caller to display (#7110)
1 parent 1d1a373 commit d818e52

2 files changed

Lines changed: 14 additions & 48 deletions

File tree

src/commands.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1463,7 +1463,7 @@ ${contents}
14631463
}
14641464
}));
14651465
context.subscriptions.push(
1466-
vscode.commands.registerCommand('githubpr.remoteAgent', async (args) => copilotRemoteAgentManager.commandImpl(args))
1466+
vscode.commands.registerCommand('githubpr.remoteAgent', async (args) => await copilotRemoteAgentManager.commandImpl(args))
14671467
);
14681468
context.subscriptions.push(
14691469
vscode.commands.registerCommand('pr.applySuggestionWithCopilot', async (comment: GHPRComment) => {

src/github/copilotRemoteAgent.ts

Lines changed: 13 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -192,14 +192,7 @@ export class CopilotRemoteAgentManager extends Disposable {
192192
return { owner, repo, remote, baseRef, repository };
193193
}
194194

195-
async commandImpl(args?: any) {
196-
// Check if the coding agent is available (enabled and assignable)
197-
const isAvailable = await this.isAvailable();
198-
if (!isAvailable) {
199-
vscode.window.showWarningMessage(vscode.l10n.t('GitHub Coding Agent is not available for this repository. Make sure the agent is enabled and assignable to this repository.'));
200-
return;
201-
}
202-
195+
async commandImpl(args?: any): Promise<string | undefined> {
203196
// https://github.com/microsoft/vscode-copilot/issues/18918
204197
const userPrompt: string | undefined = args.userPrompt;
205198
const summary: string | undefined = args.summary;
@@ -266,47 +259,20 @@ export class CopilotRemoteAgentManager extends Disposable {
266259
}
267260
}
268261

269-
await vscode.window.withProgress({
270-
location: vscode.ProgressLocation.Notification,
271-
title: vscode.l10n.t('Initializing Coding Agent...'),
272-
cancellable: false
273-
}, async (_) => {
274-
const result = await this.invokeRemoteAgent(
275-
userPrompt,
276-
summary || '',
277-
autoPushAndCommit
278-
);
279-
280-
if (result.state !== 'success') {
281-
vscode.window.showErrorMessage(result.error);
282-
return;
283-
}
262+
const result = await this.invokeRemoteAgent(
263+
userPrompt,
264+
summary || userPrompt,
265+
autoPushAndCommit,
266+
);
284267

285-
const { webviewUri, link, number } = result;
286-
const openLink = vscode.l10n.t('View');
287-
vscode.window.showInformationMessage(
288-
// allow-any-unicode-next-line
289-
vscode.l10n.t('🚀 Coding agent started! Track progress at {0}', link)
290-
, openLink
291-
).then(async selection => {
292-
if (selection === openLink) {
293-
try {
294-
const folderManager = this.repositoriesManager.getManagerForRepository(repoInfo.owner, repoInfo.repo);
295-
if (folderManager) {
296-
const pr = await folderManager.resolvePullRequest(repoInfo.owner, repoInfo.repo, number);
297-
if (pr) {
298-
await vscode.commands.executeCommand('pr.openDescription', pr);
299-
return;
300-
}
301-
}
268+
if (result.state !== 'success') {
269+
vscode.window.showErrorMessage(result.error);
270+
return;
271+
}
302272

303-
vscode.env.openExternal(webviewUri);
304-
} catch (e) {
305-
vscode.env.openExternal(webviewUri);
306-
}
307-
}
308-
});
309-
});
273+
const { webviewUri, link, number } = result;
274+
// allow-any-unicode-next-line
275+
return vscode.l10n.t('🚀 Coding agent will continue work in [#{0}]({1}). Track progress [here]({2}).', number, link, webviewUri.toString());
310276
}
311277

312278
async invokeRemoteAgent(prompt: string, problemContext: string, autoPushAndCommit = true): Promise<RemoteAgentResult> {

0 commit comments

Comments
 (0)