Skip to content

Commit 37083cf

Browse files
committed
Merge branch 'main' into copilot/fix-eed0e0d3-701e-46de-ac34-36100892efea
2 parents 62c9bc5 + afa199e commit 37083cf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1580
-280
lines changed

common/sessionParsing.ts

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
export interface SessionResponseLogChunk {
7+
choices: Array<{
8+
finish_reason: string;
9+
delta: {
10+
content?: string;
11+
role: string;
12+
tool_calls?: Array<{
13+
function: {
14+
arguments: string;
15+
name: string;
16+
};
17+
id: string;
18+
type: string;
19+
index: number;
20+
}>;
21+
};
22+
}>;
23+
created: number;
24+
id: string;
25+
usage: {
26+
completion_tokens: number;
27+
prompt_tokens: number;
28+
prompt_tokens_details: {
29+
cached_tokens: number;
30+
};
31+
total_tokens: number;
32+
};
33+
model: string;
34+
object: string;
35+
}
36+
37+
export interface ParsedToolCall {
38+
type: 'str_replace_editor' | 'think' | 'bash' | 'report_progress' | 'unknown';
39+
name: string;
40+
args: any;
41+
content: string;
42+
command?: string; // For str_replace_editor
43+
}
44+
45+
export interface ParsedChoice {
46+
type: 'assistant_content' | 'tool_call' | 'pr_title';
47+
content?: string;
48+
toolCall?: ParsedToolCall;
49+
finishReason?: string;
50+
}
51+
52+
export interface ParsedToolCallDetails {
53+
toolName: string;
54+
invocationMessage: string;
55+
pastTenseMessage?: string;
56+
originMessage?: string;
57+
toolSpecificData?: any;
58+
}
59+
60+
/**
61+
* Parse tool call arguments and return normalized tool details
62+
*/
63+
export function parseToolCallDetails(
64+
toolCall: {
65+
function: { name: string; arguments: string };
66+
id: string;
67+
type: string;
68+
index: number;
69+
},
70+
content: string
71+
): ParsedToolCallDetails {
72+
let args: any = {};
73+
try {
74+
args = toolCall.function.arguments ? JSON.parse(toolCall.function.arguments) : {};
75+
} catch {
76+
// fallback to empty args
77+
}
78+
79+
const name = toolCall.function.name;
80+
81+
if (name === 'str_replace_editor') {
82+
if (args.command === 'view') {
83+
return {
84+
toolName: args.path ? `View ${args.path}` : 'View repository',
85+
invocationMessage: `View ${args.path}`,
86+
pastTenseMessage: `View ${args.path}`
87+
};
88+
} else {
89+
return {
90+
toolName: 'Edit',
91+
invocationMessage: `Edit: ${args.path}`,
92+
pastTenseMessage: `Edit: ${args.path}`
93+
};
94+
}
95+
} else if (name === 'think') {
96+
return {
97+
toolName: 'Thought',
98+
invocationMessage: content
99+
};
100+
} else if (name === 'report_progress') {
101+
const details: ParsedToolCallDetails = {
102+
toolName: 'Progress Update',
103+
invocationMessage: args.prDescription || content
104+
};
105+
if (args.commitMessage) {
106+
details.originMessage = `Commit: ${args.commitMessage}`;
107+
}
108+
return details;
109+
} else if (name === 'bash') {
110+
const command = args.command ? `$ ${args.command}` : undefined;
111+
const bashContent = [command, content].filter(Boolean).join('\n');
112+
const details: ParsedToolCallDetails = {
113+
toolName: 'Run Bash command',
114+
invocationMessage: bashContent
115+
};
116+
117+
// Use the terminal-specific data for bash commands
118+
if (args.command) {
119+
details.toolSpecificData = {
120+
commandLine: {
121+
original: args.command,
122+
},
123+
language: 'bash'
124+
};
125+
}
126+
return details;
127+
} else {
128+
// Unknown tool type
129+
return {
130+
toolName: name || 'unknown',
131+
invocationMessage: content
132+
};
133+
}
134+
}
135+
136+
/**
137+
* Parse raw session logs text into structured log chunks
138+
*/
139+
export function parseSessionLogs(rawText: string): SessionResponseLogChunk[] {
140+
const parts = rawText
141+
.split(/\r?\n/)
142+
.filter(part => part.startsWith('data: '))
143+
.map(part => part.slice('data: '.length).trim())
144+
.map(part => JSON.parse(part));
145+
146+
return parts as SessionResponseLogChunk[];
147+
}

common/views.ts

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

66
import { ClosedEvent, CommentEvent } from '../src/common/timelineEvent';
77
import { GithubItemStateEnum, IAccount, ILabel, IMilestone, IProject, ITeam, MergeMethod, MergeMethodsAvailability } from '../src/github/interface';
8-
import { PreReviewState } from '../src/github/views';
8+
import { DisplayLabel, PreReviewState } from '../src/github/views';
99

1010
export interface RemoteInfo {
1111
owner: string;
@@ -108,7 +108,7 @@ export interface CreateParamsNew {
108108
compareBranch?: string;
109109
isDraftDefault: boolean;
110110
isDraft?: boolean;
111-
labels?: ILabel[];
111+
labels?: DisplayLabel[];
112112
projects?: IProject[];
113113
assignees?: IAccount[];
114114
reviewers?: (IAccount | ITeam)[];
@@ -169,14 +169,14 @@ export interface TitleAndDescriptionResult {
169169
description: string | undefined;
170170
}
171171

172-
export interface CloseResult {
173-
state: GithubItemStateEnum;
174-
commentEvent?: CommentEvent;
175-
closeEvent: ClosedEvent;
176-
}
177-
178-
export interface OpenCommitChangesArgs {
179-
commitSha: string;
180-
}
181-
172+
export interface CloseResult {
173+
state: GithubItemStateEnum;
174+
commentEvent?: CommentEvent;
175+
closeEvent: ClosedEvent;
176+
}
177+
178+
export interface OpenCommitChangesArgs {
179+
commitSha: string;
180+
}
181+
182182
// #endregion

package.json

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,15 @@
2929
"contribEditorContentMenu",
3030
"contribShareMenu",
3131
"diffCommand",
32+
"languageModelDataPart",
33+
"languageModelToolResultAudience",
3234
"quickDiffProvider",
3335
"remoteCodingAgents",
3436
"shareProvider",
3537
"tokenInformation",
3638
"treeViewMarkdownMessage"
3739
],
38-
"version": "0.114.0",
40+
"version": "0.116.0",
3941
"publisher": "GitHub",
4042
"engines": {
4143
"vscode": "^1.103.0"
@@ -67,6 +69,14 @@
6769
"virtualWorkspaces": true
6870
},
6971
"contributes": {
72+
"chatSessions": [
73+
{
74+
"id": "copilot-swe-agent",
75+
"name": "copilot",
76+
"displayName": "GitHub Copilot Coding Agent",
77+
"description": "Chat session for GitHub Copilot coding agent"
78+
}
79+
],
7080
"remoteCodingAgents": [
7181
{
7282
"id": "githubCodingAgent",
@@ -1702,6 +1712,12 @@
17021712
"command": "codingAgent.openSessionLog",
17031713
"title": "%command.codingAgent.openSessionLog.title%",
17041714
"category": "%command.pull.request.category%"
1715+
},
1716+
{
1717+
"command": "pr.refreshChatSessions",
1718+
"title": "%command.pr.refreshChatSessions.title%",
1719+
"icon": "$(refresh)",
1720+
"category": "%command.pull.request.category%"
17051721
}
17061722
],
17071723
"viewsWelcome": [
@@ -2591,6 +2607,11 @@
25912607
"command": "notifications.refresh",
25922608
"when": "gitHubOpenRepositoryCount != 0 && github:initialized && view == notifications:github",
25932609
"group": "navigation@1"
2610+
},
2611+
{
2612+
"command": "pr.refreshChatSessions",
2613+
"when": "view == workbench.view.chat.sessions.copilot-swe-agent",
2614+
"group": "navigation@1"
25942615
}
25952616
],
25962617
"view/item/context": [

package.nls.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@
210210
"command.review.createSuggestionFromChange.title": "Convert to Pull Request Suggestion",
211211
"command.review.copyPrLink.title": "Copy Pull Request Link",
212212
"command.pr.refreshList.title": "Refresh Pull Requests List",
213+
"command.pr.refreshChatSessions.title": "Refresh Chat Sessions",
213214
"command.pr.setFileListLayoutAsTree.title": "View as Tree",
214215
"command.pr.setFileListLayoutAsFlat.title": "View as List",
215216
"command.pr.refreshChanges.title": "Refresh",

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

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,49 @@ declare module 'vscode' {
107107
constructor(toolName: string, toolCallId: string, isError?: boolean);
108108
}
109109

110-
export type ExtendedChatResponsePart = ChatResponsePart | ChatResponseTextEditPart | ChatResponseNotebookEditPart | ChatResponseConfirmationPart | ChatResponseCodeCitationPart | ChatResponseReferencePart2 | ChatResponseMovePart | ChatResponseExtensionsPart | ChatPrepareToolInvocationPart | ChatToolInvocationPart;
110+
/**
111+
* Represents a single file diff entry in a multi diff view.
112+
*/
113+
export interface ChatResponseDiffEntry {
114+
/**
115+
* The original file URI (undefined for new files).
116+
*/
117+
originalUri?: Uri;
118+
119+
/**
120+
* The modified file URI (undefined for deleted files).
121+
*/
122+
modifiedUri?: Uri;
123+
124+
/**
125+
* Optional URI to navigate to when clicking on the file.
126+
*/
127+
goToFileUri?: Uri;
128+
}
129+
130+
/**
131+
* Represents a part of a chat response that shows multiple file diffs.
132+
*/
133+
export class ChatResponseMultiDiffPart {
134+
/**
135+
* Array of file diff entries to display.
136+
*/
137+
value: ChatResponseDiffEntry[];
138+
139+
/**
140+
* The title for the multi diff editor.
141+
*/
142+
title: string;
143+
144+
/**
145+
* Create a new ChatResponseMultiDiffPart.
146+
* @param value Array of file diff entries.
147+
* @param title The title for the multi diff editor.
148+
*/
149+
constructor(value: ChatResponseDiffEntry[], title: string);
150+
}
151+
152+
export type ExtendedChatResponsePart = ChatResponsePart | ChatResponseTextEditPart | ChatResponseNotebookEditPart | ChatResponseConfirmationPart | ChatResponseCodeCitationPart | ChatResponseReferencePart2 | ChatResponseMovePart | ChatResponseExtensionsPart | ChatResponsePullRequestPart | ChatPrepareToolInvocationPart | ChatToolInvocationPart | ChatResponseMultiDiffPart;
111153
export class ChatResponseWarningPart {
112154
value: MarkdownString;
113155
constructor(value: string | MarkdownString);
@@ -193,6 +235,15 @@ declare module 'vscode' {
193235
constructor(extensions: string[]);
194236
}
195237

238+
export class ChatResponsePullRequestPart {
239+
readonly uri: Uri;
240+
readonly linkTag: string;
241+
readonly title: string;
242+
readonly description: string;
243+
readonly author: string;
244+
constructor(uri: Uri, title: string, description: string, author: string, linkTag: string);
245+
}
246+
196247
export interface ChatResponseStream {
197248

198249
/**

0 commit comments

Comments
 (0)