@@ -59,7 +59,7 @@ import { handleModeSwitch } from './actions/chatActions.js';
5959import { ChatTreeItem , IChatAcceptInputOptions , IChatAccessibilityService , IChatCodeBlockInfo , IChatFileTreeInfo , IChatListItemRendererOptions , IChatWidget , IChatWidgetService , IChatWidgetViewContext , IChatWidgetViewOptions } from './chat.js' ;
6060import { ChatAccessibilityProvider } from './chatAccessibilityProvider.js' ;
6161import { ChatAttachmentModel } from './chatAttachmentModel.js' ;
62- import { isPromptFileChatVariable , toChatVariable } from './chatAttachmentModel/chatPromptAttachmentsCollection.js' ;
62+ import { addPromptFileChatVariable , isPromptFileChatVariable } from './chatAttachmentModel/chatPromptAttachmentsCollection.js' ;
6363import { ChatInputPart , IChatInputStyles } from './chatInputPart.js' ;
6464import { ChatListDelegate , ChatListItemRenderer , IChatRendererDelegate } from './chatListRenderer.js' ;
6565import { ChatEditorOptions } from './chatOptions.js' ;
@@ -1219,12 +1219,8 @@ export class ChatWidget extends Disposable implements IChatWidget {
12191219 if ( agentSlashPromptPart ) {
12201220 metadata = await this . promptsService . resolvePromptSlashCommand ( agentSlashPromptPart . slashPromptCommand ) ;
12211221 if ( metadata ) {
1222- const uri = metadata . uri ;
1223- if ( ! requestInput . attachedContext . some ( variable => isPromptFileChatVariable ( variable ) && isEqual ( IChatRequestVariableEntry . toUri ( variable ) , uri ) ) ) {
1224- // not yet attached, so attach it
1225- const variable = toChatVariable ( { uri : metadata . uri , isPromptFile : true } , true ) ;
1226- requestInput . attachedContext . push ( variable ) ;
1227- }
1222+ // add the prompt file to the context, but not sticky
1223+ addPromptFileChatVariable ( requestInput . attachedContext , metadata . uri ) ;
12281224 // remove the slash command from the input
12291225 requestInput . input = this . parsedInput . parts . filter ( part => ! ( part instanceof ChatRequestSlashPromptPart ) ) . map ( part => part . text ) . join ( '' ) . trim ( ) ;
12301226 }
@@ -1631,11 +1627,7 @@ export class ChatWidget extends Disposable implements IChatWidget {
16311627 . findInstructionFilesFor ( variableUris ) ;
16321628
16331629 // add instructions to the final context list
1634- attachedContext . push (
1635- ...automaticInstructions . map ( ( uri ) => {
1636- return toChatVariable ( { uri, isPromptFile : true } , true ) ;
1637- } ) ,
1638- ) ;
1630+ automaticInstructions . forEach ( instruction => addPromptFileChatVariable ( attachedContext , instruction ) ) ;
16391631
16401632 // add to attached list to make the instructions sticky
16411633 this . inputPart
0 commit comments