Skip to content

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

fix: revalidate persisted WebGPU selection on startup

Barack Sokulluacbb10009b38
diff --git a/src/chrome/src/providers/manager.js b/src/chrome/src/providers/manager.js
index 7f3a60eb0..4beed6f60 100644
--- a/src/chrome/src/providers/manager.js
+++ b/src/chrome/src/providers/manager.js
@@ -409,6 +409,20 @@ export class ProviderManager {
for (const [id, config] of Object.entries(configs)) {
this.providers.set(id, this._createProvider(id, config));
}
+ // A persisted WebGPU selection can outlive its cache (Chrome eviction or
+ // manual clear). Revalidate like setActive() does; otherwise chats fail
+ // readiness indefinitely instead of using the Cloud fallback.
+ if (this.activeProviderId === 'webgpu') {
+ try {
+ const download = await this.providers.get('webgpu')?.downloadStatus?.().catch(() => null);
+ if (download && download.ready !== true) {
+ this.activeProviderId = WEBBRAIN_CLOUD_PROVIDER_ID;
+ providerStateMigrated = true;
+ }
+ } catch {
+ // Probe failures must not block startup; chat will report the missing download.
+ }
+ }
if (providerStateMigrated) await this.save();
}
diff --git a/test/run.js b/test/run.js
index cbd9a38bf..2b1b3b331 100644
--- a/test/run.js
+++ b/test/run.js
@@ -63510,6 +63510,9 @@ test('WebGPU worker follows local text-generation and WebBrain VL vision contrac
'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');
+ const managerSource = fs.readFileSync(path.join(ROOT, 'src/chrome/src/providers/manager.js'), 'utf8');
+ assert.match(managerSource, /activeProviderId === 'webgpu'[\s\S]*?downloadStatus/,
+ 'a persisted WebGPU selection must be revalidated on startup so evicted caches fall back');
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'/);