Elffuss BraidHub

utopia-ia/elffuss-claw public

A brain that loads at once no longer leaves the download showcase up

Known since the stop-fix work: with an external provider, which loads
almost at once, the View kept showing "Preparando tu sistema operativo…" and
the demo carousel after the model was ready. modelProgress('Preparando
modelo…') starts importing loading-stage.js; modelProgress(null) came before
that import finished, found no showcase to hide, and the showcase was then
mounted for good.

ui.js counts finished loads. A showcase requested before the count changed
is not mounted when its module arrives, or is taken down right after
mounting.

ux-modelo.mjs checks it at boot, where the stand-in Ollama loads while the
View is showing: no showcase and the empty-View placeholder back. It fails on
the previous ui.js.
Changeset2401d59705ea9189ec3021fa47c34c4c3f00b247a181b3e15154918728a03935
AuthorKikoCis <kikocisneros@gmail.com> · 2026-10-11 18:28 +02:00
CommitterKikoCis <kikocisneros@gmail.com> · 2026-10-11 18:28 +02:00
Parents247da25482b5

Browse the files at this changeset

2 files changed

modified tests/ux-modelo.mjs +6 −0
@@ -33,6 +33,12 @@
3333 await p.goto(BASE + '/', { waitUntil: 'domcontentloaded' });
3434 const listo = () => p.evaluate(() => document.getElementById('model-select').value === 'ext:ollama' && document.getElementById('model-status').classList.contains('on'));
3535 ok('Ollama (de prueba) cargado', await hasta(listo));
36+// Un cerebro que carga al momento no deja puesto el escaparate de descarga
37+// («Preparando tu sistema operativo…»): su módulo llegaba DESPUÉS de que la
38+// carga terminara, y se montaba para quedarse.
39+ok('un cerebro que carga al momento no deja el escaparate de descarga en la Vista', await hasta(() => p.evaluate(() =>
40+ !document.getElementById('loading-stage') && !document.getElementById('vista-empty').hidden)),
41+ await p.evaluate(() => document.getElementById('loading-stage') ? 'escaparate puesto' : 'sin placeholder'));
3642 ok('el selector se llama «Cerebro (modelo de IA)» y el punto dice su estado', await p.getAttribute('#model-select', 'aria-label') === 'Cerebro (modelo de IA)'
3743 && await p.getAttribute('#model-status', 'aria-label') === 'Modelo listo');
3844
modified web/js/ui.js +11 −0
@@ -761,9 +761,19 @@
761761 // El escaparate se monta en la Vista SOLO si ya la estás mirando. Antes cada
762762 // cambio de cerebro —también uno remoto, que ni descarga— te llevaba a la Vista
763763 // (estando en Ajustes, saltabas a la Vista) y en el móvil te sacaba del chat.
764+//
765+// El módulo del escaparate se importa al vuelo, y un cerebro que carga al
766+// momento (un proveedor externo) llamaba a modelProgress(null) antes de que
767+// llegara: no había escaparate que quitar, y al llegar se montaba y se quedaba
768+// para siempre con «Preparando tu sistema operativo…». `_finCargas` cuenta las
769+// cargas terminadas: si cambió mientras se esperaba, no se monta (o se quita).
770+let _finCargas = 0;
764771 async function _showStage(p) {
772+ const pedido = _finCargas;
765773 const st = await _loadStage();
774+ if (pedido !== _finCargas) return;
766775 if (!st.isMounted()) await st.show($('panel-vista'), $('vista-empty'));
776+ if (pedido !== _finCargas) { st.hide($('vista-empty'), $('appframe').hidden !== false); return; }
767777 st.setProgress(_pct(p));
768778 }
769779 const mirandoLaVista = () => tabActiva() === 'vista' && (!isMobile() || document.body.classList.contains('show-viz'));
@@ -772,6 +782,7 @@
772782 const box = $('model-progress');
773783 const appHidden = $('appframe').hidden !== false; // ¿aún no hay app abierta?
774784 if (p == null) { // carga terminada
785+ _finCargas++; // (ver _showStage)
775786 box.hidden = true;
776787 _stage?.hide?.($('vista-empty'), appHidden);
777788 return;