@@ -691,34 +691,33 @@ export class AgenticChatController implements ChatHandlers {
691691 }
692692
693693 #processReadOrList( toolUse : ToolUse , chatResultStream : AgenticChatResultStream ) : ChatMessage | undefined {
694- if ( toolUse . name !== 'fsRead' ) {
695- //TODO: Implement list directory UX in next PR.
696- return { }
697- }
698- let messageId = toolUse . toolUseId || ''
699- if ( chatResultStream . getMessageIdToUpdate ( ) ) {
700- messageId = chatResultStream . getMessageIdToUpdate ( ) !
701- } else if ( messageId ) {
702- chatResultStream . setMessageIdToUpdate ( messageId )
694+ let messageIdToUpdate = toolUse . toolUseId !
695+ const currentId = chatResultStream . getMessageIdToUpdateForTool ( toolUse . name ! )
696+
697+ if ( currentId ) {
698+ messageIdToUpdate = currentId
699+ } else {
700+ chatResultStream . setMessageIdToUpdateForTool ( toolUse . name ! , messageIdToUpdate )
703701 }
702+
704703 const currentPath = ( toolUse . input as unknown as FsReadParams | ListDirectoryParams ) ?. path
705704 if ( ! currentPath ) return
706- const existingPaths = chatResultStream . getMessageOperation ( messageId ) ?. filePaths || [ ]
705+ const existingPaths = chatResultStream . getMessageOperation ( messageIdToUpdate ) ?. filePaths || [ ]
707706 // Check if path already exists in the list
708707 const isPathAlreadyProcessed = existingPaths . some ( path => path . relativeFilePath === currentPath )
709708 if ( ! isPathAlreadyProcessed ) {
710709 const currentFileDetail = {
711710 relativeFilePath : currentPath ,
712711 lineRanges : [ { first : - 1 , second : - 1 } ] ,
713712 }
714- const operationType = toolUse . name === 'fsRead' ? 'read' : 'listDir'
715- if ( operationType === 'read' ) {
716- chatResultStream . addMessageOperation ( messageId , operationType , [ ... existingPaths , currentFileDetail ] )
717- }
713+ chatResultStream . addMessageOperation ( messageIdToUpdate , toolUse . name ! , [
714+ ... existingPaths ,
715+ currentFileDetail ,
716+ ] )
718717 }
719718 let title : string
720- const itemCount = chatResultStream . getMessageOperation ( messageId ) ?. filePaths . length
721- const filePathsPushed = chatResultStream . getMessageOperation ( messageId ) ?. filePaths ?? [ ]
719+ const itemCount = chatResultStream . getMessageOperation ( messageIdToUpdate ) ?. filePaths . length
720+ const filePathsPushed = chatResultStream . getMessageOperation ( messageIdToUpdate ) ?. filePaths ?? [ ]
722721 if ( ! itemCount ) {
723722 title = 'Gathering context'
724723 } else {
@@ -742,7 +741,7 @@ export class AgenticChatController implements ChatHandlers {
742741 return {
743742 type : 'tool' ,
744743 contextList,
745- messageId,
744+ messageId : messageIdToUpdate ,
746745 body : '' ,
747746 }
748747 }
0 commit comments