Skip to content

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

feat(providers): support custom titles and unlimited duplicates

Barack Sokullu561a30be4d8b
diff --git a/docs/providers-and-models.md b/docs/providers-and-models.md
index a3576c1ce..d68ddf730 100644
--- a/docs/providers-and-models.md
+++ b/docs/providers-and-models.md
@@ -599,13 +599,22 @@ state and is separate from `activeProvider`, which is the provider currently
configured. Connection tests report reachability but do not control the Active
flag.
-Settings can create one independent duplicate of each configurable endpoint
-provider. A duplicate is stored as a normal provider entry with the stable ID
-`<source>__duplicate` and a `duplicateOf` reference to the source definition,
+Settings can rename configurable providers using **Provider title** and Save.
+The persisted `label` appears in Settings and the chat provider picker without
+changing the provider's ID, implementation, or model.
+
+Settings can create any number of independent duplicates of each configurable
+endpoint provider, including from a saved duplicate. The first duplicate keeps
+the existing ID `<source>__duplicate`; subsequent instances use
+`<source>__duplicate_2`, `<source>__duplicate_3`, and so on. Each stores a
+`duplicateOf` reference to the original source definition,
so credentials, models, endpoint URLs, compatibility options, export/import,
and active-provider selection continue to use the existing provider schema.
-The manager rejects duplicate-of-duplicate, second, orphaned, type-mismatched,
-and forged duplicate entries when loading storage. WebBrain Compass and the
+New instances start with blank credentials, endpoint, model, and overrides,
+and must be saved before selection or further duplication. Duplicates stay
+grouped after their source; deleting one leaves the other instances intact.
+The manager rejects nested, orphaned, type-mismatched, and malformed duplicate
+entries when loading storage. WebBrain Compass and the
Chromium-only WebGPU runtime are not duplicable because they do not represent
independent user-managed API credentials or endpoints; their cards keep the
Duplicate affordance disabled with an explanatory tooltip.
diff --git a/package.json b/package.json
index 1fa7b1b44..422284b22 100644
--- a/package.json
+++ b/package.json
@@ -11,6 +11,7 @@
"test:billing-notice": "node test/billing-payment-notice.mjs",
"test:provider-limits": "node test/provider-model-limits.mjs",
"test:provider-catalog": "node test/provider-catalog-integrations.mjs",
+ "test:provider-instances:ui": "node test/provider-instances-ui.mjs",
"test:openrouter-capabilities": "node --test test/openrouter-model-capabilities.mjs test/muse-tool-choice.mjs test/model-retry.mjs",
"test:markdown": "node --test test/markdown-render.mjs",
"test:accessibility-tree-benchmark": "node --test test/llm/lib/accessibility-tree-formats.test.mjs && node test/llm/accessibility-tree-benchmark.mjs --no-exact-tokenizer --check",
diff --git a/src/chrome/src/providers/manager.js b/src/chrome/src/providers/manager.js
index ca7edf836..e92de42e2 100644
--- a/src/chrome/src/providers/manager.js
+++ b/src/chrome/src/providers/manager.js
@@ -1261,12 +1261,21 @@ export class ProviderManager {
return String(config?.duplicateOf || id || '');
}
- _duplicateProviderId(id) {
- return `${id}${DUPLICATE_PROVIDER_SUFFIX}`;
+ _duplicateProviderId(id, number = 1) {
+ return `${id}${DUPLICATE_PROVIDER_SUFFIX}${number === 1 ? '' : `_${number}`}`;
+ }
+
+ _duplicateProviderNumber(id, sourceId) {
+ const prefix = this._duplicateProviderId(sourceId);
+ if (id === prefix) return 1;
+ if (!id.startsWith(`${prefix}_`)) return 0;
+ const suffix = id.slice(prefix.length + 1);
+ const number = Number(suffix);
+ return Number.isSafeInteger(number) && number >= 2 && String(number) === suffix ? number : 0;
}
_canDuplicateProvider(id, config = this.providers.get(id)?.config) {
- return !!config && !config.duplicateOf && id !== WEBBRAIN_CLOUD_PROVIDER_ID && config.type !== 'webgpu';
+ return !!config && this._providerDefinitionId(id, config) !== WEBBRAIN_CLOUD_PROVIDER_ID && config.type !== 'webgpu';
}
_isValidDuplicateConfig(id, config, configs) {
@@ -1274,8 +1283,9 @@ export class ProviderManager {
const sourceConfig = configs[sourceId];
return typeof sourceId === 'string' &&
SAFE_PROVIDER_ID_RE.test(sourceId) &&
- id === this._duplicateProviderId(sourceId) &&
+ this._duplicateProviderNumber(id, sourceId) > 0 &&
!!sourceConfig &&
+ !sourceConfig.duplicateOf &&
this._canDuplicateProvider(sourceId, sourceConfig) &&
sourceConfig.configured === true &&
sourceConfig.type === config.type;
@@ -1958,6 +1968,12 @@ export class ProviderManager {
}
const current = this.providers.get(id).config;
const updates = this._storedDefaultOverride(current, config);
+ if (Object.hasOwn(updates, 'label')) {
+ if (typeof updates.label !== 'string' || !updates.label.trim() || updates.label.trim().length > 120) {
+ throw new Error('Provider title must contain between 1 and 120 characters.');
+ }
+ updates.label = updates.label.trim();
+ }
for (const key of ['id', 'duplicateOf', 'sourceProviderId', 'isDuplicate', 'hasDuplicate', 'canDuplicate']) {
delete updates[key];
}
@@ -2054,19 +2070,19 @@ export class ProviderManager {
if (source.config.configured !== true) {
throw new Error(`Save provider before duplicating it: ${id}`);
}
- const duplicateId = this._duplicateProviderId(id);
- if (this.providers.has(duplicateId) || [...this.providers.values()].some(provider => provider.config?.duplicateOf === id)) {
- throw new Error(`${source.config.label || id} already has a duplicate.`);
- }
+ const sourceId = this._providerDefinitionId(id, source.config);
+ let number = 1;
+ while (this.providers.has(this._duplicateProviderId(sourceId, number))) number++;
+ const duplicateId = this._duplicateProviderId(sourceId, number);
- const baseline = this._defaultConfigs()[id];
+ const baseline = this._defaultConfigs()[sourceId];
if (!baseline || baseline.type !== source.config.type) {
throw new Error(`Provider definition not found: ${id}`);
}
const duplicateConfig = structuredClone(baseline);
for (const key of DUPLICATE_BLANK_CONFIG_KEYS) delete duplicateConfig[key];
- duplicateConfig.duplicateOf = id;
- duplicateConfig.label = `${baseline.label || id} 2`;
+ duplicateConfig.duplicateOf = sourceId;
+ duplicateConfig.label = `${baseline.label || sourceId} ${number + 1}`;
duplicateConfig.configured = false;
this.providers.set(duplicateId, this._createProvider(duplicateId, duplicateConfig));
try {
@@ -2075,7 +2091,7 @@ export class ProviderManager {
this.providers.delete(duplicateId);
throw error;
}
- return { providerId: duplicateId, sourceProviderId: id };
+ return { providerId: duplicateId, sourceProviderId: sourceId };
}
/** Keep the persisted active ID valid when the selected duplicate disappears. */
@@ -2123,18 +2139,22 @@ export class ProviderManager {
const duplicateEntriesBySourceId = new Map();
for (const entry of this.providers) {
const sourceId = entry[1].config?.duplicateOf;
- if (sourceId) duplicateEntriesBySourceId.set(sourceId, entry);
+ if (!sourceId) continue;
+ if (!duplicateEntriesBySourceId.has(sourceId)) duplicateEntriesBySourceId.set(sourceId, []);
+ duplicateEntriesBySourceId.get(sourceId).push(entry);
+ }
+ for (const [sourceId, entries] of duplicateEntriesBySourceId) {
+ entries.sort((a, b) => this._duplicateProviderNumber(a[0], sourceId) - this._duplicateProviderNumber(b[0], sourceId));
}
const orderedEntries = [];
for (const entry of this.providers) {
const [id, provider] = entry;
if (provider.config?.duplicateOf) continue;
orderedEntries.push(entry);
- const duplicateEntry = duplicateEntriesBySourceId.get(id);
- if (duplicateEntry) orderedEntries.push(duplicateEntry);
+ orderedEntries.push(...(duplicateEntriesBySourceId.get(id) || []));
}
- for (const entry of duplicateEntriesBySourceId.values()) {
- if (!this.providers.has(entry[1].config?.duplicateOf)) orderedEntries.push(entry);
+ for (const [sourceId, entries] of duplicateEntriesBySourceId) {
+ if (!this.providers.has(sourceId)) orderedEntries.push(...entries);
}
for (const [id, provider] of orderedEntries) {
const config = provider.config;
@@ -2147,7 +2167,7 @@ export class ProviderManager {
sourceProviderId: this._providerDefinitionId(id, config),
isDuplicate,
hasDuplicate,
- canDuplicate: this._canDuplicateProvider(id, config) && !hasDuplicate,
+ canDuplicate: this._canDuplicateProvider(id, config),
};
}
return result;
diff --git a/src/chrome/src/ui/locales/ar.js b/src/chrome/src/ui/locales/ar.js
index 0a6f4da4e..a3c3963c3 100644
--- a/src/chrome/src/ui/locales/ar.js
+++ b/src/chrome/src/ui/locales/ar.js
@@ -8,6 +8,7 @@ import { getApocalypseModeCopy } from './apocalypse-copy.mjs';
import { getEmergencyBoxCopy } from './emergency-copy.mjs';
export default {
+ 'st.providers.title': 'عنوان المزوّد',
...getGenerativeMediaCopy('ar'),
...bidiCopy,
...cloudBridgeCopy,
diff --git a/src/chrome/src/ui/locales/bn.js b/src/chrome/src/ui/locales/bn.js
index 57304316e..25a7d5243 100644
--- a/src/chrome/src/ui/locales/bn.js
+++ b/src/chrome/src/ui/locales/bn.js
@@ -6,6 +6,7 @@ import { getApocalypseModeCopy } from './apocalypse-copy.mjs';
import { getEmergencyBoxCopy } from './emergency-copy.mjs';
export default {
+ 'st.providers.title': 'প্রদানকারীর নাম',
...getGenerativeMediaCopy('bn'),
...bidiCopy,
...cloudBridgeCopy,
diff --git a/src/chrome/src/ui/locales/de.js b/src/chrome/src/ui/locales/de.js
index 9026d21ff..67c4eb94c 100644
--- a/src/chrome/src/ui/locales/de.js
+++ b/src/chrome/src/ui/locales/de.js
@@ -8,6 +8,7 @@ import { getApocalypseModeCopy } from './apocalypse-copy.mjs';
import { getEmergencyBoxCopy } from './emergency-copy.mjs';
export default {
+ 'st.providers.title': 'Anbietername',
...getGenerativeMediaCopy('de'),
...bidiCopy,
...cloudBridgeCopy,
diff --git a/src/chrome/src/ui/locales/en.js b/src/chrome/src/ui/locales/en.js
index f97d56bb2..2e8cd22ab 100644
--- a/src/chrome/src/ui/locales/en.js
+++ b/src/chrome/src/ui/locales/en.js
@@ -6,6 +6,7 @@ import apocalypseModeCopy from './apocalypse-copy.mjs';
import emergencyCopy from './emergency-copy.mjs';
export default {
+ 'st.providers.title': 'Provider title',
...getGenerativeMediaCopy('en'),
...bidiCopy,
...cloudBridgeCopy,
diff --git a/src/chrome/src/ui/locales/es.js b/src/chrome/src/ui/locales/es.js
index ffd7a76e9..6c1463bfd 100644
--- a/src/chrome/src/ui/locales/es.js
+++ b/src/chrome/src/ui/locales/es.js
@@ -8,6 +8,7 @@ import { getApocalypseModeCopy } from './apocalypse-copy.mjs';
import { getEmergencyBoxCopy } from './emergency-copy.mjs';
export default {
+ 'st.providers.title': 'Nombre del proveedor',
...getGenerativeMediaCopy('es'),
...bidiCopy,
...cloudBridgeCopy,
diff --git a/src/chrome/src/ui/locales/fa.js b/src/chrome/src/ui/locales/fa.js
index b208e7643..bb11d40ba 100644
--- a/src/chrome/src/ui/locales/fa.js
+++ b/src/chrome/src/ui/locales/fa.js
@@ -6,6 +6,7 @@ import { getApocalypseModeCopy } from './apocalypse-copy.mjs';
import { getEmergencyBoxCopy } from './emergency-copy.mjs';
export default {
+ 'st.providers.title': 'نام ارائه‌دهنده',
...getGenerativeMediaCopy('fa'),
...bidiCopy,
...cloudBridgeCopy,
diff --git a/src/chrome/src/ui/locales/fr.js b/src/chrome/src/ui/locales/fr.js
index 5b63a1a62..619f5753b 100644
--- a/src/chrome/src/ui/locales/fr.js
+++ b/src/chrome/src/ui/locales/fr.js
@@ -8,6 +8,7 @@ import { getApocalypseModeCopy } from './apocalypse-copy.mjs';
import { getEmergencyBoxCopy } from './emergency-copy.mjs';
export default {
+ 'st.providers.title': 'Nom du fournisseur',
...getGenerativeMediaCopy('fr'),
...bidiCopy,
...cloudBridgeCopy,
diff --git a/src/chrome/src/ui/locales/he.js b/src/chrome/src/ui/locales/he.js
index 4fdd81106..0107b207c 100644
--- a/src/chrome/src/ui/locales/he.js
+++ b/src/chrome/src/ui/locales/he.js
@@ -8,6 +8,7 @@ import { getApocalypseModeCopy } from './apocalypse-copy.mjs';
import { getEmergencyBoxCopy } from './emergency-copy.mjs';
export default {
+ 'st.providers.title': 'שם הספק',
...getGenerativeMediaCopy('he'),
...bidiCopy,
...cloudBridgeCopy,
diff --git a/src/chrome/src/ui/locales/hi.js b/src/chrome/src/ui/locales/hi.js
index f1da00a1e..fb9b08dd8 100644
--- a/src/chrome/src/ui/locales/hi.js
+++ b/src/chrome/src/ui/locales/hi.js
@@ -6,6 +6,7 @@ import { getApocalypseModeCopy } from './apocalypse-copy.mjs';
import { getEmergencyBoxCopy } from './emergency-copy.mjs';
export default {
+ 'st.providers.title': 'प्रदाता का नाम',
...getGenerativeMediaCopy('hi'),
...bidiCopy,
...cloudBridgeCopy,
diff --git a/src/chrome/src/ui/locales/id.js b/src/chrome/src/ui/locales/id.js
index d8edc0c2c..752cc764e 100644
--- a/src/chrome/src/ui/locales/id.js
+++ b/src/chrome/src/ui/locales/id.js
@@ -8,6 +8,7 @@ import { getApocalypseModeCopy } from './apocalypse-copy.mjs';
import { getEmergencyBoxCopy } from './emergency-copy.mjs';
export default {
+ 'st.providers.title': 'Nama penyedia',
...getGenerativeMediaCopy('id'),
...bidiCopy,
...cloudBridgeCopy,
diff --git a/src/chrome/src/ui/locales/ja.js b/src/chrome/src/ui/locales/ja.js
index d837349ce..e17613ed6 100644
--- a/src/chrome/src/ui/locales/ja.js
+++ b/src/chrome/src/ui/locales/ja.js
@@ -8,6 +8,7 @@ import { getApocalypseModeCopy } from './apocalypse-copy.mjs';
import { getEmergencyBoxCopy } from './emergency-copy.mjs';
export default {
+ 'st.providers.title': 'プロバイダー名',
...getGenerativeMediaCopy('ja'),
...bidiCopy,
...cloudBridgeCopy,
diff --git a/src/chrome/src/ui/locales/ko.js b/src/chrome/src/ui/locales/ko.js
index 76327fb3a..664590614 100644
--- a/src/chrome/src/ui/locales/ko.js
+++ b/src/chrome/src/ui/locales/ko.js
@@ -8,6 +8,7 @@ import { getApocalypseModeCopy } from './apocalypse-copy.mjs';
import { getEmergencyBoxCopy } from './emergency-copy.mjs';
export default {
+ 'st.providers.title': '공급자 이름',
...getGenerativeMediaCopy('ko'),
...bidiCopy,
...cloudBridgeCopy,
diff --git a/src/chrome/src/ui/locales/ms.js b/src/chrome/src/ui/locales/ms.js
index ff3a908db..de9fb804b 100644
--- a/src/chrome/src/ui/locales/ms.js
+++ b/src/chrome/src/ui/locales/ms.js
@@ -8,6 +8,7 @@ import { getApocalypseModeCopy } from './apocalypse-copy.mjs';
import { getEmergencyBoxCopy } from './emergency-copy.mjs';
export default {
+ 'st.providers.title': 'Nama penyedia',
...getGenerativeMediaCopy('ms'),
...bidiCopy,
...cloudBridgeCopy,
diff --git a/src/chrome/src/ui/locales/nl.js b/src/chrome/src/ui/locales/nl.js
index 9bed53a26..d2c7c4428 100644
--- a/src/chrome/src/ui/locales/nl.js
+++ b/src/chrome/src/ui/locales/nl.js
@@ -8,6 +8,7 @@ import { getApocalypseModeCopy } from './apocalypse-copy.mjs';
import { getEmergencyBoxCopy } from './emergency-copy.mjs';
export default {
+ 'st.providers.title': 'Providernaam',
...getGenerativeMediaCopy('nl'),
...bidiCopy,
...cloudBridgeCopy,
diff --git a/src/chrome/src/ui/locales/pl.js b/src/chrome/src/ui/locales/pl.js
index 4fdf1e5e5..3779ccbd4 100644
--- a/src/chrome/src/ui/locales/pl.js
+++ b/src/chrome/src/ui/locales/pl.js
@@ -8,6 +8,7 @@ import { getApocalypseModeCopy } from './apocalypse-copy.mjs';
import { getEmergencyBoxCopy } from './emergency-copy.mjs';
export default {
+ 'st.providers.title': 'Nazwa dostawcy',
...getGenerativeMediaCopy('pl'),
...bidiCopy,
...cloudBridgeCopy,
diff --git a/src/chrome/src/ui/locales/pt.js b/src/chrome/src/ui/locales/pt.js
index 4452afe32..a19fa0461 100644
--- a/src/chrome/src/ui/locales/pt.js
+++ b/src/chrome/src/ui/locales/pt.js
@@ -6,6 +6,7 @@ import { getApocalypseModeCopy } from './apocalypse-copy.mjs';
import { getEmergencyBoxCopy } from './emergency-copy.mjs';
export default {
+ 'st.providers.title': 'Nome do provedor',
...getGenerativeMediaCopy('pt'),
...bidiCopy,
...cloudBridgeCopy,
diff --git a/src/chrome/src/ui/locales/ru.js b/src/chrome/src/ui/locales/ru.js
index 18e0675a6..f687e1d43 100644
--- a/src/chrome/src/ui/locales/ru.js
+++ b/src/chrome/src/ui/locales/ru.js
@@ -8,6 +8,7 @@ import { getApocalypseModeCopy } from './apocalypse-copy.mjs';
import { getEmergencyBoxCopy } from './emergency-copy.mjs';
export default {
+ 'st.providers.title': 'Название провайдера',
...getGenerativeMediaCopy('ru'),
...bidiCopy,
...cloudBridgeCopy,
diff --git a/src/chrome/src/ui/locales/th.js b/src/chrome/src/ui/locales/th.js
index 4946f436c..ae52a073d 100644
--- a/src/chrome/src/ui/locales/th.js
+++ b/src/chrome/src/ui/locales/th.js
@@ -8,6 +8,7 @@ import { getApocalypseModeCopy } from './apocalypse-copy.mjs';
import { getEmergencyBoxCopy } from './emergency-copy.mjs';
export default {
+ 'st.providers.title': 'ชื่อผู้ให้บริการ',
...getGenerativeMediaCopy('th'),
...bidiCopy,
...cloudBridgeCopy,
diff --git a/src/chrome/src/ui/locales/tl.js b/src/chrome/src/ui/locales/tl.js
index 703020ed2..95995a524 100644
--- a/src/chrome/src/ui/locales/tl.js
+++ b/src/chrome/src/ui/locales/tl.js
@@ -8,6 +8,7 @@ import { getApocalypseModeCopy } from './apocalypse-copy.mjs';
import { getEmergencyBoxCopy } from './emergency-copy.mjs';
export default {
+ 'st.providers.title': 'Pangalan ng provider',
...getGenerativeMediaCopy('tl'),
...bidiCopy,
...cloudBridgeCopy,
diff --git a/src/chrome/src/ui/locales/tr.js b/src/chrome/src/ui/locales/tr.js
index 0d933093c..8f83a0783 100644
--- a/src/chrome/src/ui/locales/tr.js
+++ b/src/chrome/src/ui/locales/tr.js
@@ -8,6 +8,7 @@ import { getApocalypseModeCopy } from './apocalypse-copy.mjs';
import { getEmergencyBoxCopy } from './emergency-copy.mjs';
export default {
+ 'st.providers.title': 'Sağlayıcı adı',
...getGenerativeMediaCopy('tr'),
...bidiCopy,
...cloudBridgeCopy,
diff --git a/src/chrome/src/ui/locales/uk.js b/src/chrome/src/ui/locales/uk.js
index 7cc7709f6..c095d30f1 100644
--- a/src/chrome/src/ui/locales/uk.js
+++ b/src/chrome/src/ui/locales/uk.js
@@ -8,6 +8,7 @@ import { getApocalypseModeCopy } from './apocalypse-copy.mjs';
import { getEmergencyBoxCopy } from './emergency-copy.mjs';
export default {
+ 'st.providers.title': 'Назва постачальника',
...getGenerativeMediaCopy('uk'),
...bidiCopy,
...cloudBridgeCopy,
diff --git a/src/chrome/src/ui/locales/vi.js b/src/chrome/src/ui/locales/vi.js
index 228a8f468..ec524628e 100644
--- a/src/chrome/src/ui/locales/vi.js
+++ b/src/chrome/src/ui/locales/vi.js
@@ -6,6 +6,7 @@ import { getApocalypseModeCopy } from './apocalypse-copy.mjs';
import { getEmergencyBoxCopy } from './emergency-copy.mjs';
export default {
+ 'st.providers.title': 'Tên nhà cung cấp',
...getGenerativeMediaCopy('vi'),
...bidiCopy,
...cloudBridgeCopy,
diff --git a/src/chrome/src/ui/locales/zh.js b/src/chrome/src/ui/locales/zh.js
index 77a44936e..2b2d44326 100644
--- a/src/chrome/src/ui/locales/zh.js
+++ b/src/chrome/src/ui/locales/zh.js
@@ -8,6 +8,7 @@ import { getApocalypseModeCopy } from './apocalypse-copy.mjs';
import { getEmergencyBoxCopy } from './emergency-copy.mjs';
export default {
+ 'st.providers.title': '服务商名称',
...getGenerativeMediaCopy('zh'),
...bidiCopy,
...cloudBridgeCopy,
diff --git a/src/chrome/src/ui/settings.html b/src/chrome/src/ui/settings.html
index 4c2ddc551..85a18e451 100644
--- a/src/chrome/src/ui/settings.html
+++ b/src/chrome/src/ui/settings.html
@@ -300,6 +300,7 @@
.provider-card.collapsed .provider-header { margin-bottom: 0; }
.provider-card .btn-duplicate:disabled { cursor: not-allowed; opacity: 0.48; transform: none; }
+ .provider-card .btn-row { flex-wrap: wrap; }
.provider-header {
display: flex;
align-items: center;
@@ -310,6 +311,7 @@
.provider-header-clickable:hover .provider-name { color: var(--accent); }
.provider-header-left {
display: flex;
+ min-width: 0;
align-items: center;
gap: 8px;
flex-wrap: wrap;
@@ -468,7 +470,7 @@
.vision-local-option { grid-template-columns: 42px minmax(0, 1fr); }
.vision-local-action { grid-column: 2; justify-self: start; }
}
- .provider-name { font-weight: 600; font-size: 14px; }
+ .provider-name { font-weight: 600; font-size: 14px; overflow-wrap: anywhere; max-width: 100%; }
.provider-type { color: var(--text2); font-size: 11px; }
.provider-status-badges { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.provider-status-badge {
diff --git a/src/chrome/src/ui/settings.js b/src/chrome/src/ui/settings.js
index 3e715adaa..b941bcfe5 100644
--- a/src/chrome/src/ui/settings.js
+++ b/src/chrome/src/ui/settings.js
@@ -3741,15 +3741,18 @@ function renderProviders() {
</aside>`
: '';
const compatibilitySettings = renderProviderCompatibilitySettings(id, config);
- const duplicateDisabledKey = config.hasDuplicate
- ? 'st.providers.duplicate_limit'
- : (!config.canDuplicate
- ? 'st.providers.duplicate_unavailable'
- : ((!isConfigured || dirtyProviderIds.has(id)) ? 'st.providers.duplicate_inactive' : ''));
+ const duplicateDisabledKey = !config.canDuplicate
+ ? 'st.providers.duplicate_unavailable'
+ : ((!isConfigured || dirtyProviderIds.has(id)) ? 'st.providers.duplicate_inactive' : '');
const subscriptionGuide = providerSubscriptionGuideHtml(definitionId);
const body = `
${subscriptionGuide}
+ ${id !== 'webbrain_cloud' ? `<div class="field">
+ <label for="provider-title-${id}">${escapeHtml(t('st.providers.title'))}</label>
+ <input id="provider-title-${id}" type="text" data-provider="${id}" data-key="label"
+ value="${escapeHtml(config.label || id)}" maxlength="120" required>
+ </div>` : ''}
${fieldsHTML}
${providerNote}
${id === 'webbrain_cloud' ? '<div class="webbrain-payment-notice" role="status" hidden></div>' : ''}
@@ -3761,9 +3764,8 @@ function renderProviders() {
${definitionId === 'webgpu' ? `<button class="btn-secondary btn-webgpu-download" data-provider="${id}">${escapeHtml(t('st.providers.webgpu_download.start'))}</button>` : ''}
${billingButton}
${!isSelected ? `<button class="btn-secondary btn-activate" data-provider="${id}">${escapeHtml(t('st.providers.select_for_chat'))}</button>` : ''}
- ${config.isDuplicate
- ? `<button class="btn-secondary btn-remove-duplicate" data-provider="${id}">${escapeHtml(t('st.providers.remove_duplicate'))}</button>`
- : `<button class="btn-secondary btn-duplicate" data-provider="${id}"${duplicateDisabledKey ? ` disabled title="${escapeHtml(t(duplicateDisabledKey))}"` : ''}>${escapeHtml(t('st.providers.duplicate'))}</button>`}
+ <button class="btn-secondary btn-duplicate" data-provider="${id}"${duplicateDisabledKey ? ` disabled title="${escapeHtml(t(duplicateDisabledKey))}"` : ''}>${escapeHtml(t('st.providers.duplicate'))}</button>
+ ${config.isDuplicate ? `<button class="btn-secondary btn-remove-duplicate" data-provider="${id}">${escapeHtml(t('st.providers.remove_duplicate'))}</button>` : ''}
</div>
${definitionId === 'webgpu' ? `<div class="webgpu-download-status" data-webgpu-download-status="${id}" style="margin-top:8px;font-size:12px;color:var(--text2);">${escapeHtml(t('st.providers.webgpu_download.checking'))}</div>` : ''}
<div class="test-result" id="test-${id}"></div>
@@ -3788,7 +3790,7 @@ function renderProviders() {
restoreProviderApiKeyWarnings();
document.querySelectorAll('.btn-save').forEach(btn => {
- btn.addEventListener('click', () => saveProvider(btn.dataset.provider));
+ btn.addEventListener('click', () => saveProvider(btn.dataset.provider).catch(() => {}));
});
document.querySelectorAll('.btn-test').forEach(btn => {
btn.addEventListener('click', () => testProvider(btn.dataset.provider));
@@ -4258,6 +4260,7 @@ async function saveProvider(id, { showFlash = true, markConfigured = true } = {}
: providerInputValue(input);
setProviderConfigValue(config, input.dataset.key, value);
});
+ if (typeof config.label === 'string') config.label = config.label.trim();
apiKeyWarning = providerApiKeyWarning(id, config);
const updateRes = await sendToBackground('update_provider', { providerId: id, config, markConfigured });
// updateProvider may fall back to another active provider (e.g. the active
@@ -4332,12 +4335,14 @@ function refreshProviderCardStatus(id) {
card.classList.toggle('configured', isConfigured);
card.classList.toggle('selected', isSelected);
const duplicateButton = card.querySelector('.btn-duplicate');
- if (duplicateButton && providersData[id]?.canDuplicate && !providersData[id]?.hasDuplicate) {
+ if (duplicateButton && providersData[id]?.canDuplicate) {
const requiresSave = !isConfigured || dirtyProviderIds.has(id);
duplicateButton.disabled = requiresSave;
if (!requiresSave) duplicateButton.removeAttribute('title');
else duplicateButton.title = t('st.providers.duplicate_inactive');
}
+ const name = card.querySelector('.provider-name');
+ if (name) name.textContent = providersData[id]?.label || id;
const badges = card.querySelector('.provider-status-badges');
if (!badges) return;
badges.innerHTML = `
@@ -4434,7 +4439,13 @@ async function duplicateProvider(id) {
activeProviderId = refreshed.active;
restoreProviderDrafts(providerDrafts);
expandedProviders.add(created.providerId);
+ providerSearchQuery = '';
+ if (providerFilter !== 'all' && providerFilter !== providersData[created.providerId]?.category) {
+ providerFilter = 'all';
+ await chrome.storage.local.set({ providerFilter }).catch(() => {});
+ }
renderProviders();
+ document.querySelector(`.provider-card[data-provider-id="${created.providerId}"]`)?.scrollIntoView({ block: 'nearest' });
} catch (error) {
setProviderTestResult(id, 'fail', t('st.providers.failed', { error: error.message }));
}
diff --git a/src/firefox/src/providers/manager.js b/src/firefox/src/providers/manager.js
index f3066b1d0..d28aa6423 100644
--- a/src/firefox/src/providers/manager.js
+++ b/src/firefox/src/providers/manager.js
@@ -1120,12 +1120,21 @@ export class ProviderManager {
return String(config?.duplicateOf || id || '');
}
- _duplicateProviderId(id) {
- return `${id}${DUPLICATE_PROVIDER_SUFFIX}`;
+ _duplicateProviderId(id, number = 1) {
+ return `${id}${DUPLICATE_PROVIDER_SUFFIX}${number === 1 ? '' : `_${number}`}`;
+ }
+
+ _duplicateProviderNumber(id, sourceId) {
+ const prefix = this._duplicateProviderId(sourceId);
+ if (id === prefix) return 1;
+ if (!id.startsWith(`${prefix}_`)) return 0;
+ const suffix = id.slice(prefix.length + 1);
+ const number = Number(suffix);
+ return Number.isSafeInteger(number) && number >= 2 && String(number) === suffix ? number : 0;
}
_canDuplicateProvider(id, config = this.providers.get(id)?.config) {
- return !!config && !config.duplicateOf && id !== WEBBRAIN_CLOUD_PROVIDER_ID && config.type !== 'webgpu';
+ return !!config && this._providerDefinitionId(id, config) !== WEBBRAIN_CLOUD_PROVIDER_ID && config.type !== 'webgpu';
}
_isValidDuplicateConfig(id, config, configs) {
@@ -1133,8 +1142,9 @@ export class ProviderManager {
const sourceConfig = configs[sourceId];
return typeof sourceId === 'string' &&
SAFE_PROVIDER_ID_RE.test(sourceId) &&
- id === this._duplicateProviderId(sourceId) &&
+ this._duplicateProviderNumber(id, sourceId) > 0 &&
!!sourceConfig &&
+ !sourceConfig.duplicateOf &&
this._canDuplicateProvider(sourceId, sourceConfig) &&
sourceConfig.configured === true &&
sourceConfig.type === config.type;
@@ -1537,6 +1547,12 @@ export class ProviderManager {
}
const current = this.providers.get(id).config;
const updates = this._storedDefaultOverride(current, config);
+ if (Object.hasOwn(updates, 'label')) {
+ if (typeof updates.label !== 'string' || !updates.label.trim() || updates.label.trim().length > 120) {
+ throw new Error('Provider title must contain between 1 and 120 characters.');
+ }
+ updates.label = updates.label.trim();
+ }
for (const key of ['id', 'duplicateOf', 'sourceProviderId', 'isDuplicate', 'hasDuplicate', 'canDuplicate']) {
delete updates[key];
}
@@ -1600,19 +1616,19 @@ export class ProviderManager {
if (source.config.configured !== true) {
throw new Error(`Save provider before duplicating it: ${id}`);
}
- const duplicateId = this._duplicateProviderId(id);
- if (this.providers.has(duplicateId) || [...this.providers.values()].some(provider => provider.config?.duplicateOf === id)) {
- throw new Error(`${source.config.label || id} already has a duplicate.`);
- }
+ const sourceId = this._providerDefinitionId(id, source.config);
+ let number = 1;
+ while (this.providers.has(this._duplicateProviderId(sourceId, number))) number++;
+ const duplicateId = this._duplicateProviderId(sourceId, number);
- const baseline = this._defaultConfigs()[id];
+ const baseline = this._defaultConfigs()[sourceId];
if (!baseline || baseline.type !== source.config.type) {
throw new Error(`Provider definition not found: ${id}`);
}
const duplicateConfig = structuredClone(baseline);
for (const key of DUPLICATE_BLANK_CONFIG_KEYS) delete duplicateConfig[key];
- duplicateConfig.duplicateOf = id;
- duplicateConfig.label = `${baseline.label || id} 2`;
+ duplicateConfig.duplicateOf = sourceId;
+ duplicateConfig.label = `${baseline.label || sourceId} ${number + 1}`;
duplicateConfig.configured = false;
this.providers.set(duplicateId, this._createProvider(duplicateId, duplicateConfig));
try {
@@ -1621,7 +1637,7 @@ export class ProviderManager {
this.providers.delete(duplicateId);
throw error;
}
- return { providerId: duplicateId, sourceProviderId: id };
+ return { providerId: duplicateId, sourceProviderId: sourceId };
}
/** Keep the persisted active ID valid when the selected duplicate disappears. */
@@ -1669,18 +1685,22 @@ export class ProviderManager {
const duplicateEntriesBySourceId = new Map();
for (const entry of this.providers) {
const sourceId = entry[1].config?.duplicateOf;
- if (sourceId) duplicateEntriesBySourceId.set(sourceId, entry);
+ if (!sourceId) continue;
+ if (!duplicateEntriesBySourceId.has(sourceId)) duplicateEntriesBySourceId.set(sourceId, []);
+ duplicateEntriesBySourceId.get(sourceId).push(entry);
+ }
+ for (const [sourceId, entries] of duplicateEntriesBySourceId) {
+ entries.sort((a, b) => this._duplicateProviderNumber(a[0], sourceId) - this._duplicateProviderNumber(b[0], sourceId));
}
const orderedEntries = [];
for (const entry of this.providers) {
const [id, provider] = entry;
if (provider.config?.duplicateOf) continue;
orderedEntries.push(entry);
- const duplicateEntry = duplicateEntriesBySourceId.get(id);
- if (duplicateEntry) orderedEntries.push(duplicateEntry);
+ orderedEntries.push(...(duplicateEntriesBySourceId.get(id) || []));
}
- for (const entry of duplicateEntriesBySourceId.values()) {
- if (!this.providers.has(entry[1].config?.duplicateOf)) orderedEntries.push(entry);
+ for (const [sourceId, entries] of duplicateEntriesBySourceId) {
+ if (!this.providers.has(sourceId)) orderedEntries.push(...entries);
}
for (const [id, provider] of orderedEntries) {
const config = provider.config;
@@ -1693,7 +1713,7 @@ export class ProviderManager {
sourceProviderId: this._providerDefinitionId(id, config),
isDuplicate,
hasDuplicate,
- canDuplicate: this._canDuplicateProvider(id, config) && !hasDuplicate,
+ canDuplicate: this._canDuplicateProvider(id, config),
};
}
return result;
diff --git a/src/firefox/src/ui/locales/ar.js b/src/firefox/src/ui/locales/ar.js
index c6b55f3db..5cd17f748 100644
--- a/src/firefox/src/ui/locales/ar.js
+++ b/src/firefox/src/ui/locales/ar.js
@@ -8,6 +8,7 @@ import { getApocalypseModeCopy } from './apocalypse-copy.mjs';
import { getEmergencyBoxCopy } from './emergency-copy.mjs';
export default {
+ 'st.providers.title': 'عنوان المزوّد',
...getGenerativeMediaCopy('ar'),
...bidiCopy,
...cloudBridgeCopy,
diff --git a/src/firefox/src/ui/locales/bn.js b/src/firefox/src/ui/locales/bn.js
index 0f931b1a2..478a4b623 100644
--- a/src/firefox/src/ui/locales/bn.js
+++ b/src/firefox/src/ui/locales/bn.js
@@ -6,6 +6,7 @@ import { getApocalypseModeCopy } from './apocalypse-copy.mjs';
import { getEmergencyBoxCopy } from './emergency-copy.mjs';
export default {
+ 'st.providers.title': 'প্রদানকারীর নাম',
...getGenerativeMediaCopy('bn'),
...bidiCopy,
...cloudBridgeCopy,
diff --git a/src/firefox/src/ui/locales/de.js b/src/firefox/src/ui/locales/de.js
index 7e239ce4f..143e2f09c 100644
--- a/src/firefox/src/ui/locales/de.js
+++ b/src/firefox/src/ui/locales/de.js
@@ -8,6 +8,7 @@ import { getApocalypseModeCopy } from './apocalypse-copy.mjs';
import { getEmergencyBoxCopy } from './emergency-copy.mjs';
export default {
+ 'st.providers.title': 'Anbietername',
...getGenerativeMediaCopy('de'),
...bidiCopy,
...cloudBridgeCopy,
diff --git a/src/firefox/src/ui/locales/en.js b/src/firefox/src/ui/locales/en.js
index 2ef2c5e70..9fc2a6cc5 100644
--- a/src/firefox/src/ui/locales/en.js
+++ b/src/firefox/src/ui/locales/en.js
@@ -6,6 +6,7 @@ import apocalypseModeCopy from './apocalypse-copy.mjs';
import emergencyCopy from './emergency-copy.mjs';
export default {
+ 'st.providers.title': 'Provider title',
...getGenerativeMediaCopy('en'),
...bidiCopy,
...cloudBridgeCopy,
diff --git a/src/firefox/src/ui/locales/es.js b/src/firefox/src/ui/locales/es.js
index 528dcdf26..e261f544e 100644
--- a/src/firefox/src/ui/locales/es.js
+++ b/src/firefox/src/ui/locales/es.js
@@ -8,6 +8,7 @@ import { getApocalypseModeCopy } from './apocalypse-copy.mjs';
import { getEmergencyBoxCopy } from './emergency-copy.mjs';
export default {
+ 'st.providers.title': 'Nombre del proveedor',
...getGenerativeMediaCopy('es'),
...bidiCopy,
...cloudBridgeCopy,
diff --git a/src/firefox/src/ui/locales/fa.js b/src/firefox/src/ui/locales/fa.js
index f20dd6655..db6918ad7 100644
--- a/src/firefox/src/ui/locales/fa.js
+++ b/src/firefox/src/ui/locales/fa.js
@@ -6,6 +6,7 @@ import { getApocalypseModeCopy } from './apocalypse-copy.mjs';
import { getEmergencyBoxCopy } from './emergency-copy.mjs';
export default {
+ 'st.providers.title': 'نام ارائه‌دهنده',
...getGenerativeMediaCopy('fa'),
...bidiCopy,
...cloudBridgeCopy,
diff --git a/src/firefox/src/ui/locales/fr.js b/src/firefox/src/ui/locales/fr.js
index d989be4a6..4a4913591 100644
--- a/src/firefox/src/ui/locales/fr.js
+++ b/src/firefox/src/ui/locales/fr.js
@@ -8,6 +8,7 @@ import { getApocalypseModeCopy } from './apocalypse-copy.mjs';
import { getEmergencyBoxCopy } from './emergency-copy.mjs';
export default {
+ 'st.providers.title': 'Nom du fournisseur',
...getGenerativeMediaCopy('fr'),
...bidiCopy,
...cloudBridgeCopy,
diff --git a/src/firefox/src/ui/locales/he.js b/src/firefox/src/ui/locales/he.js
index e2550cc67..960b67e06 100644
--- a/src/firefox/src/ui/locales/he.js
+++ b/src/firefox/src/ui/locales/he.js
@@ -8,6 +8,7 @@ import { getApocalypseModeCopy } from './apocalypse-copy.mjs';
import { getEmergencyBoxCopy } from './emergency-copy.mjs';
export default {
+ 'st.providers.title': 'שם הספק',
...getGenerativeMediaCopy('he'),
...bidiCopy,
...cloudBridgeCopy,
diff --git a/src/firefox/src/ui/locales/hi.js b/src/firefox/src/ui/locales/hi.js
index 947f325d1..011a420a8 100644
--- a/src/firefox/src/ui/locales/hi.js
+++ b/src/firefox/src/ui/locales/hi.js
@@ -6,6 +6,7 @@ import { getApocalypseModeCopy } from './apocalypse-copy.mjs';
import { getEmergencyBoxCopy } from './emergency-copy.mjs';
export default {
+ 'st.providers.title': 'प्रदाता का नाम',
...getGenerativeMediaCopy('hi'),
...bidiCopy,
...cloudBridgeCopy,
diff --git a/src/firefox/src/ui/locales/id.js b/src/firefox/src/ui/locales/id.js
index ce262c42c..31572f154 100644
--- a/src/firefox/src/ui/locales/id.js
+++ b/src/firefox/src/ui/locales/id.js
@@ -8,6 +8,7 @@ import { getApocalypseModeCopy } from './apocalypse-copy.mjs';
import { getEmergencyBoxCopy } from './emergency-copy.mjs';
export default {
+ 'st.providers.title': 'Nama penyedia',
...getGenerativeMediaCopy('id'),
...bidiCopy,
...cloudBridgeCopy,
diff --git a/src/firefox/src/ui/locales/ja.js b/src/firefox/src/ui/locales/ja.js
index 895f3f37d..95808353e 100644
--- a/src/firefox/src/ui/locales/ja.js
+++ b/src/firefox/src/ui/locales/ja.js
@@ -8,6 +8,7 @@ import { getApocalypseModeCopy } from './apocalypse-copy.mjs';
import { getEmergencyBoxCopy } from './emergency-copy.mjs';
export default {
+ 'st.providers.title': 'プロバイダー名',
...getGenerativeMediaCopy('ja'),
...bidiCopy,
...cloudBridgeCopy,
diff --git a/src/firefox/src/ui/locales/ko.js b/src/firefox/src/ui/locales/ko.js
index d97d386fc..9b3596c34 100644
--- a/src/firefox/src/ui/locales/ko.js
+++ b/src/firefox/src/ui/locales/ko.js
@@ -8,6 +8,7 @@ import { getApocalypseModeCopy } from './apocalypse-copy.mjs';
import { getEmergencyBoxCopy } from './emergency-copy.mjs';
export default {
+ 'st.providers.title': '공급자 이름',
...getGenerativeMediaCopy('ko'),
...bidiCopy,
...cloudBridgeCopy,
diff --git a/src/firefox/src/ui/locales/ms.js b/src/firefox/src/ui/locales/ms.js
index f9b6ed2b5..4bda2b8cf 100644
--- a/src/firefox/src/ui/locales/ms.js
+++ b/src/firefox/src/ui/locales/ms.js
@@ -8,6 +8,7 @@ import { getApocalypseModeCopy } from './apocalypse-copy.mjs';
import { getEmergencyBoxCopy } from './emergency-copy.mjs';
export default {
+ 'st.providers.title': 'Nama penyedia',
...getGenerativeMediaCopy('ms'),
...bidiCopy,
...cloudBridgeCopy,
diff --git a/src/firefox/src/ui/locales/nl.js b/src/firefox/src/ui/locales/nl.js
index d8802096b..73662c85a 100644
--- a/src/firefox/src/ui/locales/nl.js
+++ b/src/firefox/src/ui/locales/nl.js
@@ -8,6 +8,7 @@ import { getApocalypseModeCopy } from './apocalypse-copy.mjs';
import { getEmergencyBoxCopy } from './emergency-copy.mjs';
export default {
+ 'st.providers.title': 'Providernaam',
...getGenerativeMediaCopy('nl'),
...bidiCopy,
...cloudBridgeCopy,
diff --git a/src/firefox/src/ui/locales/pl.js b/src/firefox/src/ui/locales/pl.js
index 5a600a15a..826bf0a46 100644
--- a/src/firefox/src/ui/locales/pl.js
+++ b/src/firefox/src/ui/locales/pl.js
@@ -8,6 +8,7 @@ import { getApocalypseModeCopy } from './apocalypse-copy.mjs';
import { getEmergencyBoxCopy } from './emergency-copy.mjs';
export default {
+ 'st.providers.title': 'Nazwa dostawcy',
...getGenerativeMediaCopy('pl'),
...bidiCopy,
...cloudBridgeCopy,
diff --git a/src/firefox/src/ui/locales/pt.js b/src/firefox/src/ui/locales/pt.js
index 782bb9ecf..d590de2e3 100644
--- a/src/firefox/src/ui/locales/pt.js
+++ b/src/firefox/src/ui/locales/pt.js
@@ -6,6 +6,7 @@ import { getApocalypseModeCopy } from './apocalypse-copy.mjs';
import { getEmergencyBoxCopy } from './emergency-copy.mjs';
export default {
+ 'st.providers.title': 'Nome do provedor',
...getGenerativeMediaCopy('pt'),
...bidiCopy,
...cloudBridgeCopy,
diff --git a/src/firefox/src/ui/locales/ru.js b/src/firefox/src/ui/locales/ru.js
index d58c637ee..f5f48d5b1 100644
--- a/src/firefox/src/ui/locales/ru.js
+++ b/src/firefox/src/ui/locales/ru.js
@@ -8,6 +8,7 @@ import { getApocalypseModeCopy } from './apocalypse-copy.mjs';
import { getEmergencyBoxCopy } from './emergency-copy.mjs';
export default {
+ 'st.providers.title': 'Название провайдера',
...getGenerativeMediaCopy('ru'),
...bidiCopy,
...cloudBridgeCopy,
diff --git a/src/firefox/src/ui/locales/th.js b/src/firefox/src/ui/locales/th.js
index 814c493c8..dea975ee0 100644
--- a/src/firefox/src/ui/locales/th.js
+++ b/src/firefox/src/ui/locales/th.js
@@ -8,6 +8,7 @@ import { getApocalypseModeCopy } from './apocalypse-copy.mjs';
import { getEmergencyBoxCopy } from './emergency-copy.mjs';
export default {
+ 'st.providers.title': 'ชื่อผู้ให้บริการ',
...getGenerativeMediaCopy('th'),
...bidiCopy,
...cloudBridgeCopy,
diff --git a/src/firefox/src/ui/locales/tl.js b/src/firefox/src/ui/locales/tl.js
index e4f040d61..628b162f3 100644
--- a/src/firefox/src/ui/locales/tl.js
+++ b/src/firefox/src/ui/locales/tl.js
@@ -8,6 +8,7 @@ import { getApocalypseModeCopy } from './apocalypse-copy.mjs';
import { getEmergencyBoxCopy } from './emergency-copy.mjs';
export default {
+ 'st.providers.title': 'Pangalan ng provider',
...getGenerativeMediaCopy('tl'),
...bidiCopy,
...cloudBridgeCopy,
diff --git a/src/firefox/src/ui/locales/tr.js b/src/firefox/src/ui/locales/tr.js
index c716fb555..4db886f2f 100644
--- a/src/firefox/src/ui/locales/tr.js
+++ b/src/firefox/src/ui/locales/tr.js
@@ -8,6 +8,7 @@ import { getApocalypseModeCopy } from './apocalypse-copy.mjs';
import { getEmergencyBoxCopy } from './emergency-copy.mjs';
export default {
+ 'st.providers.title': 'Sağlayıcı adı',
...getGenerativeMediaCopy('tr'),
...bidiCopy,
...cloudBridgeCopy,
diff --git a/src/firefox/src/ui/locales/uk.js b/src/firefox/src/ui/locales/uk.js
index 75cb30f6e..636e33936 100644
--- a/src/firefox/src/ui/locales/uk.js
+++ b/src/firefox/src/ui/locales/uk.js
@@ -8,6 +8,7 @@ import { getApocalypseModeCopy } from './apocalypse-copy.mjs';
import { getEmergencyBoxCopy } from './emergency-copy.mjs';
export default {
+ 'st.providers.title': 'Назва постачальника',
...getGenerativeMediaCopy('uk'),
...bidiCopy,
...cloudBridgeCopy,
diff --git a/src/firefox/src/ui/locales/vi.js b/src/firefox/src/ui/locales/vi.js
index 75694c66e..072487bb3 100644
--- a/src/firefox/src/ui/locales/vi.js
+++ b/src/firefox/src/ui/locales/vi.js
@@ -6,6 +6,7 @@ import { getApocalypseModeCopy } from './apocalypse-copy.mjs';
import { getEmergencyBoxCopy } from './emergency-copy.mjs';
export default {
+ 'st.providers.title': 'Tên nhà cung cấp',
...getGenerativeMediaCopy('vi'),
...bidiCopy,
...cloudBridgeCopy,
diff --git a/src/firefox/src/ui/locales/zh.js b/src/firefox/src/ui/locales/zh.js
index 2f6231f2e..9f8d1d3bc 100644
--- a/src/firefox/src/ui/locales/zh.js
+++ b/src/firefox/src/ui/locales/zh.js
@@ -8,6 +8,7 @@ import { getApocalypseModeCopy } from './apocalypse-copy.mjs';
import { getEmergencyBoxCopy } from './emergency-copy.mjs';
export default {
+ 'st.providers.title': '服务商名称',
...getGenerativeMediaCopy('zh'),
...bidiCopy,
...cloudBridgeCopy,
diff --git a/src/firefox/src/ui/settings.html b/src/firefox/src/ui/settings.html
index 6ef1c3210..d46fe32e7 100644
--- a/src/firefox/src/ui/settings.html
+++ b/src/firefox/src/ui/settings.html
@@ -311,6 +311,7 @@
.provider-header-clickable:hover .provider-name { color: var(--accent); }
.provider-header-left {
display: flex;
+ min-width: 0;
align-items: center;
gap: 8px;
flex-wrap: wrap;
@@ -384,7 +385,7 @@
height: 16px;
padding: 1px;
}
- .provider-name { font-weight: 600; font-size: 14px; }
+ .provider-name { font-weight: 600; font-size: 14px; overflow-wrap: anywhere; max-width: 100%; }
.provider-type { color: var(--text2); font-size: 11px; }
.provider-status-badges { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.provider-status-badge {
@@ -1274,6 +1275,7 @@
.btn-sign-in:hover { background: var(--accent2); }
.btn-sign-in:disabled { opacity: 0.55; cursor: default; transform: none; }
.provider-card .btn-duplicate:disabled { cursor: not-allowed; opacity: 0.48; transform: none; }
+ .provider-card .btn-row { flex-wrap: wrap; }
.btn-sign-out {
background: var(--bg3);
color: var(--text);
diff --git a/src/firefox/src/ui/settings.js b/src/firefox/src/ui/settings.js
index ffb154e5b..887d349c2 100644
--- a/src/firefox/src/ui/settings.js
+++ b/src/firefox/src/ui/settings.js
@@ -3324,15 +3324,18 @@ function renderProviders() {
</aside>`
: '';
const compatibilitySettings = renderProviderCompatibilitySettings(id, config);
- const duplicateDisabledKey = config.hasDuplicate
- ? 'st.providers.duplicate_limit'
- : (!config.canDuplicate
- ? 'st.providers.duplicate_unavailable'
- : ((!isConfigured || dirtyProviderIds.has(id)) ? 'st.providers.duplicate_inactive' : ''));
+ const duplicateDisabledKey = !config.canDuplicate
+ ? 'st.providers.duplicate_unavailable'
+ : ((!isConfigured || dirtyProviderIds.has(id)) ? 'st.providers.duplicate_inactive' : '');
const subscriptionGuide = providerSubscriptionGuideHtml(definitionId);
const body = `
${subscriptionGuide}
+ ${id !== 'webbrain_cloud' ? `<div class="field">
+ <label for="provider-title-${id}">${escapeHtml(t('st.providers.title'))}</label>
+ <input id="provider-title-${id}" type="text" data-provider="${id}" data-key="label"
+ value="${escapeHtml(config.label || id)}" maxlength="120" required>
+ </div>` : ''}
${fieldsHTML}
${providerNote}
${id === 'webbrain_cloud' ? '<div class="webbrain-payment-notice" role="status" hidden></div>' : ''}
@@ -3343,9 +3346,8 @@ function renderProviders() {
<button class="btn-secondary btn-test" data-provider="${id}">${escapeHtml(t('st.providers.test'))}</button>
${billingButton}
${!isSelected ? `<button class="btn-secondary btn-activate" data-provider="${id}">${escapeHtml(t('st.providers.select_for_chat'))}</button>` : ''}
- ${config.isDuplicate
- ? `<button class="btn-secondary btn-remove-duplicate" data-provider="${id}">${escapeHtml(t('st.providers.remove_duplicate'))}</button>`
- : `<button class="btn-secondary btn-duplicate" data-provider="${id}"${duplicateDisabledKey ? ` disabled title="${escapeHtml(t(duplicateDisabledKey))}"` : ''}>${escapeHtml(t('st.providers.duplicate'))}</button>`}
+ <button class="btn-secondary btn-duplicate" data-provider="${id}"${duplicateDisabledKey ? ` disabled title="${escapeHtml(t(duplicateDisabledKey))}"` : ''}>${escapeHtml(t('st.providers.duplicate'))}</button>
+ ${config.isDuplicate ? `<button class="btn-secondary btn-remove-duplicate" data-provider="${id}">${escapeHtml(t('st.providers.remove_duplicate'))}</button>` : ''}
</div>
<div class="test-result" id="test-${id}"></div>
`;
@@ -3366,7 +3368,7 @@ function renderProviders() {
restoreProviderApiKeyWarnings();
document.querySelectorAll('.btn-save').forEach(btn => {
- btn.addEventListener('click', () => saveProvider(btn.dataset.provider));
+ btn.addEventListener('click', () => saveProvider(btn.dataset.provider).catch(() => {}));
});
document.querySelectorAll('.btn-test').forEach(btn => {
btn.addEventListener('click', () => testProvider(btn.dataset.provider));
@@ -3805,6 +3807,7 @@ async function saveProvider(id, { showFlash = true, markConfigured = true } = {}
: providerInputValue(input);
setProviderConfigValue(config, input.dataset.key, value);
});
+ if (typeof config.label === 'string') config.label = config.label.trim();
apiKeyWarning = providerApiKeyWarning(id, config);
await sendToBackground('update_provider', { providerId: id, config, markConfigured });
} catch (e) {
@@ -3848,12 +3851,14 @@ function refreshProviderCardStatus(id) {
card.classList.toggle('configured', isConfigured);
card.classList.toggle('selected', isSelected);
const duplicateButton = card.querySelector('.btn-duplicate');
- if (duplicateButton && providersData[id]?.canDuplicate && !providersData[id]?.hasDuplicate) {
+ if (duplicateButton && providersData[id]?.canDuplicate) {
const requiresSave = !isConfigured || dirtyProviderIds.has(id);
duplicateButton.disabled = requiresSave;
if (!requiresSave) duplicateButton.removeAttribute('title');
else duplicateButton.title = t('st.providers.duplicate_inactive');
}
+ const name = card.querySelector('.provider-name');
+ if (name) name.textContent = providersData[id]?.label || id;
const badges = card.querySelector('.provider-status-badges');
if (!badges) return;
badges.innerHTML = `
@@ -3944,7 +3949,13 @@ async function duplicateProvider(id) {
activeProviderId = refreshed.active;
restoreProviderDrafts(providerDrafts);
expandedProviders.add(created.providerId);
+ providerSearchQuery = '';
+ if (providerFilter !== 'all' && providerFilter !== providersData[created.providerId]?.category) {
+ providerFilter = 'all';
+ await browser.storage.local.set({ providerFilter }).catch(() => {});
+ }
renderProviders();
+ document.querySelector(`.provider-card[data-provider-id="${created.providerId}"]`)?.scrollIntoView({ block: 'nearest' });
} catch (error) {
setProviderTestResult(id, 'fail', t('st.providers.failed', { error: error.message }));
}
diff --git a/test/provider-instances-ui.mjs b/test/provider-instances-ui.mjs
new file mode 100644
index 000000000..db572b303
--- /dev/null
+++ b/test/provider-instances-ui.mjs
@@ -0,0 +1,168 @@
+import { chromium, firefox } from 'playwright';
+import { createServer } from 'node:http';
+import { readFile, mkdir } from 'node:fs/promises';
+import { resolve, extname, sep } from 'node:path';
+import assert from 'node:assert/strict';
+
+const root = resolve('.');
+const output = resolve(process.env.PROVIDER_UI_OUTPUT || '.build/provider-instances-ui');
+await mkdir(output, { recursive: true });
+const server = createServer(async (req, res) => {
+ try {
+ const file = resolve(root, '.' + new URL(req.url, 'http://localhost').pathname);
+ if (!file.startsWith(root + sep)) throw new Error('outside root');
+ res.setHeader('Content-Type', ({
+ '.js': 'text/javascript', '.mjs': 'text/javascript', '.html': 'text/html',
+ '.css': 'text/css', '.svg': 'image/svg+xml', '.png': 'image/png',
+ })[extname(file)] || 'text/plain');
+ res.end(await readFile(file));
+ } catch {
+ res.statusCode = 404;
+ res.end();
+ }
+});
+await new Promise(resolve => server.listen(0, '127.0.0.1', resolve));
+const origin = `http://127.0.0.1:${server.address().port}`;
+
+try {
+ for (const [build, engine] of [['chrome', chromium], ['firefox', firefox]]) {
+ if (process.env.PROVIDER_UI_BROWSER && process.env.PROVIDER_UI_BROWSER !== build) continue;
+ const browser = await engine.launch();
+ try {
+ for (const width of [390, 1280]) {
+ const page = await browser.newPage({ viewport: { width, height: 1000 } });
+ const errors = [];
+ page.on('pageerror', error => errors.push(error.message));
+ await page.addInitScript(({ build }) => {
+ localStorage.setItem('wbLocale', 'en');
+ const data = JSON.parse(sessionStorage.getItem('provider-test-store') || '{}');
+ window.testStore = data;
+ const storage = {
+ async get(keys) {
+ return keys == null ? { ...data } : Object.fromEntries(
+ (Array.isArray(keys) ? keys : typeof keys === 'string' ? [keys] : Object.keys(keys))
+ .map(key => [key, data[key]]),
+ );
+ },
+ async set(values) {
+ Object.assign(data, structuredClone(values));
+ sessionStorage.setItem('provider-test-store', JSON.stringify(data));
+ },
+ async remove(keys) {
+ for (const key of Array.isArray(keys) ? keys : [keys]) delete data[key];
+ },
+ };
+ let managerPromise;
+ const runtime = {
+ id: 'provider-ui-test',
+ getURL: path => `${location.origin}/src/${build}/${path}`,
+ getManifest: () => ({ version: '39.1.3' }),
+ getPlatformInfo: async () => ({ os: 'test', arch: 'x64' }),
+ onMessage: { addListener() {} },
+ sendMessage(msg, callback) {
+ managerPromise ||= import(`/src/${build}/src/providers/manager.js`).then(async ({ ProviderManager }) => {
+ const manager = new ProviderManager();
+ if (!data.providers) {
+ const defaults = manager._defaultConfigs();
+ data.providers = {
+ llamacpp: { ...defaults.llamacpp, configured: true, model: 'qwen' },
+ openai: { ...defaults.openai, configured: true, apiKey: 'synthetic-key' },
+ };
+ data.activeProvider = 'llamacpp';
+ }
+ await manager.load();
+ window.testManager = manager;
+ return manager;
+ });
+ const pending = managerPromise.then(async manager => {
+ if (msg.action === 'get_providers') return { providers: manager.getAll(), active: manager.activeProviderId };
+ if (msg.action === 'update_provider') {
+ await manager.updateProvider(msg.providerId, msg.config, { markConfigured: msg.markConfigured !== false });
+ return { activeProviderId: manager.activeProviderId };
+ }
+ if (msg.action === 'duplicate_provider') return manager.duplicateProvider(msg.providerId);
+ if (msg.action === 'remove_duplicate_provider') return manager.removeDuplicateProvider(msg.providerId);
+ if (msg.action === 'set_active_provider') await manager.setActive(msg.providerId);
+ return {};
+ }).catch(error => ({ error: error.message }));
+ pending.then(result => callback?.(result));
+ return pending;
+ },
+ };
+ window.chrome = window.browser = {
+ storage: { local: storage, onChanged: { addListener() {} } },
+ runtime, commands: { getAll: async () => [] }, tabs: { create: async () => ({}) },
+ };
+ }, { build });
+ await page.goto(`${origin}/src/${build}/src/ui/settings.html#providers`);
+ const card = id => page.locator(`.provider-card[data-provider-id="${id}"]`);
+ const rootCard = card('llamacpp');
+ await rootCard.locator('input[data-key="label"]').waitFor();
+ await rootCard.locator('input[data-key="label"]').fill(' ');
+ await rootCard.locator('.btn-save').click();
+ await rootCard.locator('.test-result.fail.show').waitFor();
+ assert.equal(await page.evaluate(() => testManager.getAll().llamacpp.label), 'llama.cpp (Local)');
+ await rootCard.locator('input[data-key="label"]').fill('strata (flash next)');
+ assert.equal(await rootCard.locator('.btn-duplicate').isDisabled(), true);
+ await rootCard.locator('.btn-save').click();
+ await page.waitForFunction(() => testStore.providers.llamacpp.label === 'strata (flash next)');
+ assert.equal(await rootCard.locator('.provider-name').innerText(), 'strata (flash next)');
+ assert.equal(await rootCard.locator('.btn-duplicate').isEnabled(), true);
+
+ await card('openai').locator('.provider-header').click();
+ await card('openai').locator('input[data-key="apiKey"]').fill('unsaved-draft-key');
+ await rootCard.locator('.btn-duplicate').click();
+ const first = card('llamacpp__duplicate');
+ await first.locator('input[data-key="label"]').waitFor();
+ assert.equal(await card('openai').locator('input[data-key="apiKey"]').inputValue(), 'unsaved-draft-key');
+ assert.equal(await first.locator('input[data-key="baseUrl"]').inputValue(), '');
+ assert.equal(await first.locator('.btn-duplicate').isDisabled(), true);
+ const customTitle = '<Personal & local>';
+ await first.locator('input[data-key="label"]').fill(customTitle);
+ await first.locator('input[data-key="baseUrl"]').fill('http://localhost:8081');
+ await first.locator('.btn-save').click();
+ await page.waitForFunction(() => testStore.providers.llamacpp__duplicate.configured);
+ assert.equal(await first.locator('.provider-name').innerText(), customTitle);
+ assert.equal(await first.locator('.provider-name > *').count(), 0, 'titles render as text');
+ await page.locator('.provider-filter-pill[data-filter="active"]').click();
+ await page.locator('#input-provider-search').fill('personal');
+ await first.locator('.btn-duplicate').click();
+ await card('llamacpp__duplicate_2').locator('input[data-key="label"]').waitFor();
+ assert.equal(await page.locator('#input-provider-search').inputValue(), '');
+ assert.equal(await page.locator('.provider-filter-pill.active').getAttribute('data-filter'), 'all');
+ await rootCard.locator('.btn-duplicate').click();
+ await card('llamacpp__duplicate_3').locator('input[data-key="label"]').waitFor();
+ const longTitle = 'W'.repeat(120);
+ await card('llamacpp__duplicate_3').locator('input[data-key="label"]').fill(longTitle);
+ await card('llamacpp__duplicate_3').locator('.btn-save').click();
+ await page.waitForFunction(() => testStore.providers.llamacpp__duplicate_3.label.length === 120);
+ await card('llamacpp__duplicate_3').scrollIntoViewIfNeeded();
+ await page.screenshot({ path: resolve(output, `${build}-${width}.png`) });
+ assert.equal(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth), true, 'long names must fit the viewport');
+
+ await page.reload();
+ await rootCard.locator('input[data-key="label"]').waitFor();
+ assert.equal(await rootCard.locator('.provider-name').innerText(), 'strata (flash next)');
+ assert.equal(await first.locator('.provider-name').innerText(), customTitle);
+ assert.equal(await card('llamacpp__duplicate_2').count(), 1);
+ assert.equal(await card('llamacpp__duplicate_3').locator('.provider-name').innerText(), longTitle);
+ await first.locator('.provider-header').click();
+ await first.locator('.btn-activate').click();
+ await page.waitForFunction(() => testStore.activeProvider === 'llamacpp__duplicate');
+ page.once('dialog', dialog => dialog.accept());
+ await first.locator('.btn-remove-duplicate').click();
+ await first.waitFor({ state: 'detached' });
+ assert.equal(await card('llamacpp__duplicate_2').count(), 1);
+ assert.equal(await card('llamacpp__duplicate_3').count(), 1);
+ assert.equal(await page.evaluate(() => testStore.activeProvider), 'llamacpp');
+ assert.deepEqual(errors, []);
+ console.log(`PASS ${build} ${width}px: rename, duplicate, drafts, reload, selection, removal`);
+ await page.close();
+ }
+ } finally {
+ await browser.close();
+ }
+ }
+} finally {
+ await new Promise(resolve => server.close(resolve));
+}
diff --git a/test/run.js b/test/run.js
index 87b9c9b3a..f4c99fe99 100644
--- a/test/run.js
+++ b/test/run.js
@@ -70386,7 +70386,7 @@ function makeProviderManagerWriteRuntime(writes) {
};
}
-test('ProviderManager creates one blank independent duplicate per provider', async () => {
+test('ProviderManager creates unlimited blank independent duplicates per provider', async () => {
const originalChrome = globalThis.chrome;
const originalBrowser = globalThis.browser;
@@ -70455,24 +70455,69 @@ test('ProviderManager creates one blank independent duplicate per provider', asy
const surfacedIds = Object.keys(surfaced);
assert.equal(surfacedIds.indexOf(created.providerId), surfacedIds.indexOf('openai') + 1, `${label}: duplicate should appear immediately after its source`);
assert.equal(surfaced.openai.hasDuplicate, true, `${label}: source should advertise its existing duplicate`);
- assert.equal(surfaced.openai.canDuplicate, false, `${label}: source should enforce the one-duplicate limit in UI metadata`);
+ assert.equal(surfaced.openai.canDuplicate, true, `${label}: source should allow more duplicates`);
assert.equal(surfaced[created.providerId].isDuplicate, true, `${label}: duplicate metadata missing`);
assert.equal(surfaced[created.providerId].sourceProviderId, 'openai', `${label}: duplicate source metadata missing`);
- assert.equal(surfaced[created.providerId].canDuplicate, false, `${label}: duplicates must not be duplicable`);
+ assert.equal(surfaced[created.providerId].canDuplicate, true, `${label}: saved duplicates should support further duplication`);
- await assert.rejects(
- () => manager.duplicateProvider('openai'),
- /already has a duplicate/i,
- `${label}: a second duplicate should be rejected`,
- );
- await assert.rejects(
- () => manager.duplicateProvider(created.providerId),
- /cannot be duplicated/i,
- `${label}: duplicating a duplicate should be rejected`,
- );
assert.equal(writes.length, 2, `${label}: create and independent update should each persist once`);
assert.equal(writes.at(-1)?.providers?.openai?.apiKey, `${label}-work-key`);
assert.equal(writes.at(-1)?.providers?.[created.providerId]?.apiKey, `${label}-personal-key`);
+ const second = await manager.duplicateProvider('openai');
+ assert.equal(second.providerId, 'openai__duplicate_2');
+ assert.equal(manager.providers.get(second.providerId)?.config.label, 'OpenAI 3');
+ await assert.rejects(() => manager.duplicateProvider(second.providerId), /save provider before duplicating/i);
+ const third = await manager.duplicateProvider(created.providerId);
+ assert.deepEqual(third, { providerId: 'openai__duplicate_3', sourceProviderId: 'openai' });
+ assert.equal(manager.providers.get(third.providerId)?.config.duplicateOf, 'openai');
+ assert.equal(manager.providers.get(third.providerId)?.config.apiKey, undefined);
+ const additional = [];
+ for (let i = 0; i < 10; i++) additional.push((await manager.duplicateProvider('openai')).providerId);
+ const ids = Object.keys(manager.getAll());
+ assert.deepEqual(ids.slice(ids.indexOf('openai') + 1, ids.indexOf('kimi')),
+ [created.providerId, second.providerId, third.providerId, ...additional]);
+ await manager.removeDuplicateProvider(second.providerId);
+ assert.equal(manager.providers.has(third.providerId), true);
+ assert.equal(manager.providers.get(created.providerId)?.config.apiKey, `${label}-personal-key`);
+ assert.equal((await manager.duplicateProvider('openai')).providerId, second.providerId);
+ }
+ } finally {
+ globalThis.chrome = originalChrome;
+ globalThis.browser = originalBrowser;
+ }
+});
+
+test('ProviderManager saves custom titles independently without changing provider identity', async () => {
+ const originalChrome = globalThis.chrome;
+ const originalBrowser = globalThis.browser;
+ try {
+ for (const [label, PM, runtimeKey] of [
+ ['chrome', ProviderManagerCh, 'chrome'],
+ ['firefox', ProviderManagerFx, 'browser'],
+ ]) {
+ const writes = [];
+ globalThis[runtimeKey] = makeProviderManagerWriteRuntime(writes);
+ const manager = new PM();
+ const defaults = manager._defaultConfigs();
+ manager.providers.set('llamacpp', manager._createProvider('llamacpp', {
+ ...defaults.llamacpp, model: 'qwen', configured: true,
+ }));
+ manager.activeProviderId = 'llamacpp';
+ await manager.updateProvider('llamacpp', { label: ' strata (flash next) ' });
+ const duplicate = await manager.duplicateProvider('llamacpp');
+ await manager.updateProvider(duplicate.providerId, { label: '<Personal & local>', baseUrl: 'http://localhost:8081', model: 'flash-next' });
+ assert.equal(manager.getAll().llamacpp.label, 'strata (flash next)');
+ assert.equal(manager.getAll()[duplicate.providerId].label, '<Personal & local>');
+ assert.equal(manager.activeProviderId, 'llamacpp');
+ assert.equal(manager.providers.get('llamacpp')?.config.type, 'llamacpp');
+ assert.equal(manager.providers.get('llamacpp')?.config.model, 'qwen');
+ assert.equal(manager.getAll()[duplicate.providerId].sourceProviderId, 'llamacpp');
+ assert.equal(writes.at(-1).providers.llamacpp.label, 'strata (flash next)');
+ assert.equal(writes.at(-1).providers[duplicate.providerId].label, '<Personal & local>');
+ for (const invalid of ['', ' ', 'x'.repeat(121), null, {}]) {
+ await assert.rejects(() => manager.updateProvider('llamacpp', { label: invalid }), /provider title/i);
+ }
+ assert.equal(manager.getAll().llamacpp.label, 'strata (flash next)');
}
} finally {
globalThis.chrome = originalChrome;
@@ -70518,7 +70563,7 @@ test('ProviderManager removes only duplicates and safely reselects their source'
assert.equal(writes.at(-1)?.activeProvider, 'openai', `${label}: fallback selection was not persisted atomically`);
const recreated = await manager.duplicateProvider('openai');
- assert.equal(recreated.providerId, providerId, `${label}: removing a duplicate should release the one-duplicate limit`);
+ assert.equal(recreated.providerId, providerId, `${label}: removing a duplicate should release its ID`);
await assert.rejects(
() => manager.duplicateProvider('webbrain_cloud'),
@@ -70615,7 +70660,7 @@ test('duplicated local providers retain their source-native model and vision beh
}
});
-test('ProviderManager reloads one valid duplicate and purges forged duplicate entries', async () => {
+test('ProviderManager reloads multiple named duplicates and purges forged duplicate entries', async () => {
const originalChrome = globalThis.chrome;
const originalBrowser = globalThis.browser;
const validGuid = '11111111-1111-4111-8111-111111111111';
@@ -70649,6 +70694,7 @@ test('ProviderManager reloads one valid duplicate and purges forged duplicate en
const defaults = new PM()._defaultConfigs();
const source = {
...defaults.openai,
+ label: 'Work account',
apiKey: `${label}-work-key`,
configured: true,
};
@@ -70664,7 +70710,13 @@ test('ProviderManager reloads one valid duplicate and purges forged duplicate en
providers: {
openai: source,
openai__duplicate: validDuplicate,
- openai__duplicate_2: { ...validDuplicate },
+ openai__duplicate_2: { ...validDuplicate, label: 'Personal account' },
+ openai__duplicate_3: { ...validDuplicate, configured: false, label: 'New endpoint' },
+ openai__duplicate_0: { ...validDuplicate },
+ openai__duplicate_02: { ...validDuplicate },
+ openai__duplicate_bad: { ...validDuplicate },
+ openai__duplicate__duplicate: { ...validDuplicate, duplicateOf: 'openai__duplicate' },
+ openai__duplicate_4: { ...validDuplicate, type: 'anthropic' },
missing__duplicate: { ...validDuplicate, duplicateOf: 'missing' },
webbrain_cloud__duplicate: {
...structuredClone(defaults.webbrain_cloud),
@@ -70690,14 +70742,20 @@ test('ProviderManager reloads one valid duplicate and purges forged duplicate en
await manager.load();
assert.equal(manager.activeProviderId, 'openai__duplicate', `${label}: a valid selected duplicate should survive reload`);
assert.equal(manager.providers.get('openai__duplicate')?.config.apiKey, `${label}-personal-key`);
- assert.equal(manager.providers.has('openai__duplicate_2'), false, `${label}: forged second duplicate should be rejected`);
+ assert.equal(manager.providers.get('openai')?.config.label, 'Work account');
+ assert.equal(manager.getAll().openai__duplicate_2?.label, 'Personal account');
+ assert.equal(manager.providers.get('openai__duplicate_3')?.config.configured, false);
+ for (const invalidId of ['openai__duplicate_0', 'openai__duplicate_02', 'openai__duplicate_bad', 'openai__duplicate__duplicate', 'openai__duplicate_4']) {
+ assert.equal(manager.providers.has(invalidId), false, `${label}: invalid duplicate ${invalidId} should be rejected`);
+ assert.equal(storageData.providers[invalidId], undefined);
+ }
assert.equal(manager.providers.has('missing__duplicate'), false, `${label}: orphan duplicate should be rejected`);
assert.equal(manager.providers.has('webbrain_cloud__duplicate'), false, `${label}: managed cloud duplicate should be rejected`);
assert.equal(manager.providers.has('kimi__duplicate'), false, `${label}: duplicate created before its source was saved should be rejected`);
assert.equal(manager.providers.has('groq'), true, `${label}: forged metadata must not delete a built-in provider`);
assert.equal(manager.providers.get('groq')?.config.duplicateOf, undefined, `${label}: forged duplicate metadata should be stripped from built-ins`);
assert.equal(storageData.providers.openai__duplicate?.apiKey, `${label}-personal-key`, `${label}: valid duplicate was not persisted`);
- assert.equal(storageData.providers.openai__duplicate_2, undefined, `${label}: forged duplicate was not purged from storage`);
+ assert.equal(storageData.providers.openai__duplicate_2?.label, 'Personal account', `${label}: additional duplicate title should survive reload`);
assert.equal(storageData.providers.missing__duplicate, undefined, `${label}: orphan duplicate was not purged from storage`);
assert.equal(storageData.providers.webbrain_cloud__duplicate, undefined, `${label}: managed duplicate was not purged from storage`);
assert.equal(storageData.providers.kimi__duplicate, undefined, `${label}: pre-Save duplicate was not purged from storage`);
@@ -70722,8 +70780,8 @@ test('duplicate provider controls are wired through background and settings in b
assert.match(settings, /const definitionId = providerDefinitionId\(id, config\);[\s\S]*?providerConfigs\[definitionId\]/, `${label}: duplicate cards should reuse source fields`);
assert.match(settings, /class="btn-secondary btn-duplicate"[\s\S]*?st\.providers\.duplicate/, `${label}: duplicate button missing`);
assert.match(settings, /class="btn-secondary btn-remove-duplicate"[\s\S]*?st\.providers\.remove_duplicate/, `${label}: remove duplicate button missing`);
- assert.match(settings, /config\.hasDuplicate[\s\S]*?st\.providers\.duplicate_limit[\s\S]*?st\.providers\.duplicate_unavailable/, `${label}: disabled duplicate buttons should explain limits and unsupported providers`);
- assert.match(settings, /const duplicateDisabledKey = config\.hasDuplicate[\s\S]*?!config\.canDuplicate[\s\S]*?!isConfigured \|\| dirtyProviderIds\.has\(id\)[\s\S]*?'st\.providers\.duplicate_inactive'/, `${label}: an inactive or edited source provider should disable Duplicate`);
+ assert.match(settings, /const duplicateDisabledKey = !config\.canDuplicate[\s\S]*?st\.providers\.duplicate_unavailable[\s\S]*?!isConfigured \|\| dirtyProviderIds\.has\(id\)[\s\S]*?'st\.providers\.duplicate_inactive'/, `${label}: unsupported, inactive or edited providers should disable Duplicate`);
+ assert.doesNotMatch(settings, /st\.providers\.duplicate_limit/, `${label}: settings must not enforce the old duplicate cap`);
assert.ok(settings.includes('${duplicateDisabledKey ? ` disabled title="'), `${label}: unavailable Duplicate actions should use native disabled buttons`);
assert.match(settings, /document\.querySelectorAll\('\.btn-duplicate'\)[\s\S]*?duplicateProvider\(btn\.dataset\.provider\)/, `${label}: initially disabled Duplicate buttons should be ready after Save enables them`);
assert.match(settings, /input\[data-provider\], select\[data-provider\], textarea\[data-provider\][\s\S]*?markProviderDirty\(input\.dataset\.provider\)/, `${label}: editing a saved provider should disable Duplicate until Save`);
@@ -128389,7 +128447,7 @@ test('Settings limits the subscription proxy guide to relevant provider cards',
}
assert.match(settings, /if \(definitionId === 'local_openai_proxy'\)[\s\S]*?provider-local-proxy-guide/,
`${label}: the generic local proxy card should have permanent guide context`);
- assert.match(settings, /const subscriptionGuide = providerSubscriptionGuideHtml\(definitionId\);[\s\S]*?const body = `\s*\$\{subscriptionGuide\}\s*\$\{fieldsHTML\}/,
+ assert.match(settings, /const subscriptionGuide = providerSubscriptionGuideHtml\(definitionId\);[\s\S]*?const body = `\s*\$\{subscriptionGuide\}[\s\S]*?\$\{fieldsHTML\}/,
`${label}: contextual guidance should appear before API-key fields and work for duplicates`);
assert.equal((settings.match(/provider-subscription-guide-icon/g) || []).length, 2,
`${label}: cloud-account and local-proxy guide branches should both include the decorative plug`);