Skip to content

Commit 8482530

Browse files
Samiya CaurDevtools-frontend LUCI CQ
authored andcommitted
Update settings tab to include Code suggestions
Add icon for text-analysis Bug: 425865106 Change-Id: I73f00471807e040b50c59d76275bce8457b04a37 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6786612 Reviewed-by: Ergün Erdoğmuş <[email protected]> Auto-Submit: Samiya Caur <[email protected]> Commit-Queue: Samiya Caur <[email protected]>
1 parent f897a19 commit 8482530

File tree

6 files changed

+78
-10
lines changed

6 files changed

+78
-10
lines changed

config/gni/devtools_grd_files.gni

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ grd_files_bundled_sources = [
278278
"front_end/Images/sync.svg",
279279
"front_end/Images/table.svg",
280280
"front_end/Images/terminal.svg",
281+
"front_end/Images/text-analysis.svg",
281282
"front_end/Images/thumb-down-filled.svg",
282283
"front_end/Images/thumb-down.svg",
283284
"front_end/Images/thumb-up-filled.svg",

config/gni/devtools_image_files.gni

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ devtools_svg_sources = [
276276
"sync.svg",
277277
"table.svg",
278278
"terminal.svg",
279+
"text-analysis.svg",
279280
"thumb-down-filled.svg",
280281
"thumb-down.svg",
281282
"thumb-up-filled.svg",
Lines changed: 3 additions & 0 deletions
Loading

front_end/panels/settings/AISettingsTab.test.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ describeWithEnvironment('AISettingsTab', () => {
2727
updateHostConfig({
2828
devToolsAiGeneratedTimelineLabels: {
2929
enabled: true,
30+
},
31+
devToolsAiCodeCompletion: {
32+
enabled: true,
3033
}
3134
});
3235
});
@@ -59,28 +62,30 @@ describeWithEnvironment('AISettingsTab', () => {
5962
Common.Settings.moduleSetting('console-insights-enabled').set(false);
6063
Common.Settings.moduleSetting('ai-assistance-enabled').set(true);
6164
Common.Settings.moduleSetting('ai-annotations-enabled').set(true);
65+
Common.Settings.moduleSetting('ai-code-completion-fre-completed').set(false);
6266

6367
view = new Settings.AISettingsTab.AISettingsTab();
6468
renderElementIntoDOM(view);
6569
await view.render();
6670
assert.isNotNull(view.shadowRoot);
6771

6872
const switches = Array.from(view.shadowRoot.querySelectorAll('devtools-switch'));
69-
assert.lengthOf(switches, 3);
73+
assert.lengthOf(switches, 4);
7074
const details = Array.from(view.shadowRoot.querySelectorAll('.whole-row'));
71-
assert.lengthOf(details, 3);
75+
assert.lengthOf(details, 4);
7276
const dropdownButtons = Array.from(view.shadowRoot.querySelectorAll('.dropdown devtools-button')) as HTMLElement[];
73-
assert.lengthOf(dropdownButtons, 3);
77+
assert.lengthOf(dropdownButtons, 4);
7478
const toggleContainers =
7579
Array.from(view.shadowRoot.querySelectorAll('.toggle-container')) as Switch.Switch.Switch[];
76-
assert.lengthOf(toggleContainers, 3);
80+
assert.lengthOf(toggleContainers, 4);
7781
return {switches, details, dropdownButtons, toggleContainers, view};
7882
}
7983

8084
it('renders', async () => {
8185
Common.Settings.moduleSetting('console-insights-enabled').set(true);
8286
Common.Settings.moduleSetting('ai-assistance-enabled').set(true);
8387
Common.Settings.moduleSetting('ai-annotations-enabled').set(true);
88+
Common.Settings.moduleSetting('ai-code-completion-fre-completed').set(true);
8489

8590
view = new Settings.AISettingsTab.AISettingsTab();
8691
renderElementIntoDOM(view);
@@ -98,18 +103,20 @@ describeWithEnvironment('AISettingsTab', () => {
98103

99104
const settingCards = view.shadowRoot.querySelectorAll('.setting-card h2');
100105
const settingNames = Array.from(settingCards).map(element => element.textContent);
101-
assert.deepEqual(settingNames, ['Console Insights', 'AI assistance', 'Auto annotations']);
106+
assert.deepEqual(settingNames, ['Console Insights', 'AI assistance', 'Auto annotations', 'Code suggestions']);
102107

103108
const settingCardDesc = view.shadowRoot.querySelectorAll('.setting-description');
104109
assert.strictEqual(settingCardDesc[0].textContent, 'Helps you understand and fix console warnings and errors');
105110
assert.strictEqual(settingCardDesc[1].textContent, 'Get help with understanding CSS styles');
106111
assert.strictEqual(settingCardDesc[2].textContent, 'Get AI suggestions for performance panel annotations');
112+
assert.strictEqual(settingCardDesc[3].textContent, 'Get help completing your code');
107113
});
108114

109115
it('renders different dislaimers for managed users which have logging disabled', async () => {
110116
Common.Settings.moduleSetting('console-insights-enabled').set(true);
111117
Common.Settings.moduleSetting('ai-assistance-enabled').set(true);
112118
Common.Settings.moduleSetting('ai-annotations-enabled').set(true);
119+
Common.Settings.moduleSetting('ai-code-completion-fre-completed').set(true);
113120
updateHostConfig({
114121
aidaAvailability: {
115122
enabled: true,
@@ -208,6 +215,8 @@ describeWithEnvironment('AISettingsTab', () => {
208215
assert.strictEqual(toggleContainers[1].title, underAgeExplainer);
209216
assert.isTrue(switches[2].disabled);
210217
assert.strictEqual(toggleContainers[2].title, underAgeExplainer);
218+
assert.isTrue(switches[3].disabled);
219+
assert.strictEqual(toggleContainers[3].title, underAgeExplainer);
211220

212221
aidaAccessStub.restore();
213222
});
@@ -226,6 +235,8 @@ describeWithEnvironment('AISettingsTab', () => {
226235
assert.strictEqual(toggleContainers[1].title, notLoggedInExplainer);
227236
assert.isTrue(switches[2].disabled);
228237
assert.strictEqual(toggleContainers[2].title, notLoggedInExplainer);
238+
assert.isTrue(switches[3].disabled);
239+
assert.strictEqual(toggleContainers[3].title, notLoggedInExplainer);
229240

230241
aidaAccessStub.returns(Promise.resolve(Host.AidaClient.AidaAccessPreconditions.AVAILABLE));
231242
Host.AidaClient.HostConfigTracker.instance().dispatchEventToListeners(
@@ -235,6 +246,7 @@ describeWithEnvironment('AISettingsTab', () => {
235246
assert.isFalse(switches[0].disabled);
236247
assert.isFalse(switches[1].disabled);
237248
assert.isFalse(switches[2].disabled);
249+
assert.isFalse(switches[3].disabled);
238250
aidaAccessStub.restore();
239251
});
240252

front_end/panels/settings/AISettingsTab.ts

Lines changed: 53 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ const UIStrings = {
4646
*/
4747
sendsDataToGoogleNoLogging:
4848
'Your content will not be used by human reviewers to improve AI. Your organization may change these settings at any time.',
49-
5049
/**
5150
*@description Text describing a fact to consider when using AI features
5251
*/
@@ -61,7 +60,7 @@ const UIStrings = {
6160
*/
6261
helpUnderstandConsole: 'Helps you understand and fix console warnings and errors',
6362
/**
64-
*@description Text describing the 'Console Insights' feature
63+
*@description Text describing the 'Auto Annotations' feature
6564
*/
6665
getAIAnnotationsSuggestions: 'Get AI suggestions for performance panel annotations',
6766
/**
@@ -117,6 +116,10 @@ const UIStrings = {
117116
*/
118117
helpUnderstandStylingNetworkPerformanceAndFile:
119118
'Get help with understanding CSS styles, network requests, performance, and files',
119+
/**
120+
*@description Text describing the 'Code suggestions' feature
121+
*/
122+
helpUnderstandCodeSuggestions: 'Get help completing your code',
120123
/**
121124
*@description Text which is a hyperlink to more documentation
122125
*/
@@ -162,6 +165,21 @@ const UIStrings = {
162165
*/
163166
generatedAiAnnotationsSendDataNoLogging:
164167
'Your performance trace is sent to Google to generate an explanation. This data will not be used to improve Google’s AI models.',
168+
/**
169+
*@description Description of the 'Code suggestions' feature
170+
*/
171+
asYouTypeCodeSuggestions:
172+
'As you type in the Console or Sources panel, you’ll get code suggestions. Press Tab to accept one.',
173+
/**
174+
*@description Explainer for which data is being sent for the 'Code suggestions' feature
175+
*/
176+
codeSuggestionsSendData:
177+
'To generate code suggestions, your console input, the history of your current console session, and the contents of the currently open file are shared with Google. This data may be seen by human reviewers to improve this feature.',
178+
/**
179+
*@description Explainer for which data is being sent for the 'Code suggestions' feature when logging is not enabled
180+
*/
181+
codeSuggestionsSendDataNoLogging:
182+
'To generate code suggestions, your console input, the history of your current console session, and the contents of the currently open file are shared with Google. This data will not be used to improve Google’s AI models.',
165183
/**
166184
*@description Label for a link to the terms of service
167185
*/
@@ -210,6 +228,7 @@ export class AISettingsTab extends LegacyWrapper.LegacyWrapper.WrappableComponen
210228
#consoleInsightsSetting?: Common.Settings.Setting<boolean>;
211229
#aiAnnotationsSetting?: Common.Settings.Setting<boolean>;
212230
#aiAssistanceSetting?: Common.Settings.Setting<boolean>;
231+
#aiCodeCompletionSetting?: Common.Settings.Setting<boolean>;
213232
#aidaAvailability = Host.AidaClient.AidaAccessPreconditions.NO_ACCOUNT_EMAIL;
214233
#boundOnAidaAvailabilityChange: () => Promise<void>;
215234
// Setting to parameters needed to display it in the UI.
@@ -234,6 +253,12 @@ export class AISettingsTab extends LegacyWrapper.LegacyWrapper.WrappableComponen
234253
this.#aiAnnotationsSetting = Common.Settings.Settings.instance().createSetting('ai-annotations-enabled', false);
235254
}
236255

256+
if (Root.Runtime.hostConfig.devToolsAiCodeCompletion?.enabled) {
257+
// Get an existing setting or, if it does not exist, create a new one.
258+
this.#aiCodeCompletionSetting =
259+
Common.Settings.Settings.instance().createSetting('ai-code-completion-fre-completed', false);
260+
}
261+
237262
this.#boundOnAidaAvailabilityChange = this.#onAidaAvailabilityChange.bind(this);
238263
this.#initSettings();
239264
}
@@ -306,7 +331,7 @@ export class AISettingsTab extends LegacyWrapper.LegacyWrapper.WrappableComponen
306331
}
307332

308333
if (this.#aiAnnotationsSetting) {
309-
const aiAssistanceData: AiSettingParams = {
334+
const aiAnnotationsData: AiSettingParams = {
310335
settingName: i18n.i18n.lockedString('Auto annotations'),
311336
iconName: 'pen-spark',
312337
settingDescription: i18nString(UIStrings.getAIAnnotationsSuggestions),
@@ -325,11 +350,34 @@ export class AISettingsTab extends LegacyWrapper.LegacyWrapper.WrappableComponen
325350
},
326351
settingExpandState: {
327352
isSettingExpanded: false,
328-
expandSettingJSLogContext: 'freestyler.accordion',
353+
expandSettingJSLogContext: 'auto-annotations.accordion',
354+
},
355+
};
356+
357+
this.#settingToParams.set(this.#aiAnnotationsSetting, aiAnnotationsData);
358+
}
359+
360+
if (this.#aiCodeCompletionSetting) {
361+
const aiCodeCompletionData: AiSettingParams = {
362+
settingName: i18n.i18n.lockedString('Code suggestions'),
363+
iconName: 'text-analysis',
364+
settingDescription: i18nString(UIStrings.helpUnderstandCodeSuggestions),
365+
enableSettingText: i18nString(UIStrings.enableAiSuggestedAnnotations),
366+
settingItems: [{iconName: 'code', text: i18nString(UIStrings.asYouTypeCodeSuggestions)}],
367+
toConsiderSettingItems: [{
368+
iconName: 'google',
369+
text: noLogging ? i18nString(UIStrings.codeSuggestionsSendDataNoLogging) :
370+
i18nString(UIStrings.codeSuggestionsSendData)
371+
}],
372+
// TODO: Add a relevant link
373+
learnMoreLink: {url: '', linkJSLogContext: 'learn-more.code-completion'},
374+
settingExpandState: {
375+
isSettingExpanded: false,
376+
expandSettingJSLogContext: 'code-completion.accordion',
329377
},
330378
};
331379

332-
this.#settingToParams.set(this.#aiAnnotationsSetting, aiAssistanceData);
380+
this.#settingToParams.set(this.#aiCodeCompletionSetting, aiCodeCompletionData);
333381
}
334382
}
335383

front_end/testing/EnvironmentHelpers.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,9 @@ export async function initializeGlobalVars({reset = true} = {}) {
299299
createSettingValue(
300300
Common.Settings.SettingCategory.AI, 'ai-assistance-patching-fre-completed', false,
301301
Common.Settings.SettingType.BOOLEAN),
302+
createSettingValue(
303+
Common.Settings.SettingCategory.AI, 'ai-code-completion-fre-completed', false,
304+
Common.Settings.SettingType.BOOLEAN),
302305
createSettingValue(
303306
Common.Settings.SettingCategory.MOBILE, 'emulation.show-device-outline', false,
304307
Common.Settings.SettingType.BOOLEAN),

0 commit comments

Comments
 (0)