Skip to content

Commit 7289da2

Browse files
committed
Stream coding agent stages in discrete steps
1 parent 40ffcba commit 7289da2

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/github/copilotApi.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ export class CopilotApi {
7979
return `vscode-pull-request-github/${extensionVersion}`;
8080
}
8181

82-
8382
async postRemoteAgentJob(
8483
owner: string,
8584
name: string,

src/github/copilotRemoteAgent.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ export class CopilotRemoteAgentManager extends Disposable {
9494
historySummaryLength: historySummary?.length.toString() || '0',
9595
source,
9696
});
97-
stream.progress(vscode.l10n.t('Delegating to coding agent'));
9897
const result = await this.invokeRemoteAgent(
9998
promptSummary || prompt,
10099
[
@@ -103,6 +102,7 @@ export class CopilotRemoteAgentManager extends Disposable {
103102
].join('\n\n').trim(),
104103
token,
105104
false,
105+
stream,
106106
);
107107
if (result.state !== 'success') {
108108
Logger.error(`Failed to provide new chat session item: ${result.error}`, CopilotRemoteAgentManager.ID);
@@ -194,7 +194,7 @@ export class CopilotRemoteAgentManager extends Disposable {
194194
stream.markdown(result);
195195
stream.markdown('\n\n');
196196

197-
stream.progress(vscode.l10n.t('Waiting for coding agent to respond'));
197+
stream.progress(vscode.l10n.t('Attaching to session'));
198198

199199
// Wait for new session and stream its progress
200200
const newSession = await this.waitForNewSession(pullRequest, stream, token, true);
@@ -705,7 +705,7 @@ export class CopilotRemoteAgentManager extends Disposable {
705705
return vscode.l10n.t('🚀 Coding agent will continue work in [#{0}]({1}). Track progress [here]({2}).', number, link, webviewUri.toString());
706706
}
707707

708-
async invokeRemoteAgent(prompt: string, problemContext?: string, token?: vscode.CancellationToken, autoPushAndCommit = true): Promise<RemoteAgentResult> {
708+
async invokeRemoteAgent(prompt: string, problemContext?: string, token?: vscode.CancellationToken, autoPushAndCommit = true, chatStream?: vscode.ChatResponseStream): Promise<RemoteAgentResult> {
709709
const capiClient = await this.copilotApi;
710710
if (!capiClient) {
711711
return { error: vscode.l10n.t('Failed to initialize Copilot API'), state: 'error' };
@@ -731,6 +731,7 @@ export class CopilotRemoteAgentManager extends Disposable {
731731
return { error: vscode.l10n.t('Uncommitted changes detected. Please commit or stash your changes before starting the remote agent. Enable \'{0}\' to push your changes automatically.', CODING_AGENT_AUTO_COMMIT_AND_PUSH), state: 'error' };
732732
}
733733
try {
734+
chatStream?.progress(vscode.l10n.t('Waiting for local changes'));
734735
head_ref = await this.gitOperationsManager.commitAndPushChanges(repoInfo);
735736
} catch (error) {
736737
return { error: error.message, state: 'error' };
@@ -755,6 +756,7 @@ export class CopilotRemoteAgentManager extends Disposable {
755756
const { problemStatement, isTruncated } = truncatePrompt(prompt, problemContext);
756757

757758
if (isTruncated) {
759+
chatStream?.progress(vscode.l10n.t('Truncating context'));
758760
const truncationResult = await vscode.window.showWarningMessage(
759761
vscode.l10n.t('Prompt size exceeded'), { modal: true, detail: vscode.l10n.t('Your prompt will be truncated to fit within coding agent\'s context window. This may affect the quality of the response.') }, CONTINUE_TRUNCATION);
760762
const userCancelled = token?.isCancellationRequested || !truncationResult || truncationResult !== CONTINUE_TRUNCATION;
@@ -784,10 +786,12 @@ export class CopilotRemoteAgentManager extends Disposable {
784786
};
785787

786788
try {
789+
chatStream?.progress(vscode.l10n.t('Delegating to coding agent'));
787790
const response = await capiClient.postRemoteAgentJob(owner, repo, payload, isTruncated);
788791

789792
// For v1 API, we need to fetch the job details to get the PR info
790793
// Since the PR might not be created immediately, we need to poll for it
794+
chatStream?.progress(vscode.l10n.t('Creating pull request'));
791795
const jobInfo = await this.waitForJobWithPullRequest(capiClient, owner, repo, response.job_id, token);
792796
if (!jobInfo || !jobInfo.pull_request) {
793797
return { error: vscode.l10n.t('Failed to retrieve pull request information from job'), state: 'error' };
@@ -803,6 +807,7 @@ export class CopilotRemoteAgentManager extends Disposable {
803807
const webviewUri = await toOpenPullRequestWebviewUri({ owner, repo, pullRequestNumber: number });
804808
const prLlmString = `The remote agent has begun work and has created a pull request. Details about the pull request are being shown to the user. If the user wants to track progress or iterate on the agent's work, they should use the pull request.`;
805809

810+
chatStream?.progress(vscode.l10n.t('Attaching to session'));
806811
await this.waitForQueuedToInProgress(response.session_id, token);
807812
return {
808813
state: 'success',

0 commit comments

Comments
 (0)