utopia-ia/elffuss-code public
Changesets · Branches · Tags · Compare
| Changeset | c020a5bdc1e7f39ed998fd2e431b6a5c79dbd7a4f946c18f6b251f8ed43c2962 |
|---|---|
| Author | KikoCis <kikocisneros@gmail.com> · 2026-10-10 16:49 +02:00 |
| Committer | KikoCis <kikocisneros@gmail.com> · 2026-10-11 14:15 +02:00 |
| Parents | 27f8f5c38db4 |
5 files changed
added tests/mobile-drawer.mjs +58 −0
| @@ -0,0 +1,58 @@ | ||
| 1 | +// Móvil: el cajón ☰ con el árbol y las herramientas. | |
| 2 | +// | |
| 3 | +// En un teléfono la barra de actividad, el árbol y la barra de menús están | |
| 4 | +// ocultos, así que en la vista Editor no había forma de abrir un fichero (solo | |
| 5 | +// enlaces del chat o @) y la Mente, el terminal, las vistas 3D y las skills | |
| 6 | +// eran inalcanzables. Ahora ☰ abre un cajón con todo eso. | |
| 7 | +// | |
| 8 | +// BASE=http://127.0.0.1:8898 node tests/mobile-drawer.mjs | |
| 9 | +import { chromium } from 'playwright'; | |
| 10 | +const BASE = process.env.BASE || 'http://localhost:8799'; | |
| 11 | +let fails = 0; const ok = (n, c, e = '') => { console.log((c ? '✅' : '❌') + ' ' + n + (e ? ' — ' + e : '')); if (!c) fails++; }; | |
| 12 | + | |
| 13 | +const b = await chromium.launch(); | |
| 14 | +const ctx = await b.newContext({ locale: 'es-ES', viewport: { width: 390, height: 844 }, isMobile: true, hasTouch: true }); | |
| 15 | +await ctx.addInitScript(() => { try { localStorage.setItem('elffusscode.model', 'rules'); } catch {} }); | |
| 16 | +await ctx.route(/soundcloud/, r => r.abort()); | |
| 17 | +const p = await ctx.newPage(); | |
| 18 | +const errs = []; p.on('pageerror', e => errs.push(e.message.slice(0, 160))); | |
| 19 | + | |
| 20 | +await p.goto(BASE + '/manifest.json'); | |
| 21 | +await p.evaluate(async () => { | |
| 22 | + const root = await navigator.storage.getDirectory(); | |
| 23 | + const w = await (await root.getFileHandle('README.md', { create: true })).createWritable(); await w.write('# Hola\n'); await w.close(); | |
| 24 | +}); | |
| 25 | +await p.goto(BASE + '/?test-opfs', { waitUntil: 'domcontentloaded' }); | |
| 26 | +await p.waitForFunction(() => window.monaco && document.querySelector('#tree [data-path]'), null, { timeout: 30000 }); | |
| 27 | +const visible = sel => p.evaluate(sel => { const e = document.querySelector(sel); if (!e) return false; const r = e.getBoundingClientRect(); return r.width > 0 && r.height > 0 && getComputedStyle(e).display !== 'none'; }, sel); | |
| 28 | + | |
| 29 | +ok('en el móvil, el árbol y la barra de actividad empiezan ocultos', !(await visible('#sidebar')) && !(await visible('#activity'))); | |
| 30 | +ok('…y hay un botón ☰', await visible('#btn-drawer')); | |
| 31 | +await p.tap('#btn-drawer'); | |
| 32 | +await p.waitForTimeout(200); | |
| 33 | +ok('☰ abre el cajón con el árbol y las herramientas', await visible('#sidebar') && await visible('#activity') && await visible('#act-term') && await p.evaluate(() => document.getElementById('btn-drawer').getAttribute('aria-expanded') === 'true')); | |
| 34 | +await p.tap('#tree .file[data-path="README.md"]'); | |
| 35 | +await p.waitForTimeout(400); | |
| 36 | +const trasAbrir = await p.evaluate(() => ({ editor: document.body.classList.contains('show-editor'), cajon: document.body.classList.contains('drawer-open'), activa: document.querySelector('#tabs-bar .tab.active')?.dataset.path })); | |
| 37 | +ok('un fichero del cajón se abre en la vista Editor y el cajón se cierra', trasAbrir.editor && !trasAbrir.cajon && trasAbrir.activa === 'README.md', JSON.stringify(trasAbrir)); | |
| 38 | +await p.tap('#btn-drawer'); | |
| 39 | +await p.waitForTimeout(150); | |
| 40 | +await p.tap('#act-term'); | |
| 41 | +await p.waitForTimeout(400); | |
| 42 | +ok('desde el cajón se llega al terminal', await visible('#terminal-panel') && !(await p.evaluate(() => document.body.classList.contains('drawer-open')))); | |
| 43 | +await p.tap('#btn-drawer'); | |
| 44 | +await p.waitForTimeout(150); | |
| 45 | +await p.keyboard.press('Escape'); | |
| 46 | +await p.waitForTimeout(150); | |
| 47 | +ok('Escape cierra el cajón y devuelve el foco a ☰', await p.evaluate(() => !document.body.classList.contains('drawer-open'))); | |
| 48 | +await p.tap('#btn-drawer'); | |
| 49 | +await p.waitForTimeout(150); | |
| 50 | +await p.tap('#act-mind'); | |
| 51 | +await p.waitForSelector('#mind-overlay', { timeout: 45000 }).catch(() => {}); | |
| 52 | +ok('desde el cajón se llega a la Mente', await p.evaluate(() => !!document.getElementById('mind-overlay') && getComputedStyle(document.getElementById('mind-overlay')).display !== 'none')); | |
| 53 | + | |
| 54 | +console.log('\n errores JS:', errs[0] || 'ninguno'); | |
| 55 | +ok('sin errores de página', errs.length === 0, errs.join(' | ')); | |
| 56 | +console.log(fails ? `\n❌ ${fails} FALLO(S)` : '\n✅ MÓVIL: EL CAJÓN LLEVA A TODO'); | |
| 57 | +await b.close(); | |
| 58 | +process.exit(fails ? 1 : 0); |
modified web/css/code.css +23 −0
| @@ -499,6 +499,29 @@ | ||
| 499 | 499 | #settings-panel { position: fixed; top: 46px; left: 46px; right: 0; z-index: 90; max-height: 78vh; overflow-y: auto; box-shadow: 0 12px 40px rgba(0,0,0,.6); } |
| 500 | 500 | @media (max-width: 760px) { #settings-panel { left: 0; } } |
| 501 | 501 | |
| 502 | +/* ---------- móvil: cajón con el árbol y las herramientas ---------- | |
| 503 | + En el móvil la barra de actividad, el árbol y la barra de menús están | |
| 504 | + ocultos: sin esto, en la vista Editor no había forma de abrir un fichero | |
| 505 | + (salvo enlaces del chat) ni de llegar a la Mente, el terminal, las vistas 3D | |
| 506 | + o las skills. ☰ abre un cajón con todo eso. */ | |
| 507 | +#btn-drawer { display: none; } | |
| 508 | +@media (max-width: 760px) { | |
| 509 | + #btn-drawer { display: inline-flex; font-size: 1rem; } | |
| 510 | + body.drawer-open #activity { | |
| 511 | + display: flex; flex-direction: row; flex-wrap: wrap; justify-content: flex-start; | |
| 512 | + position: fixed; left: 0; top: var(--drawer-top, 52px); width: min(86vw, 340px); height: auto; | |
| 513 | + z-index: 96; padding: 4px; border-right: none; border-bottom: 1px solid var(--line); | |
| 514 | + } | |
| 515 | + body.drawer-open #activity #act-mind { margin: 0; } | |
| 516 | + body.drawer-open #activity button { width: 36px; height: 40px; border-left: none; border-bottom: 2px solid transparent; } | |
| 517 | + body.drawer-open #sidebar { | |
| 518 | + display: flex; position: fixed; left: 0; top: calc(var(--drawer-top, 52px) + var(--drawer-act, 50px)); bottom: 0; | |
| 519 | + width: min(86vw, 340px); z-index: 95; box-shadow: 12px 0 40px rgba(0,0,0,.55); | |
| 520 | + } | |
| 521 | + body.drawer-open #drawer-scrim { display: block; } | |
| 522 | +} | |
| 523 | +#drawer-scrim { display: none; position: fixed; inset: 0; z-index: 94; background: rgba(0,0,0,.45); } | |
| 524 | + | |
| 502 | 525 | /* barra indeterminada (descargas sin loaded/total, p. ej. Gemma vía LiteRT-LM) */ |
| 503 | 526 | #model-progress .track { overflow: hidden; } |
| 504 | 527 | #model-bar.indet { width: 35%; animation: indet 1.1s ease-in-out infinite; } |
modified web/index.html +1 −0
| @@ -69,6 +69,7 @@ | ||
| 69 | 69 | <button data-menu="git">Git</button> |
| 70 | 70 | </nav> |
| 71 | 71 | <div class="controls"> |
| 72 | + <button id="btn-drawer" class="ghost icon-btn" type="button" aria-expanded="false" aria-controls="sidebar" title="Archivos y herramientas" aria-label="Archivos y herramientas">☰</button> | |
| 72 | 73 | <button id="git-branch" class="chip" title="rama actual" hidden></button> |
| 73 | 74 | <button id="model-dot" type="button" class="dot off" title="modelo" aria-label="modelo"></button> |
| 74 | 75 | <select id="model-select" hidden></select> |
modified web/js/i18n.js +2 −0
| @@ -222,6 +222,7 @@ | ||
| 222 | 222 | setTelManual: "O manda algo tú directamente (un fallo que viste, algo que eches en falta…)", |
| 223 | 223 | viewBuilding: "Construyendo…", viewFailed: "No pude construir la vista: {e}", flipChat: "Chat", flipEditor: "Editor", |
| 224 | 224 | termClear: "limpiar", tTermClear: "limpiar la pantalla del terminal", |
| 225 | + drawerTitle: "Archivos y herramientas", | |
| 225 | 226 | clearModelsConfirm: "Vas a borrar {size} de modelos guardados en este navegador.\n\nNo se pierde nada tuyo: solo los pesos descargados. La próxima vez habrá que bajarlos otra vez.\n\n¿Seguir?", |
| 226 | 227 | clearModelsShared: "Ojo: el almacén compartido de Elffuss no se pudo consultar desde aquí; puede quedar algo guardado ahí.", |
| 227 | 228 | clearModelsDone: "💾 Liberados {size}.", clearModelsFailed: "No se pudo vaciar: {what}.", |
| @@ -445,6 +446,7 @@ | ||
| 445 | 446 | setTelManual: "Or send something yourself (a bug you saw, something you miss…)", |
| 446 | 447 | viewBuilding: "Building…", viewFailed: "Couldn't build the view: {e}", flipChat: "Chat", flipEditor: "Editor", |
| 447 | 448 | termClear: "clear", tTermClear: "clear the terminal screen", |
| 449 | + drawerTitle: "Files and tools", | |
| 448 | 450 | clearModelsConfirm: "You are about to delete {size} of models stored in this browser.\n\nNothing of yours is lost: only the downloaded weights. Next time they will be downloaded again.\n\nContinue?", |
| 449 | 451 | clearModelsShared: "Note: Elffuss's shared store could not be checked from here; something may remain stored there.", |
| 450 | 452 | clearModelsDone: "💾 Freed {size}.", clearModelsFailed: "Couldn't clear: {what}.", |
modified web/js/main.js +40 −0
| @@ -1592,6 +1592,45 @@ | ||
| 1592 | 1592 | $('model-dot').addEventListener('click', () => { renderSettings(); requestAnimationFrame(() => $('settings-panel').querySelector('.model-card.active, .model-card')?.focus()); }); |
| 1593 | 1593 | pintaDot('off', 'rules'); |
| 1594 | 1594 | // móvil: conmutar chat ↔ editor |
| 1595 | +// ☰ (solo en el móvil): cajón con el árbol de ficheros y la barra de | |
| 1596 | +// actividad. Abrir un fichero desde ahí pasa a la vista Editor y cierra el | |
| 1597 | +// cajón; Escape o tocar fuera lo cierran. | |
| 1598 | +function abreCajon(abrir) { | |
| 1599 | + const on = abrir ?? !document.body.classList.contains('drawer-open'); | |
| 1600 | + if (on) { | |
| 1601 | + document.documentElement.style.setProperty('--drawer-top', Math.round(document.querySelector('#ide header').getBoundingClientRect().bottom) + 'px'); | |
| 1602 | + if (!$('drawer-scrim')) { | |
| 1603 | + const scrim = document.createElement('div'); | |
| 1604 | + scrim.id = 'drawer-scrim'; | |
| 1605 | + scrim.onclick = () => abreCajon(false); | |
| 1606 | + document.body.appendChild(scrim); | |
| 1607 | + } | |
| 1608 | + } | |
| 1609 | + document.body.classList.toggle('drawer-open', on); | |
| 1610 | + // el árbol empieza justo debajo de la fila de herramientas, mida lo que mida | |
| 1611 | + if (on) document.documentElement.style.setProperty('--drawer-act', Math.round($('activity').getBoundingClientRect().height) + 'px'); | |
| 1612 | + $('btn-drawer').setAttribute('aria-expanded', on ? 'true' : 'false'); | |
| 1613 | + if (on) ($('tree').querySelector('[tabindex="0"]') || $('act-files'))?.focus(); | |
| 1614 | + else if (document.activeElement && ($('sidebar').contains(document.activeElement) || $('activity').contains(document.activeElement))) $('btn-drawer').focus(); | |
| 1615 | +} | |
| 1616 | +$('btn-drawer').title = t('drawerTitle'); | |
| 1617 | +$('btn-drawer').setAttribute('aria-label', t('drawerTitle')); | |
| 1618 | +$('btn-drawer').addEventListener('click', () => abreCajon()); | |
| 1619 | +// Elegir algo del cajón lo cierra; un fichero del árbol además enseña el editor. | |
| 1620 | +$('tree').addEventListener('click', e => { | |
| 1621 | + if (!document.body.classList.contains('drawer-open')) return; | |
| 1622 | + if (!e.target.closest('.file')) return; | |
| 1623 | + document.body.classList.add('show-editor'); | |
| 1624 | + paintFlip(true); | |
| 1625 | + abreCajon(false); | |
| 1626 | +}); | |
| 1627 | +$('activity').addEventListener('click', e => { | |
| 1628 | + if (!document.body.classList.contains('drawer-open') || !e.target.closest('button')) return; | |
| 1629 | + if (e.target.closest('#act-files')) return; // en el cajón, el árbol ya se ve | |
| 1630 | + abreCajon(false); | |
| 1631 | + if (e.target.closest('#act-arch, #act-city, #act-term')) { document.body.classList.add('show-editor'); paintFlip(true); } | |
| 1632 | +}, true); | |
| 1633 | + | |
| 1595 | 1634 | $('code-flip').addEventListener('click', () => { |
| 1596 | 1635 | const showEditor = !document.body.classList.contains('show-editor'); |
| 1597 | 1636 | document.body.classList.toggle('show-editor', showEditor); |
| @@ -1906,6 +1945,7 @@ | ||
| 1906 | 1945 | { abierta: () => !$('history-panel').hidden, cerrar: () => cierraHistorial() }, |
| 1907 | 1946 | { abierta: () => !$('settings-panel').hidden, cerrar: () => cierraAjustes() }, |
| 1908 | 1947 | { abierta: () => !$('view-overlay').hidden, cerrar: () => closeView({ foco: true }) }, |
| 1948 | + { abierta: () => document.body.classList.contains('drawer-open'), cerrar: () => abreCajon(false) }, | |
| 1909 | 1949 | ]; |
| 1910 | 1950 | document.addEventListener('keydown', e => { |
| 1911 | 1951 | if (e.key !== 'Escape' || e.defaultPrevented || e.isComposing) return; |