Skip to content

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

fix: probe requested worker for active WebGPU transfers across same runtime

Barack Sokullu73cb0914b306
diff --git a/src/chrome/src/offscreen/vision-inference-host.js b/src/chrome/src/offscreen/vision-inference-host.js
index dd7b96f48..4e46332bc 100644
--- a/src/chrome/src/offscreen/vision-inference-host.js
+++ b/src/chrome/src/offscreen/vision-inference-host.js
@@ -346,10 +346,21 @@ async function probeExistingTextWorkerStatus(modelId = '', options = {}) {
}
async function findActiveTextTransfer(requestedModel) {
- const other = isBitgpuTextModel(requestedModel)
- ? await probeExistingTextWorkerStatus('', { probeActive: true })
- : await probeExistingTextWorkerStatus(WEBGPU_BONSAI27_MODEL_ID, { probeActive: true });
- return isActiveTextTransfer(other) ? other : null;
+ // Probe both runtimes: the other worker (Bonsai vs ONNX) and the requested
+ // worker itself for a different model. Probing only the other runtime misses
+ // same-worker transfers (e.g. ONNX A downloading while status for ONNX B is
+ // requested), leaving Settings with no Stop control for the running transfer.
+ const probes = isBitgpuTextModel(requestedModel)
+ ? [
+ probeExistingTextWorkerStatus('', { probeActive: true }),
+ probeExistingTextWorkerStatus(WEBGPU_BONSAI27_MODEL_ID, { probeActive: true }),
+ ]
+ : [
+ probeExistingTextWorkerStatus(WEBGPU_BONSAI27_MODEL_ID, { probeActive: true }),
+ probeExistingTextWorkerStatus('', { probeActive: true }),
+ ];
+ const results = await Promise.all(probes);
+ return results.find(isActiveTextTransfer) || null;
}
function startExclusiveTextDownload(message) {
diff --git a/test/run.js b/test/run.js
index 9fa98daca..13a0288df 100644
--- a/test/run.js
+++ b/test/run.js
@@ -63501,6 +63501,8 @@ test('WebGPU worker follows local text-generation and WebBrain VL vision contrac
assert.match(host, /probeExistingTextWorkerStatus/);
assert.match(host, /probeActive: true/,
'cross-worker transfer checks must query active transfers independently of a hard-coded model');
+ assert.match(host, /Promise\.all\(probes\)/,
+ 'active-transfer checks must probe the requested worker as well as the other runtime so same-worker downloads stay stoppable');
assert.match(worker, /payload\?\.probeActive === true[\s\S]*?textDownloadSnapshot/,
'text-download-status probes must return the active transfer when requested');
assert.match(host, /sendTextWorkerMessage\(message\.model, 'text-download-status'/);