33 * Licensed under the MIT License. See License.txt in the project root for license information.
44 *--------------------------------------------------------------------------------------------*/
55
6+ import * as nodePath from 'path' ;
67import vscode from 'vscode' ;
78import { parseSessionLogs , parseToolCallDetails } from '../../common/sessionParsing' ;
89import { Repository } from '../api/api' ;
@@ -1095,7 +1096,7 @@ export class CopilotRemoteAgentManager extends Disposable {
10951096 } ;
10961097 }
10971098
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 } > {
10991100 try {
11001101 if ( ! newLogContent . trim ( ) ) {
11011102 return { hasStreamedContent : false , hasSetupStepProgress : false } ;
@@ -1123,7 +1124,7 @@ export class CopilotRemoteAgentManager extends Disposable {
11231124
11241125 if ( delta . content && delta . content . trim ( ) ) {
11251126 // 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 ) ;
11271128 if ( toolPart ) {
11281129 stream . push ( toolPart ) ;
11291130 hasStreamedContent = true ;
@@ -1143,7 +1144,7 @@ export class CopilotRemoteAgentManager extends Disposable {
11431144
11441145 if ( delta . tool_calls ) {
11451146 for ( const toolCall of delta . tool_calls ) {
1146- const toolPart = this . createToolInvocationPart ( toolCall , delta . content || '' ) ;
1147+ const toolPart = this . createToolInvocationPart ( pullRequest , toolCall , delta . content || '' ) ;
11471148 if ( toolPart ) {
11481149 stream . push ( toolPart ) ;
11491150 hasStreamedContent = true ;
@@ -1242,7 +1243,7 @@ export class CopilotRemoteAgentManager extends Disposable {
12421243 if ( sessionInfo . state !== 'in_progress' ) {
12431244 if ( logs . length > lastProcessedLength ) {
12441245 const newLogContent = logs . slice ( lastProcessedLength ) ;
1245- const streamResult = await this . streamNewLogContent ( stream , newLogContent ) ;
1246+ const streamResult = await this . streamNewLogContent ( pullRequest , stream , newLogContent ) ;
12461247 if ( streamResult . hasStreamedContent ) {
12471248 hasActiveProgress = false ;
12481249 }
@@ -1255,7 +1256,7 @@ export class CopilotRemoteAgentManager extends Disposable {
12551256 if ( logs . length > lastLogLength ) {
12561257 Logger . appendLine ( `New logs detected, attempting to stream content` , CopilotRemoteAgentManager . ID ) ;
12571258 const newLogContent = logs . slice ( lastProcessedLength ) ;
1258- const streamResult = await this . streamNewLogContent ( stream , newLogContent ) ;
1259+ const streamResult = await this . streamNewLogContent ( pullRequest , stream , newLogContent ) ;
12591260 lastProcessedLength = logs . length ;
12601261
12611262 if ( streamResult . hasStreamedContent ) {
@@ -1353,7 +1354,7 @@ export class CopilotRemoteAgentManager extends Disposable {
13531354 return undefined ;
13541355 }
13551356
1356- private createToolInvocationPart ( toolCall : any , deltaContent : string = '' ) : vscode . ChatToolInvocationPart | undefined {
1357+ private createToolInvocationPart ( pullRequest : PullRequestModel , toolCall : any , deltaContent : string = '' ) : vscode . ChatToolInvocationPart | undefined {
13571358 if ( ! toolCall . function ?. name || ! toolCall . id ) {
13581359 return undefined ;
13591360 }
@@ -1375,17 +1376,26 @@ export class CopilotRemoteAgentManager extends Disposable {
13751376 if ( toolCall . function . name === 'bash' ) {
13761377 toolPart . invocationMessage = new vscode . MarkdownString ( `\`\`\`bash\n${ toolDetails . invocationMessage } \n\`\`\`` ) ;
13771378 } else {
1378- toolPart . invocationMessage = toolDetails . invocationMessage ;
1379+ toolPart . invocationMessage = new vscode . MarkdownString ( toolDetails . invocationMessage ) ;
13791380 }
13801381
13811382 if ( toolDetails . pastTenseMessage ) {
1382- toolPart . pastTenseMessage = toolDetails . pastTenseMessage ;
1383+ toolPart . pastTenseMessage = new vscode . MarkdownString ( toolDetails . pastTenseMessage ) ;
13831384 }
13841385 if ( toolDetails . originMessage ) {
1385- toolPart . originMessage = toolDetails . originMessage ;
1386+ toolPart . originMessage = new vscode . MarkdownString ( toolDetails . originMessage ) ;
13861387 }
13871388 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+ }
13891399 }
13901400 } catch ( error ) {
13911401 toolPart . toolName = toolCall . function . name || 'unknown' ;
@@ -1425,7 +1435,7 @@ export class CopilotRemoteAgentManager extends Disposable {
14251435 currentResponseContent = '' ;
14261436 }
14271437
1428- const toolPart = this . createToolInvocationPart ( toolCall , args . name || delta . content ) ;
1438+ const toolPart = this . createToolInvocationPart ( pullRequest , toolCall , args . name || delta . content ) ;
14291439 if ( toolPart ) {
14301440 responseParts . push ( toolPart ) ;
14311441 }
@@ -1446,7 +1456,7 @@ export class CopilotRemoteAgentManager extends Disposable {
14461456 }
14471457
14481458 for ( const toolCall of delta . tool_calls ) {
1449- const toolPart = this . createToolInvocationPart ( toolCall , delta . content || '' ) ;
1459+ const toolPart = this . createToolInvocationPart ( pullRequest , toolCall , delta . content || '' ) ;
14501460 if ( toolPart ) {
14511461 responseParts . push ( toolPart ) ;
14521462 }
0 commit comments