@@ -59,7 +59,7 @@ import { handleModeSwitch } from './actions/chatActions.js';
59
59
import { ChatTreeItem , IChatAcceptInputOptions , IChatAccessibilityService , IChatCodeBlockInfo , IChatFileTreeInfo , IChatListItemRendererOptions , IChatWidget , IChatWidgetService , IChatWidgetViewContext , IChatWidgetViewOptions } from './chat.js' ;
60
60
import { ChatAccessibilityProvider } from './chatAccessibilityProvider.js' ;
61
61
import { ChatAttachmentModel } from './chatAttachmentModel.js' ;
62
- import { isPromptFileChatVariable , toChatVariable } from './chatAttachmentModel/chatPromptAttachmentsCollection.js' ;
62
+ import { addPromptFileChatVariable , isPromptFileChatVariable } from './chatAttachmentModel/chatPromptAttachmentsCollection.js' ;
63
63
import { ChatInputPart , IChatInputStyles } from './chatInputPart.js' ;
64
64
import { ChatListDelegate , ChatListItemRenderer , IChatRendererDelegate } from './chatListRenderer.js' ;
65
65
import { ChatEditorOptions } from './chatOptions.js' ;
@@ -1219,12 +1219,8 @@ export class ChatWidget extends Disposable implements IChatWidget {
1219
1219
if ( agentSlashPromptPart ) {
1220
1220
metadata = await this . promptsService . resolvePromptSlashCommand ( agentSlashPromptPart . slashPromptCommand ) ;
1221
1221
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 ) ;
1228
1224
// remove the slash command from the input
1229
1225
requestInput . input = this . parsedInput . parts . filter ( part => ! ( part instanceof ChatRequestSlashPromptPart ) ) . map ( part => part . text ) . join ( '' ) . trim ( ) ;
1230
1226
}
@@ -1631,11 +1627,7 @@ export class ChatWidget extends Disposable implements IChatWidget {
1631
1627
. findInstructionFilesFor ( variableUris ) ;
1632
1628
1633
1629
// 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 ) ) ;
1639
1631
1640
1632
// add to attached list to make the instructions sticky
1641
1633
this . inputPart
0 commit comments