@@ -691,34 +691,33 @@ export class AgenticChatController implements ChatHandlers {
691
691
}
692
692
693
693
#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 )
703
701
}
702
+
704
703
const currentPath = ( toolUse . input as unknown as FsReadParams | ListDirectoryParams ) ?. path
705
704
if ( ! currentPath ) return
706
- const existingPaths = chatResultStream . getMessageOperation ( messageId ) ?. filePaths || [ ]
705
+ const existingPaths = chatResultStream . getMessageOperation ( messageIdToUpdate ) ?. filePaths || [ ]
707
706
// Check if path already exists in the list
708
707
const isPathAlreadyProcessed = existingPaths . some ( path => path . relativeFilePath === currentPath )
709
708
if ( ! isPathAlreadyProcessed ) {
710
709
const currentFileDetail = {
711
710
relativeFilePath : currentPath ,
712
711
lineRanges : [ { first : - 1 , second : - 1 } ] ,
713
712
}
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
+ ] )
718
717
}
719
718
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 ?? [ ]
722
721
if ( ! itemCount ) {
723
722
title = 'Gathering context'
724
723
} else {
@@ -742,7 +741,7 @@ export class AgenticChatController implements ChatHandlers {
742
741
return {
743
742
type : 'tool' ,
744
743
contextList,
745
- messageId,
744
+ messageId : messageIdToUpdate ,
746
745
body : '' ,
747
746
}
748
747
}
0 commit comments