Skip to content

Commit 842a3f3

Browse files
jackfranklindevtools-frontend-scoped@luci-project-accounts.iam.gserviceaccount.com
authored andcommitted
AI: ensure users who enable AI with V2 do not see opt in
This CL fixes a case where: 1. We ship AIv2 2. A user enables AI Assistance for the first time 3. They go to AI Assistance, and see the opt-in dialog. (3) is not correct; because the user opted in under V2, they do not need to see the dialog. This CL fixes this by setting the dialog to "seen" in the event that a user with V2 enables it. Fixed: 502511336 Change-Id: I9753fa60c1c749f5e10d78ff0c36b6c46053028e Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/7760115 Auto-Submit: Jack Franklin <jacktfranklin@chromium.org> Reviewed-by: Kim-Anh Tran <kimanh@chromium.org> Commit-Queue: Kim-Anh Tran <kimanh@chromium.org>
1 parent ee63ce8 commit 842a3f3

File tree

2 files changed

+60
-3
lines changed

2 files changed

+60
-3
lines changed

front_end/panels/settings/AISettingsTab.test.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,4 +320,50 @@ describeWithEnvironment('AISettingsTab', () => {
320320
assert.exists(aiAssistanceParams);
321321
assert.strictEqual(aiAssistanceParams.settingDescription, 'Get help with understanding CSS styles');
322322
});
323+
324+
it('marks the V2 opt-in dialog as seen when turning on AI assistance in V2', async () => {
325+
updateHostConfig({
326+
devToolsAiAssistanceV2: {
327+
enabled: true,
328+
},
329+
});
330+
const aiAssistanceEnabledSetting = Common.Settings.moduleSetting('ai-assistance-enabled');
331+
aiAssistanceEnabledSetting.set(false);
332+
const v2OptInSeenSetting = Common.Settings.moduleSetting('ai-assistance-v2-opt-in-change-dialog-seen');
333+
v2OptInSeenSetting.set(false);
334+
335+
const {view} = await setupWidget();
336+
337+
const settingToParams = Array.from(view.input.settingToParams.entries());
338+
const aiAssistanceEntry = settingToParams.find(entry => entry[1].settingName === 'AI assistance');
339+
assert.exists(aiAssistanceEntry);
340+
341+
view.input.toggleSetting(aiAssistanceEntry[0], new Switch.Switch.SwitchChangeEvent(true));
342+
343+
assert.isTrue(aiAssistanceEnabledSetting.get());
344+
assert.isTrue(v2OptInSeenSetting.get());
345+
});
346+
347+
it('does not mark the V2 opt-in dialog as seen when turning on AI assistance in V1', async () => {
348+
updateHostConfig({
349+
devToolsAiAssistanceV2: {
350+
enabled: false,
351+
},
352+
});
353+
const aiAssistanceEnabledSetting = Common.Settings.moduleSetting('ai-assistance-enabled');
354+
aiAssistanceEnabledSetting.set(false);
355+
const v2OptInSeenSetting = Common.Settings.moduleSetting('ai-assistance-v2-opt-in-change-dialog-seen');
356+
v2OptInSeenSetting.set(false);
357+
358+
const {view} = await setupWidget();
359+
360+
const settingToParams = Array.from(view.input.settingToParams.entries());
361+
const aiAssistanceEntry = settingToParams.find(entry => entry[1].settingName === 'AI assistance');
362+
assert.exists(aiAssistanceEntry);
363+
364+
view.input.toggleSetting(aiAssistanceEntry[0], new Switch.Switch.SwitchChangeEvent(true));
365+
366+
assert.isTrue(aiAssistanceEnabledSetting.get());
367+
assert.isFalse(v2OptInSeenSetting.get());
368+
});
323369
});

front_end/panels/settings/AISettingsTab.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -684,9 +684,20 @@ export class AISettingsTab extends UI.Widget.VBox {
684684
.createSetting('console-insights-skip-reminder', true, Common.Settings.SettingStorageType.SESSION)
685685
.set(true);
686686
}
687-
} else if (setting.name === 'ai-assistance-enabled' && !setting.get()) {
688-
// If the "AI Assistance" is toggled off, we remove all the history entries related to the feature.
689-
void AiAssistanceModel.AiHistoryStorage.AiHistoryStorage.instance().deleteAll();
687+
} else if (setting.name === 'ai-assistance-enabled') {
688+
if (!setting.get()) {
689+
// If the "AI Assistance" is toggled off, we remove all the history entries related to the feature.
690+
void AiAssistanceModel.AiHistoryStorage.AiHistoryStorage.instance().deleteAll();
691+
}
692+
693+
if (Root.Runtime.hostConfig.devToolsAiAssistanceV2?.enabled && setting.get()) {
694+
// If the user turns on ai-assistance whilst on the V2 experiment, they
695+
// do not need to see the opt-in change management dialog. This dialog
696+
// exists to inform users who opted-in to "V1" that in "V2" there are
697+
// some data access changes. But if a user opts-in when on "V2", they
698+
// do not need to see that dialog.
699+
Common.Settings.Settings.instance().moduleSetting('ai-assistance-v2-opt-in-change-dialog-seen').set(true);
700+
}
690701
}
691702
this.requestUpdate();
692703
}

0 commit comments

Comments
 (0)