@@ -77,10 +77,9 @@ import { IChatAgentService } from '../common/chatAgents.js';
77
77
import { ChatContextKeys } from '../common/chatContextKeys.js' ;
78
78
import { IChatEditingSession } from '../common/chatEditingService.js' ;
79
79
import { ChatEntitlement , IChatEntitlementService } from '../common/chatEntitlementService.js' ;
80
- import { IChatRequestVariableEntry , ChatRequestVariableSet , isPromptFileVariableEntry , isElementVariableEntry , isImageVariableEntry , isNotebookOutputVariableEntry , isPasteVariableEntry , isSCMHistoryItemVariableEntry , toPromptFileVariableEntry } from '../common/chatVariableEntries.js' ;
80
+ import { IChatRequestVariableEntry , ChatRequestVariableSet , isPromptFileVariableEntry , isElementVariableEntry , isImageVariableEntry , isNotebookOutputVariableEntry , isPasteVariableEntry , isSCMHistoryItemVariableEntry } from '../common/chatVariableEntries.js' ;
81
81
import { ChatMode2 , IChatMode , IChatModeService , isBuiltinChatMode , validateChatMode2 } from '../common/chatModes.js' ;
82
82
import { IChatFollowup } from '../common/chatService.js' ;
83
- import { IChatVariablesService } from '../common/chatVariables.js' ;
84
83
import { IChatResponseViewModel } from '../common/chatViewModel.js' ;
85
84
import { ChatInputHistoryMaxEntries , IChatHistoryEntry , IChatInputState , IChatWidgetHistoryService } from '../common/chatWidgetHistoryService.js' ;
86
85
import { ChatAgentLocation , ChatConfiguration , ChatMode , isChatMode , validateChatMode } from '../common/constants.js' ;
@@ -97,7 +96,6 @@ import { ChatEditingShowChangesAction, ViewPreviousEditsAction } from './chatEdi
97
96
import { ChatFollowups } from './chatFollowups.js' ;
98
97
import { ChatSelectedTools } from './chatSelectedTools.js' ;
99
98
import { IChatViewState } from './chatWidget.js' ;
100
- import { ChatFileReference } from './contrib/chatDynamicVariables/chatFileReference.js' ;
101
99
import { ChatImplicitContext } from './contrib/chatImplicitContext.js' ;
102
100
import { ChatRelatedFiles } from './contrib/chatInputRelatedFilesContrib.js' ;
103
101
import { resizeImage } from './imageUtils.js' ;
@@ -167,35 +165,18 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge
167
165
168
166
public async getAttachedAndImplicitContext ( sessionId : string ) : Promise < ChatRequestVariableSet > {
169
167
170
- // prompt files may have nested child references to other prompt
171
- // files that are resolved asynchronously, hence we need to wait
172
- // for the entire prompt instruction tree to be processed
173
-
174
168
const contextArr = new ChatRequestVariableSet ( ) ;
175
169
170
+ // get prompt file variables (instructions) and all rereferenced contents first
176
171
contextArr . add ( ... await this . attachmentModel . getPromptFileVariables ( ) ) ;
172
+
173
+ // then add all other attachments (includes prompt file variables, but they will be ignored if already added)
177
174
contextArr . add ( ...this . attachmentModel . attachments ) ;
178
175
179
176
if ( this . implicitContext ?. enabled && this . implicitContext . value ) {
180
177
const implicitChatVariables = await this . implicitContext . toBaseEntries ( ) ;
181
178
contextArr . add ( ...implicitChatVariables ) ;
182
179
}
183
-
184
- // factor in nested file links of a prompt into the implicit context
185
- const variables = this . variableService . getDynamicVariables ( sessionId ) ;
186
- for ( const variable of variables ) {
187
- if ( ! ( variable instanceof ChatFileReference ) ) {
188
- continue ;
189
- }
190
-
191
- // the usual URIs list of prompt instructions is `bottom-up`, therefore
192
- // we do the same here - first add all child references to the list
193
- contextArr . add (
194
- ...variable . allValidReferences . map ( ( link ) => {
195
- return toPromptFileVariableEntry ( link . uri , false ) ;
196
- } ) ,
197
- ) ;
198
- }
199
180
return contextArr ;
200
181
}
201
182
@@ -375,7 +356,6 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge
375
356
@ITextModelService private readonly textModelResolverService : ITextModelService ,
376
357
@IStorageService private readonly storageService : IStorageService ,
377
358
@ILabelService private readonly labelService : ILabelService ,
378
- @IChatVariablesService private readonly variableService : IChatVariablesService ,
379
359
@IChatAgentService private readonly agentService : IChatAgentService ,
380
360
@ISharedWebContentExtractorService private readonly sharedWebExtracterService : ISharedWebContentExtractorService ,
381
361
@IWorkbenchAssignmentService private readonly experimentService : IWorkbenchAssignmentService ,
0 commit comments