Skip to content

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

Show selected model logos in the sidepanel picker

Codex release-state test09e7920c0f6d
diff --git a/src/chrome/src/ui/provider-icons.js b/src/chrome/src/ui/provider-icons.js
index 790afd8cb..53341f0b5 100644
--- a/src/chrome/src/ui/provider-icons.js
+++ b/src/chrome/src/ui/provider-icons.js
@@ -59,6 +59,38 @@ 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 compat
diff --git a/src/chrome/src/ui/sidepanel.html b/src/chrome/src/ui/sidepanel.html
index 1a69b0184..fa1e57fb5 100644
--- a/src/chrome/src/ui/sidepanel.html
+++ b/src/chrome/src/ui/sidepanel.html
@@ -391,21 +391,21 @@
</button>
<div class="provider-picker" id="provider-picker">
<!-- Native select kept as the value source for existing handlers.
- The closed button shows an engine icon, not the model's name, to
- save toolbar room: the name is its tooltip and accessible name,
- and the open menu marks it. Brand icons show only in the menu.
- The connection dot sits on the engine's corner, inside the
- button, so it reads as the model's status and opens the menu. -->
+ The chosen model's logo shares the button with its connection
+ badge. The engine is the fallback for a missing logo; the
+ model's name remains in the tooltip and accessible name. -->
<select id="provider-select" class="provider-select-native" title="LLM Provider" tabindex="-1" aria-hidden="true"></select>
<button type="button" id="provider-picker-btn" class="provider-picker-btn" aria-haspopup="listbox" aria-expanded="false" aria-controls="provider-picker-menu" aria-describedby="status-dot" aria-label="LLM Provider">
<span class="provider-picker-engine">
- <svg class="provider-picker-icon" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.25" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
- <path d="M10 4h6"/>
- <path d="M13 4v3"/>
- <path d="M7 7h9l2 2h2v8h-3l-2 2H9l-2-2z"/>
- <path d="M3 11v4"/>
- <path d="M3 13h4"/>
- </svg>
+ <span class="provider-picker-icon" aria-hidden="true">
+ <svg class="provider-picker-fallback" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.25" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
+ <path d="M10 4h6"/>
+ <path d="M13 4v3"/>
+ <path d="M7 7h9l2 2h2v8h-3l-2 2H9l-2-2z"/>
+ <path d="M3 11v4"/>
+ <path d="M3 13h4"/>
+ </svg>
+ </span>
<span id="status-dot" class="status-dot offline"></span>
</span>
<span class="provider-picker-label" id="provider-picker-label"></span>
diff --git a/src/chrome/src/ui/sidepanel.js b/src/chrome/src/ui/sidepanel.js
index d44228db1..5cac6039d 100644
--- a/src/chrome/src/ui/sidepanel.js
+++ b/src/chrome/src/ui/sidepanel.js
@@ -81,7 +81,7 @@ import {
buildFeedbackUrl,
normalizeState as normalizeStoreReviewState,
} from './store-review-prompt.js';
-import { providerIconUrl } from './provider-icons.js';
+import { modelIconUrl, 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';
@@ -743,6 +743,8 @@ if (statusDot) statusDot.title = statusDotTitle();
const providerPickerLabelById = new Map();
// The configured model of each provider, for the picker's tooltip and name.
const providerPickerModelById = new Map();
+// Duplicated provider instances keep the original provider's brand.
+const providerPickerSourceById = new Map();
let languagePickerTypeahead = '';
let languagePickerTypeaheadTimer = null;
@@ -8354,6 +8356,39 @@ function bindPickerMenuHighlight(menu) {
bindPickerMenuHighlight(providerPickerMenu);
bindPickerMenuHighlight(languagePickerMenu);
+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);
+ if (icon.dataset.src === src) return;
+ icon.dataset.src = src;
+ icon.classList.remove('has-logo');
+ icon.querySelector('img')?.remove();
+ if (!src) return;
+
+ const img = document.createElement('img');
+ img.className = 'provider-icon provider-picker-logo hidden';
+ img.alt = '';
+ img.width = 18;
+ img.height = 18;
+ img.draggable = false;
+ // Keep the engine visible until the logo loads. A late result from a
+ // previous selection must never change the current selection's icon.
+ img.onload = () => {
+ if (img.parentElement !== icon) return;
+ img.classList.remove('hidden');
+ icon.classList.add('has-logo');
+ };
+ img.onerror = () => {
+ if (img.parentElement !== icon) return;
+ img.remove();
+ icon.classList.remove('has-logo');
+ };
+ icon.appendChild(img);
+ img.src = src;
+}
+
function syncProviderPickerButton() {
if (!providerSelect || !providerPickerLabel) return;
const id = providerSelect.value;
@@ -8362,6 +8397,7 @@ function syncProviderPickerButton() {
|| id
|| '';
providerPickerLabel.textContent = shortLabel;
+ syncProviderPickerIcon();
if (providerPickerBtn) {
// 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).
@@ -8393,6 +8429,7 @@ function appendProviderPickerGroup(label) {
}
function appendProviderPickerOption(id, name, meta, iconProviderId = id) {
+ providerPickerSourceById.set(id, iconProviderId);
if (!providerPickerMenu) return;
const btn = document.createElement('button');
btn.type = 'button';
@@ -8401,8 +8438,7 @@ function appendProviderPickerOption(id, name, meta, iconProviderId = id) {
btn.dataset.value = id;
btn.setAttribute('aria-selected', 'false');
- // Icons only in the open menu β€” closed header stays text-only so the
- // WebBrain mark (and other brand chips) don't compete with the chrome.
+ // Menu rows identify the provider; the closed button resolves its model's logo.
const iconSrc = providerIconUrl(iconProviderId);
if (iconSrc) {
const img = document.createElement('img');
@@ -8616,6 +8652,7 @@ async function loadProviders() {
providerPickerMenu?.replaceChildren();
providerPickerLabelById.clear();
providerPickerModelById.clear();
+ providerPickerSourceById.clear();
// Managed tier names are presentation only; keep background IDs/configs intact.
const cloudLabel = 'Compass Light';
diff --git a/src/chrome/styles/sidepanel.css b/src/chrome/styles/sidepanel.css
index f225d83ff..34eac0623 100644
--- a/src/chrome/styles/sidepanel.css
+++ b/src/chrome/styles/sidepanel.css
@@ -3525,13 +3525,21 @@ html[data-ui-scale="175"] .conversation-action-label {
padding: 4px 4px 4px 5px;
}
-/* In the composer the picker is an engine icon: the model's name is its
- tooltip and accessible name, so a long name never crowds the toolbar. */
+/* Keep the model logo and engine fallback the same size, so switching
+ providers never moves the connection badge or crowds the toolbar. */
.provider-picker-icon {
+ display: inline-flex;
+ width: 18px;
+ height: 18px;
flex: 0 0 auto;
}
-/* The connection dot is a badge on the engine's lower corner, inside the
+.provider-picker-logo.hidden,
+.provider-picker-icon.has-logo .provider-picker-fallback {
+ display: none;
+}
+
+/* The connection dot is a badge on the logo's lower corner, inside the
button: it reads as the model's status, and clicking it opens the menu like
the rest of the button. A ring in the button's background keeps it clear of
the icon's strokes. */
diff --git a/src/firefox/src/ui/provider-icons.js b/src/firefox/src/ui/provider-icons.js
index b2807d9d0..68449cc29 100644
--- a/src/firefox/src/ui/provider-icons.js
+++ b/src/firefox/src/ui/provider-icons.js
@@ -58,6 +58,38 @@ 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 compat
diff --git a/src/firefox/src/ui/sidepanel.html b/src/firefox/src/ui/sidepanel.html
index f87199924..06ba6b16f 100644
--- a/src/firefox/src/ui/sidepanel.html
+++ b/src/firefox/src/ui/sidepanel.html
@@ -353,21 +353,21 @@
</button>
<div class="provider-picker" id="provider-picker">
<!-- Native select kept as the value source for existing handlers.
- The closed button shows an engine icon, not the model's name, to
- save toolbar room: the name is its tooltip and accessible name,
- and the open menu marks it. Brand icons show only in the menu.
- The connection dot sits on the engine's corner, inside the
- button, so it reads as the model's status and opens the menu. -->
+ The chosen model's logo shares the button with its connection
+ badge. The engine is the fallback for a missing logo; the
+ model's name remains in the tooltip and accessible name. -->
<select id="provider-select" class="provider-select-native" title="LLM Provider" tabindex="-1" aria-hidden="true"></select>
<button type="button" id="provider-picker-btn" class="provider-picker-btn" aria-haspopup="listbox" aria-expanded="false" aria-controls="provider-picker-menu" aria-describedby="status-dot" aria-label="LLM Provider">
<span class="provider-picker-engine">
- <svg class="provider-picker-icon" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.25" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
- <path d="M10 4h6"/>
- <path d="M13 4v3"/>
- <path d="M7 7h9l2 2h2v8h-3l-2 2H9l-2-2z"/>
- <path d="M3 11v4"/>
- <path d="M3 13h4"/>
- </svg>
+ <span class="provider-picker-icon" aria-hidden="true">
+ <svg class="provider-picker-fallback" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.25" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
+ <path d="M10 4h6"/>
+ <path d="M13 4v3"/>
+ <path d="M7 7h9l2 2h2v8h-3l-2 2H9l-2-2z"/>
+ <path d="M3 11v4"/>
+ <path d="M3 13h4"/>
+ </svg>
+ </span>
<span id="status-dot" class="status-dot offline"></span>
</span>
<span class="provider-picker-label" id="provider-picker-label"></span>
diff --git a/src/firefox/src/ui/sidepanel.js b/src/firefox/src/ui/sidepanel.js
index e1af08974..27dbcb289 100644
--- a/src/firefox/src/ui/sidepanel.js
+++ b/src/firefox/src/ui/sidepanel.js
@@ -80,7 +80,7 @@ import {
buildFeedbackUrl,
normalizeState as normalizeStoreReviewState,
} from './store-review-prompt.js';
-import { providerIconUrl } from './provider-icons.js';
+import { modelIconUrl, 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';
@@ -618,6 +618,8 @@ if (statusDot) statusDot.title = statusDotTitle();
const providerPickerLabelById = new Map();
// The configured model of each provider, for the picker's tooltip and name.
const providerPickerModelById = new Map();
+// Duplicated provider instances keep the original provider's brand.
+const providerPickerSourceById = new Map();
let languagePickerTypeahead = '';
let languagePickerTypeaheadTimer = null;
@@ -8184,6 +8186,39 @@ function bindPickerMenuHighlight(menu) {
bindPickerMenuHighlight(providerPickerMenu);
bindPickerMenuHighlight(languagePickerMenu);
+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);
+ if (icon.dataset.src === src) return;
+ icon.dataset.src = src;
+ icon.classList.remove('has-logo');
+ icon.querySelector('img')?.remove();
+ if (!src) return;
+
+ const img = document.createElement('img');
+ img.className = 'provider-icon provider-picker-logo hidden';
+ img.alt = '';
+ img.width = 18;
+ img.height = 18;
+ img.draggable = false;
+ // Keep the engine visible until the logo loads. A late result from a
+ // previous selection must never change the current selection's icon.
+ img.onload = () => {
+ if (img.parentElement !== icon) return;
+ img.classList.remove('hidden');
+ icon.classList.add('has-logo');
+ };
+ img.onerror = () => {
+ if (img.parentElement !== icon) return;
+ img.remove();
+ icon.classList.remove('has-logo');
+ };
+ icon.appendChild(img);
+ img.src = src;
+}
+
function syncProviderPickerButton() {
if (!providerSelect || !providerPickerLabel) return;
const id = providerSelect.value;
@@ -8192,6 +8227,7 @@ function syncProviderPickerButton() {
|| id
|| '';
providerPickerLabel.textContent = shortLabel;
+ syncProviderPickerIcon();
if (providerPickerBtn) {
// 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).
@@ -8223,6 +8259,7 @@ function appendProviderPickerGroup(label) {
}
function appendProviderPickerOption(id, name, meta, iconProviderId = id) {
+ providerPickerSourceById.set(id, iconProviderId);
if (!providerPickerMenu) return;
const btn = document.createElement('button');
btn.type = 'button';
@@ -8231,8 +8268,7 @@ function appendProviderPickerOption(id, name, meta, iconProviderId = id) {
btn.dataset.value = id;
btn.setAttribute('aria-selected', 'false');
- // Icons only in the open menu β€” closed header stays text-only so the
- // WebBrain mark (and other brand chips) don't compete with the chrome.
+ // Menu rows identify the provider; the closed button resolves its model's logo.
const iconSrc = providerIconUrl(iconProviderId);
if (iconSrc) {
const img = document.createElement('img');
@@ -8446,6 +8482,7 @@ async function loadProviders() {
providerPickerMenu?.replaceChildren();
providerPickerLabelById.clear();
providerPickerModelById.clear();
+ providerPickerSourceById.clear();
// Managed tier names are presentation only; keep background IDs/configs intact.
const cloudLabel = 'Compass Light';
diff --git a/src/firefox/styles/sidepanel.css b/src/firefox/styles/sidepanel.css
index 6dfa90a53..26165989c 100644
--- a/src/firefox/styles/sidepanel.css
+++ b/src/firefox/styles/sidepanel.css
@@ -3351,13 +3351,21 @@ html[data-ui-scale="175"] .conversation-action-label {
padding: 4px 4px 4px 5px;
}
-/* In the composer the picker is an engine icon: the model's name is its
- tooltip and accessible name, so a long name never crowds the toolbar. */
+/* Keep the model logo and engine fallback the same size, so switching
+ providers never moves the connection badge or crowds the toolbar. */
.provider-picker-icon {
+ display: inline-flex;
+ width: 18px;
+ height: 18px;
flex: 0 0 auto;
}
-/* The connection dot is a badge on the engine's lower corner, inside the
+.provider-picker-logo.hidden,
+.provider-picker-icon.has-logo .provider-picker-fallback {
+ display: none;
+}
+
+/* The connection dot is a badge on the logo's lower corner, inside the
button: it reads as the model's status, and clicking it opens the menu like
the rest of the button. A ring in the button's background keeps it clear of
the icon's strokes. */
diff --git a/test/model-picker-icon.mjs b/test/model-picker-icon.mjs
index b3f82a9cb..fe1e1576b 100644
--- a/test/model-picker-icon.mjs
+++ b/test/model-picker-icon.mjs
@@ -1,5 +1,5 @@
-// The composer's model picker shows an engine icon instead of the model's
-// name; the name is its tooltip and accessible name (src/*/src/ui/sidepanel.*).
+// The composer's model picker shows the selected model's logo, with an
+// engine fallback; its name remains in the tooltip and accessible name.
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
import { test } from 'node:test';
@@ -13,10 +13,10 @@ const extract = (source, name) => {
};
for (const build of ['chrome', 'firefox']) {
- test(`${build}: the closed model picker is an engine icon`, () => {
+ test(`${build}: the closed model picker keeps an engine fallback and connection badge`, () => {
const html = read(build, 'src/ui/sidepanel.html');
const button = html.match(/<button type="button" id="provider-picker-btn"[\s\S]*?<\/button>/)[0];
- assert.match(button, /<span class="provider-picker-engine">\s*<svg class="provider-picker-icon"[^>]*aria-hidden="true">[\s\S]*?<\/svg>\s*<span id="status-dot" class="status-dot offline"><\/span>\s*<\/span>\s*<span class="provider-picker-label" id="provider-picker-label"><\/span>/,
+ assert.match(button, /<span class="provider-picker-engine">\s*<span class="provider-picker-icon" aria-hidden="true">\s*<svg class="provider-picker-fallback"[^>]*aria-hidden="true">[\s\S]*?<\/svg>\s*<\/span>\s*<span id="status-dot" class="status-dot offline"><\/span>\s*<\/span>\s*<span class="provider-picker-label" id="provider-picker-label"><\/span>/,
'the icon comes first, hidden from assistive technology, with the connection dot on it');
assert.match(button, /aria-describedby="status-dot"/, 'the connection status describes the button');
assert.equal(html.match(/id="status-dot"/g).length, 1, 'the dot is no longer a separate toolbar item');
@@ -35,6 +35,7 @@ for (const build of ['chrome', 'firefox']) {
const options = [{ dataset: { value: 'openrouter' }, attrs: {}, setAttribute(k, v) { this.attrs[k] = v; } },
{ dataset: { value: 'local' }, attrs: {}, setAttribute(k, v) { this.attrs[k] = v; } }];
const context = vm.createContext({
+ syncProviderPickerIcon() {},
t: (key, params = {}) => String(en[key] || key).replace(/\{(\w+)\}/g, (_, k) => params[k] ?? ''),
// The option text carries the provider's status, never its model.
providerSelect: { value: 'openrouter', selectedOptions: [{ textContent: 'OpenRouter β€” Active' }] },
@@ -80,6 +81,7 @@ for (const build of ['chrome', 'firefox']) {
const panel = read(build, 'src/ui/sidepanel.js');
let answer;
const context = vm.createContext({
+ syncProviderPickerIcon() {},
t: (key, params = {}) => String(en[key] || key).replace(/\{(\w+)\}/g, (_, k) => params[k] ?? ''),
providerSelect: { value: 'openrouter' },
providerTestRequestId: 0,
@@ -106,6 +108,7 @@ for (const build of ['chrome', 'firefox']) {
let locale = 'en';
let answer;
const context = vm.createContext({
+ syncProviderPickerIcon() {},
t: (key, params = {}) => String(dicts[locale][key] || key).replace(/\{(\w+)\}/g, (_, k) => params[k] ?? ''),
providerSelect: { value: 'openrouter', selectedOptions: [{ textContent: 'OpenRouter β€” Active' }] },
providerTestRequestId: 0,
@@ -154,6 +157,7 @@ for (const build of ['chrome', 'firefox']) {
};
const wait = (name) => new Promise((resolve) => { pending[name] = resolve; });
const context = vm.createContext({
+ syncProviderPickerIcon() {},
t: (key, params = {}) => String(en[key] || key).replace(/\{(\w+)\}/g, (_, k) => params[k] ?? ''),
providerSelect,
MORE_PROVIDERS_OPTION_VALUE: '__more_providers__',
diff --git a/test/model-picker-status-ui.mjs b/test/model-picker-status-ui.mjs
index 8022d00d9..500b665af 100644
--- a/test/model-picker-status-ui.mjs
+++ b/test/model-picker-status-ui.mjs
@@ -1,18 +1,23 @@
-// The provider's online/offline dot is a badge on the composer's engine icon,
+// The provider's online/offline dot is a badge on the composer's model 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 (scripts are left out; the dot's class is set
-// the way testConnection() sets it).
+// 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 { after, before, describe, test } from 'node:test';
import { chromium, firefox } from 'playwright';
const read = async (build, file) => (await fs.readFile(new URL(`../src/${build}/${file}`, import.meta.url), 'utf8')).replace(/\r\n/g, '\n');
+const extract = (source, name) => {
+ const start = source.search(new RegExp(`^function ${name}\\(`, 'm'));
+ assert.ok(start >= 0, name);
+ return source.slice(start, source.indexOf('\n}', start) + 2);
+};
for (const [build, engine] of [['chrome', chromium], ['firefox', firefox]]) {
describe(`${build}: model picker status dot`, () => {
- let browser, html, css;
+ let browser, html, css, iconHelper;
before(async () => {
browser = await engine.launch({ headless: true });
html = (await read(build, 'src/ui/sidepanel.html'))
@@ -20,21 +25,50 @@ for (const [build, engine] of [['chrome', chromium], ['firefox', firefox]]) {
.filter((line) => !line.trim().startsWith('<script'))
.join('\n');
css = await read(build, 'styles/sidepanel.css');
+ const panelSource = await read(build, 'src/ui/sidepanel.js');
+ iconHelper = ['syncProviderPickerIcon', 'syncProviderPickerButton'].map(name => extract(panelSource, name)).join('\n');
});
after(async () => { await browser?.close(); });
- async function panel(run, { dir = 'ltr', theme = 'dark', state = 'online' } = {}) {
+ async function panel(run, { dir = 'ltr', theme = 'dark', state = 'online', failedLogo = '' } = {}) {
const context = await browser.newContext({ viewport: { width: 420, height: 640 } });
try {
- await context.route('**/*', (route) => {
+ await context.route('**/*', async (route) => {
const { pathname } = new URL(route.request().url());
if (pathname === '/panel') return route.fulfill({ contentType: 'text/html', body: html });
+ if (['/src/ui/provider-icons.js', '/src/providers/provider-catalog.js'].includes(pathname)) {
+ return route.fulfill({ contentType: 'text/javascript', body: await read(build, pathname.slice(1)) });
+ }
+ if (/^\/icons\/providers\/[a-z0-9_-]+\.(svg|png)$/.test(pathname) && !pathname.endsWith(`/${failedLogo}`)) {
+ const body = await fs.readFile(new URL(`../src/${build}${pathname}`, import.meta.url));
+ return route.fulfill({ contentType: pathname.endsWith('.svg') ? 'image/svg+xml' : 'image/png', body });
+ }
return route.fulfill({ status: 404, body: '' });
});
const page = await context.newPage();
page.setDefaultTimeout(2500);
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';
+ const providerPickerBtn = document.getElementById('provider-picker-btn');
+ const providerPickerLabel = document.getElementById('provider-picker-label');
+ const providerPickerMenu = document.getElementById('provider-picker-menu');
+ const providerSelect = { value: '' };
+ const providerPickerLabelById = new Map();
+ const providerPickerModelById = new Map();
+ const providerPickerSourceById = new Map();
+ const statusDot = null; // The fixture sets connection states directly.
+ const t = (key, params) => params?.name ? 'Model: ' + params.name : 'Choose a model';
+ ${iconHelper}
+ window.selectModel = (model, id = 'openrouter', source = id) => {
+ providerSelect.value = id;
+ providerPickerModelById.set(id, model);
+ providerPickerSourceById.set(id, source);
+ syncProviderPickerButton();
+ };
+ ` });
+ await page.waitForFunction(() => typeof window.selectModel === 'function');
await page.evaluate(({ dir, theme, state }) => {
document.documentElement.dir = dir;
if (theme === 'light') document.documentElement.dataset.theme = 'light';
@@ -73,7 +107,7 @@ for (const [build, engine] of [['chrome', chromium], ['firefox', firefox]]) {
return color;
}, variable);
- test('the dot sits on the engine icon inside the picker button, not after its arrow', async () => {
+ test('the dot sits on the icon inside the picker button, not after its arrow', async () => {
await panel(async (page) => {
const placement = await page.evaluate(() => {
const dot = document.getElementById('status-dot');
@@ -98,6 +132,99 @@ for (const [build, engine] of [['chrome', chromium], ['firefox', firefox]]) {
});
});
+ const selectModel = (page, model, id = 'openrouter', source = id) => page.evaluate(
+ ({ model, id, source }) => window.selectModel(model, id, source), { model, id, source },
+ );
+ const loadedLogo = async (page, file) => {
+ const logo = page.locator('.provider-picker-icon .provider-picker-logo');
+ await logo.waitFor({ state: 'visible' });
+ await page.waitForFunction((file) => {
+ const img = document.querySelector('.provider-picker-icon .provider-picker-logo');
+ return img?.complete && img.naturalWidth > 0 && img.src.endsWith(`/icons/providers/${file}`);
+ }, file);
+ assert.equal(await page.locator('.provider-picker-fallback').isVisible(), false);
+ assert.equal(await page.locator('.provider-picker-icon').getAttribute('aria-hidden'), 'true');
+ return logo;
+ };
+
+ test('the selected model logo changes within one provider and retains the green/red status badge', async () => {
+ await panel(async (page) => {
+ await selectModel(page, 'openai/gpt-6-luna');
+ await loadedLogo(page, 'openai.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);
+ assert.equal(before.hitsButton, true);
+ const green = await resolved(page, '--success');
+ await page.waitForFunction(green => getComputedStyle(document.getElementById('status-dot')).backgroundColor === green, green);
+
+ await selectModel(page, 'anthropic/claude-sonnet-4');
+ 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.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 });
+ });
+ });
+
+ test('while a logo loads, the engine stays visible without widening the icon', async () => {
+ await panel(async (page) => {
+ let resumeLogo;
+ let requestStarted;
+ const started = new Promise(resolve => { requestStarted = resolve; });
+ await page.route('**/icons/providers/openai.svg', async route => {
+ await new Promise(resolve => { resumeLogo = resolve; requestStarted(); });
+ await route.fallback();
+ });
+ const before = await geometry(page);
+ await selectModel(page, 'openai/gpt-6-luna');
+ await started;
+ try {
+ assert.equal(await page.locator('.provider-picker-fallback').isVisible(), true);
+ assert.equal(await page.locator('.provider-picker-logo').isVisible(), false);
+ const loading = await geometry(page);
+ assert.deepEqual(loading.icon, before.icon);
+ assert.deepEqual(loading.dot, before.dot);
+ } finally {
+ resumeLogo();
+ }
+ await loadedLogo(page, 'openai.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 () => {
+ await panel(async (page) => {
+ await selectModel(page, 'qwen3.5-9b', 'local-instance', 'ollama');
+ await loadedLogo(page, 'alibaba.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);
+ assert.equal(await page.locator('#status-dot').isVisible(), true);
+ });
+ });
+
+ 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 page.waitForFunction(() => !document.querySelector('.provider-picker-logo'));
+ assert.equal(await page.locator('.provider-picker-fallback').isVisible(), true);
+ const g = await geometry(page);
+ assert.ok(g.dot.width >= 6 && g.dot.height >= 6);
+ assert.equal(g.hitsButton, true);
+ }, { state: 'offline', failedLogo: 'anthropic.svg' });
+ });
+
if (build === 'chrome') {
test('screen readers get the connection status as the button description', async () => {
await panel(async (page) => {