Skip to content

Commit

Permalink
Set up maxRequests setting to be controlled by separate experiments f…
Browse files Browse the repository at this point in the history
…or free vs pro users (#239170)
  • Loading branch information
roblourens authored Jan 30, 2025
1 parent 92fb591 commit d9ea0ed
Showing 1 changed file with 24 additions and 16 deletions.
40 changes: 24 additions & 16 deletions src/vs/workbench/contrib/chat/browser/chatSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ import { IConfigurationRegistry, Extensions as ConfigurationExtensions, IConfigu
import { IQuickInputService } from '../../../../platform/quickinput/common/quickInput.js';
import { ILifecycleService } from '../../../services/lifecycle/common/lifecycle.js';
import { equalsIgnoreCase } from '../../../../base/common/strings.js';
import { IWorkbenchAssignmentService } from '../../../services/assignment/common/assignmentService.js';

const defaultChat = {
extensionId: product.defaultChatAgent?.extensionId ?? '',
Expand Down Expand Up @@ -120,6 +121,7 @@ export class ChatSetupContribution extends Disposable implements IWorkbenchContr
@IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService,
@ICommandService private readonly commandService: ICommandService,
@ITelemetryService private readonly telemetryService: ITelemetryService,
@IWorkbenchAssignmentService private readonly experimentService: IWorkbenchAssignmentService,
) {
super();

Expand Down Expand Up @@ -324,23 +326,29 @@ export class ChatSetupContribution extends Disposable implements IWorkbenchContr

let lastNode: IConfigurationNode | undefined;
const registerSetting = () => {
const node: IConfigurationNode = {
id: 'chatSidebar',
title: localize('interactiveSessionConfigurationTitle', "Chat"),
type: 'object',
properties: {
'chat.agent.maxRequests': {
type: 'number',
description: localize('chat.agent.maxRequests', "The maximum number of requests to allow Copilot Edits to use in agent mode."),
default: context.state.entitlement === ChatEntitlement.Limited ? 5 : 15,
tags: ['experimental', 'onExp']
},
}
};
configurationRegistry.updateConfigurations({ remove: lastNode ? [lastNode] : [], add: [node] });
lastNode = node;
const treatmentId = context.state.entitlement === ChatEntitlement.Limited ?
'chatAgentMaxRequestsFree' :
'chatAgentMaxRequestsPro';
this.experimentService.getTreatment<number>(treatmentId).then(value => {
const defaultValue = value ?? (context.state.entitlement === ChatEntitlement.Limited ? 5 : 15);
const node: IConfigurationNode = {
id: 'chatSidebar',
title: localize('interactiveSessionConfigurationTitle', "Chat"),
type: 'object',
properties: {
'chat.agent.maxRequests': {
type: 'number',
description: localize('chat.agent.maxRequests', "The maximum number of requests to allow Copilot Edits to use in agent mode."),
default: defaultValue,
tags: ['experimental']
},
}
};
configurationRegistry.updateConfigurations({ remove: lastNode ? [lastNode] : [], add: [node] });
lastNode = node;
});
};
this._register(Event.runAndSubscribe(context.onDidChange, () => registerSetting()));
this._register(Event.runAndSubscribe(Event.debounce(context.onDidChange, () => { }, 1000), () => registerSetting()));
}
}

Expand Down

0 comments on commit d9ea0ed

Please sign in to comment.