Skip to content

Open-source AI browser agent for Chrome and Firefox (monorepo) 🧠

Config export: keep the latent On defaults for Off and pre-mode Auto profiles

Claudeecdeb3418f14
diff --git a/src/chrome/src/config-transfer.js b/src/chrome/src/config-transfer.js
index 4d28d5e9e..e967de532 100644
--- a/src/chrome/src/config-transfer.js
+++ b/src/chrome/src/config-transfer.js
@@ -296,10 +296,12 @@ function normalizeSettings(source, { strict = false } = {}) {
settings.decisionInputRate = source.decisionProvider === 'typesafe' || (!source.decisionProvider && source.typesafeApiKey)
? .042 : ['local', 'webgpu_d1', 'webgpu_chat'].includes(source.decisionProvider) ? 0 : .02;
}
- const isLegacyPreModeProfile = !DECISION_MODES.includes(source?.decisionMode) && Object.hasOwn(source, 'systemOneEnabled');
- const isExplicitOn = source?.decisionMode === 'on';
- const isModernAuto = resolveDecisionMode(source) === 'auto' && !isLegacyPreModeProfile;
- if (isExplicitOn || isModernAuto) {
+ // A profile saved before modes existed and left in On keeps the old reading: a missing switch is
+ // off. Every other profile (explicit On, Auto or Off, or a pre-mode profile that was not On)
+ // switches to On with the omitted switches enabled, so they are materialized as on and a round
+ // trip does not turn them into the old `false` defaults.
+ const isLegacyOnProfile = !DECISION_MODES.includes(source?.decisionMode) && source?.systemOneEnabled === true;
+ if (!isLegacyOnProfile) {
for (const key of Object.values(DECISION_FEATURE_KEYS)) {
if (!Object.hasOwn(source, key)) {
settings[key] = true;
diff --git a/src/firefox/src/config-transfer.js b/src/firefox/src/config-transfer.js
index 00cd53ee4..46c2f169d 100644
--- a/src/firefox/src/config-transfer.js
+++ b/src/firefox/src/config-transfer.js
@@ -320,10 +320,12 @@ function normalizeSettings(source, { strict = false } = {}) {
settings.decisionInputRate = decisionProvider === 'typesafe' || (!decisionProvider && source.typesafeApiKey)
? .042 : ['local', 'webgpu_d1'].includes(decisionProvider) ? 0 : .02;
}
- const isLegacyPreModeProfile = !DECISION_MODES.includes(source?.decisionMode) && Object.hasOwn(source, 'systemOneEnabled');
- const isExplicitOn = source?.decisionMode === 'on';
- const isModernAuto = resolveDecisionMode(source) === 'auto' && !isLegacyPreModeProfile;
- if (isExplicitOn || isModernAuto) {
+ // A profile saved before modes existed and left in On keeps the old reading: a missing switch is
+ // off. Every other profile (explicit On, Auto or Off, or a pre-mode profile that was not On)
+ // switches to On with the omitted switches enabled, so they are materialized as on and a round
+ // trip does not turn them into the old `false` defaults.
+ const isLegacyOnProfile = !DECISION_MODES.includes(source?.decisionMode) && source?.systemOneEnabled === true;
+ if (!isLegacyOnProfile) {
for (const key of Object.values(DECISION_FEATURE_KEYS)) {
if (!Object.hasOwn(source, key)) {
settings[key] = true;
diff --git a/test/decision-mode.mjs b/test/decision-mode.mjs
index a1bced986..701e940fd 100644
--- a/test/decision-mode.mjs
+++ b/test/decision-mode.mjs
@@ -283,3 +283,22 @@ for (const build of ['chrome', 'firefox']) {
assert.match(source, new RegExp(`materializeLegacyDecisionFeatures\\(await ${api}\\.storage\\.local\\.get\\(DECISION_SETTINGS_KEYS\\)\\);\\s*await ${api}\\.storage\\.local\\.set\\(\\{ \\.\\.\\.legacyFeatures, \\[DECISION_MODE_KEY\\]: mode, systemOneEnabled: mode === 'on' \\}\\)`));
});
}
+
+for (const build of ['chrome', 'firefox']) {
+ test(`${build}: exporting an Off profile keeps the latent On defaults`, async () => {
+ const transfer = await import(`../src/${build}/src/config-transfer.js`);
+ const config = await import(`../src/${build}/src/agent/decision-config.js`);
+ const keys = Object.values(config.DECISION_FEATURE_KEYS);
+ const roundTrip = (stored) => transfer.parseConfigImport(JSON.stringify(transfer.createConfigExport(stored))).settings;
+ for (const stored of [{ decisionMode: 'off' }, { decisionMode: 'auto' }, { decisionMode: 'on' }, { systemOneEnabled: false }, {}]) {
+ const restored = roundTrip(stored);
+ for (const key of keys) assert.equal(restored[key], true, `${JSON.stringify(stored)}: ${key} stays on by default`);
+ const features = config.resolveDecisionConfig({ ...restored, decisionMode: 'on', systemOneEnabled: true }).features;
+ for (const feature of ['watch', 'completion', 'classifications', 'browser']) assert.equal(features[feature], true);
+ }
+ // Explicit values are never overwritten, and a pre-mode On profile keeps its old (off) reading.
+ assert.equal(roundTrip({ decisionMode: 'off', systemOneWatchEnabled: false }).systemOneWatchEnabled, false);
+ const legacyOn = roundTrip({ systemOneEnabled: true });
+ for (const key of keys.filter((k) => k !== 'systemOneDoneEnabled')) assert.equal(legacyOn[key], false, `pre-mode On: ${key} stays off`);
+ });
+}