Skip to content

Commit d3873b5

Browse files
Merge branch 'main' into not-close-file
2 parents 4d33539 + 1f2bae6 commit d3873b5

Some content is hidden

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

58 files changed

+2508
-598
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+
}

package.json

Lines changed: 89 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"activeComment",
1515
"chatParticipantAdditions",
1616
"chatParticipantPrivate",
17+
"chatSessionsProvider",
1718
"codiconDecoration",
1819
"codeActionRanges",
1920
"commentingRangeHint",
@@ -28,16 +29,18 @@
2829
"contribEditorContentMenu",
2930
"contribShareMenu",
3031
"diffCommand",
32+
"languageModelDataPart",
33+
"languageModelToolResultAudience",
3134
"quickDiffProvider",
3235
"remoteCodingAgents",
3336
"shareProvider",
3437
"tokenInformation",
3538
"treeViewMarkdownMessage"
3639
],
37-
"version": "0.114.0",
40+
"version": "0.116.0",
3841
"publisher": "GitHub",
3942
"engines": {
40-
"vscode": "^1.102.0"
43+
"vscode": "^1.103.0"
4144
},
4245
"categories": [
4346
"Other",
@@ -66,6 +69,14 @@
6669
"virtualWorkspaces": true
6770
},
6871
"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+
],
6980
"remoteCodingAgents": [
7081
{
7182
"id": "githubCodingAgent",
@@ -1295,6 +1306,21 @@
12951306
"category": "%command.pull.request.category%",
12961307
"icon": "$(eye)"
12971308
},
1309+
{
1310+
"command": "pr.checkoutFromDescription",
1311+
"title": "%command.pr.checkoutFromDescription.title%",
1312+
"category": "%command.pull.request.category%"
1313+
},
1314+
{
1315+
"command": "pr.checkoutOnVscodeDevFromDescription",
1316+
"title": "%command.pr.checkoutOnVscodeDevFromDescription.title%",
1317+
"category": "%command.pull.request.category%"
1318+
},
1319+
{
1320+
"command": "pr.openSessionLogFromDescription",
1321+
"title": "%command.pr.openSessionLogFromDescription.title%",
1322+
"category": "%command.pull.request.category%"
1323+
},
12981324
{
12991325
"command": "review.diffWithPrHead",
13001326
"title": "%command.review.diffWithPrHead.title%",
@@ -1422,6 +1448,11 @@
14221448
"title": "%command.pr.copyVscodeDevPrLink.title%",
14231449
"category": "%command.issues.category%"
14241450
},
1451+
{
1452+
"command": "pr.copyPrLink",
1453+
"title": "%command.pr.copyPrLink.title%",
1454+
"category": "%command.issues.category%"
1455+
},
14251456
{
14261457
"command": "pr.refreshComments",
14271458
"title": "%command.pr.refreshComments.title%",
@@ -1686,6 +1717,12 @@
16861717
"command": "codingAgent.openSessionLog",
16871718
"title": "%command.codingAgent.openSessionLog.title%",
16881719
"category": "%command.pull.request.category%"
1720+
},
1721+
{
1722+
"command": "pr.refreshChatSessions",
1723+
"title": "%command.pr.refreshChatSessions.title%",
1724+
"icon": "$(refresh)",
1725+
"category": "%command.pull.request.category%"
16891726
}
16901727
],
16911728
"viewsWelcome": [
@@ -1957,6 +1994,18 @@
19571994
"command": "pr.toggleEditorCommentingOff",
19581995
"when": "false"
19591996
},
1997+
{
1998+
"command": "pr.checkoutFromDescription",
1999+
"when": "false"
2000+
},
2001+
{
2002+
"command": "pr.checkoutOnVscodeDevFromDescription",
2003+
"when": "false"
2004+
},
2005+
{
2006+
"command": "pr.openSessionLogFromDescription",
2007+
"when": "false"
2008+
},
19602009
{
19612010
"command": "review.suggestDiff",
19622011
"when": "false"
@@ -2117,6 +2166,10 @@
21172166
"command": "pr.copyVscodeDevPrLink",
21182167
"when": "github:inReviewMode && remoteName != codespaces && embedderIdentifier != github.dev"
21192168
},
2169+
{
2170+
"command": "pr.copyPrLink",
2171+
"when": "false"
2172+
},
21202173
{
21212174
"command": "pr.goToNextDiffInPr",
21222175
"when": "activeEditor == workbench.editors.textDiffEditor && resourcePath in github:unviewedFiles"
@@ -2559,6 +2612,11 @@
25592612
"command": "notifications.refresh",
25602613
"when": "gitHubOpenRepositoryCount != 0 && github:initialized && view == notifications:github",
25612614
"group": "navigation@1"
2615+
},
2616+
{
2617+
"command": "pr.refreshChatSessions",
2618+
"when": "view == workbench.view.chat.sessions.copilot-swe-agent",
2619+
"group": "navigation@1"
25622620
}
25632621
],
25642622
"view/item/context": [
@@ -3277,6 +3335,35 @@
32773335
{
32783336
"command": "review.requestChangesOnDotComDescription",
32793337
"when": "webviewId == PullRequestOverview && github:reviewCommentMenu && github:reviewCommentRequestChangesOnDotCom"
3338+
},
3339+
{
3340+
"command": "pr.copyPrLink",
3341+
"when": "webviewId == PullRequestOverview && github:copyMenu"
3342+
},
3343+
{
3344+
"command": "pr.copyVscodeDevPrLink",
3345+
"when": "webviewId == PullRequestOverview && github:copyMenu"
3346+
},
3347+
{
3348+
"command": "pr.openChanges",
3349+
"group": "checkout@0",
3350+
"when": "webviewId == PullRequestOverview && github:checkoutMenu"
3351+
},
3352+
{
3353+
"command": "pr.checkoutOnVscodeDevFromDescription",
3354+
"group": "checkout@1",
3355+
"when": "webviewId == PullRequestOverview && github:checkoutMenu"
3356+
},
3357+
{
3358+
"command": "pr.openSessionLogFromDescription",
3359+
"when": "webviewId == PullRequestOverview && github:codingAgentMenu"
3360+
}
3361+
3362+
],
3363+
"chat/chatSessions": [
3364+
{
3365+
"command": "pr.openDescription",
3366+
"when": "chatSessionType == copilot-swe-agent"
32803367
}
32813368
]
32823369
},

package.nls.json

Lines changed: 6 additions & 1 deletion
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",
@@ -257,7 +258,8 @@
257258
"command.issues.category": "GitHub Issues",
258259
"command.issue.createIssueFromSelection.title": "Create Issue From Selection",
259260
"command.issue.createIssueFromClipboard.title": "Create Issue From Clipboard",
260-
"command.pr.copyVscodeDevPrLink.title": "Copy vscode.dev Pull Request Link",
261+
"command.pr.copyVscodeDevPrLink.title": "Copy vscode.dev Link",
262+
"command.pr.copyPrLink.title": "Copy Link",
261263
"command.pr.createPrMenuCreate.title": "Create",
262264
"command.pr.createPrMenuDraft.title": "Create Draft",
263265
"command.pr.createPrMenuSquash.title": "Create + Auto-Squash",
@@ -270,6 +272,9 @@
270272
"command.pr.closeRelatedEditors.title": "Close All Pull Request Editors",
271273
"command.pr.toggleEditorCommentingOn.title": "Toggle Editor Commenting On",
272274
"command.pr.toggleEditorCommentingOff.title": "Toggle Editor Commenting Off",
275+
"command.pr.checkoutFromDescription.title": "Checkout",
276+
"command.pr.checkoutOnVscodeDevFromDescription.title": "Checkout on vscode.dev",
277+
"command.pr.openSessionLogFromDescription.title": "View Session",
273278
"command.issue.openDescription.title": "View Issue Description",
274279
"command.issue.copyGithubDevLink.title": "Copy github.dev Link",
275280
"command.issue.copyGithubPermalink.title": "Copy GitHub Permalink",

resources/icons/copilot-error.svg

Lines changed: 4 additions & 0 deletions
Loading
Lines changed: 4 additions & 0 deletions
Loading
Lines changed: 4 additions & 0 deletions
Loading

resources/icons/loading.svg

Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)