@@ -708,7 +708,7 @@ export class ChatController {
708708 customization : getSelectedCustomization ( ) ,
709709 toolResults : toolResults ,
710710 origin : Origin . IDE ,
711- chatHistory : this . chatHistoryManager . getHistory ( ) ,
711+ chatHistory : this . chatHistoryStorage . getHistory ( tabID ) . getHistory ( ) ,
712712 context : session . context ?? [ ] ,
713713 relevantTextDocuments : [ ] ,
714714 additionalContents : [ ] ,
@@ -1064,146 +1064,6 @@ export class ChatController {
10641064 }
10651065 }
10661066
1067- private async processToolUseMessage ( message : CustomFormActionMessage ) {
1068- const tabID = message . tabID
1069- if ( ! tabID ) {
1070- return
1071- }
1072- this . editorContextExtractor
1073- . extractContextForTrigger ( 'ChatMessage' )
1074- . then ( async ( context ) => {
1075- const triggerID = randomUUID ( )
1076- this . triggerEventsStorage . addTriggerEvent ( {
1077- id : triggerID ,
1078- tabID : message . tabID ,
1079- message : undefined ,
1080- type : 'chat_message' ,
1081- context,
1082- } )
1083- const session = this . sessionStorage . getSession ( tabID )
1084- const toolUse = session . toolUse
1085- if ( ! toolUse || ! toolUse . input ) {
1086- return
1087- }
1088- session . setToolUse ( undefined )
1089-
1090- const toolResults : ToolResult [ ] = [ ]
1091-
1092- const result = ToolUtils . tryFromToolUse ( toolUse )
1093- if ( 'type' in result ) {
1094- const tool : Tool = result
1095-
1096- try {
1097- await ToolUtils . validate ( tool )
1098-
1099- const chatStream = new ChatStream ( this . messenger , tabID , triggerID , toolUse . toolUseId )
1100- const output = await ToolUtils . invoke ( tool , chatStream )
1101-
1102- toolResults . push ( {
1103- content : [
1104- output . output . kind === OutputKind . Text
1105- ? { text : output . output . content }
1106- : { json : output . output . content } ,
1107- ] ,
1108- toolUseId : toolUse . toolUseId ,
1109- status : ToolResultStatus . SUCCESS ,
1110- } )
1111- } catch ( e : any ) {
1112- toolResults . push ( {
1113- content : [ { text : e . message } ] ,
1114- toolUseId : toolUse . toolUseId ,
1115- status : ToolResultStatus . ERROR ,
1116- } )
1117- }
1118- } else {
1119- const toolResult : ToolResult = result
1120- toolResults . push ( toolResult )
1121- }
1122-
1123- await this . generateResponse (
1124- {
1125- message : '' ,
1126- trigger : ChatTriggerType . ChatMessage ,
1127- query : undefined ,
1128- codeSelection : context ?. focusAreaContext ?. selectionInsideExtendedCodeBlock ,
1129- fileText : context ?. focusAreaContext ?. extendedCodeBlock ?? '' ,
1130- fileLanguage : context ?. activeFileContext ?. fileLanguage ,
1131- filePath : context ?. activeFileContext ?. filePath ,
1132- matchPolicy : context ?. activeFileContext ?. matchPolicy ,
1133- codeQuery : context ?. focusAreaContext ?. names ,
1134- userIntent : undefined ,
1135- customization : getSelectedCustomization ( ) ,
1136- toolResults : toolResults ,
1137- origin : Origin . IDE ,
1138- chatHistory : this . chatHistoryStorage . getHistory ( tabID ) . getHistory ( ) ,
1139- context : [ ] ,
1140- relevantTextDocuments : [ ] ,
1141- additionalContents : [ ] ,
1142- documentReferences : [ ] ,
1143- useRelevantDocuments : false ,
1144- contextLengths : {
1145- ...defaultContextLengths ,
1146- } ,
1147- } ,
1148- triggerID
1149- )
1150- } )
1151- . catch ( ( e ) => {
1152- this . processException ( e , tabID )
1153- } )
1154- }
1155-
1156- private async processPromptMessageAsNewThread ( message : PromptMessage ) {
1157- const session = this . sessionStorage . getSession ( message . tabID )
1158- session . clearListOfReadFiles ( )
1159- session . setShowDiffOnFileWrite ( false )
1160- this . editorContextExtractor
1161- . extractContextForTrigger ( 'ChatMessage' )
1162- . then ( async ( context ) => {
1163- const triggerID = randomUUID ( )
1164- this . triggerEventsStorage . addTriggerEvent ( {
1165- id : triggerID ,
1166- tabID : message . tabID ,
1167- message : message . message ,
1168- type : 'chat_message' ,
1169- context,
1170- } )
1171-
1172- // Save the context for the agentic loop
1173- session . setContext ( message . context )
1174-
1175- await this . generateResponse (
1176- {
1177- message : message . message ?? '' ,
1178- trigger : ChatTriggerType . ChatMessage ,
1179- query : message . message ,
1180- codeSelection : context ?. focusAreaContext ?. selectionInsideExtendedCodeBlock ,
1181- fileText : context ?. focusAreaContext ?. extendedCodeBlock ?? '' ,
1182- fileLanguage : context ?. activeFileContext ?. fileLanguage ,
1183- filePath : context ?. activeFileContext ?. filePath ,
1184- matchPolicy : context ?. activeFileContext ?. matchPolicy ,
1185- codeQuery : context ?. focusAreaContext ?. names ,
1186- userIntent : this . userIntentRecognizer . getFromPromptChatMessage ( message ) ,
1187- customization : getSelectedCustomization ( ) ,
1188- chatHistory : this . chatHistoryStorage . getHistory ( message . tabID ) . getHistory ( ) ,
1189- origin : Origin . IDE ,
1190- context : message . context ?? [ ] ,
1191- relevantTextDocuments : [ ] ,
1192- additionalContents : [ ] ,
1193- documentReferences : [ ] ,
1194- useRelevantDocuments : false ,
1195- contextLengths : {
1196- ...defaultContextLengths ,
1197- } ,
1198- } ,
1199- triggerID
1200- )
1201- } )
1202- . catch ( ( e ) => {
1203- this . processException ( e , message . tabID )
1204- } )
1205- }
1206-
12071067 private async generateStaticTextResponse ( responseType : StaticTextResponseType , triggerID : string ) {
12081068 // Loop while we waiting for tabID to be set
12091069 const triggerEvent = this . triggerEventsStorage . getTriggerEvent ( triggerID )
0 commit comments