mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-21 23:59:34 +01:00
chat - fix perf regression in contributions (#242021)
This commit is contained in:
@@ -497,5 +497,4 @@ registerSingleton(IChatMarkdownAnchorService, ChatMarkdownAnchorService, Instant
|
||||
registerSingleton(ILanguageModelIgnoredFilesService, LanguageModelIgnoredFilesService, InstantiationType.Delayed);
|
||||
registerSingleton(IChatQuotasService, ChatQuotasService, InstantiationType.Delayed);
|
||||
registerSingleton(IChatEntitlementsService, ChatEntitlementsService, InstantiationType.Delayed);
|
||||
|
||||
registerSingleton(IPromptsService, PromptsService, InstantiationType.Delayed);
|
||||
|
||||
@@ -99,8 +99,8 @@ export class ChatEntitlementsService extends Disposable implements IChatEntitlem
|
||||
|
||||
declare _serviceBrand: undefined;
|
||||
|
||||
readonly context: ChatSetupContext | undefined;
|
||||
readonly requests: ChatSetupRequests | undefined;
|
||||
readonly context: Lazy<ChatSetupContext> | undefined;
|
||||
readonly requests: Lazy<ChatSetupRequests> | undefined;
|
||||
|
||||
constructor(
|
||||
@IInstantiationService instantiationService: IInstantiationService,
|
||||
@@ -116,12 +116,12 @@ export class ChatEntitlementsService extends Disposable implements IChatEntitlem
|
||||
return;
|
||||
}
|
||||
|
||||
this.context = this._register(instantiationService.createInstance(ChatSetupContext));
|
||||
this.requests = this._register(instantiationService.createInstance(ChatSetupRequests, this.context));
|
||||
const context = this.context = new Lazy(() => this._register(instantiationService.createInstance(ChatSetupContext)));
|
||||
this.requests = new Lazy(() => this._register(instantiationService.createInstance(ChatSetupRequests, context.value)));
|
||||
}
|
||||
|
||||
async resolve(token: CancellationToken): Promise<IChatEntitlements | undefined> {
|
||||
return this.requests?.forceResolveEntitlement(undefined, token);
|
||||
return this.requests?.value.forceResolveEntitlement(undefined, token);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,8 +143,8 @@ export class ChatSetupContribution extends Disposable implements IWorkbenchContr
|
||||
) {
|
||||
super();
|
||||
|
||||
const context = chatEntitlementsService.context;
|
||||
const requests = chatEntitlementsService.requests;
|
||||
const context = chatEntitlementsService.context?.value;
|
||||
const requests = chatEntitlementsService.requests?.value;
|
||||
if (!context || !requests) {
|
||||
return; // disabled
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import { Checkbox } from '../../../../base/browser/ui/toggle/toggle.js';
|
||||
import { IConfigurationService } from '../../../../platform/configuration/common/configuration.js';
|
||||
import { Command } from '../../../../editor/common/languages.js';
|
||||
import { ICommandService } from '../../../../platform/commands/common/commands.js';
|
||||
import { Lazy } from '../../../../base/common/lazy.js';
|
||||
|
||||
export class ChatStatusBarEntry extends Disposable implements IWorkbenchContribution {
|
||||
|
||||
@@ -32,7 +33,7 @@ export class ChatStatusBarEntry extends Disposable implements IWorkbenchContribu
|
||||
private entry: IStatusbarEntryAccessor | undefined = undefined;
|
||||
private readonly entryDisposables = this._register(new MutableDisposable());
|
||||
|
||||
private dateFormatter = safeIntl.DateTimeFormat(language, { year: 'numeric', month: 'long', day: 'numeric' });
|
||||
private dateFormatter = new Lazy(() => safeIntl.DateTimeFormat(language, { year: 'numeric', month: 'long', day: 'numeric' }));
|
||||
|
||||
constructor(
|
||||
@IStatusbarService private readonly statusbarService: IStatusbarService,
|
||||
@@ -147,7 +148,7 @@ export class ChatStatusBarEntry extends Disposable implements IWorkbenchContribu
|
||||
completionsQuotaIndicator(completionsTotal, completionsRemaining);
|
||||
});
|
||||
|
||||
container.appendChild($('div', undefined, localize('limitQuota', "Limits will reset on {0}.", this.dateFormatter.format(quotaResetDate))));
|
||||
container.appendChild($('div', undefined, localize('limitQuota', "Limits will reset on {0}.", this.dateFormatter.value.format(quotaResetDate))));
|
||||
|
||||
// Settings
|
||||
container.appendChild($('hr'));
|
||||
|
||||
Reference in New Issue
Block a user