Skip to content

Commit 5a8a050

Browse files
authored
Populate thinking progress to chat editor (#7743)
* Populate thinking progress to chat editor * fix test
1 parent f31968e commit 5a8a050

4 files changed

Lines changed: 15 additions & 6 deletions

File tree

common/sessionParsing.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,10 @@ export function parseToolCallDetails(
282282
} : undefined
283283
};
284284
} else if (name === 'think') {
285+
const thought = (args as unknown as { thought?: string }).thought || content || 'Thought';
285286
return {
286-
toolName: 'Thought',
287-
invocationMessage: content || 'Thought',
287+
toolName: 'think',
288+
invocationMessage: thought,
288289
};
289290
} else if (name === 'report_progress') {
290291
const details: ParsedToolCallDetails = {

src/github/copilotRemoteAgent.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1333,7 +1333,7 @@ export class CopilotRemoteAgentManager extends Disposable {
13331333
return undefined;
13341334
}
13351335

1336-
private createToolInvocationPart(pullRequest: PullRequestModel, toolCall: any, deltaContent: string = ''): vscode.ChatToolInvocationPart | undefined {
1336+
private createToolInvocationPart(pullRequest: PullRequestModel, toolCall: any, deltaContent: string = ''): vscode.ChatToolInvocationPart | vscode.ChatResponseThinkingProgressPart | undefined {
13371337
if (!toolCall.function?.name || !toolCall.id) {
13381338
return undefined;
13391339
}
@@ -1352,6 +1352,10 @@ export class CopilotRemoteAgentManager extends Disposable {
13521352
const toolDetails = parseToolCallDetails(toolCall, deltaContent);
13531353
toolPart.toolName = toolDetails.toolName;
13541354

1355+
if (toolCall.toolName === 'think') {
1356+
return new vscode.ChatResponseThinkingProgressPart(toolCall.invocationMessage);
1357+
}
1358+
13551359
if (toolCall.function.name === 'bash') {
13561360
toolPart.invocationMessage = new vscode.MarkdownString(`\`\`\`bash\n${toolDetails.invocationMessage}\n\`\`\``);
13571361
} else {

src/github/copilotRemoteAgent/chatSessionContentBuilder.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ export class ChatSessionContentBuilder {
301301
delta: AssistantDelta,
302302
choice: Choice,
303303
pullRequest: PullRequestModel,
304-
responseParts: Array<vscode.ChatResponseMarkdownPart | vscode.ChatToolInvocationPart | vscode.ChatResponseMultiDiffPart>,
304+
responseParts: Array<vscode.ChatResponseMarkdownPart | vscode.ChatToolInvocationPart | vscode.ChatResponseMultiDiffPart | vscode.ChatResponseThinkingProgressPart>,
305305
currentResponseContent: string,
306306
): string {
307307
if (delta.role === 'assistant') {
@@ -369,7 +369,7 @@ export class ChatSessionContentBuilder {
369369
return currentResponseContent;
370370
}
371371

372-
private createToolInvocationPart(pullRequest: PullRequestModel, toolCall: ToolCall, deltaContent: string = ''): vscode.ChatToolInvocationPart | undefined {
372+
private createToolInvocationPart(pullRequest: PullRequestModel, toolCall: ToolCall, deltaContent: string = ''): vscode.ChatToolInvocationPart | vscode.ChatResponseThinkingProgressPart | undefined {
373373
if (!toolCall.function?.name || !toolCall.id) {
374374
return undefined;
375375
}
@@ -388,6 +388,10 @@ export class ChatSessionContentBuilder {
388388
const toolDetails = parseToolCallDetails(toolCall, deltaContent);
389389
toolPart.toolName = toolDetails.toolName;
390390

391+
if (toolPart.toolName === 'think') {
392+
return new vscode.ChatResponseThinkingProgressPart(toolDetails.invocationMessage);
393+
}
394+
391395
if (toolCall.function.name === 'bash') {
392396
toolPart.invocationMessage = new vscode.MarkdownString(`\`\`\`bash\n${toolDetails.invocationMessage}\n\`\`\``);
393397
} else {

src/test/common/sessionParsing.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ another non-data line`;
134134

135135
const result = parseToolCallDetails(toolCall, 'I need to analyze this code');
136136

137-
assert.strictEqual(result.toolName, 'Thought');
137+
assert.strictEqual(result.toolName, 'think');
138138
assert.strictEqual(result.invocationMessage, 'I need to analyze this code');
139139
});
140140

0 commit comments

Comments
 (0)