Open-source AI browser agent for Chrome and Firefox (monorepo) ðŸ§
JavaScript ai-agentai-agentsai-toolsbrowser-aibrowser-automationbrowser-extensionchrome-aichrome-devtoolschrome-extensionchrome-extensionsfirefox-addonfirefox-addonsfirefox-extensionfirefox-extensionsgemmagemma4minimaxoffline-aioffline-llmqwen
Model picker: name the configured model, not the option's status
Claudec9a9f1e02a4a
diff --git a/src/chrome/src/ui/sidepanel.js b/src/chrome/src/ui/sidepanel.jsindex a58b2a90c..128a452dd 100644--- a/src/chrome/src/ui/sidepanel.js+++ b/src/chrome/src/ui/sidepanel.js@@ -731,6 +731,8 @@ const MORE_PROVIDERS_OPTION_VALUE = '__more_providers__';const statusDot = document.getElementById('status-dot');// Short labels for the closed picker button (menu rows keep the longer status text).const providerPickerLabelById = new Map();+// The configured model of each provider, for the picker's tooltip and name.+const providerPickerModelById = new Map();let languagePickerTypeahead = '';let languagePickerTypeaheadTimer = null;@@ -8063,8 +8065,10 @@ function syncProviderPickerButton() {|| '';providerPickerLabel.textContent = shortLabel;if (providerPickerBtn) {- // The button shows an icon only, so its name says which model is active.- const name = providerSelect.selectedOptions?.[0]?.textContent || shortLabel;+ // The button shows an icon only, so its name says which provider and+ // model are active (the option text carries a status, not the model).+ const model = providerPickerModelById.get(id) || '';+ const name = shortLabel && model && !shortLabel.includes(model) ? `${shortLabel} · ${model}` : (shortLabel || model);const label = name ? t('sp.provider_picker.current', { name }) : t('sp.provider_picker.none');providerPickerBtn.title = label;providerPickerBtn.setAttribute('aria-label', label);@@ -8307,6 +8311,7 @@ async function loadProviders() {providerSelect.replaceChildren();providerPickerMenu?.replaceChildren();providerPickerLabelById.clear();+ providerPickerModelById.clear();const cloudConfig = res.providers.webbrain_cloud || { label: 'WebBrain Compass' };const cloudLabel = cloudConfig.label || 'WebBrain Compass';@@ -8343,6 +8348,7 @@ async function loadProviders() {opt.textContent = `${name} — ${t('sp.providers.active')}`;activeGroup.appendChild(opt);providerPickerLabelById.set(id, name);+ if (typeof config.model === 'string' && config.model.trim()) providerPickerModelById.set(id, config.model.trim());appendProviderPickerOption(id, name, t('sp.providers.active'), config.sourceProviderId || id);}providerSelect.appendChild(activeGroup);diff --git a/src/firefox/src/ui/sidepanel.js b/src/firefox/src/ui/sidepanel.jsindex fab85af2c..aa8179297 100644--- a/src/firefox/src/ui/sidepanel.js+++ b/src/firefox/src/ui/sidepanel.js@@ -606,6 +606,8 @@ const MORE_PROVIDERS_OPTION_VALUE = '__more_providers__';const statusDot = document.getElementById('status-dot');// Short labels for the closed picker button (menu rows keep the longer status text).const providerPickerLabelById = new Map();+// The configured model of each provider, for the picker's tooltip and name.+const providerPickerModelById = new Map();let languagePickerTypeahead = '';let languagePickerTypeaheadTimer = null;@@ -7898,8 +7900,10 @@ function syncProviderPickerButton() {|| '';providerPickerLabel.textContent = shortLabel;if (providerPickerBtn) {- // The button shows an icon only, so its name says which model is active.- const name = providerSelect.selectedOptions?.[0]?.textContent || shortLabel;+ // The button shows an icon only, so its name says which provider and+ // model are active (the option text carries a status, not the model).+ const model = providerPickerModelById.get(id) || '';+ const name = shortLabel && model && !shortLabel.includes(model) ? `${shortLabel} · ${model}` : (shortLabel || model);const label = name ? t('sp.provider_picker.current', { name }) : t('sp.provider_picker.none');providerPickerBtn.title = label;providerPickerBtn.setAttribute('aria-label', label);@@ -8142,6 +8146,7 @@ async function loadProviders() {providerSelect.replaceChildren();providerPickerMenu?.replaceChildren();providerPickerLabelById.clear();+ providerPickerModelById.clear();const cloudConfig = res.providers.webbrain_cloud || { label: 'WebBrain Compass' };const cloudLabel = cloudConfig.label || 'WebBrain Compass';@@ -8178,6 +8183,7 @@ async function loadProviders() {opt.textContent = `${name} — ${t('sp.providers.active')}`;activeGroup.appendChild(opt);providerPickerLabelById.set(id, name);+ if (typeof config.model === 'string' && config.model.trim()) providerPickerModelById.set(id, config.model.trim());appendProviderPickerOption(id, name, t('sp.providers.active'), config.sourceProviderId || id);}providerSelect.appendChild(activeGroup);diff --git a/test/model-picker-icon.mjs b/test/model-picker-icon.mjsindex e263b60cd..9a0a9213b 100644--- a/test/model-picker-icon.mjs+++ b/test/model-picker-icon.mjs@@ -31,9 +31,11 @@ for (const build of ['chrome', 'firefox']) {{ dataset: { value: 'local' }, attrs: {}, setAttribute(k, v) { this.attrs[k] = v; } }];const context = vm.createContext({t: (key, params = {}) => String(en[key] || key).replace(/\{(\w+)\}/g, (_, k) => params[k] ?? ''),- providerSelect: { value: 'openrouter', selectedOptions: [{ textContent: 'OpenRouter · openai/gpt-6-luna' }] },+ // The option text carries the provider's status, never its model.+ providerSelect: { value: 'openrouter', selectedOptions: [{ textContent: 'OpenRouter — Active' }] },providerPickerLabel: { textContent: '' },- providerPickerLabelById: new Map([['openrouter', 'OpenRouter']]),+ providerPickerLabelById: new Map([['openrouter', 'OpenRouter'], ['webbrain_cloud', 'WebBrain Compass'], ['local', 'gpt-6-luna']]),+ providerPickerModelById: new Map([['openrouter', 'openai/gpt-6-luna'], ['local', 'gpt-6-luna']]),providerPickerBtn: { title: '', setAttribute(k, v) { attributes[k] = v; } },providerPickerMenu: { querySelectorAll: () => options },});@@ -42,6 +44,14 @@ for (const build of ['chrome', 'firefox']) {assert.equal(context.providerPickerBtn.title, 'Model: OpenRouter · openai/gpt-6-luna');assert.equal(attributes['aria-label'], 'Model: OpenRouter · openai/gpt-6-luna');assert.deepEqual(options.map(option => option.attrs['aria-selected']), ['true', 'false'], 'the open menu marks it');+ assert.match(panel, /if \(typeof config\.model === 'string' && config\.model\.trim\(\)\) providerPickerModelById\.set\(id, config\.model\.trim\(\)\);/, 'loadProviders records each configured model');+ // A provider without a configured model, and a label that already names it.+ context.providerSelect = { value: 'webbrain_cloud', selectedOptions: [{ textContent: 'WebBrain Compass — No setup' }] };+ context.syncProviderPickerButton();+ assert.equal(attributes['aria-label'], 'Model: WebBrain Compass');+ context.providerSelect = { value: 'local', selectedOptions: [{ textContent: 'gpt-6-luna — Active' }] };+ context.syncProviderPickerButton();+ assert.equal(attributes['aria-label'], 'Model: gpt-6-luna');// Nothing selected yet.context.providerSelect = { value: '', selectedOptions: [] };context.syncProviderPickerButton();