diff --git a/src/commands.ts b/src/commands.ts index 3bfb030099..2d98a2fe93 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -18,7 +18,7 @@ import { ITelemetry } from './common/telemetry'; import { asTempStorageURI, fromPRUri, fromReviewUri, Schemes, toPRUri } from './common/uri'; import { formatError } from './common/utils'; import { EXTENSION_ID } from './constants'; -import { CopilotRemoteAgentManager } from './github/copilotRemoteAgent'; +import { CopilotRemoteAgentManager, ICopilotRemoteAgentCommandArgs } from './github/copilotRemoteAgent'; import { FolderRepositoryManager } from './github/folderRepositoryManager'; import { GitHubRepository } from './github/githubRepository'; import { Issue } from './github/interface'; @@ -1463,7 +1463,7 @@ ${contents} } })); context.subscriptions.push( - vscode.commands.registerCommand('githubpr.remoteAgent', async (args) => await copilotRemoteAgentManager.commandImpl(args)) + vscode.commands.registerCommand('githubpr.remoteAgent', async (args: ICopilotRemoteAgentCommandArgs) => await copilotRemoteAgentManager.commandImpl(args)) ); context.subscriptions.push( vscode.commands.registerCommand('pr.applySuggestionWithCopilot', async (comment: GHPRComment) => { diff --git a/src/github/copilotRemoteAgent.ts b/src/github/copilotRemoteAgent.ts index 9301a962a3..c3ace05495 100644 --- a/src/github/copilotRemoteAgent.ts +++ b/src/github/copilotRemoteAgent.ts @@ -26,6 +26,12 @@ export interface IAPISessionLogs { logs: string; } +export interface ICopilotRemoteAgentCommandArgs { + userPrompt: string; + summary?: string; + source?: string; +} + const LEARN_MORE = vscode.l10n.t('Learn about Coding Agent'); // Without Pending Changes const CONTINUE = vscode.l10n.t('Continue'); @@ -192,11 +198,12 @@ export class CopilotRemoteAgentManager extends Disposable { return { owner, repo, remote, baseRef, repository }; } - async commandImpl(args?: any): Promise { - // https://github.com/microsoft/vscode-copilot/issues/18918 - const userPrompt: string | undefined = args.userPrompt; - const summary: string | undefined = args.summary; + async commandImpl(args?: ICopilotRemoteAgentCommandArgs): Promise { + if (!args) { + return; + } + const { userPrompt, summary, source } = args; if (!userPrompt || userPrompt.trim().length === 0) { return; } @@ -216,7 +223,7 @@ export class CopilotRemoteAgentManager extends Disposable { let autoPushAndCommit = false; const message = vscode.l10n.t('GitHub Coding Agent will continue your work in \'{0}\'', repoName); - if (hasChanges && this.autoCommitAndPushEnabled()) { + if (source !== 'prompt' && hasChanges && this.autoCommitAndPushEnabled()) { const modalResult = await vscode.window.showInformationMessage( message, { @@ -242,7 +249,7 @@ export class CopilotRemoteAgentManager extends Disposable { } } else { const modalResult = await vscode.window.showInformationMessage( - message, + (source !== 'prompt' ? message : vscode.l10n.t('GitHub Coding Agent will implement the specification outlined in this prompt file')), { modal: true, }, @@ -271,6 +278,17 @@ export class CopilotRemoteAgentManager extends Disposable { } const { webviewUri, link, number } = result; + + if (source === 'prompt') { + const VIEW = vscode.l10n.t('View'); + const finished = vscode.l10n.t('Coding agent has begun work on your prompt in #{0}', number); + vscode.window.showInformationMessage(finished, VIEW).then((value) => { + if (value === VIEW) { + vscode.commands.executeCommand('vscode.open', webviewUri); + } + }); + } + // allow-any-unicode-next-line return vscode.l10n.t('🚀 Coding agent will continue work in [#{0}]({1}). Track progress [here]({2}).', number, link, webviewUri.toString()); }