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
fix(settings): persist draft model and pass explicitly to WebGPU download actions
Emre Sokullu211a8c20e913
diff --git a/src/chrome/src/ui/settings.js b/src/chrome/src/ui/settings.jsindex 33e42c300..87c6ecd05 100644--- a/src/chrome/src/ui/settings.js+++ b/src/chrome/src/ui/settings.js@@ -2763,6 +2763,11 @@ function renderWebgpuDownloadControl(id, state) {if (line) line.textContent = webgpuDownloadStatusLine(state);}+function getDisplayedWebgpuModel(id = 'webgpu') {+ const input = document.querySelector(`input[data-provider="${id}"][data-key="model"]`);+ return String(input?.value || providersData[id]?.model || '').trim();+}+async function refreshWebgpuDownloadControls() {const ids = [...new Set([...document.querySelectorAll('.btn-webgpu-download')].map(btn => btn.dataset.provider))];if (!ids.length) {@@ -2775,7 +2780,9 @@ async function refreshWebgpuDownloadControls() {let active = false;for (const id of ids) {try {- const state = normalizeWebgpuDownloadSnapshot(await sendToBackground('get_webgpu_download_status') || {});+ const model = getDisplayedWebgpuModel(id);+ const query = model ? { model } : {};+ const state = normalizeWebgpuDownloadSnapshot(await sendToBackground('get_webgpu_download_status', query) || {});renderWebgpuDownloadControl(id, state);if (!state.ready && ['checking', 'downloading', 'paused', 'stopping'].includes(state.status)) active = true;} catch (error) {@@ -2797,11 +2804,18 @@ async function handleWebgpuDownloadButton(btn) {webgpuDownloadActionInFlight = true;try {btn.disabled = true;- const state = normalizeWebgpuDownloadSnapshot(await sendToBackground('get_webgpu_download_status') || {});+ // Persist any form changes on the WebGPU card first so the background+ // provider configuration stays in sync with the user's selected model.+ if (dirtyProviderIds.has(id)) {+ await saveProvider(id, { showFlash: false });+ }+ const model = getDisplayedWebgpuModel(id);+ const msg = model ? { model } : {};+ const state = normalizeWebgpuDownloadSnapshot(await sendToBackground('get_webgpu_download_status', msg) || {});if (state.ready || ['downloading', 'paused'].includes(state.status)) {- await sendToBackground('stop_webgpu_download');+ await sendToBackground('stop_webgpu_download', msg);} else {- await sendToBackground('start_webgpu_download');+ await sendToBackground('start_webgpu_download', msg);}} catch (error) {const line = document.querySelector(`[data-webgpu-download-status="${id}"]`);@@ -3478,6 +3492,7 @@ function renderProviders() {markProviderDirty(providerId);refreshProviderCompatibilitySummary(providerId);refreshVisionStatus(providerId);+ if (providerId === 'webgpu') refreshWebgpuDownloadControls();});});document.querySelectorAll('select[data-key="visionMode"]').forEach((select) => {@@ -3500,6 +3515,7 @@ function renderProviders() {refreshProviderCompatibilitySummary(input.dataset.provider);refreshVisionStatus(input.dataset.provider);if (providerDefinitionId(input.dataset.provider) === 'ollama') refreshVisionStatus(input.dataset.provider);+ if (input.dataset.provider === 'webgpu' && input.dataset.key === 'model') refreshWebgpuDownloadControls();});});document.querySelectorAll('.btn-reset-compatibility').forEach((button) => {diff --git a/test/run.js b/test/run.jsindex a57a339fa..9f87fdb73 100644--- a/test/run.js+++ b/test/run.js@@ -63566,12 +63566,16 @@ test('WebGPU worker follows local text-generation and WebBrain VL vision contracassert.match(apocalypseScript, /webgpu-text-download-state/);assert.match(settingsScript, /btn-webgpu-download/,'the Settings WebGPU card must offer its own download control so the chat error first path works');- assert.match(settingsScript, /sendToBackground\('start_webgpu_download'\)/,- 'the Settings download control must start the model fetch');- assert.match(settingsScript, /sendToBackground\('stop_webgpu_download'\)/,- 'the Settings download control must stop or remove the model fetch');- assert.match(settingsScript, /sendToBackground\('get_webgpu_download_status'\)/,- 'the Settings download control must reflect live download state');+ assert.match(settingsScript, /saveProvider\(id, \{ showFlash: false \}\)/,+ 'clicking the download button must persist any dirty WebGPU settings first');+ assert.match(settingsScript, /getDisplayedWebgpuModel/,+ 'Settings download actions must target the currently displayed model');+ assert.match(settingsScript, /sendToBackground\('start_webgpu_download', msg\)/,+ 'the Settings download control must pass the target model when starting');+ assert.match(settingsScript, /sendToBackground\('stop_webgpu_download', msg\)/,+ 'the Settings download control must pass the target model when stopping');+ assert.match(settingsScript, /sendToBackground\('get_webgpu_download_status', query\)/,+ 'the Settings download control must query the displayed model status');assert.match(settingsScript, /data-webgpu-download-status/,'the Settings WebGPU card must render a download status line');assert.doesNotMatch(settingsScript, /data-webgpu-download-action=/,