Skip to content

Commit f625f12

Browse files
authored
Special handling for prompt file (#7115)
* special handling from prompt (https://github.com/microsoft/vscode/pull/252581/files) * add types to command args
1 parent 715971b commit f625f12

2 files changed

Lines changed: 26 additions & 8 deletions

File tree

src/commands.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { ITelemetry } from './common/telemetry';
1818
import { asTempStorageURI, fromPRUri, fromReviewUri, Schemes, toPRUri } from './common/uri';
1919
import { formatError } from './common/utils';
2020
import { EXTENSION_ID } from './constants';
21-
import { CopilotRemoteAgentManager } from './github/copilotRemoteAgent';
21+
import { CopilotRemoteAgentManager, ICopilotRemoteAgentCommandArgs } from './github/copilotRemoteAgent';
2222
import { FolderRepositoryManager } from './github/folderRepositoryManager';
2323
import { GitHubRepository } from './github/githubRepository';
2424
import { Issue } from './github/interface';
@@ -1534,7 +1534,7 @@ ${contents}
15341534
}
15351535
}));
15361536
context.subscriptions.push(
1537-
vscode.commands.registerCommand('githubpr.remoteAgent', async (args) => await copilotRemoteAgentManager.commandImpl(args))
1537+
vscode.commands.registerCommand('githubpr.remoteAgent', async (args: ICopilotRemoteAgentCommandArgs) => await copilotRemoteAgentManager.commandImpl(args))
15381538
);
15391539
context.subscriptions.push(
15401540
vscode.commands.registerCommand('pr.applySuggestionWithCopilot', async (comment: GHPRComment) => {

src/github/copilotRemoteAgent.ts

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ export interface IAPISessionLogs {
2626
logs: string;
2727
}
2828

29+
export interface ICopilotRemoteAgentCommandArgs {
30+
userPrompt: string;
31+
summary?: string;
32+
source?: string;
33+
}
34+
2935
const LEARN_MORE = vscode.l10n.t('Learn about Coding Agent');
3036
// Without Pending Changes
3137
const CONTINUE = vscode.l10n.t('Continue');
@@ -192,11 +198,12 @@ export class CopilotRemoteAgentManager extends Disposable {
192198
return { owner, repo, remote, baseRef, repository };
193199
}
194200

195-
async commandImpl(args?: any): Promise<string | undefined> {
196-
// https://github.com/microsoft/vscode-copilot/issues/18918
197-
const userPrompt: string | undefined = args.userPrompt;
198-
const summary: string | undefined = args.summary;
201+
async commandImpl(args?: ICopilotRemoteAgentCommandArgs): Promise<string | undefined> {
202+
if (!args) {
203+
return;
204+
}
199205

206+
const { userPrompt, summary, source } = args;
200207
if (!userPrompt || userPrompt.trim().length === 0) {
201208
return;
202209
}
@@ -216,7 +223,7 @@ export class CopilotRemoteAgentManager extends Disposable {
216223

217224
let autoPushAndCommit = false;
218225
const message = vscode.l10n.t('GitHub Coding Agent will continue your work in \'{0}\'', repoName);
219-
if (hasChanges && this.autoCommitAndPushEnabled()) {
226+
if (source !== 'prompt' && hasChanges && this.autoCommitAndPushEnabled()) {
220227
const modalResult = await vscode.window.showInformationMessage(
221228
message,
222229
{
@@ -242,7 +249,7 @@ export class CopilotRemoteAgentManager extends Disposable {
242249
}
243250
} else {
244251
const modalResult = await vscode.window.showInformationMessage(
245-
message,
252+
(source !== 'prompt' ? message : vscode.l10n.t('GitHub Coding Agent will implement the specification outlined in this prompt file')),
246253
{
247254
modal: true,
248255
},
@@ -271,6 +278,17 @@ export class CopilotRemoteAgentManager extends Disposable {
271278
}
272279

273280
const { webviewUri, link, number } = result;
281+
282+
if (source === 'prompt') {
283+
const VIEW = vscode.l10n.t('View');
284+
const finished = vscode.l10n.t('Coding agent has begun work on your prompt in #{0}', number);
285+
vscode.window.showInformationMessage(finished, VIEW).then((value) => {
286+
if (value === VIEW) {
287+
vscode.commands.executeCommand('vscode.open', webviewUri);
288+
}
289+
});
290+
}
291+
274292
// allow-any-unicode-next-line
275293
return vscode.l10n.t('🚀 Coding agent will continue work in [#{0}]({1}). Track progress [here]({2}).', number, link, webviewUri.toString());
276294
}

0 commit comments

Comments
 (0)