@@ -20,7 +20,7 @@ import { Progress } from 'vs/platform/progress/common/progress';
20
20
import { IStorageService , StorageScope , StorageTarget } from 'vs/platform/storage/common/storage' ;
21
21
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry' ;
22
22
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace' ;
23
- import { IChatAgentRequest , IChatAgentResult , IChatAgentService } from 'vs/workbench/contrib/chat/common/chatAgents' ;
23
+ import { IChatAgent , IChatAgentRequest , IChatAgentResult , IChatAgentService } from 'vs/workbench/contrib/chat/common/chatAgents' ;
24
24
import { CONTEXT_PROVIDER_EXISTS } from 'vs/workbench/contrib/chat/common/chatContextKeys' ;
25
25
import { ChatModel , ChatModelInitState , ChatRequestModel , ChatWelcomeMessageModel , IChatModel , IChatRequestVariableData , ISerializableChatData , ISerializableChatsData , getHistoryEntriesFromModel , updateRanges } from 'vs/workbench/contrib/chat/common/chatModel' ;
26
26
import { ChatRequestAgentPart , ChatRequestAgentSubcommandPart , ChatRequestSlashCommandPart , IParsedChatRequest , getPromptText } from 'vs/workbench/contrib/chat/common/chatParserTypes' ;
@@ -193,6 +193,12 @@ export class ChatService extends Disposable implements IChatService {
193
193
}
194
194
195
195
this . _register ( storageService . onWillSaveState ( ( ) => this . saveState ( ) ) ) ;
196
+
197
+ this . _register ( Event . debounce ( this . chatAgentService . onDidChangeAgents , ( ) => { } , 500 ) ( ( ) => {
198
+ for ( const model of this . _sessionModels . values ( ) ) {
199
+ this . warmSlashCommandCache ( model ) ;
200
+ }
201
+ } ) ) ;
196
202
}
197
203
198
204
private saveState ( ) : void {
@@ -358,9 +364,15 @@ export class ChatService extends Disposable implements IChatService {
358
364
this . initializeSession ( model , CancellationToken . None ) ;
359
365
}
360
366
367
+ private warmSlashCommandCache ( model : IChatModel , agent ?: IChatAgent ) {
368
+ const agents = agent ? [ agent ] : this . chatAgentService . getAgents ( ) ;
369
+ agents . forEach ( agent => agent . provideSlashCommands ( model , [ ] , CancellationToken . None ) ) ;
370
+ }
371
+
361
372
private async initializeSession ( model : ChatModel , token : CancellationToken ) : Promise < void > {
362
373
try {
363
374
this . trace ( 'initializeSession' , `Initialize session ${ model . sessionId } ` ) ;
375
+ this . warmSlashCommandCache ( model ) ;
364
376
model . startInitialize ( ) ;
365
377
await this . extensionService . activateByEvent ( `onInteractiveSession:${ model . providerId } ` ) ;
366
378
0 commit comments