Skip to content

Commit f94e477

Browse files
authored
Reset auto cache on auth change (#1224)
1 parent 742c75e commit f94e477

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/platform/endpoint/common/automodeService.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { RequestType } from '@vscode/copilot-api';
77
import type { ChatRequest } from 'vscode';
88
import { createServiceIdentifier } from '../../../util/common/services';
99
import { TaskSingler } from '../../../util/common/taskSingler';
10+
import { Disposable } from '../../../util/vs/base/common/lifecycle';
1011
import { IAuthenticationService } from '../../authentication/common/authentication';
1112
import { IChatMLFetcher } from '../../chat/common/chatMLFetcher';
1213
import { ILogService } from '../../log/common/logService';
@@ -30,7 +31,7 @@ export interface IAutomodeService {
3031
resolveAutoModeEndpoint(chatRequest: ChatRequest | undefined, knownEndpoints: IChatEndpoint[]): Promise<IChatEndpoint>;
3132
}
3233

33-
export class AutomodeService implements IAutomodeService {
34+
export class AutomodeService extends Disposable implements IAutomodeService {
3435
readonly _serviceBrand: undefined;
3536
private readonly _autoModelCache: Map<string, { endpoint: IChatEndpoint; expiration: number; autoModeToken: string; lastRequestId?: string }> = new Map();
3637
private readonly _taskSingler = new TaskSingler<IChatEndpoint>();
@@ -42,6 +43,10 @@ export class AutomodeService implements IAutomodeService {
4243
@ILogService private readonly _logService: ILogService,
4344
@IChatMLFetcher private readonly _chatMLFetcher: IChatMLFetcher,
4445
) {
46+
super();
47+
this._register(this._authService.onDidAuthenticationChange(() => {
48+
this._autoModelCache.clear();
49+
}));
4550
this._serviceBrand = undefined;
4651
}
4752

0 commit comments

Comments
 (0)