Skip to content

Commit b897ec3

Browse files
committed
Merge branch 'main' into dev/mjbvz/eslint9
2 parents c69301d + c991802 commit b897ec3

33 files changed

Lines changed: 913 additions & 405 deletions

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## 0.118.2
4+
5+
### Fixes
6+
7+
- Long coding agent problem statement results in unrecoverable error (Truncate coding agent problem_statement). https://github.com/microsoft/vscode-pull-request-github/issues/7861
8+
39
## 0.118.1
410

511
### Fixes

package.json

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"activeComment",
1515
"chatParticipantAdditions",
1616
"chatParticipantPrivate",
17-
"chatSessionsProvider",
17+
"chatSessionsProvider@2",
1818
"codiconDecoration",
1919
"codeActionRanges",
2020
"commentingRangeHint",
@@ -40,7 +40,7 @@
4040
"version": "0.118.0",
4141
"publisher": "GitHub",
4242
"engines": {
43-
"vscode": "^1.104.0"
43+
"vscode": "^1.105.0"
4444
},
4545
"categories": [
4646
"Other",
@@ -744,6 +744,19 @@
744744
"default": true,
745745
"description": "%githubIssues.assignWhenWorking.description%"
746746
},
747+
"githubIssues.issueAvatarDisplay": {
748+
"type": "string",
749+
"enum": [
750+
"author",
751+
"assignee"
752+
],
753+
"enumDescriptions": [
754+
"%githubIssues.issueAvatarDisplay.author%",
755+
"%githubIssues.issueAvatarDisplay.assignee%"
756+
],
757+
"default": "author",
758+
"description": "%githubIssues.issueAvatarDisplay.description%"
759+
},
747760
"githubPullRequests.focusedMode": {
748761
"properties": {
749762
"oneOf": [
@@ -4190,7 +4203,7 @@
41904203
"test:preprocess-gql": "node scripts/preprocess-gql --in src/github/queries.gql --out out/src/github/queries.gql && node scripts/preprocess-gql --in src/github/queriesExtra.gql --out out/src/github/queriesExtra.gql && node scripts/preprocess-gql --in src/github/queriesShared.gql --out out/src/github/queriesShared.gql && node scripts/preprocess-gql --in src/github/queriesLimited.gql --out out/src/github/queriesLimited.gql",
41914204
"test:preprocess-svg": "node scripts/preprocess-svg --in ../resources/ --out out/resources",
41924205
"test:preprocess-fixtures": "node scripts/preprocess-fixtures --in src --out out",
4193-
"update-dts": "cd \"src/@types\" && npx vscode-dts main && npx vscode-dts dev",
4206+
"update-dts": "cd \"src/@types\" && node ../../node_modules/@vscode/dts/index.js main && node ../../node_modules/@vscode/dts/index.js dev",
41944207
"watch": "webpack --watch --mode development --env esbuild",
41954208
"watch:web": "webpack --watch --mode development --config-name extension:webworker --config-name webviews",
41964209
"hygiene": "node ./build/hygiene.js",
@@ -4213,6 +4226,7 @@
42134226
"@types/webpack-env": "^1.16.0",
42144227
"@typescript-eslint/eslint-plugin": "^8.44.0",
42154228
"@typescript-eslint/parser": "^8.44.0",
4229+
"@vscode/dts": "^0.4.1",
42164230
"@vscode/test-cli": "^0.0.11",
42174231
"@vscode/test-electron": "^2.5.2",
42184232
"@vscode/test-web": "^0.0.71",

package.nls.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,9 @@
149149
"githubIssues.queries.default.createdIssues": "Created Issues",
150150
"githubIssues.queries.default.recentIssues": "Recent Issues",
151151
"githubIssues.assignWhenWorking.description": "Assigns the issue you're working on to you. Only applies when the issue you're working on is in a repo you currently have open.",
152+
"githubIssues.issueAvatarDisplay.description": "Controls which avatar to display in the issue list.",
153+
"githubIssues.issueAvatarDisplay.author": "Show the avatar of the issue creator",
154+
"githubIssues.issueAvatarDisplay.assignee": "Show the avatar of the first assignee (show GitHub icon if no assignees)",
152155
"githubPullRequests.focusedMode.description": "The layout to use when a pull request is checked out. Set to false to prevent layout changes.",
153156
"githubPullRequests.focusedMode.firstDiff": "Show the first diff in the pull request. If there are no changes, show the overview.",
154157
"githubPullRequests.focusedMode.overview": "Show the overview of the pull request.",

src/@types/vscode.proposed.chatSessionsProvider.d.ts

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6+
// version: 2
7+
68
declare module 'vscode' {
79
/**
810
* Represents the status of a chat session.
@@ -34,6 +36,13 @@ declare module 'vscode' {
3436
readonly onDidChangeChatSessionItems: Event<void>;
3537

3638
/**
39+
* Event that the provider can fire to signal that the current (original) chat session should be replaced with a new (modified) chat session.
40+
* The UI can use this information to gracefully migrate the user to the new session.
41+
*/
42+
readonly onDidCommitChatSessionItem: Event<{ original: ChatSessionItem /** untitled */; modified: ChatSessionItem /** newly created */ }>;
43+
44+
/**
45+
* DEPRECATED: Will be removed!
3746
* Creates a new chat session.
3847
*
3948
* @param options Options for the new session including an optional initial prompt and history
@@ -46,16 +55,6 @@ declare module 'vscode' {
4655
*/
4756
readonly request: ChatRequest;
4857

49-
/**
50-
* Initial prompt to initiate the session
51-
*/
52-
readonly prompt?: string;
53-
54-
/**
55-
* History to initialize the session with
56-
*/
57-
readonly history?: ReadonlyArray<ChatRequestTurn | ChatResponseTurn>;
58-
5958
/**
6059
* Additional metadata to use for session creation
6160
*/
@@ -190,7 +189,16 @@ declare module 'vscode' {
190189
*
191190
* @returns A disposable that unregisters the provider when disposed.
192191
*/
193-
export function registerChatSessionContentProvider(chatSessionType: string, provider: ChatSessionContentProvider, capabilities?: ChatSessionCapabilities): Disposable;
192+
export function registerChatSessionContentProvider(chatSessionType: string, provider: ChatSessionContentProvider, chatParticipant: ChatParticipant, capabilities?: ChatSessionCapabilities): Disposable;
193+
}
194+
195+
export interface ChatContext {
196+
readonly chatSessionContext?: ChatSessionContext;
197+
}
198+
199+
export interface ChatSessionContext {
200+
readonly chatSessionItem: ChatSessionItem; // Maps to URI of chat session editor (could be 'untitled-1', etc..)
201+
readonly isUntitled: boolean;
194202
}
195203

196204
export interface ChatSessionCapabilities {

src/common/settingKeys.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export const DEFAULT = 'default';
5454
export const IGNORE_MILESTONES = 'ignoreMilestones';
5555
export const ALLOW_FETCH = 'allowFetch';
5656
export const ALWAYS_PROMPT_FOR_NEW_ISSUE_REPO = 'alwaysPromptForNewIssueRepo';
57+
export const ISSUE_AVATAR_DISPLAY = 'issueAvatarDisplay';
5758
export const EXPERIMENTAL_CHAT = 'experimental.chat';
5859
export const EXPERIMENTAL_USE_QUICK_CHAT = 'experimental.useQuickChat';
5960
export const EXPERIMENTAL_NOTIFICATIONS_PAGE_SIZE = 'experimental.notificationsViewPageSize';

src/common/uri.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { Buffer } from 'buffer';
99
import * as pathUtils from 'path';
1010
import fetch from 'cross-fetch';
1111
import * as vscode from 'vscode';
12+
import { RemoteInfo } from '../../common/types';
1213
import { Repository } from '../api/api';
1314
import { EXTENSION_ID } from '../constants';
1415
import { IAccount, isITeam, ITeam, reviewerId } from '../github/interface';
@@ -675,6 +676,24 @@ export function fromOpenPullRequestWebviewUri(uri: vscode.Uri): OpenPullRequestW
675676
} catch (e) { }
676677
}
677678

679+
export function toQueryUri(params: { remote: RemoteInfo | undefined, isCopilot?: boolean }) {
680+
const uri = vscode.Uri.from({ scheme: Schemes.PRQuery, path: params.isCopilot ? 'copilot' : undefined, query: params.remote ? JSON.stringify({ remote: params.remote }) : undefined });
681+
return uri;
682+
}
683+
684+
export function fromQueryUri(uri: vscode.Uri): { remote: RemoteInfo | undefined, isCopilot?: boolean } | undefined {
685+
if (uri.scheme !== Schemes.PRQuery) {
686+
return;
687+
}
688+
try {
689+
const query = uri.query ? JSON.parse(uri.query) : undefined;
690+
return {
691+
remote: query.remote,
692+
isCopilot: uri.path === 'copilot'
693+
};
694+
} catch (e) { }
695+
}
696+
678697
export enum Schemes {
679698
File = 'file',
680699
Review = 'review', // File content for a checked out PR
@@ -694,8 +713,6 @@ export enum Schemes {
694713
GitHubCommit = 'githubcommit' // file content from GitHub for a commit
695714
}
696715

697-
export const COPILOT_QUERY = vscode.Uri.from({ scheme: Schemes.PRQuery, path: 'copilot' });
698-
699716
export function resolvePath(from: vscode.Uri, to: string) {
700717
if (from.scheme === Schemes.File) {
701718
return pathUtils.resolve(from.fsPath, to);

src/extension.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,11 @@ async function deferredActivate(context: vscode.ExtensionContext, showPRControll
420420
const copilotRemoteAgentManager = new CopilotRemoteAgentManager(credentialStore, reposManager, telemetry, context, apiImpl);
421421
context.subscriptions.push(copilotRemoteAgentManager);
422422
if (vscode.chat?.registerChatSessionItemProvider) {
423+
const chatParticipant = vscode.chat.createChatParticipant(COPILOT_SWE_AGENT, async (request, context, stream, token) =>
424+
await copilotRemoteAgentManager.chatParticipantImpl(request, context, stream, token)
425+
);
426+
context.subscriptions.push(chatParticipant);
427+
423428
const provider = new class implements vscode.ChatSessionContentProvider, vscode.ChatSessionItemProvider {
424429
label = vscode.l10n.t('GitHub Copilot Coding Agent');
425430
provideChatSessionItems = async (token) => {
@@ -429,9 +434,7 @@ async function deferredActivate(context: vscode.ExtensionContext, showPRControll
429434
return await copilotRemoteAgentManager.provideChatSessionContent(id, token);
430435
};
431436
onDidChangeChatSessionItems = copilotRemoteAgentManager.onDidChangeChatSessions;
432-
provideNewChatSessionItem = async (options: { readonly request: vscode.ChatRequest; prompt?: string; history: ReadonlyArray<vscode.ChatRequestTurn | vscode.ChatResponseTurn>; metadata?: any; }, token: vscode.CancellationToken): Promise<vscode.ChatSessionItem> => {
433-
return await copilotRemoteAgentManager.provideNewChatSessionItem(options, token);
434-
};
437+
onDidCommitChatSessionItem = copilotRemoteAgentManager.onDidCommitChatSession;
435438
}();
436439

437440
context.subscriptions.push(vscode.chat?.registerChatSessionItemProvider(
@@ -442,7 +445,8 @@ async function deferredActivate(context: vscode.ExtensionContext, showPRControll
442445
context.subscriptions.push(vscode.chat?.registerChatSessionContentProvider(
443446
COPILOT_SWE_AGENT,
444447
provider,
445-
{ supportsInterruptions: true, }
448+
chatParticipant,
449+
{ supportsInterruptions: true }
446450
));
447451
}
448452

src/github/copilotApi.ts

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ import { hasEnterpriseUri } from './utils';
1919

2020
const LEARN_MORE_URL = 'https://aka.ms/coding-agent-docs';
2121
const PREMIUM_REQUESTS_URL = 'https://docs.github.com/en/copilot/concepts/copilot-billing/understanding-and-managing-requests-in-copilot#what-are-premium-requests';
22-
22+
// https://github.com/github/sweagentd/blob/59e7d9210ca3ebba029918387e525eea73cb1f4a/internal/problemstatement/problemstatement.go#L36-L53
23+
export const MAX_PROBLEM_STATEMENT_LENGTH = 30_000 - 50; // 50 character buffer
2324
export interface RemoteAgentJobPayload {
2425
problem_statement: string;
2526
event_type: string;
@@ -45,14 +46,6 @@ export interface ChatSessionWithPR extends vscode.ChatSessionItem {
4546
pullRequest: PullRequestModel;
4647
}
4748

48-
export interface ChatSessionFromSummarizedChat extends vscode.ChatSessionItem {
49-
prompt: string;
50-
summary?: string;
51-
// Cache
52-
pullRequest?: PullRequestModel;
53-
sessionInfo?: SessionInfo;
54-
}
55-
5649
export class CopilotApi {
5750
protected static readonly ID = 'copilotApi';
5851

@@ -75,25 +68,36 @@ export class CopilotApi {
7568
return this.makeApiCallFullUrl(`${this.baseUrl}${api}`, init);
7669
}
7770

71+
private get userAgent(): string {
72+
const extensionVersion = vscode.extensions.getExtension('GitHub.vscode-pull-request-github')?.packageJSON.version ?? 'unknown';
73+
return `vscode-pull-request-github/${extensionVersion}`;
74+
}
75+
76+
7877
async postRemoteAgentJob(
7978
owner: string,
8079
name: string,
8180
payload: RemoteAgentJobPayload,
81+
isTruncated: boolean,
8282
): Promise<RemoteAgentJobResponse> {
8383
const repoSlug = `${owner}/${name}`;
8484
const apiUrl = `/agents/swe/v0/jobs/${repoSlug}`;
8585
let status: number | undefined;
86+
87+
const problemStatementLength = payload.problem_statement.length.toString();
88+
const payloadJson = JSON.stringify(payload);
89+
const payloadLength = payloadJson.length.toString();
8690
Logger.trace(`postRemoteAgentJob: Posting job to ${apiUrl} with payload: ${JSON.stringify(payload)}`, CopilotApi.ID);
8791
try {
8892
const response = await this.makeApiCall(apiUrl, {
8993
method: 'POST',
9094
headers: {
91-
'Copilot-Integration-Id': 'copilot-developer-dev',
9295
'Authorization': `Bearer ${this.token}`,
9396
'Content-Type': 'application/json',
94-
'Accept': 'application/json'
97+
'Accept': 'application/json',
98+
'User-Agent': this.userAgent,
9599
},
96-
body: JSON.stringify(payload)
100+
body: payloadJson
97101
});
98102

99103
status = response.status;
@@ -106,21 +110,33 @@ export class CopilotApi {
106110
/*
107111
__GDPR__
108112
"remoteAgent.postRemoteAgentJob" : {
109-
"status" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
113+
"status" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
114+
"payloadLength": { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
115+
"problemStatementLength": { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
116+
"isTruncated": { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
110117
}
111118
*/
112119
this.telemetry.sendTelemetryEvent('remoteAgent.postRemoteAgentJob', {
113120
status: status.toString(),
121+
payloadLength,
122+
problemStatementLength,
123+
isTruncated: isTruncated.toString(),
114124
});
115125
return data;
116126
} catch (error) {
117127
/* __GDPR__
118128
"remoteAgent.postRemoteAgentJob" : {
119-
"status" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
129+
"status" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
130+
"payloadLength": { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
131+
"problemStatementLength": { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
132+
"isTruncated": { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
120133
}
121134
*/
122135
this.telemetry.sendTelemetryErrorEvent('remoteAgent.postRemoteAgentJob', {
123136
status: status?.toString() || '999',
137+
payloadLength,
138+
problemStatementLength,
139+
isTruncated: isTruncated.toString(),
124140
});
125141
throw error;
126142
}
@@ -259,10 +275,10 @@ export class CopilotApi {
259275
const response = await this.makeApiCall(`/agents/swe/v0/jobs/${owner}/${repo}/session/${sessionId}`, {
260276
method: 'GET',
261277
headers: {
262-
'Copilot-Integration-Id': 'copilot-developer-dev',
263278
'Authorization': `Bearer ${this.token}`,
264279
'Content-Type': 'application/json',
265-
'Accept': 'application/json'
280+
'Accept': 'application/json',
281+
'User-Agent': this.userAgent,
266282
}
267283
});
268284
if (!response.ok) {

0 commit comments

Comments
 (0)