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
Show the provider's logo on the composer's model picker
Barack Sokullu4301d2311fd5
diff --git a/src/chrome/src/ui/provider-icons.js b/src/chrome/src/ui/provider-icons.jsindex 53341f0b5..790afd8cb 100644--- a/src/chrome/src/ui/provider-icons.js+++ b/src/chrome/src/ui/provider-icons.js@@ -59,38 +59,6 @@ export function providerIconUrl(id) {return `../../icons/providers/${file}`;}-// Match model families as tokens, including namespaced IDs and quantized-// filenames. More specific families precede base families in distill names.-const MODEL_ICON_FAMILIES = [- [/(?:^|[^a-z0-9])claude(?=$|[^a-z])/, 'anthropic'],- [/(?:^|[^a-z0-9])(?:(?:chat)?gpt|o\d+)(?=$|[^a-z])/, 'openai'],- [/^openai$/, 'openai'],- [/(?:^|[^a-z0-9])deepseek(?=$|[^a-z])/, 'deepseek'],- [/(?:^|[^a-z0-9])nemotron(?=$|[^a-z])/, 'nvidia'],- [/(?:^|[^a-z0-9])qwen(?=$|[^a-z])/, 'alibaba'],- [/(?:^|[^a-z0-9])(?:gemini|gemma)(?=$|[^a-z])/, 'gemini'],- [/(?:^|[^a-z0-9])(?:mistral|mixtral|ministral|magistral|codestral|devstral|pixtral)(?=$|[^a-z])/, 'mistral'],- [/(?:^|[^a-z0-9])(?:chatglm|glm)(?=$|[^a-z])/, 'z_ai'],- [/(?:^|[^a-z0-9])kimi(?=$|[^a-z])/, 'kimi'],- [/(?:^|[^a-z0-9])minimax(?=$|[^a-z])/, 'minimax'],- [/(?:^|[^a-z0-9])grok(?=$|[^a-z])/, 'xai'],- [/(?:^|[^a-z0-9])llama(?=$|[^a-z])/, 'llama'],- [/(?:^|[^a-z0-9])command(?=$|[^a-z])/, 'cohere'],- [/(?:^|[^a-z0-9])sonar(?=$|[^a-z])/, 'perplexity'],- [/(?:^|[^a-z0-9])step(?=$|[^a-z])/, 'stepfun'],- [/(?:^|[^a-z0-9])solar(?=$|[^a-z])/, 'upstage'],- [/(?:^|[^a-z0-9])mimo(?=$|[^a-z])/, 'xiaomi'],- [/(?:^|[^a-z0-9])ling(?=$|[^a-z])/, 'bailing'],-];--/** Prefer the selected model's brand, then its provider; unknowns stay empty. */-export function modelIconUrl(model, providerId) {- const name = typeof model === 'string' ? model.trim().toLowerCase() : '';- const family = MODEL_ICON_FAMILIES.find(([pattern]) => pattern.test(name));- const id = family?.[1] || (providerId === 'webbrain_cloud_max' ? 'webbrain_cloud' : providerId);- return Object.hasOwn(PROVIDER_ICON_FILES, id) ? providerIconUrl(id) : '';-}-/*** @param {string} id* @param {string} [label] unused when decorative (default); kept for call-site compatdiff --git a/src/chrome/src/ui/sidepanel.js b/src/chrome/src/ui/sidepanel.jsindex 624a8a38c..acb3ec9ba 100644--- a/src/chrome/src/ui/sidepanel.js+++ b/src/chrome/src/ui/sidepanel.js@@ -82,7 +82,7 @@ import {buildFeedbackUrl,normalizeState as normalizeStoreReviewState,} from './store-review-prompt.js';-import { modelIconUrl, providerIconUrl } from './provider-icons.js';+import { providerIconUrl } from './provider-icons.js';import { getFeedbackCopy } from './feedback-copy.js';import { requestFeedbackConsent, submitFeedbackWithTrace } from './feedback-consent.js';import { parseWatchSlashCommand, WATCH_COMMAND_USAGE } from './watch-command.js';@@ -8375,7 +8375,9 @@ function syncProviderPickerIcon() {const icon = providerPickerBtn?.querySelector('.provider-picker-icon');if (!icon) return;const id = providerSelect?.value || '';- const src = modelIconUrl(providerPickerModelById.get(id), providerPickerSourceById.get(id) || id);+ // The provider's logo, as in the menu: a model's brand (Claude on+ // OpenRouter, Qwen on Ollama) would hide which provider runs it.+ const src = providerIconUrl(providerPickerSourceById.get(id) || id);if (icon.dataset.src === src) return;icon.dataset.src = src;icon.classList.remove('has-logo');@@ -8453,7 +8455,7 @@ function appendProviderPickerOption(id, name, meta, iconProviderId = id) {btn.dataset.value = id;btn.setAttribute('aria-selected', 'false');- // Menu rows identify the provider; the closed button resolves its model's logo.+ // Menu rows and the closed button both show the provider's logo.const iconSrc = providerIconUrl(iconProviderId);if (iconSrc) {const img = document.createElement('img');diff --git a/src/chrome/styles/sidepanel.css b/src/chrome/styles/sidepanel.cssindex 406d90e6a..f2a73acda 100644--- a/src/chrome/styles/sidepanel.css+++ b/src/chrome/styles/sidepanel.css@@ -3575,7 +3575,7 @@ html[data-ui-scale="175"] .conversation-action-label {padding: 4px 4px 4px 5px;}-/* Keep the model logo and engine fallback the same size, so switching+/* Keep the provider logo and engine fallback the same size, so switchingproviders never moves the connection badge or crowds the toolbar. */.provider-picker-icon {display: inline-flex;diff --git a/src/firefox/src/ui/provider-icons.js b/src/firefox/src/ui/provider-icons.jsindex 68449cc29..b2807d9d0 100644--- a/src/firefox/src/ui/provider-icons.js+++ b/src/firefox/src/ui/provider-icons.js@@ -58,38 +58,6 @@ export function providerIconUrl(id) {return `../../icons/providers/${file}`;}-// Match model families as tokens, including namespaced IDs and quantized-// filenames. More specific families precede base families in distill names.-const MODEL_ICON_FAMILIES = [- [/(?:^|[^a-z0-9])claude(?=$|[^a-z])/, 'anthropic'],- [/(?:^|[^a-z0-9])(?:(?:chat)?gpt|o\d+)(?=$|[^a-z])/, 'openai'],- [/^openai$/, 'openai'],- [/(?:^|[^a-z0-9])deepseek(?=$|[^a-z])/, 'deepseek'],- [/(?:^|[^a-z0-9])nemotron(?=$|[^a-z])/, 'nvidia'],- [/(?:^|[^a-z0-9])qwen(?=$|[^a-z])/, 'alibaba'],- [/(?:^|[^a-z0-9])(?:gemini|gemma)(?=$|[^a-z])/, 'gemini'],- [/(?:^|[^a-z0-9])(?:mistral|mixtral|ministral|magistral|codestral|devstral|pixtral)(?=$|[^a-z])/, 'mistral'],- [/(?:^|[^a-z0-9])(?:chatglm|glm)(?=$|[^a-z])/, 'z_ai'],- [/(?:^|[^a-z0-9])kimi(?=$|[^a-z])/, 'kimi'],- [/(?:^|[^a-z0-9])minimax(?=$|[^a-z])/, 'minimax'],- [/(?:^|[^a-z0-9])grok(?=$|[^a-z])/, 'xai'],- [/(?:^|[^a-z0-9])llama(?=$|[^a-z])/, 'llama'],- [/(?:^|[^a-z0-9])command(?=$|[^a-z])/, 'cohere'],- [/(?:^|[^a-z0-9])sonar(?=$|[^a-z])/, 'perplexity'],- [/(?:^|[^a-z0-9])step(?=$|[^a-z])/, 'stepfun'],- [/(?:^|[^a-z0-9])solar(?=$|[^a-z])/, 'upstage'],- [/(?:^|[^a-z0-9])mimo(?=$|[^a-z])/, 'xiaomi'],- [/(?:^|[^a-z0-9])ling(?=$|[^a-z])/, 'bailing'],-];--/** Prefer the selected model's brand, then its provider; unknowns stay empty. */-export function modelIconUrl(model, providerId) {- const name = typeof model === 'string' ? model.trim().toLowerCase() : '';- const family = MODEL_ICON_FAMILIES.find(([pattern]) => pattern.test(name));- const id = family?.[1] || (providerId === 'webbrain_cloud_max' ? 'webbrain_cloud' : providerId);- return Object.hasOwn(PROVIDER_ICON_FILES, id) ? providerIconUrl(id) : '';-}-/*** @param {string} id* @param {string} [label] unused when decorative (default); kept for call-site compatdiff --git a/src/firefox/src/ui/sidepanel.js b/src/firefox/src/ui/sidepanel.jsindex 60a93f046..4ed26a431 100644--- a/src/firefox/src/ui/sidepanel.js+++ b/src/firefox/src/ui/sidepanel.js@@ -81,7 +81,7 @@ import {buildFeedbackUrl,normalizeState as normalizeStoreReviewState,} from './store-review-prompt.js';-import { modelIconUrl, providerIconUrl } from './provider-icons.js';+import { providerIconUrl } from './provider-icons.js';import { getFeedbackCopy } from './feedback-copy.js';import { requestFeedbackConsent, submitFeedbackWithTrace } from './feedback-consent.js';import { parseWatchSlashCommand, WATCH_COMMAND_USAGE } from './watch-command.js';@@ -8205,7 +8205,9 @@ function syncProviderPickerIcon() {const icon = providerPickerBtn?.querySelector('.provider-picker-icon');if (!icon) return;const id = providerSelect?.value || '';- const src = modelIconUrl(providerPickerModelById.get(id), providerPickerSourceById.get(id) || id);+ // The provider's logo, as in the menu: a model's brand (Claude on+ // OpenRouter, Qwen on Ollama) would hide which provider runs it.+ const src = providerIconUrl(providerPickerSourceById.get(id) || id);if (icon.dataset.src === src) return;icon.dataset.src = src;icon.classList.remove('has-logo');@@ -8283,7 +8285,7 @@ function appendProviderPickerOption(id, name, meta, iconProviderId = id) {btn.dataset.value = id;btn.setAttribute('aria-selected', 'false');- // Menu rows identify the provider; the closed button resolves its model's logo.+ // Menu rows and the closed button both show the provider's logo.const iconSrc = providerIconUrl(iconProviderId);if (iconSrc) {const img = document.createElement('img');diff --git a/src/firefox/styles/sidepanel.css b/src/firefox/styles/sidepanel.cssindex 4d2124041..562201fbb 100644--- a/src/firefox/styles/sidepanel.css+++ b/src/firefox/styles/sidepanel.css@@ -3402,7 +3402,7 @@ html[data-ui-scale="175"] .conversation-action-label {padding: 4px 4px 4px 5px;}-/* Keep the model logo and engine fallback the same size, so switching+/* Keep the provider logo and engine fallback the same size, so switchingproviders never moves the connection badge or crowds the toolbar. */.provider-picker-icon {display: inline-flex;diff --git a/test/model-picker-icon.mjs b/test/model-picker-icon.mjsindex fe1e1576b..a33184970 100644--- a/test/model-picker-icon.mjs+++ b/test/model-picker-icon.mjs@@ -1,5 +1,5 @@-// The composer's model picker shows the selected model's logo, with an-// engine fallback; its name remains in the tooltip and accessible name.+// The composer's model picker shows the selected provider's logo, with an+// engine fallback; the model's name remains in the tooltip and accessible name.import assert from 'node:assert/strict';import { readFileSync } from 'node:fs';import { test } from 'node:test';diff --git a/test/model-picker-status-ui.mjs b/test/model-picker-status-ui.mjsindex 500b665af..82ef45b4d 100644--- a/test/model-picker-status-ui.mjs+++ b/test/model-picker-status-ui.mjs@@ -1,10 +1,11 @@-// The provider's online/offline dot is a badge on the composer's model logo,+// The provider's online/offline dot is a badge on the composer's provider logo,// inside the model picker button: it reads as the model's status, and clicking// it opens the menu like the rest of the button. Runs the real panel markup and// styles in each build's engine, with the real icon helper and bundled assets.// The dot's class is set the way testConnection() sets it.import assert from 'node:assert/strict';import fs from 'node:fs/promises';+import { fileURLToPath } from 'node:url';import { after, before, describe, test } from 'node:test';import { chromium, firefox } from 'playwright';@@ -50,7 +51,7 @@ for (const [build, engine] of [['chrome', chromium], ['firefox', firefox]]) {await page.goto('https://owned-panel.invalid/panel');await page.addStyleTag({ content: css });await page.addScriptTag({ type: 'module', content: `- import { modelIconUrl } from '/src/ui/provider-icons.js';+ import { providerIconUrl } from '/src/ui/provider-icons.js';const providerPickerBtn = document.getElementById('provider-picker-btn');const providerPickerLabel = document.getElementById('provider-picker-label');const providerPickerMenu = document.getElementById('provider-picker-menu');@@ -147,10 +148,10 @@ for (const [build, engine] of [['chrome', chromium], ['firefox', firefox]]) {return logo;};- test('the selected model logo changes within one provider and retains the green/red status badge', async () => {+ test('the logo is the provider\'s, whatever model it runs, and keeps the green/red status badge', async () => {await panel(async (page) => {await selectModel(page, 'openai/gpt-6-luna');- await loadedLogo(page, 'openai.svg');+ await loadedLogo(page, 'openrouter.svg');assert.equal(await page.locator('#provider-picker-btn').getAttribute('aria-label'), 'Model: openrouter · openai/gpt-6-luna');const before = await geometry(page);assert.ok(before.dot.width >= 6 && before.dot.height >= 6);@@ -159,17 +160,21 @@ for (const [build, engine] of [['chrome', chromium], ['firefox', firefox]]) {await page.waitForFunction(green => getComputedStyle(document.getElementById('status-dot')).backgroundColor === green, green);await selectModel(page, 'anthropic/claude-sonnet-4');+ await loadedLogo(page, 'openrouter.svg');+ assert.equal(await page.locator('#provider-picker-btn').getAttribute('aria-label'), 'Model: openrouter · anthropic/claude-sonnet-4',+ 'the model is still named in the tooltip');+ await selectModel(page, 'claude-sonnet-4', 'anthropic');await loadedLogo(page, 'anthropic.svg');await page.locator('#status-dot').evaluate(el => { el.className = 'status-dot offline'; });const red = await resolved(page, '--error');await page.waitForFunction(red => getComputedStyle(document.getElementById('status-dot')).backgroundColor === red, red);const after = await geometry(page);- assert.deepEqual(after.icon, before.icon, 'changing model logos does not shift the badge');+ assert.deepEqual(after.icon, before.icon, 'changing provider logos does not shift the badge');assert.deepEqual(after.dot, before.dot);assert.equal(after.hitsButton, true);await fs.mkdir(new URL('../.build/model-picker-logo/', import.meta.url), { recursive: true });- await page.locator('.composer-toolbar').screenshot({ path: new URL(`../.build/model-picker-logo/${build}.png`, import.meta.url).pathname });+ await page.locator('.composer-toolbar').screenshot({ path: fileURLToPath(new URL(`../.build/model-picker-logo/${build}.png`, import.meta.url)) });});});@@ -178,7 +183,7 @@ for (const [build, engine] of [['chrome', chromium], ['firefox', firefox]]) {let resumeLogo;let requestStarted;const started = new Promise(resolve => { requestStarted = resolve; });- await page.route('**/icons/providers/openai.svg', async route => {+ await page.route('**/icons/providers/openrouter.svg', async route => {await new Promise(resolve => { resumeLogo = resolve; requestStarted(); });await route.fallback();});@@ -194,17 +199,17 @@ for (const [build, engine] of [['chrome', chromium], ['firefox', firefox]]) {} finally {resumeLogo();}- await loadedLogo(page, 'openai.svg');+ await loadedLogo(page, 'openrouter.svg');const after = await geometry(page);assert.deepEqual(after.icon, before.icon);assert.deepEqual(after.dot, before.dot);});});- test('unknown models and providers show the engine fallback after switching from a loaded logo', async () => {+ test('a duplicated provider keeps its source\'s logo; an unknown provider shows the engine fallback', async () => {await panel(async (page) => {await selectModel(page, 'qwen3.5-9b', 'local-instance', 'ollama');- await loadedLogo(page, 'alibaba.svg');+ await loadedLogo(page, 'ollama.svg');await selectModel(page, 'unknown-family', 'unknown-provider');assert.equal(await page.locator('.provider-picker-fallback').isVisible(), true);assert.equal(await page.locator('.provider-picker-logo').count(), 0);@@ -215,8 +220,8 @@ for (const [build, engine] of [['chrome', chromium], ['firefox', firefox]]) {test('a missing logo asset restores the engine fallback with the status badge visible', async () => {await panel(async (page) => {await selectModel(page, 'openai/gpt-6-luna');- await loadedLogo(page, 'openai.svg');- await selectModel(page, 'anthropic/claude-sonnet-4');+ await loadedLogo(page, 'openrouter.svg');+ await selectModel(page, 'claude-sonnet-4', 'anthropic');await page.waitForFunction(() => !document.querySelector('.provider-picker-logo'));assert.equal(await page.locator('.provider-picker-fallback').isVisible(), true);const g = await geometry(page);