utopia-ia/elffuss-claw public
Changesets · Branches · Tags · Compare
| Changeset | c019865fced5647bf9c6b79155cd3e401a7560ebbad43ee0f89c8dd0eadd41cc |
|---|---|
| Author | KikoCis <kikocisneros@gmail.com> · 2026-10-10 16:43 +02:00 |
| Committer | KikoCis <kikocisneros@gmail.com> · 2026-10-11 17:49 +02:00 |
| Parents | 3e1357bd3b63 |
5 files changed
added tests/ux-movil.mjs +74 −0
| @@ -0,0 +1,74 @@ | ||
| 1 | +// Teléfono y ventanas estrechas. | |
| 2 | +// · A 390 px, en la vista: la página no se desplaza de lado (las pestañas se | |
| 3 | +// desplazan dentro) y «💬 Chat» se ve entero para volver. | |
| 4 | +// · En el chat, el botón de vista no tapa la fila de chips; su texto y su | |
| 5 | +// nombre van en el idioma de la página. | |
| 6 | +// · La puerta de móvil sale en un teléfono, no en una ventana estrecha con | |
| 7 | +// ratón; si la descarga falla, la tarjeta se queda con el error y | |
| 8 | +// «Reintentar». | |
| 9 | +// | |
| 10 | +// BASE=http://localhost:8743 node tests/ux-movil.mjs | |
| 11 | +import { navegador, contexto, pagina, ok, hasta, espera, fin, OUT } from './ux-comun.mjs'; | |
| 12 | + | |
| 13 | +const b = await navegador(); | |
| 14 | +const telefono = { viewport: { width: 390, height: 844 }, isMobile: true, hasTouch: true }; | |
| 15 | +const solapan = (a, c) => !(a.x + a.width <= c.x || c.x + c.width <= a.x || a.y + a.height <= c.y || c.y + c.height <= a.y); | |
| 16 | + | |
| 17 | +// ── 390 px: chat y vista ──────────────────────────────────────────────────── | |
| 18 | +{ | |
| 19 | + const { ctx } = await contexto(b, telefono); | |
| 20 | + const { p, errores } = await pagina(ctx); | |
| 21 | + const flip = p.locator('#btn-flip'); | |
| 22 | + ok('en el chat, el botón dice «✳ Vista» y su nombre explica adónde lleva', (await flip.innerText()).trim() === '✳ Vista' | |
| 23 | + && /Ver lo que crea Elffuss/.test(await flip.getAttribute('aria-label'))); | |
| 24 | + const [bf, bc] = [await flip.boundingBox(), await p.locator('#chips').boundingBox()]; | |
| 25 | + ok('…y no tapa la fila de chips', !solapan(bf, bc), JSON.stringify({ bf, bc })); | |
| 26 | + await flip.click(); | |
| 27 | + await espera(200); | |
| 28 | + const vista = await p.evaluate(() => { | |
| 29 | + const f = document.getElementById('btn-flip').getBoundingClientRect(); | |
| 30 | + return { | |
| 31 | + ancho: document.documentElement.scrollWidth, ventana: innerWidth, | |
| 32 | + viz: document.getElementById('viz').getBoundingClientRect().width, | |
| 33 | + tabsDesplazan: document.getElementById('tabs').scrollWidth > document.getElementById('tabs').clientWidth, | |
| 34 | + flip: { izq: f.left, der: f.right, texto: document.getElementById('btn-flip').textContent }, | |
| 35 | + }; | |
| 36 | + }); | |
| 37 | + ok('en la vista la página no se desplaza de lado', vista.ancho <= vista.ventana && vista.viz <= vista.ventana, JSON.stringify(vista)); | |
| 38 | + ok('…las pestañas se desplazan dentro de su fila', vista.tabsDesplazan); | |
| 39 | + ok('…y «💬 Chat» se ve entero para volver', vista.flip.izq >= 0 && vista.flip.der <= vista.ventana && /Chat/.test(vista.flip.texto), JSON.stringify(vista.flip)); | |
| 40 | + if (OUT) await p.screenshot({ path: OUT + '/ux-movil-vista.png' }); | |
| 41 | + await p.click('#tabs button[data-tab="ajustes"]'); | |
| 42 | + ok('la última pestaña (Ajustes) se puede alcanzar y abrir', await p.evaluate(() => document.getElementById('panel-ajustes').classList.contains('active'))); | |
| 43 | + ok('sin errores de página', errores.length === 0, errores.slice(0, 3).join(' | ')); | |
| 44 | + await ctx.close(); | |
| 45 | +} | |
| 46 | +{ | |
| 47 | + const { ctx } = await contexto(b, { ...telefono, locale: 'en-US' }); | |
| 48 | + const { p } = await pagina(ctx); | |
| 49 | + ok('en inglés el botón dice «✳ View»', (await p.locator('#btn-flip').innerText()).trim() === '✳ View'); | |
| 50 | + await ctx.close(); | |
| 51 | +} | |
| 52 | + | |
| 53 | +// ── la puerta de móvil: teléfono sí, ventana estrecha con ratón no ────────── | |
| 54 | +const sinCerebroGuardado = { model: null }; | |
| 55 | +{ | |
| 56 | + const { ctx } = await contexto(b, { ...sinCerebroGuardado, viewport: { width: 760, height: 900 } }); | |
| 57 | + const { p } = await pagina(ctx); | |
| 58 | + await espera(2500); | |
| 59 | + ok('ventana de 760 px con ratón: NO sale «En el móvil todavía no funciona»', await p.locator('.mobile-gate').count() === 0); | |
| 60 | + await ctx.close(); | |
| 61 | +} | |
| 62 | +{ | |
| 63 | + const { ctx } = await contexto(b, { ...sinCerebroGuardado, ...telefono }); | |
| 64 | + const { p } = await pagina(ctx); | |
| 65 | + ok('en un teléfono sí sale la tarjeta', await hasta(async () => await p.locator('.mobile-gate').count() === 1)); | |
| 66 | + await p.locator('.mobile-gate button').click(); | |
| 67 | + // la descarga de verdad está cortada en las pruebas (Hugging Face bloqueado): falla | |
| 68 | + ok('si falla, la tarjeta se queda con el error y «Reintentar»', await hasta(async () => | |
| 69 | + /No ha cargado/.test(await p.locator('.mobile-gate').innerText().catch(() => '')) && | |
| 70 | + (await p.locator('.mobile-gate button').innerText()) === 'Reintentar', { veces: 400 })); | |
| 71 | + await ctx.close(); | |
| 72 | +} | |
| 73 | + | |
| 74 | +await fin(b, 'MÓVIL: sin desbordes, «💬 Chat» a la vista y la puerta solo en teléfonos'); |
modified web/css/elffuss.css +9 −2
| @@ -197,7 +197,10 @@ | ||
| 197 | 197 | @media (max-width: 560px) { .cbtn.hardwork .hw-txt { display: none; } } |
| 198 | 198 | |
| 199 | 199 | /* ---------- visualizador ---------- */ |
| 200 | -#viz { display: flex; flex-direction: column; min-height: 0; background: var(--bg2); } | |
| 200 | +/* min-width: 0 para que la fila de pestañas se desplace DENTRO y no ensanche la | |
| 201 | + columna: en un teléfono, con 7 pestañas, #viz medía 447 px en una pantalla de | |
| 202 | + 390 y la página entera se desplazaba de lado (y «💬 Chat» quedaba fuera). */ | |
| 203 | +#viz { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--bg2); } | |
| 201 | 204 | #tabs { display: flex; gap: 2px; padding: 8px 12px 0; border-bottom: 1px solid var(--line); } |
| 202 | 205 | #tabs button { |
| 203 | 206 | background: none; |
| @@ -420,8 +423,12 @@ | ||
| 420 | 423 | |
| 421 | 424 | /* ---------- móvil: una columna, chat ↔ visualizador conmutables ---------- */ |
| 422 | 425 | @media (max-width: 700px) { |
| 423 | - main { grid-template-columns: 1fr; } | |
| 426 | + main { grid-template-columns: minmax(0, 1fr); } | |
| 424 | 427 | #btn-flip { display: block; } |
| 428 | + /* por encima de los chips y del compositor (su alto lo mide ui.js en | |
| 429 | + --alto-pie): antes tapaba la fila de chips */ | |
| 430 | + #btn-flip { bottom: calc(var(--alto-pie, 150px) + 8px); } | |
| 431 | + body.show-viz #btn-flip { bottom: 14px; } | |
| 425 | 432 | #viz { display: none; } |
| 426 | 433 | body.show-viz #viz { display: flex; } |
| 427 | 434 | body.show-viz #chat { display: none; } |
modified web/js/i18n.js +12 −0
| @@ -152,6 +152,12 @@ | ||
| 152 | 152 | diskFreed: 'Liberados {size}', diskSharedFail: '⚠ el almacén compartido no respondió: puede quedar algo guardado allí', |
| 153 | 153 | diskFail: 'No se pudo vaciar: {err}', |
| 154 | 154 | storeShared: ' · incluye {gb} del almacén compartido', storeSharedUnknown: ' · no se pudo consultar el almacén compartido', |
| 155 | + flipToView: 'Ver lo que crea Elffuss (la vista)', flipToChat: 'Volver al chat', | |
| 156 | + mobTitle: '📱 En el móvil todavía no funciona', | |
| 157 | + mobDesc: 'Elffuss ejecuta el modelo dentro de tu propio navegador. En el móvil eso hoy no sale bien: habría que descargar {size} y el navegador suele cerrar la pestaña antes de terminar. Así que no te lo descargo sin preguntar.', | |
| 158 | + mobDesktop: 'Ábrelo en un ordenador y sí funciona: ahí es donde vive.', | |
| 159 | + mobAnyway: 'Descargarlo igualmente ({size})', mobLoading: 'Descargando… mientras, el modo básico te atiende.', | |
| 160 | + mobFailed: '⚠️ No ha cargado en este teléfono. Puedes reintentarlo, o seguir en modo básico.', mobRetry: 'Reintentar', | |
| 155 | 161 | }, |
| 156 | 162 | en: { |
| 157 | 163 | welcome: 'An operating system with a soul that lives in your browser. Here apps aren’t installed: they’re created when you ask, appearing on the right. I can use your folders (with permission), store encrypted secrets, schedule tasks and browse for you. Everything stays on your machine.', |
| @@ -300,6 +306,12 @@ | ||
| 300 | 306 | diskFreed: 'Freed {size}', diskSharedFail: '⚠ the shared store did not answer: something may still be stored there', |
| 301 | 307 | diskFail: 'Could not clear it: {err}', |
| 302 | 308 | storeShared: ' · includes {gb} in the shared store', storeSharedUnknown: ' · the shared store could not be queried', |
| 309 | + flipToView: 'See what Elffuss creates (the view)', flipToChat: 'Back to the chat', | |
| 310 | + mobTitle: '📱 It does not work on phones yet', | |
| 311 | + mobDesc: 'Elffuss runs the model inside your own browser. On a phone that does not go well today: it would need to download {size} and the browser usually closes the tab before it finishes. So I will not download it without asking.', | |
| 312 | + mobDesktop: 'Open it on a computer and it works: that is where it lives.', | |
| 313 | + mobAnyway: 'Download it anyway ({size})', mobLoading: 'Downloading… meanwhile, basic mode is here for you.', | |
| 314 | + mobFailed: '⚠️ It did not load on this phone. You can retry, or stay in basic mode.', mobRetry: 'Retry', | |
| 303 | 315 | }, |
| 304 | 316 | uk: { |
| 305 | 317 | welcome: "Операційна система з душею, що живе у твоєму браузері. Тут застосунки не встановлюють — їх створюють на твій запит, і вони з’являються праворуч. Можу працювати з твоїми теками (за дозволом), зберігати зашифровані секрети, планувати завдання й гортати за тебе. Усе лишається на твоєму пристрої.", |
modified web/js/kernel.js +10 −3
| @@ -249,6 +249,10 @@ | ||
| 249 | 249 | // (El comentario decía «Móvil → Elffuss LM» y el código devolvía otra cosa |
| 250 | 250 | // desde hace tiempo: era el comentario el que estaba desactualizado.) |
| 251 | 251 | const isMobile = () => matchMedia('(max-width: 820px)').matches || matchMedia('(pointer: coarse)').matches; |
| 252 | +// Para la puerta de móvil: un teléfono o tableta de verdad (dedo y sin «hover», | |
| 253 | +// o el navegador lo dice), no el ancho de la ventana. | |
| 254 | +const esTelefono = () => navigator.userAgentData?.mobile === true || | |
| 255 | + (matchMedia('(pointer: coarse)').matches && matchMedia('(hover: none)').matches); | |
| 252 | 256 | async function gpuCapacity() { |
| 253 | 257 | const mem = navigator.deviceMemory || 8; |
| 254 | 258 | if (!navigator.gpu) return { gpu: false, maxBuf: 0, mem }; |
| @@ -990,9 +994,12 @@ | ||
| 990 | 994 | // antes de sostener el modelo, así que muchas veces se gastaban para nada. |
| 991 | 995 | // Se avisa, se deja el botón por si quiere insistir, y se recuerda su |
| 992 | 996 | // elección. El modo básico sigue atendiendo mientras tanto. |
| 993 | - if (isMobile() && localStorage.getItem('elffuss.movil.ok') !== '1') { | |
| 994 | - ui.mobileGate('~600 MB', () => { | |
| 995 | - (async () => { for (const id of chain) if (await changeModel(id)) return; })(); | |
| 997 | + // Un TELÉFONO, no una ventana estrecha: con ratón y 760 px de ancho también | |
| 998 | + // salía «En el móvil todavía no funciona… ábrelo en un ordenador». | |
| 999 | + if (esTelefono() && localStorage.getItem('elffuss.movil.ok') !== '1') { | |
| 1000 | + ui.mobileGate('~600 MB', async () => { | |
| 1001 | + for (const id of chain) if (await changeModel(id)) return true; | |
| 1002 | + return false; | |
| 996 | 1003 | }); |
| 997 | 1004 | return; |
| 998 | 1005 | } |
modified web/js/ui.js +39 −11
| @@ -340,7 +340,15 @@ | ||
| 340 | 340 | export function mostrarChat() { if (isMobile()) flipTo('chat'); } |
| 341 | 341 | function flipTo(side) { |
| 342 | 342 | document.body.classList.toggle('show-viz', side === 'viz'); |
| 343 | - $('btn-flip').textContent = side === 'viz' ? tr('flipChat') : tr('flipView'); | |
| 343 | + pintarFlip(); | |
| 344 | +} | |
| 345 | +// El botón dice adónde lleva, en el idioma de la página (empezaba con «Vista» | |
| 346 | +// escrito en el HTML para todos los idiomas). | |
| 347 | +function pintarFlip() { | |
| 348 | + const enViz = document.body.classList.contains('show-viz'); | |
| 349 | + const b = $('btn-flip'); | |
| 350 | + b.textContent = enViz ? tr('flipChat') : tr('flipView'); | |
| 351 | + b.setAttribute('aria-label', enViz ? tr('flipToChat') : tr('flipToView')); | |
| 344 | 352 | } |
| 345 | 353 | |
| 346 | 354 | // ---------- pestañas ---------- |
| @@ -1122,6 +1130,13 @@ | ||
| 1122 | 1130 | $('model-select').addEventListener('change', e => onModelChange(e.target.value)); |
| 1123 | 1131 | $('btn-flip').addEventListener('click', () => |
| 1124 | 1132 | flipTo(document.body.classList.contains('show-viz') ? 'chat' : 'viz')); |
| 1133 | + pintarFlip(); | |
| 1134 | + // En el teléfono el botón flota por encima de los chips y del compositor: su | |
| 1135 | + // alto real (cambia con el idioma y el teclado) va a --alto-pie. | |
| 1136 | + const altoPie = () => document.documentElement.style.setProperty('--alto-pie', | |
| 1137 | + (($('composer')?.offsetHeight || 0) + ($('chips')?.offsetHeight || 0)) + 'px'); | |
| 1138 | + try { const ro = new ResizeObserver(altoPie); ro.observe($('composer')); ro.observe($('chips')); } catch { /* sin ResizeObserver: queda el valor por defecto */ } | |
| 1139 | + altoPie(); | |
| 1125 | 1140 | |
| 1126 | 1141 | // iconos vectoriales (sin emojis) |
| 1127 | 1142 | $('model-ico').innerHTML = UI.code; |
| @@ -1207,18 +1222,31 @@ | ||
| 1207 | 1222 | // giga de datos de alguien que no había pedido nada, y encima con muchas |
| 1208 | 1223 | // papeletas de no llegar a funcionar (el navegador de móvil cierra la pestaña |
| 1209 | 1224 | // bastante antes de sostener un modelo entero). Ahora se avisa y se espera. |
| 1225 | +// | |
| 1226 | +// `onAccept()` devuelve si el cerebro cargó. Si no, la tarjeta se queda con el | |
| 1227 | +// error y un «Reintentar» (antes desaparecía al pulsar y un fallo solo dejaba un | |
| 1228 | +// aviso pasajero). Quién es un teléfono lo decide el kernel (esTelefono). | |
| 1210 | 1229 | export function mobileGate(sizeText, onAccept) { |
| 1211 | - const box = el('div', 'card col'); | |
| 1230 | + const box = el('div', 'card col mobile-gate'); | |
| 1212 | 1231 | box.style.cssText = 'margin:14px 0;padding:14px;gap:8px'; |
| 1213 | - box.appendChild(el('b', null, '📱 En el móvil todavía no funciona')); | |
| 1214 | - box.appendChild(el('span', 'muted', | |
| 1215 | - 'Elffuss ejecuta el modelo dentro de tu propio navegador. En el móvil eso hoy no sale bien: ' + | |
| 1216 | - 'habría que descargar ' + sizeText + ' y el navegador suele cerrar la pestaña antes de terminar. ' + | |
| 1217 | - 'Así que no te lo descargo sin preguntar.')); | |
| 1218 | - box.appendChild(el('span', 'muted', 'Ábrelo en un ordenador y sí funciona: ahí es donde vive.')); | |
| 1219 | - box.appendChild(btn('Descargarlo igualmente (' + sizeText + ')', 'ghost', () => { | |
| 1232 | + box.setAttribute('role', 'region'); | |
| 1233 | + box.setAttribute('aria-label', tr('mobTitle')); | |
| 1234 | + box.appendChild(el('b', null, tr('mobTitle'))); | |
| 1235 | + box.appendChild(el('span', 'muted', tr('mobDesc', { size: sizeText }))); | |
| 1236 | + box.appendChild(el('span', 'muted', tr('mobDesktop'))); | |
| 1237 | + const estado = el('span', 'muted'); | |
| 1238 | + estado.setAttribute('role', 'status'); | |
| 1239 | + const boton = btn(tr('mobAnyway', { size: sizeText }), 'ghost', async () => { | |
| 1220 | 1240 | try { localStorage.setItem('elffuss.movil.ok', '1'); } catch { /* — */ } |
| 1221 | - box.remove(); onAccept(); | |
| 1222 | - })); | |
| 1241 | + boton.disabled = true; | |
| 1242 | + estado.textContent = tr('mobLoading'); | |
| 1243 | + let cargo = false; | |
| 1244 | + try { cargo = await onAccept(); } catch { cargo = false; } | |
| 1245 | + if (cargo) { box.remove(); return; } | |
| 1246 | + estado.textContent = tr('mobFailed'); | |
| 1247 | + boton.textContent = tr('mobRetry'); | |
| 1248 | + boton.disabled = false; | |
| 1249 | + }); | |
| 1250 | + box.append(estado, boton); | |
| 1223 | 1251 | (document.getElementById('log') || document.body).appendChild(box); |
| 1224 | 1252 | } |