Separate `aidaAvailability` section in hostConfig
Whether AIDA is available or not affects more than one DevTools
feature. Instead of repeating that info in multiple objects within `hostConfig`, move it to its own section instead.
This CL should land first, before landing the Chromium CL
(https://crrev.com/c/5783303) which updates the `hostConfig`'s shape
there. `hostConfigOldToNew()` in `devtools_compatibility.js` ensures
that DevTools is still able to handle receiving the old shape in the
meantime.
In addition, when remote debugging an older version of Chrome, a
DevTools version matching the remove Chrome is being executed. In
order to not break this older DevTools version, `hostConfigNewToOld()`
is added to convert the new `hostConfig` shape back to the old shape,
which the old DevTools will be able to handle.
Disable tests CL: https://crrev.com/c/5782922
Re-enable tests CL: https://crrev.com/c/5782872
Chromium CL: https://crrev.com/c/5783303
Doc: go/chrome-devtools:genai-availability (non-public)
Bug: b/348136212
Change-Id: I746330bd009bc03f06a5d2cdb40a8830fb200af3
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/5782756
Reviewed-by: Ergün Erdoğmuş <[email protected]>
Reviewed-by: Alex Rudenko <[email protected]>
Commit-Queue: Wolfgang Beyer <[email protected]>
diff --git a/front_end/core/common/SettingRegistration.test.ts b/front_end/core/common/SettingRegistration.test.ts
index c1229ff..3c4ea57 100644
--- a/front_end/core/common/SettingRegistration.test.ts
+++ b/front_end/core/common/SettingRegistration.test.ts
@@ -128,9 +128,8 @@
localStorage: dummyStorage,
config: {
devToolsConsoleInsights: {
- aidaModelId: 'mockModel',
- aidaTemperature: 0.2,
- optIn: false,
+ modelId: 'mockModel',
+ temperature: 0.2,
enabled: true,
},
} as Root.Runtime.HostConfig,
diff --git a/front_end/core/host/AidaClient.test.ts b/front_end/core/host/AidaClient.test.ts
index e08e545..b23efe8 100644
--- a/front_end/core/host/AidaClient.test.ts
+++ b/front_end/core/host/AidaClient.test.ts
@@ -25,7 +25,7 @@
const stub = getGetHostConfigStub({
devToolsConsoleInsights: {
enabled: true,
- aidaTemperature: 0.5,
+ temperature: 0.5,
},
});
const request = Host.AidaClient.AidaClient.buildConsoleInsightsRequest('foo');
@@ -45,7 +45,7 @@
const stub = getGetHostConfigStub({
devToolsConsoleInsights: {
enabled: true,
- aidaTemperature: 0,
+ temperature: 0,
},
});
const request = Host.AidaClient.AidaClient.buildConsoleInsightsRequest('foo');
@@ -65,8 +65,8 @@
const stub = getGetHostConfigStub({
devToolsConsoleInsights: {
enabled: true,
- aidaModelId: TEST_MODEL_ID,
- aidaTemperature: 0.5,
+ modelId: TEST_MODEL_ID,
+ temperature: 0.5,
},
});
const request = Host.AidaClient.AidaClient.buildConsoleInsightsRequest('foo');
@@ -85,10 +85,12 @@
it('adds metadata to disallow logging', () => {
const stub = getGetHostConfigStub({
+ aidaAvailability: {
+ disallowLogging: true,
+ },
devToolsConsoleInsights: {
enabled: true,
- aidaTemperature: 0.5,
- disallowLogging: true,
+ temperature: 0.5,
},
});
const request = Host.AidaClient.AidaClient.buildConsoleInsightsRequest('foo');
diff --git a/front_end/core/host/AidaClient.ts b/front_end/core/host/AidaClient.ts
index d4fa79c..f64803e 100644
--- a/front_end/core/host/AidaClient.ts
+++ b/front_end/core/host/AidaClient.ts
@@ -134,10 +134,10 @@
let temperature = NaN;
let modelId = '';
if (config.devToolsConsoleInsights?.enabled) {
- temperature = config.devToolsConsoleInsights.aidaTemperature || 0;
- modelId = config.devToolsConsoleInsights.aidaModelId || '';
+ temperature = config.devToolsConsoleInsights.temperature || 0;
+ modelId = config.devToolsConsoleInsights.modelId || '';
}
- const disallowLogging = config.devToolsConsoleInsights?.disallowLogging ?? true;
+ const disallowLogging = config.aidaAvailability?.disallowLogging ?? true;
if (!isNaN(temperature)) {
request.options ??= {};
diff --git a/front_end/core/host/InspectorFrontendHost.ts b/front_end/core/host/InspectorFrontendHost.ts
index f713aab..6aa06b6 100644
--- a/front_end/core/host/InspectorFrontendHost.ts
+++ b/front_end/core/host/InspectorFrontendHost.ts
@@ -401,23 +401,21 @@
getHostConfig(callback: (arg0: Root.Runtime.HostConfig) => void): void {
const result: Root.Runtime.HostConfig = {
- devToolsConsoleInsights: {
- aidaModelId: '',
- aidaTemperature: 0,
+ aidaAvailability: {
+ enabled: true,
blockedByAge: false,
blockedByEnterprisePolicy: false,
blockedByGeo: false,
- blockedByRollout: false,
disallowLogging: false,
+ },
+ devToolsConsoleInsights: {
+ modelId: '',
+ temperature: 0,
enabled: false,
- optIn: false,
},
devToolsFreestylerDogfood: {
- aidaModelId: '',
- aidaTemperature: 0,
- blockedByAge: false,
- blockedByEnterprisePolicy: false,
- blockedByGeo: false,
+ modelId: '',
+ temperature: 0,
enabled: false,
},
devToolsVeLogging: {
diff --git a/front_end/core/root/Runtime.ts b/front_end/core/root/Runtime.ts
index bd6b277..29cf988 100644
--- a/front_end/core/root/Runtime.ts
+++ b/front_end/core/root/Runtime.ts
@@ -304,24 +304,29 @@
TIMELINE_SERVER_TIMINGS = 'timeline-server-timings',
}
-export interface HostConfigConsoleInsights {
- aidaModelId: string;
- aidaTemperature: number;
+export interface AidaAvailability {
+ enabled: boolean;
blockedByAge: boolean;
blockedByEnterprisePolicy: boolean;
blockedByGeo: boolean;
- blockedByRollout: boolean;
disallowLogging: boolean;
+}
+
+export interface HostConfigConsoleInsights {
+ modelId: string;
+ temperature: number;
enabled: boolean;
- optIn: boolean;
}
export interface HostConfigFreestylerDogfood {
- aidaModelId: string;
- aidaTemperature: number;
- blockedByAge: boolean;
- blockedByEnterprisePolicy: boolean;
- blockedByGeo: boolean;
+ modelId: string;
+ temperature: number;
+ enabled: boolean;
+}
+
+export interface HostConfigExplainThisResourceDogfood {
+ modelId: string;
+ temperature: number;
enabled: boolean;
}
@@ -338,8 +343,10 @@
// window being of different versions, and consequently potentially having
// differently shaped `HostConfig`s.
export type HostConfig = Platform.TypeScriptUtilities.RecursivePartial<{
+ aidaAvailability: AidaAvailability,
devToolsConsoleInsights: HostConfigConsoleInsights,
devToolsFreestylerDogfood: HostConfigFreestylerDogfood,
+ devToolsExplainThisResourceDogfood: HostConfigExplainThisResourceDogfood,
devToolsVeLogging: HostConfigVeLogging,
/**
* OffTheRecord here indicates that the user's profile is either incognito,
diff --git a/front_end/devtools_compatibility.js b/front_end/devtools_compatibility.js
index 8a44f34..6061e28 100644
--- a/front_end/devtools_compatibility.js
+++ b/front_end/devtools_compatibility.js
@@ -641,7 +641,85 @@
* @param {function(Object<string, Object<string, string|boolean>>):void} callback
*/
getHostConfig(callback) {
- DevToolsAPI.sendMessageToEmbedder('getHostConfig', [], /** @type {function(?Object)} */ (callback));
+ DevToolsAPI.sendMessageToEmbedder('getHostConfig', [], hostConfig => {
+ const majorVersion = getRemoteMajorVersion();
+ if (majorVersion && majorVersion < 129 && hostConfig?.aidaAvailability) {
+ return callback(this.hostConfigNewToOld(hostConfig));
+ }
+ // TODO(crbug.com/348136212): Remove as soon as Chromium sends the new shape.
+ if (hostConfig && !hostConfig.aidaAvailability && hostConfig.devToolsConsoleInsights) {
+ return callback(this.hostConfigOldToNew(hostConfig));
+ }
+ return callback(hostConfig);
+ });
+ }
+
+ // TODO(crbug.com/348136212): Remove as soon as Chromium sends the new shape.
+ /**
+ * @param {Object<string, Object<string, string|boolean>>} oldConfig
+ */
+ hostConfigOldToNew(oldConfig) {
+ const aidaAvailability = {
+ // Not a perfect match, but good enough temporarily.
+ enabled: oldConfig.devToolsConsoleInsights?.enabled ?? false,
+ blockedByAge: oldConfig.devToolsConsoleInsights?.blockedByAge ?? true,
+ blockedByEnterprisePolicy: oldConfig.devToolsConsoleInsights?.blockedByEnterprisePolicy ?? true,
+ blockedByGeo: oldConfig.devToolsConsoleInsights?.blockedByGeo ?? true,
+ disallowLogging: oldConfig.devToolsConsoleInsights?.disallowLogging ?? true,
+ };
+ const devToolsConsoleInsights = {
+ enabled: oldConfig.devToolsConsoleInsights?.enabled ?? false,
+ modelId: oldConfig.devToolsConsoleInsights?.aidaModelId ?? '',
+ temperature: oldConfig.devToolsConsoleInsights?.aidaTemperature ?? 0,
+ };
+ const devToolsFreestylerDogfood = {
+ enabled: oldConfig.devToolsFreestylerDogfood?.enabled ?? false,
+ modelId: oldConfig.devToolsFreestylerDogfood?.aidaModelId ?? '',
+ temperature: oldConfig.devToolsFreestylerDogfood?.aidaTemperature ?? 0,
+ };
+ const devToolsExplainThisResourceDogfood = {
+ enabled: oldConfig.devToolsExplainThisResourceDogfood?.enabled ?? false,
+ modelId: oldConfig.devToolsExplainThisResourceDogfood?.aidaModelId ?? '',
+ temperature: oldConfig.devToolsExplainThisResourceDogfood?.aidaTemperature ?? 0,
+ };
+ return {
+ ...oldConfig,
+ aidaAvailability,
+ devToolsConsoleInsights,
+ devToolsExplainThisResourceDogfood,
+ devToolsFreestylerDogfood,
+ };
+ }
+
+ /**
+ * @param {Object<string, Object<string, string|boolean>>} newConfig
+ */
+ hostConfigNewToOld(newConfig) {
+ const devToolsConsoleInsights = {
+ enabled: (newConfig.devToolsConsoleInsights?.enabled && newConfig.aidaAvailability?.enabled) ?? false,
+ aidaModelId: newConfig.devToolsConsoleInsights?.modelId ?? '',
+ aidaTemperature: newConfig.devToolsConsoleInsights?.temperature ?? 0,
+ blockedByAge: newConfig.aidaAvailability?.blockedByAge ?? true,
+ blockedByEnterprisePolicy: newConfig.aidaAvailability?.blockedByEnterprisePolicy ?? true,
+ blockedByGeo: newConfig.aidaAvailability?.blockedByGeo ?? true,
+ blockedByRollout: false,
+ disallowLogging: newConfig.aidaAvailability?.disallowLogging ?? true,
+ optIn: false,
+ };
+ const devToolsFreestylerDogfood = {
+ enabled: (newConfig.devToolsFreestylerDogfood?.enabled && newConfig.aidaAvailability?.enabled) ?? false,
+ aidaModelId: newConfig.devToolsFreestylerDogfood?.modelId ?? '',
+ aidaTemperature: newConfig.devToolsFreestylerDogfood?.temperature ?? 0,
+ blockedByAge: newConfig.aidaAvailability?.blockedByAge ?? true,
+ blockedByEnterprisePolicy: newConfig.aidaAvailability?.blockedByEnterprisePolicy ?? true,
+ blockedByGeo: newConfig.aidaAvailability?.blockedByGeo ?? true,
+ };
+ return {
+ devToolsConsoleInsights,
+ devToolsFreestylerDogfood,
+ devToolsVeLogging: newConfig.devToolsVeLogging,
+ isOffTheRecord: newConfig.isOffTheRecord,
+ };
}
/**
diff --git a/front_end/entrypoints/main/SettingTracker.test.ts b/front_end/entrypoints/main/SettingTracker.test.ts
index c5fa89b..9129bff 100644
--- a/front_end/entrypoints/main/SettingTracker.test.ts
+++ b/front_end/entrypoints/main/SettingTracker.test.ts
@@ -27,23 +27,6 @@
false);
});
- it('sets console-insights-enabled to false if feature is opt-in', async () => {
- const dummyStorage = new Common.Settings.SettingsStorage({});
- Common.Settings.Settings.instance({
- forceNew: true,
- syncedStorage: dummyStorage,
- globalStorage: dummyStorage,
- localStorage: dummyStorage,
- config: {'devToolsConsoleInsights': {'enabled': true, 'optIn': true}} as Root.Runtime.HostConfig,
- });
- Common.Settings.moduleSetting('console-insights-enabled').set(true);
- const toggledSetting = Common.Settings.Settings.instance().createLocalSetting('console-insights-toggled', false);
- toggledSetting.set(false);
- settingTracker = new Main.SettingTracker.SettingTracker();
- assert.strictEqual(Common.Settings.moduleSetting('console-insights-enabled').get(), false);
- assert.strictEqual(toggledSetting.get(), false);
- });
-
it('sets console-insights-enabled to true if feature is opt-out', async () => {
const dummyStorage = new Common.Settings.SettingsStorage({});
Common.Settings.Settings.instance({
diff --git a/front_end/entrypoints/main/SettingTracker.ts b/front_end/entrypoints/main/SettingTracker.ts
index 434e028..5a4778f 100644
--- a/front_end/entrypoints/main/SettingTracker.ts
+++ b/front_end/entrypoints/main/SettingTracker.ts
@@ -47,9 +47,7 @@
Common.Settings.Settings.instance().createLocalSetting(consoleInsightsToggledSettingName, false);
const enabledSetting = this.#getModuleSetting(consoleInsightsEnabledSettingName);
if (!toggledSetting.get()) {
- // If the setting was not toggled, update according to host config.
- const config = Common.Settings.Settings.instance().getHostConfig();
- enabledSetting?.set(config.devToolsConsoleInsights?.optIn !== true);
+ enabledSetting?.set(true);
}
}
}
diff --git a/front_end/panels/explain/components/ConsoleInsight.test.ts b/front_end/panels/explain/components/ConsoleInsight.test.ts
index 757c9e2..fb87496 100644
--- a/front_end/panels/explain/components/ConsoleInsight.test.ts
+++ b/front_end/panels/explain/components/ConsoleInsight.test.ts
@@ -202,9 +202,11 @@
it('has no thumbs up/down buttons if logging is disabled', async () => {
const stub = getGetHostConfigStub({
+ aidaAvailability: {
+ disallowLogging: true,
+ },
devToolsConsoleInsights: {
enabled: true,
- disallowLogging: true,
},
});
const component = await renderInsight();
diff --git a/front_end/panels/explain/components/ConsoleInsight.ts b/front_end/panels/explain/components/ConsoleInsight.ts
index b80a78a..8ab17da 100644
--- a/front_end/panels/explain/components/ConsoleInsight.ts
+++ b/front_end/panels/explain/components/ConsoleInsight.ts
@@ -384,7 +384,7 @@
Host.userMetrics.actionTaken(Host.UserMetrics.Action.InsightRatedNegative);
}
const disallowLogging =
- Common.Settings.Settings.instance().getHostConfig().devToolsConsoleInsights?.disallowLogging ?? true;
+ Common.Settings.Settings.instance().getHostConfig().aidaAvailability?.disallowLogging ?? true;
void this.#aidaClient.registerClientEvent({
corresponding_aida_rpc_global_id: this.#state.metadata.rpcGlobalId,
disable_user_content_logging: disallowLogging,
@@ -663,7 +663,7 @@
#renderMain(): LitHtml.TemplateResult {
const jslog = `${VisualLogging.section(this.#state.type).track({resize: true})}`;
const disallowLogging =
- Common.Settings.Settings.instance().getHostConfig().devToolsConsoleInsights?.disallowLogging ?? true;
+ Common.Settings.Settings.instance().getHostConfig().aidaAvailability?.disallowLogging ?? true;
// clang-format off
switch (this.#state.type) {
case State.LOADING:
@@ -761,7 +761,7 @@
#renderFooter(): LitHtml.LitTemplate {
const showThumbsUpDownButtons =
- !(Common.Settings.Settings.instance().getHostConfig().devToolsConsoleInsights?.disallowLogging ?? true);
+ !(Common.Settings.Settings.instance().getHostConfig().aidaAvailability?.disallowLogging ?? true);
// clang-format off
const disclaimer = LitHtml.html`<span>
This feature may display inaccurate or offensive information that doesn't represent Google's views.
diff --git a/front_end/panels/explain/explain-meta.ts b/front_end/panels/explain/explain-meta.ts
index d90664a..0f03ac6 100644
--- a/front_end/panels/explain/explain-meta.ts
+++ b/front_end/panels/explain/explain-meta.ts
@@ -45,10 +45,6 @@
* not allow this feature.
*/
policyRestricted: 'Your organization turned off this feature. Contact your administrators for more information.',
- /**
- * @description Message shown to the user if the feature roll out is currently happening.
- */
- rolloutRestricted: 'This feature is currently being rolled out. Stay tuned.',
};
const str_ = i18n.i18n.registerUIStrings('panels/explain/explain-meta.ts', UIStrings);
const i18nLazyString = i18n.i18n.getLazilyComputedLocalizedString.bind(undefined, str_);
@@ -93,27 +89,19 @@
}
function isAgeRestricted(config?: Root.Runtime.HostConfig): boolean {
- return config?.devToolsConsoleInsights?.blockedByAge === true;
-}
-
-function isRolloutRestricted(config?: Root.Runtime.HostConfig): boolean {
- return config?.devToolsConsoleInsights?.blockedByRollout === true;
+ return config?.aidaAvailability?.blockedByAge === true;
}
function isGeoRestricted(config?: Root.Runtime.HostConfig): boolean {
- return config?.devToolsConsoleInsights?.blockedByGeo === true;
+ return config?.aidaAvailability?.blockedByGeo === true;
}
function isPolicyRestricted(config?: Root.Runtime.HostConfig): boolean {
- return config?.devToolsConsoleInsights?.blockedByEnterprisePolicy === true;
-}
-
-function isOptIn(config?: Root.Runtime.HostConfig): boolean {
- return config?.devToolsConsoleInsights?.optIn === true;
+ return config?.aidaAvailability?.blockedByEnterprisePolicy === true;
}
function isFeatureEnabled(config?: Root.Runtime.HostConfig): boolean {
- return config?.devToolsConsoleInsights?.enabled === true;
+ return (config?.aidaAvailability?.enabled && config?.devToolsConsoleInsights?.enabled) === true;
}
Common.Settings.registerSettingExtension({
@@ -121,7 +109,7 @@
settingName: setting,
settingType: Common.Settings.SettingType.BOOLEAN,
title: i18nLazyString(UIStrings.enableConsoleInsights),
- defaultValue: (config: Root.Runtime.HostConfig): boolean => !isOptIn(config),
+ defaultValue: true,
reloadRequired: true,
condition: config => isFeatureEnabled(config),
disabledCondition: config => {
@@ -137,9 +125,6 @@
if (isPolicyRestricted(config)) {
return {disabled: true, reason: i18nString(UIStrings.policyRestricted)};
}
- if (isRolloutRestricted(config)) {
- return {disabled: true, reason: i18nString(UIStrings.rolloutRestricted)};
- }
return {disabled: false};
},
});
@@ -155,7 +140,7 @@
},
condition: config => {
return isFeatureEnabled(config) && !isAgeRestricted(config) && !isGeoRestricted(config) &&
- !isLocaleRestricted() && !isPolicyRestricted(config) && !isRolloutRestricted(config);
+ !isLocaleRestricted() && !isPolicyRestricted(config);
},
});
}
diff --git a/front_end/panels/freestyler/FreestylerAgent.test.ts b/front_end/panels/freestyler/FreestylerAgent.test.ts
index 1a92335..04fc918 100644
--- a/front_end/panels/freestyler/FreestylerAgent.test.ts
+++ b/front_end/panels/freestyler/FreestylerAgent.test.ts
@@ -16,7 +16,7 @@
function mockHostConfig(modelId?: string) {
getGetHostConfigStub({
devToolsFreestylerDogfood: {
- aidaModelId: modelId,
+ modelId: modelId,
},
});
}
diff --git a/front_end/panels/freestyler/FreestylerAgent.ts b/front_end/panels/freestyler/FreestylerAgent.ts
index 8025bfa..4de7d0b 100644
--- a/front_end/panels/freestyler/FreestylerAgent.ts
+++ b/front_end/panels/freestyler/FreestylerAgent.ts
@@ -164,8 +164,8 @@
chat_history: opts.chatHistory,
client: Host.AidaClient.CLIENT_NAME,
options: {
- temperature: config.devToolsFreestylerDogfood?.aidaTemperature ?? 0,
- model_id: config.devToolsFreestylerDogfood?.aidaModelId ?? undefined,
+ temperature: config.devToolsFreestylerDogfood?.temperature ?? 0,
+ model_id: config.devToolsFreestylerDogfood?.modelId ?? undefined,
},
metadata: {
// TODO: disable logging based on query params.
diff --git a/front_end/panels/freestyler/freestyler-meta.ts b/front_end/panels/freestyler/freestyler-meta.ts
index 6a07a39..12d503d 100644
--- a/front_end/panels/freestyler/freestyler-meta.ts
+++ b/front_end/panels/freestyler/freestyler-meta.ts
@@ -69,15 +69,15 @@
}
function isAgeRestricted(config?: Root.Runtime.HostConfig): boolean {
- return config?.devToolsFreestylerDogfood?.blockedByAge === true;
+ return config?.aidaAvailability?.blockedByAge === true;
}
function isGeoRestricted(config?: Root.Runtime.HostConfig): boolean {
- return config?.devToolsFreestylerDogfood?.blockedByGeo === true;
+ return config?.aidaAvailability?.blockedByGeo === true;
}
function isPolicyRestricted(config?: Root.Runtime.HostConfig): boolean {
- return config?.devToolsFreestylerDogfood?.blockedByEnterprisePolicy === true;
+ return config?.aidaAvailability?.blockedByEnterprisePolicy === true;
}
let loadedFreestylerModule: (typeof Freestyler|undefined);
@@ -89,7 +89,7 @@
}
function isFeatureAvailable(config?: Root.Runtime.HostConfig): boolean {
- return config?.devToolsFreestylerDogfood?.enabled === true;
+ return (config?.aidaAvailability?.enabled && config?.devToolsFreestylerDogfood?.enabled) === true;
}
UI.ViewManager.registerViewExtension({
diff --git a/front_end/testing/EnvironmentHelpers.ts b/front_end/testing/EnvironmentHelpers.ts
index 1ceaf4d..e367f66 100644
--- a/front_end/testing/EnvironmentHelpers.ts
+++ b/front_end/testing/EnvironmentHelpers.ts
@@ -499,16 +499,19 @@
export function getGetHostConfigStub(config: Root.Runtime.HostConfig): sinon.SinonStub {
const settings = Common.Settings.Settings.instance();
return sinon.stub(settings, 'getHostConfig').returns({
+ aidaAvailability: {
+ disallowLogging: false,
+ ...config.aidaAvailability,
+ },
devToolsConsoleInsights: {
enabled: false,
- aidaModelId: '',
- aidaTemperature: 0.2,
- disallowLogging: false,
+ modelId: '',
+ temperature: 0.2,
...config.devToolsConsoleInsights,
} as Root.Runtime.HostConfigConsoleInsights,
devToolsFreestylerDogfood: {
- aidaModelId: '',
- aidaTemperature: 0,
+ modelId: '',
+ temperature: 0,
enabled: false,
...config.devToolsFreestylerDogfood,
} as Root.Runtime.HostConfigFreestylerDogfood,