File tree Expand file tree Collapse file tree 4 files changed +28
-1
lines changed
src/vs/workbench/contrib/chat Expand file tree Collapse file tree 4 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -139,6 +139,7 @@ export interface IChatWidget {
139
139
readonly onDidAcceptInput : Event < void > ;
140
140
readonly onDidHide : Event < void > ;
141
141
readonly onDidSubmitAgent : Event < { agent : IChatAgentData ; slashCommand ?: IChatAgentCommand } > ;
142
+ readonly onDidChangeAgent : Event < { agent : IChatAgentData ; slashCommand ?: IChatAgentCommand } > ;
142
143
readonly onDidChangeParsedInput : Event < void > ;
143
144
readonly onDidChangeContext : Event < { removed ?: IChatRequestVariableEntry [ ] ; added ?: IChatRequestVariableEntry [ ] } > ;
144
145
readonly location : ChatAgentLocation ;
Original file line number Diff line number Diff line change @@ -88,6 +88,9 @@ export class ChatWidget extends Disposable implements IChatWidget {
88
88
private readonly _onDidSubmitAgent = this . _register ( new Emitter < { agent : IChatAgentData ; slashCommand ?: IChatAgentCommand } > ( ) ) ;
89
89
public readonly onDidSubmitAgent = this . _onDidSubmitAgent . event ;
90
90
91
+ private _onDidChangeAgent = this . _register ( new Emitter < { agent : IChatAgentData ; slashCommand ?: IChatAgentCommand } > ( ) ) ;
92
+ readonly onDidChangeAgent = this . _onDidChangeAgent . event ;
93
+
91
94
private _onDidFocus = this . _register ( new Emitter < void > ( ) ) ;
92
95
readonly onDidFocus = this . _onDidFocus . event ;
93
96
@@ -688,6 +691,11 @@ export class ChatWidget extends Disposable implements IChatWidget {
688
691
c . setInputState ( viewState . inputState ?. [ c . id ] ) ;
689
692
}
690
693
} ) ;
694
+ this . viewModelDisposables . add ( model . onDidChange ( ( e ) => {
695
+ if ( e . kind === 'setAgent' ) {
696
+ this . _onDidChangeAgent . fire ( { agent : e . agent , slashCommand : e . command } ) ;
697
+ }
698
+ } ) ) ;
691
699
692
700
if ( this . tree ) {
693
701
this . onDidChangeItems ( ) ;
Original file line number Diff line number Diff line change @@ -242,12 +242,22 @@ class InputEditorSlashCommandMode extends Disposable {
242
242
private readonly widget : IChatWidget
243
243
) {
244
244
super ( ) ;
245
+ this . _register ( this . widget . onDidChangeAgent ( e => {
246
+ if ( e . slashCommand && e . slashCommand . isSticky || ! e . slashCommand && e . agent . metadata . isSticky ) {
247
+ this . repopulateAgentCommand ( e . agent , e . slashCommand ) ;
248
+ }
249
+ } ) ) ;
245
250
this . _register ( this . widget . onDidSubmitAgent ( e => {
246
251
this . repopulateAgentCommand ( e . agent , e . slashCommand ) ;
247
252
} ) ) ;
248
253
}
249
254
250
255
private async repopulateAgentCommand ( agent : IChatAgentData , slashCommand : IChatAgentCommand | undefined ) {
256
+ // Make sure we don't repopulate if the user already has something in the input
257
+ if ( this . widget . inputEditor . getValue ( ) . trim ( ) ) {
258
+ return ;
259
+ }
260
+
251
261
let value : string | undefined ;
252
262
if ( slashCommand && slashCommand . isSticky ) {
253
263
value = `${ chatAgentLeader } ${ agent . name } ${ chatSubcommandLeader } ${ slashCommand . name } ` ;
Original file line number Diff line number Diff line change @@ -545,7 +545,8 @@ export function isSerializableSessionData(obj: unknown): obj is ISerializableCha
545
545
export type IChatChangeEvent =
546
546
| IChatInitEvent
547
547
| IChatAddRequestEvent | IChatChangedRequestEvent | IChatRemoveRequestEvent
548
- | IChatAddResponseEvent ;
548
+ | IChatAddResponseEvent
549
+ | IChatSetAgentEvent ;
549
550
550
551
export interface IChatAddRequestEvent {
551
552
kind : 'addRequest' ;
@@ -586,6 +587,12 @@ export interface IChatRemoveRequestEvent {
586
587
reason : ChatRequestRemovalReason ;
587
588
}
588
589
590
+ export interface IChatSetAgentEvent {
591
+ kind : 'setAgent' ;
592
+ agent : IChatAgentData ;
593
+ command ?: IChatAgentCommand ;
594
+ }
595
+
589
596
export interface IChatInitEvent {
590
597
kind : 'initialize' ;
591
598
}
@@ -892,6 +899,7 @@ export class ChatModel extends Disposable implements IChatModel {
892
899
const agent = this . chatAgentService . getAgent ( progress . agentId ) ;
893
900
if ( agent ) {
894
901
request . response . setAgent ( agent , progress . command ) ;
902
+ this . _onDidChange . fire ( { kind : 'setAgent' , agent, command : progress . command } ) ;
895
903
}
896
904
} else {
897
905
this . logService . error ( `Couldn't handle progress: ${ JSON . stringify ( progress ) } ` ) ;
You can’t perform that action at this time.
0 commit comments