@@ -133,7 +133,6 @@ export function buildChatHistoryFromEvents(events: readonly SessionEvent[]): (Ch
133133 const turns : ( ChatRequestTurn2 | ChatResponseTurn2 ) [ ] = [ ] ;
134134 let currentResponseParts : ExtendedChatResponsePart [ ] = [ ] ;
135135 const pendingToolInvocations = new Map < string , ChatToolInvocationPart > ( ) ;
136- const toolNames = new Map < string , string > ( ) ;
137136
138137 for ( const event of events ) {
139138 switch ( event . type ) {
@@ -172,7 +171,7 @@ export function buildChatHistoryFromEvents(events: readonly SessionEvent[]): (Ch
172171 break ;
173172 }
174173 case 'tool.execution_start' : {
175- const responsePart = processToolExecutionStart ( event , toolNames , pendingToolInvocations ) ;
174+ const responsePart = processToolExecutionStart ( event , pendingToolInvocations ) ;
176175 if ( responsePart instanceof ChatResponseThinkingProgressPart ) {
177176 currentResponseParts . push ( responsePart ) ;
178177 }
@@ -196,13 +195,12 @@ export function buildChatHistoryFromEvents(events: readonly SessionEvent[]): (Ch
196195 return turns ;
197196}
198197
199- export function processToolExecutionStart ( event : ToolExecutionStartEvent , toolNames : Map < string , string > , pendingToolInvocations : Map < string , ChatToolInvocationPart | ChatResponseThinkingProgressPart > ) : ChatToolInvocationPart | ChatResponseThinkingProgressPart | undefined {
198+ export function processToolExecutionStart ( event : ToolExecutionStartEvent , pendingToolInvocations : Map < string , ChatToolInvocationPart | ChatResponseThinkingProgressPart > ) : ChatToolInvocationPart | ChatResponseThinkingProgressPart | undefined {
200199 const toolInvocation = createCopilotCLIToolInvocation (
201200 event . data . toolName ,
202201 event . data . toolCallId ,
203202 event . data . arguments
204203 ) ;
205- toolNames . set ( event . data . toolCallId , event . data . toolName ) ;
206204 if ( toolInvocation ) {
207205 // Store pending invocation to update with result later
208206 pendingToolInvocations . set ( event . data . toolCallId , toolInvocation ) ;
@@ -239,9 +237,6 @@ export function createCopilotCLIToolInvocation(
239237 if ( toolName === CopilotCLIToolNames . ReportIntent ) {
240238 return undefined ; // Ignore these for now
241239 }
242- if ( isCopilotCliEditToolCall ( toolName , args ) ) {
243- return undefined ;
244- }
245240 if ( toolName === CopilotCLIToolNames . Think ) {
246241 const thought = ( args as { thought ?: string } ) ?. thought ;
247242 if ( thought && typeof thought === 'string' ) {
@@ -255,8 +250,8 @@ export function createCopilotCLIToolInvocation(
255250 invocation . isComplete = false ;
256251
257252 // Format based on tool name
258- if ( toolName === CopilotCLIToolNames . StrReplaceEditor && ( args as StrReplaceEditorArgs ) ?. command === 'view' ) {
259- formatViewToolInvocation ( invocation , args as StrReplaceEditorArgs ) ;
253+ if ( toolName === CopilotCLIToolNames . StrReplaceEditor ) {
254+ formatStrReplaceEditorInvocation ( invocation , args as StrReplaceEditorArgs ) ;
260255 } else if ( toolName === CopilotCLIToolNames . Bash ) {
261256 formatBashInvocation ( invocation , args as BashArgs ) ;
262257 } else if ( toolName === CopilotCLIToolNames . View ) {
@@ -272,9 +267,38 @@ function formatViewToolInvocation(invocation: ChatToolInvocationPart, args: StrR
272267 const path = args . path ?? '' ;
273268 const display = path ? formatUriForMessage ( path ) : '' ;
274269
275- invocation . invocationMessage = new MarkdownString ( l10n . t ( "Read {0}" , display ) ) ;
270+ invocation . invocationMessage = new MarkdownString ( l10n . t ( "Viewed {0}" , display ) ) ;
276271}
277272
273+ function formatStrReplaceEditorInvocation ( invocation : ChatToolInvocationPart , args : StrReplaceEditorArgs ) : void {
274+ const command = args . command ;
275+ const path = args . path ?? '' ;
276+ const display = path ? formatUriForMessage ( path ) : '' ;
277+
278+ switch ( command ) {
279+ case 'view' :
280+ if ( args . view_range ) {
281+ invocation . invocationMessage = new MarkdownString ( l10n . t ( "Viewed {0} (lines {1}-{2})" , display , args . view_range [ 0 ] , args . view_range [ 1 ] ) ) ;
282+ } else {
283+ invocation . invocationMessage = new MarkdownString ( l10n . t ( "Viewed {0}" , display ) ) ;
284+ }
285+ break ;
286+ case 'str_replace' :
287+ invocation . invocationMessage = new MarkdownString ( l10n . t ( "Edited {0}" , display ) ) ;
288+ break ;
289+ case 'insert' :
290+ invocation . invocationMessage = new MarkdownString ( l10n . t ( "Inserted text in {0}" , display ) ) ;
291+ break ;
292+ case 'create' :
293+ invocation . invocationMessage = new MarkdownString ( l10n . t ( "Created {0}" , display ) ) ;
294+ break ;
295+ case 'undo_edit' :
296+ invocation . invocationMessage = new MarkdownString ( l10n . t ( "Undid edit in {0}" , display ) ) ;
297+ break ;
298+ default :
299+ invocation . invocationMessage = new MarkdownString ( l10n . t ( "Modified {0}" , display ) ) ;
300+ }
301+ }
278302
279303function formatBashInvocation ( invocation : ChatToolInvocationPart , args : BashArgs ) : void {
280304 const command = args . command ?? '' ;
0 commit comments