@@ -7,6 +7,7 @@ import { RequestType } from '@vscode/copilot-api';
7
7
import type { ChatRequest } from 'vscode' ;
8
8
import { createServiceIdentifier } from '../../../util/common/services' ;
9
9
import { TaskSingler } from '../../../util/common/taskSingler' ;
10
+ import { Disposable } from '../../../util/vs/base/common/lifecycle' ;
10
11
import { IAuthenticationService } from '../../authentication/common/authentication' ;
11
12
import { IChatMLFetcher } from '../../chat/common/chatMLFetcher' ;
12
13
import { ILogService } from '../../log/common/logService' ;
@@ -30,7 +31,7 @@ export interface IAutomodeService {
30
31
resolveAutoModeEndpoint ( chatRequest : ChatRequest | undefined , knownEndpoints : IChatEndpoint [ ] ) : Promise < IChatEndpoint > ;
31
32
}
32
33
33
- export class AutomodeService implements IAutomodeService {
34
+ export class AutomodeService extends Disposable implements IAutomodeService {
34
35
readonly _serviceBrand : undefined ;
35
36
private readonly _autoModelCache : Map < string , { endpoint : IChatEndpoint ; expiration : number ; autoModeToken : string ; lastRequestId ?: string } > = new Map ( ) ;
36
37
private readonly _taskSingler = new TaskSingler < IChatEndpoint > ( ) ;
@@ -42,6 +43,10 @@ export class AutomodeService implements IAutomodeService {
42
43
@ILogService private readonly _logService : ILogService ,
43
44
@IChatMLFetcher private readonly _chatMLFetcher : IChatMLFetcher ,
44
45
) {
46
+ super ( ) ;
47
+ this . _register ( this . _authService . onDidAuthenticationChange ( ( ) => {
48
+ this . _autoModelCache . clear ( ) ;
49
+ } ) ) ;
45
50
this . _serviceBrand = undefined ;
46
51
}
47
52
0 commit comments