3419
3420
constructor(
3422
>
userHome: URI,
3423
>
private readonly _getClient: () => Promise<CopilotClient>,
3424
>
private readonly _onDidRefresh: () => void,
3425
>
@IFileService private readonly _fileService: IFileService,
3426
>
@IAgentConfigurationService private readonly _configurationService: IAgentConfigurationService,
3427
>
@ILogService private readonly _logService: ILogService,
3428
>
@IInstantiationService instantiationService: IInstantiationService,
3429
>
) {
3430
>
super();
3431
>
this._discovery = this._register(instantiationService.createInstance(SessionCustomizationDiscovery, workingDirectory, userHome, URI.file));
3432
>
this._settled = this._queueRefresh(false, 0);
3433
>
this._register(this._discovery.onDidChange(() => {
3434
this._settled = this._queueRefresh(true);
3436
>
this._register(this._configurationService.onDidRootConfigChange(() => {
3437
this._settled = this._queueRefresh(true);
3439
>
}
3440
3441
override dispose(): void {
3443
>
this._refreshPromise = null;
3444
>
super.dispose();
3445
>
}
3446
3447
whenSettled(): Promise<void> {
3449
>
}
3450
3451
currentCustomizations(): readonly DirectoryCustomization[] {
3453
>
}
3454
3455
private _queueRefresh(notify: boolean, delay = REFRESH_DEBOUNCE_MS): Promise<void> {
3457
>
this._refreshPromise = null;
3458
>
this._pendingRefreshNotify = this._pendingRefreshNotify || notify;
3459
>
3460
>
return this._refreshDelayer.trigger(() => {
3461
>
const shouldNotify = this._pendingRefreshNotify;
3462
>
this._pendingRefreshNotify = false;
3463
>
const refreshPromise = this._refreshPromise = createCancelablePromise(async token => {
3464
>
const didRefresh = await this._refresh(token);
3465
>
if (didRefresh && shouldNotify) {
3466
this._onDidRefresh();
3467
}
3469
>
3470
>
return refreshPromise.then(() => {
3471
>
if (this._refreshPromise === refreshPromise) {
3472
>
this._refreshPromise = null;
3473
>
}
3474
>
}, err => {
3475
if (this._refreshPromise === refreshPromise) {
3476
this._refreshPromise = null;