Skip to content

Commit dc09970

Browse files
OrKoNDevtools-frontend LUCI CQ
authored andcommitted
[AI Assistance] Configure userTier
Bug: 393064551 Change-Id: Ic0da9c66c80a4a87f9f49efd25055b4622e0270b Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6349178 Auto-Submit: Alex Rudenko <[email protected]> Reviewed-by: Nikolay Vitkov <[email protected]> Commit-Queue: Nikolay Vitkov <[email protected]>
1 parent e7bd28d commit dc09970

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

front_end/panels/ai_assistance/agents/PatchAgent.test.ts

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5+
import * as Host from '../../../core/host/host.js';
56
import * as Platform from '../../../core/platform/platform.js';
67
import {mockAidaClient, type MockAidaResponse} from '../../../testing/AiAssistanceHelpers.js';
7-
import {describeWithEnvironment} from '../../../testing/EnvironmentHelpers.js';
8+
import {describeWithEnvironment, updateHostConfig} from '../../../testing/EnvironmentHelpers.js';
89
import {createFileSystemUISourceCode} from '../../../testing/UISourceCodeHelpers.js';
910
import {type ActionResponse, FileUpdateAgent, PatchAgent, type ResponseData, ResponseType} from '../ai_assistance.js';
1011

@@ -99,4 +100,29 @@ describeWithEnvironment('PatchAgent', () => {
99100
action,
100101
{type: 'action' as ActionResponse['type'], output: '{"success":true}', code: undefined, canceled: false});
101102
});
103+
104+
it('builds a request with a user tier', async () => {
105+
updateHostConfig({
106+
devToolsFreestyler: {
107+
userTier: 'PUBLIC',
108+
},
109+
});
110+
const {project} = createFileSystemUISourceCode({
111+
url: Platform.DevToolsPath.urlString`file:///path/to/overrides/example.html`,
112+
fileSystemPath: Platform.DevToolsPath.urlString`file:///path/to/overrides`,
113+
mimeType: 'text/html',
114+
content: 'content',
115+
});
116+
const agent = new PatchAgent({
117+
aidaClient: mockAidaClient(),
118+
project,
119+
fileUpdateAgent: new FileUpdateAgent({
120+
aidaClient: mockAidaClient(),
121+
})
122+
});
123+
assert.strictEqual(
124+
agent.buildRequest({text: 'test input'}, Host.AidaClient.Role.USER).metadata?.user_tier,
125+
3,
126+
);
127+
});
102128
});

front_end/panels/ai_assistance/agents/PatchAgent.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// found in the LICENSE file.
44

55
import * as Host from '../../../core/host/host.js';
6+
import * as Root from '../../../core/root/root.js';
67
import type * as Workspace from '../../../models/workspace/workspace.js';
78
import {AgentProject} from '../AgentProject.js';
89
import {debugLog} from '../debug.js';
@@ -46,7 +47,7 @@ export class PatchAgent extends AiAgent<Workspace.Workspace.Project> {
4647
readonly clientFeature = Host.AidaClient.ClientFeature.CHROME_PATCH_AGENT;
4748

4849
get userTier(): string|undefined {
49-
return 'TESTERS';
50+
return Root.Runtime.hostConfig.devToolsFreestyler?.userTier;
5051
}
5152

5253
get options(): RequestOptions {
@@ -222,7 +223,7 @@ export class FileUpdateAgent extends AiAgent<Workspace.Workspace.Project> {
222223
readonly clientFeature = Host.AidaClient.ClientFeature.CHROME_PATCH_AGENT;
223224

224225
get userTier(): string|undefined {
225-
return 'TESTERS';
226+
return Root.Runtime.hostConfig.devToolsFreestyler?.userTier;
226227
}
227228

228229
get options(): RequestOptions {

0 commit comments

Comments
 (0)