Elffuss BraidHub

utopia-ia/elffuss-code public

Without WebGPU the IDE loads the light ONNX model again

Inherited from main (b7d7db0): that commit took
the bare 'onnx' id out of the model options, but pickLocalBrain(),
defaultBrain(), preloadModel() and the fallback after a Gemma that does not fit
still asked for 'onnx'. preloadModel() only loads ids the selector offers, so
with no WebGPU (where no Gemma is offered either) nothing was left to load and
the IDE started with no model and said nothing. They now ask for
'onnx:qwen3.5-0.8b', the id the selector and the cards offer, which loads the
same Qwen3.5-0.8B (on wasm without WebGPU). Claw already uses that id.

The ONNX card's subtitle also went back to the model it describes: it still
read "Modelo propio · 850 MB · tool-calls + apps", the text of the Elffuss LM
that was removed, and it was never shown because its key was the bare id.

tests/onnx-autoload.mjs (WebGPU hidden, transformers.js stood in by page.route,
no model downloaded): with no saved model the IDE loads Qwen3.5-0.8B on wasm
and selects it with the offered id; a saved bare 'onnx' lands on the same; in
Basic mode nothing loads.
Changeset08a4eae756d032a896848dac0f2a880c95874c1ef27e2f1ff19ba4c2705deae0
AuthorKikoCis <kikocisneros@gmail.com> · 2026-10-11 15:10 +02:00
CommitterKikoCis <kikocisneros@gmail.com> · 2026-10-11 15:10 +02:00
Parentsab2541aae104

Browse the files at this changeset

3 files changed

added tests/onnx-autoload.mjs +68 −0
@@ -0,0 +1,68 @@
1+// Sin WebGPU (no hay Gemma que ofrecer) y sin modelo elegido, el IDE carga solo
2+// el ONNX ligero, Qwen3.5-0.8B, con el id que ofrece el selector.
3+//
4+// Antes se pedía 'onnx' a secas, un id que ya no está entre las opciones
5+// (b7d7db0): preloadModel() solo carga lo que se ofrece, así que no quedaba
6+// nada que cargar y el IDE arrancaba sin cerebro, sin decir nada.
7+//
8+// transformers.js es de mentira (page.route): no se descarga ningún modelo.
9+//
10+// BASE=http://localhost:8799 node tests/onnx-autoload.mjs
11+import { chromium } from 'playwright';
12+const BASE = process.env.BASE || 'http://localhost:8799';
13+let fails = 0; const ok = (n, c, e = '') => { console.log((c ? '✅' : '❌') + ' ' + n + (e ? ' — ' + e : '')); if (!c) fails++; };
14+
15+const FALSO_TF = `
16+export const env = {};
17+export class TextStreamer { constructor(t, o) { this.o = o; } }
18+export class InterruptableStoppingCriteria { interrupt() {} }
19+export async function pipeline(task, id, opts) {
20+ (window.__tf = window.__tf || []).push({ task, id, device: opts?.device, dtype: opts?.dtype });
21+ const g = async () => [{ generated_text: 'hola' }];
22+ g.tokenizer = {}; g.dispose = () => {};
23+ return g;
24+}`;
25+
26+const b = await chromium.launch();
27+async function arranca(guardado) {
28+ const ctx = await b.newContext({ locale: 'es-ES' });
29+ await ctx.addInitScript(g => {
30+ try { Object.defineProperty(Navigator.prototype, 'gpu', { get() { return undefined; }, configurable: true }); } catch { /* */ }
31+ try { if (g) localStorage.setItem('elffusscode.model', g); } catch { /* */ }
32+ }, guardado);
33+ const p = await ctx.newPage({ viewport: { width: 1400, height: 900 } });
34+ const errs = []; p.on('pageerror', e => errs.push(e.message.slice(0, 160)));
35+ await p.route(/cdn\.jsdelivr\.net\/npm\/@huggingface\/transformers@4/, r => r.fulfill({ status: 200, contentType: 'text/javascript', body: FALSO_TF }));
36+ await p.goto(BASE + '/?test-opfs', { waitUntil: 'domcontentloaded' });
37+ await p.waitForFunction(() => /dot on/.test(document.getElementById('model-dot')?.className || ''), null, { timeout: 20000 }).catch(() => {});
38+ const r = await p.evaluate(() => ({
39+ tf: window.__tf || [], guardado: localStorage.getItem('elffusscode.model'),
40+ dot: document.getElementById('model-dot')?.className, nombre: document.getElementById('model-dot')?.getAttribute('aria-label'),
41+ sel: document.getElementById('model-select')?.value,
42+ opciones: [...document.querySelectorAll('#model-select option')].map(o => o.value),
43+ }));
44+ await ctx.close();
45+ return { ...r, errs };
46+}
47+
48+const r1 = await arranca(null);
49+ok('sin WebGPU y sin modelo guardado, el IDE carga solo el ONNX ligero (Qwen3.5-0.8B, por wasm)',
50+ r1.tf.length === 1 && r1.tf[0].id === 'onnx-community/Qwen3.5-0.8B-ONNX' && r1.tf[0].device === 'wasm', JSON.stringify(r1.tf));
51+ok('…y queda elegido con el id que ofrece el selector', r1.guardado === 'onnx:qwen3.5-0.8b' && r1.sel === 'onnx:qwen3.5-0.8b' && r1.opciones.includes(r1.sel), JSON.stringify({ guardado: r1.guardado, sel: r1.sel, opciones: r1.opciones }));
52+ok('…con el punto de estado encendido y el nombre del modelo', /\bon\b/.test(r1.dot || '') && /Qwen3\.5-0\.8B/.test(r1.nombre || ''), JSON.stringify({ dot: r1.dot, nombre: r1.nombre }));
53+
54+// Quien tenía guardado el id viejo ('onnx' a secas, de cuando era Elffuss LM)
55+// también arranca con el ligero, no sin modelo.
56+const r2 = await arranca('onnx');
57+ok('con el id viejo «onnx» guardado, carga el ligero con el id nuevo', r2.tf.length === 1 && r2.guardado === 'onnx:qwen3.5-0.8b' && r2.sel === 'onnx:qwen3.5-0.8b', JSON.stringify({ tf: r2.tf.length, guardado: r2.guardado, sel: r2.sel }));
58+
59+// Con el modo Básico elegido no se carga nada (eso no cambia).
60+const r3 = await arranca('rules');
61+ok('con «Básico» elegido no se carga ningún modelo', r3.tf.length === 0 && r3.guardado === 'rules', JSON.stringify({ tf: r3.tf.length, guardado: r3.guardado }));
62+
63+const errs = [...r1.errs, ...r2.errs, ...r3.errs];
64+console.log('\n errores JS:', errs[0] || 'ninguno');
65+ok('sin errores de página', errs.length === 0, errs.join(' | '));
66+console.log(fails ? `\n❌ ${fails} FALLO(S)` : '\n✅ SIN GPU EL IDE ARRANCA CON EL MODELO LIGERO');
67+await b.close();
68+process.exit(fails ? 1 : 0);
modified web/js/i18n.js +2 −2
@@ -75,7 +75,7 @@
7575 setBrainTitle: "Cerebro (modelo)",
7676 setModelE4bSub: "El mejor · WebGPU local · ~4 GB",
7777 setModelE2bSub: "Ligero · WebGPU local · ~2 GB",
78- setModelOnnxSub: "Modelo propio · 850 MB · tool-calls + apps",
78+ setModelOnnxSub: "Ligero · WebGPU o CPU · ~600 MB",
7979 setModelRulesSub: "Órdenes directas, cero descarga",
8080 setBridgeTitle: "🔌 Bridge local (ejecución real en tu máquina)",
8181 setBridgeDisconnected: "desconectado",
@@ -300,7 +300,7 @@
300300 setBrainTitle: "Brain (model)",
301301 setModelE4bSub: "The best · local WebGPU · ~4 GB",
302302 setModelE2bSub: "Light · local WebGPU · ~2 GB",
303- setModelOnnxSub: "Our own model · 850 MB · tool-calls + apps",
303+ setModelOnnxSub: "Light · WebGPU or CPU · ~600 MB",
304304 setModelRulesSub: "Direct commands, zero download",
305305 setBridgeTitle: "🔌 Local bridge (real execution on your machine)",
306306 setBridgeDisconnected: "disconnected",
modified web/js/main.js +14 −6
@@ -618,6 +618,14 @@
618618 } catch { return { gpu: false, maxBuf: 0, mem }; }
619619 }
620620
621+// El ONNX ligero (Qwen3.5-0.8B, WebGPU o wasm), con el MISMO id que ofrecen el
622+// selector y las tarjetas. Aquí se pedía 'onnx' a secas, un id que b7d7db0 quitó
623+// de las opciones; preloadModel() solo carga lo que se ofrece, así que sin
624+// WebGPU (donde tampoco hay Gemma) no quedaba nada y el IDE arrancaba sin
625+// modelo, y el respaldo de un Gemma que no cabe cargaba uno que el selector no
626+// sabía enseñar.
627+const ONNX_LIGERO = 'onnx:qwen3.5-0.8b';
628+
621629 // Auto-selección: el modelo MÁS GRANDE que entre en esta máquina. Gemma por
622630 // LiteRT si la GPU aguanta sus buffers; si no, un ONNX pequeño (WebGPU o wasm).
623631 async function pickLocalBrain() {
@@ -627,10 +635,10 @@
627635 if (c.maxBuf >= 2 ** 30 && c.mem >= 6) return 'litert:gemma-e2b'; // ~2 GB
628636 }
629637 if (c.gpu && isMobile()) return 'litert:gemma-e2b';
630- return 'onnx'; // ONNX pequeño: Qwen3.5-0.8B por defecto (ver model-config.js)
638+ return ONNX_LIGERO;
631639 }
632640 // heurística vieja como último recurso síncrono
633-const defaultBrain = () => !realGPU ? 'onnx' : (isMobile() ? 'litert:gemma-e2b' : 'litert:gemma-e4b');
641+const defaultBrain = () => !realGPU ? ONNX_LIGERO : (isMobile() ? 'litert:gemma-e2b' : 'litert:gemma-e4b');
634642
635643 // El runtime propio y su modelo grande se SONDEAN, no se cablean: el motor
636644 // llega por rsync y el modelo son gigabytes que pueden no estar alojados.
@@ -856,7 +864,7 @@
856864 sessionStorage.setItem('elffusscode.skipGemma', '1');
857865 showModelProgress(t('fallbackToast'));
858866 loadingId = null;
859- const okc = await changeModel('onnx');
867+ const okc = await changeModel(ONNX_LIGERO);
860868 _fellBack = false;
861869 if (okc) return true;
862870 }
@@ -894,8 +902,8 @@
894902 if (hayMotor || hay27 || hayMini) rebuildSelect();
895903 const avail = new Set(modelOptions().map(o => o.id));
896904 const skipGemma = sessionStorage.getItem('elffusscode.skipGemma') === '1';
897- const def = skipGemma ? 'onnx' : await pickLocalBrain();
898- const chain = [...new Set([saved, def, 'onnx']
905+ const def = skipGemma ? ONNX_LIGERO : await pickLocalBrain();
906+ const chain = [...new Set([saved, def, ONNX_LIGERO]
899907 .filter(id => id && id !== 'rules' && avail.has(id)))];
900908 // MÓVIL: no descargar ~1,9 GB sin permiso. defaultBrain() elige gemma-e2b en
901909 // móvil, y medido el 2026-09-08 con un iPhone emulado contra producción: al
@@ -1037,7 +1045,7 @@
10371045 const SUBS = {
10381046 'litert:gemma-e4b': t("setModelE4bSub"),
10391047 'litert:gemma-e2b': t("setModelE2bSub"),
1040- 'onnx': t("setModelOnnxSub"),
1048+ [ONNX_LIGERO]: t("setModelOnnxSub"),
10411049 'rules': t("setModelRulesSub"),
10421050 };
10431051 const LOCAL = modelOptionsLocales().map((o) => {