Skip to content

Commit b6f9059

Browse files
Copilotjoshspicer
andauthored
#copilotCodingAgent tool adds follow-ups if active PR is open (#7222)
* checkpoint * Initial plan * Add public getStateForPR method and fix encapsulation violation Co-authored-by: joshspicer <23246594+joshspicer@users.noreply.github.com> --------- Co-authored-by: Josh Spicer <23246594+joshspicer@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
1 parent ae07692 commit b6f9059

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/github/copilotRemoteAgent.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import vscode from 'vscode';
77
import { Repository } from '../api/api';
8-
import { COPILOT_LOGINS } from '../common/copilot';
8+
import { COPILOT_LOGINS, CopilotPRStatus } from '../common/copilot';
99
import { commands } from '../common/executeCommands';
1010
import { Disposable } from '../common/lifecycle';
1111
import Logger from '../common/logger';
@@ -663,4 +663,8 @@ export class CopilotRemoteAgentManager extends Disposable {
663663
const key = this._stateModel.makeKey(owner, repo, pullRequestNumber);
664664
return this._stateModel.notifications.has(key);
665665
}
666+
667+
public getStateForPR(owner: string, repo: string, prNumber: number): CopilotPRStatus {
668+
return this._stateModel.get(owner, repo, prNumber);
669+
}
666670
}

src/lm/tools/copilotRemoteAgentTool.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ export class CopilotRemoteAgentTool implements vscode.LanguageModelTool<CopilotR
7070
]);
7171
}
7272

73+
7374
/* __GDPR__
7475
"remoteAgent.tool.invoke" : {
7576
"hasExistingPR" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
@@ -81,13 +82,23 @@ export class CopilotRemoteAgentTool implements vscode.LanguageModelTool<CopilotR
8182
hasBody: body ? 'true' : 'false'
8283
});
8384

85+
let pullRequestNumber: number | undefined;
8486
if (existingPullRequest) {
85-
const pullRequestNumber = parseInt(existingPullRequest, 10);
87+
pullRequestNumber = parseInt(existingPullRequest, 10);
8688
if (isNaN(pullRequestNumber)) {
8789
return new vscode.LanguageModelToolResult([
8890
new vscode.LanguageModelTextPart(vscode.l10n.t('Invalid pull request number: {0}', existingPullRequest))
8991
]);
9092
}
93+
} else {
94+
const { repo, owner } = targetRepo;
95+
const activePR = targetRepo.fm.activePullRequest;
96+
if (activePR && this.manager.getStateForPR(owner, repo, activePR.number)) {
97+
pullRequestNumber = activePR.number;
98+
}
99+
}
100+
101+
if (pullRequestNumber) {
91102
await this.manager.addFollowUpToExistingPR(pullRequestNumber, title, body);
92103
return new vscode.LanguageModelToolResult([
93104
new vscode.LanguageModelTextPart(vscode.l10n.t('Follow-up added to pull request #{0}.', pullRequestNumber)),

0 commit comments

Comments
 (0)