File tree Expand file tree Collapse file tree 3 files changed +9
-5
lines changed
src/vs/workbench/contrib/chat/browser Expand file tree Collapse file tree 3 files changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -348,18 +348,20 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge
348
348
}
349
349
350
350
attachContext ( overwrite : boolean , ...contentReferences : IChatRequestVariableEntry [ ] ) : void {
351
- const removed = Array . from ( this . _attachedContext ) ;
351
+ const removed = [ ] ;
352
352
if ( overwrite ) {
353
+ removed . push ( ...Array . from ( this . _attachedContext ) ) ;
353
354
this . _attachedContext . clear ( ) ;
354
355
}
355
356
356
357
if ( contentReferences . length > 0 ) {
357
358
for ( const reference of contentReferences ) {
358
359
this . _attachedContext . add ( reference ) ;
359
360
}
360
- this . initAttachedContext ( this . attachedContextContainer ) ;
361
361
}
362
+
362
363
if ( removed . length > 0 || contentReferences . length > 0 ) {
364
+ this . initAttachedContext ( this . attachedContextContainer ) ;
363
365
this . _onDidChangeContext . fire ( { removed, added : contentReferences } ) ;
364
366
}
365
367
}
Original file line number Diff line number Diff line change @@ -786,10 +786,10 @@ export class ChatWidget extends Disposable implements IChatWidget {
786
786
} ) ;
787
787
788
788
if ( result ) {
789
- this . inputPart . clearContext ( ) ;
790
789
this . inputPart . acceptInput ( isUserQuery ) ;
791
790
this . _onDidSubmitAgent . fire ( { agent : result . agent , slashCommand : result . slashCommand } ) ;
792
791
this . inputPart . updateState ( this . collectInputState ( ) ) ;
792
+ this . inputPart . clearContext ( ) ;
793
793
result . responseCompletePromise . then ( ( ) => {
794
794
const responses = this . viewModel ?. getItems ( ) . filter ( isResponseVM ) ;
795
795
const lastResponse = responses ?. [ responses . length - 1 ] ;
Original file line number Diff line number Diff line change @@ -70,8 +70,10 @@ export class ChatContextAttachments extends Disposable implements IChatWidgetCon
70
70
}
71
71
72
72
private _removeContext ( attachments : IChatRequestVariableEntry [ ] ) {
73
- attachments . forEach ( this . _attachedContext . delete , this . _attachedContext ) ;
74
- this . _onDidChangeInputState . fire ( ) ;
73
+ if ( attachments . length ) {
74
+ attachments . forEach ( this . _attachedContext . delete , this . _attachedContext ) ;
75
+ this . _onDidChangeInputState . fire ( ) ;
76
+ }
75
77
}
76
78
77
79
private _clearAttachedContext ( ) {
You can’t perform that action at this time.
0 commit comments