3
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
4
*--------------------------------------------------------------------------------------------*/
5
5
6
+ import * as nodePath from 'path' ;
6
7
import vscode from 'vscode' ;
7
8
import { parseSessionLogs , parseToolCallDetails } from '../../common/sessionParsing' ;
8
9
import { Repository } from '../api/api' ;
@@ -1095,7 +1096,7 @@ export class CopilotRemoteAgentManager extends Disposable {
1095
1096
} ;
1096
1097
}
1097
1098
1098
- private async streamNewLogContent ( stream : vscode . ChatResponseStream , newLogContent : string ) : Promise < { hasStreamedContent : boolean ; hasSetupStepProgress : boolean } > {
1099
+ private async streamNewLogContent ( pullRequest : PullRequestModel , stream : vscode . ChatResponseStream , newLogContent : string ) : Promise < { hasStreamedContent : boolean ; hasSetupStepProgress : boolean } > {
1099
1100
try {
1100
1101
if ( ! newLogContent . trim ( ) ) {
1101
1102
return { hasStreamedContent : false , hasSetupStepProgress : false } ;
@@ -1123,7 +1124,7 @@ export class CopilotRemoteAgentManager extends Disposable {
1123
1124
1124
1125
if ( delta . content && delta . content . trim ( ) ) {
1125
1126
// Finished setup step - create/update tool part
1126
- const toolPart = this . createToolInvocationPart ( toolCall , args . name || delta . content ) ;
1127
+ const toolPart = this . createToolInvocationPart ( pullRequest , toolCall , args . name || delta . content ) ;
1127
1128
if ( toolPart ) {
1128
1129
stream . push ( toolPart ) ;
1129
1130
hasStreamedContent = true ;
@@ -1143,7 +1144,7 @@ export class CopilotRemoteAgentManager extends Disposable {
1143
1144
1144
1145
if ( delta . tool_calls ) {
1145
1146
for ( const toolCall of delta . tool_calls ) {
1146
- const toolPart = this . createToolInvocationPart ( toolCall , delta . content || '' ) ;
1147
+ const toolPart = this . createToolInvocationPart ( pullRequest , toolCall , delta . content || '' ) ;
1147
1148
if ( toolPart ) {
1148
1149
stream . push ( toolPart ) ;
1149
1150
hasStreamedContent = true ;
@@ -1242,7 +1243,7 @@ export class CopilotRemoteAgentManager extends Disposable {
1242
1243
if ( sessionInfo . state !== 'in_progress' ) {
1243
1244
if ( logs . length > lastProcessedLength ) {
1244
1245
const newLogContent = logs . slice ( lastProcessedLength ) ;
1245
- const streamResult = await this . streamNewLogContent ( stream , newLogContent ) ;
1246
+ const streamResult = await this . streamNewLogContent ( pullRequest , stream , newLogContent ) ;
1246
1247
if ( streamResult . hasStreamedContent ) {
1247
1248
hasActiveProgress = false ;
1248
1249
}
@@ -1255,7 +1256,7 @@ export class CopilotRemoteAgentManager extends Disposable {
1255
1256
if ( logs . length > lastLogLength ) {
1256
1257
Logger . appendLine ( `New logs detected, attempting to stream content` , CopilotRemoteAgentManager . ID ) ;
1257
1258
const newLogContent = logs . slice ( lastProcessedLength ) ;
1258
- const streamResult = await this . streamNewLogContent ( stream , newLogContent ) ;
1259
+ const streamResult = await this . streamNewLogContent ( pullRequest , stream , newLogContent ) ;
1259
1260
lastProcessedLength = logs . length ;
1260
1261
1261
1262
if ( streamResult . hasStreamedContent ) {
@@ -1353,7 +1354,7 @@ export class CopilotRemoteAgentManager extends Disposable {
1353
1354
return undefined ;
1354
1355
}
1355
1356
1356
- private createToolInvocationPart ( toolCall : any , deltaContent : string = '' ) : vscode . ChatToolInvocationPart | undefined {
1357
+ private createToolInvocationPart ( pullRequest : PullRequestModel , toolCall : any , deltaContent : string = '' ) : vscode . ChatToolInvocationPart | undefined {
1357
1358
if ( ! toolCall . function ?. name || ! toolCall . id ) {
1358
1359
return undefined ;
1359
1360
}
@@ -1375,17 +1376,26 @@ export class CopilotRemoteAgentManager extends Disposable {
1375
1376
if ( toolCall . function . name === 'bash' ) {
1376
1377
toolPart . invocationMessage = new vscode . MarkdownString ( `\`\`\`bash\n${ toolDetails . invocationMessage } \n\`\`\`` ) ;
1377
1378
} else {
1378
- toolPart . invocationMessage = toolDetails . invocationMessage ;
1379
+ toolPart . invocationMessage = new vscode . MarkdownString ( toolDetails . invocationMessage ) ;
1379
1380
}
1380
1381
1381
1382
if ( toolDetails . pastTenseMessage ) {
1382
- toolPart . pastTenseMessage = toolDetails . pastTenseMessage ;
1383
+ toolPart . pastTenseMessage = new vscode . MarkdownString ( toolDetails . pastTenseMessage ) ;
1383
1384
}
1384
1385
if ( toolDetails . originMessage ) {
1385
- toolPart . originMessage = toolDetails . originMessage ;
1386
+ toolPart . originMessage = new vscode . MarkdownString ( toolDetails . originMessage ) ;
1386
1387
}
1387
1388
if ( toolDetails . toolSpecificData ) {
1388
- toolPart . toolSpecificData = toolDetails . toolSpecificData ;
1389
+ if ( 'command' in toolDetails . toolSpecificData ) {
1390
+ if ( ( toolDetails . toolSpecificData . command === 'view' || toolDetails . toolSpecificData . command === 'edit' ) && toolDetails . toolSpecificData . fileLabel ) {
1391
+ const uri = vscode . Uri . file ( nodePath . join ( pullRequest . githubRepository . rootUri . fsPath , toolDetails . toolSpecificData . fileLabel ) ) ;
1392
+ toolPart . invocationMessage = new vscode . MarkdownString ( `${ toolPart . toolName } [](${ uri . toString ( ) } )` ) ;
1393
+ toolPart . invocationMessage . supportHtml = true ;
1394
+ toolPart . pastTenseMessage = new vscode . MarkdownString ( `${ toolPart . toolName } [](${ uri . toString ( ) } )` ) ;
1395
+ }
1396
+ } else {
1397
+ toolPart . toolSpecificData = toolDetails . toolSpecificData ;
1398
+ }
1389
1399
}
1390
1400
} catch ( error ) {
1391
1401
toolPart . toolName = toolCall . function . name || 'unknown' ;
@@ -1425,7 +1435,7 @@ export class CopilotRemoteAgentManager extends Disposable {
1425
1435
currentResponseContent = '' ;
1426
1436
}
1427
1437
1428
- const toolPart = this . createToolInvocationPart ( toolCall , args . name || delta . content ) ;
1438
+ const toolPart = this . createToolInvocationPart ( pullRequest , toolCall , args . name || delta . content ) ;
1429
1439
if ( toolPart ) {
1430
1440
responseParts . push ( toolPart ) ;
1431
1441
}
@@ -1446,7 +1456,7 @@ export class CopilotRemoteAgentManager extends Disposable {
1446
1456
}
1447
1457
1448
1458
for ( const toolCall of delta . tool_calls ) {
1449
- const toolPart = this . createToolInvocationPart ( toolCall , delta . content || '' ) ;
1459
+ const toolPart = this . createToolInvocationPart ( pullRequest , toolCall , delta . content || '' ) ;
1450
1460
if ( toolPart ) {
1451
1461
responseParts . push ( toolPart ) ;
1452
1462
}
0 commit comments