utopia-ia/elffuss-code public
Changesets · Branches · Tags · Compare
| Changeset | 1b46672e7cf9ef5fed2cb1626b0f96415afcabe761e32387297d18d30dd48f10 |
|---|---|
| Author | KikoCis <kikocisneros@gmail.com> · 2026-10-13 13:09 +02:00 |
| Committer | KikoCis <kikocisneros@gmail.com> · 2026-10-13 13:09 +02:00 |
| Parents | 17d8624c4d4f |
4 files changed
added tests/ciudad-se-cierra.mjs +87 −0
| @@ -0,0 +1,87 @@ | ||
| 1 | +// La vista (ciudad o arquitectura) tapa el editor. Si con ella abierta el | |
| 2 | +// usuario abre OTRA cosa, la vista se cierra: antes esa otra cosa se abría | |
| 3 | +// debajo, inerte, y parecía rota. La CONSOLA es la excepción: si está abierta | |
| 4 | +// nada se le pone encima, así que convive con la vista, que termina sobre ella. | |
| 5 | +// | |
| 6 | +// Control: sin hacer nada, la ciudad sigue abierta. Sin él, un test que la | |
| 7 | +// cerrara siempre pasaría igual. | |
| 8 | +import { chromium } from 'playwright'; | |
| 9 | +const BASE = process.env.BASE || 'http://localhost:8799'; | |
| 10 | +let fails = 0; | |
| 11 | +const ok = (n, c, e = '') => { console.log((c ? '✅' : '❌') + ' ' + n + (e ? ' — ' + e : '')); if (!c) fails++; }; | |
| 12 | + | |
| 13 | +const b = await chromium.launch({ args: ['--use-gl=swiftshader', '--enable-unsafe-swiftshader'] }); | |
| 14 | +const ctx = await b.newContext({ viewport: { width: 1280, height: 800 } }); | |
| 15 | +await ctx.addInitScript(() => { try { localStorage.setItem('elffusscode.model', 'rules'); } catch {} }); | |
| 16 | +const p = await ctx.newPage(); | |
| 17 | +const errs = []; p.on('pageerror', e => errs.push(e.message.slice(0, 160))); | |
| 18 | +await p.goto(BASE + '/?test-opfs'); | |
| 19 | +await p.waitForFunction(() => !!document.querySelector('#editor .monaco-editor'), null, { timeout: 30000 }); | |
| 20 | +await p.evaluate(async () => { | |
| 21 | + const r = await navigator.storage.getDirectory(); | |
| 22 | + const f = await r.getFileHandle('a.js', { create: true }); const w = await f.createWritable(); await w.write('x'); await w.close(); | |
| 23 | + const c = await import('/js/tools/code.js'); await c.openProject(r); | |
| 24 | + await (await import('/js/ide.js')).refreshTree(); | |
| 25 | +}); | |
| 26 | +await p.waitForTimeout(500); | |
| 27 | + | |
| 28 | +const estado = () => p.evaluate(() => { | |
| 29 | + const t = document.getElementById('terminal-panel'), r = t.getBoundingClientRect(); | |
| 30 | + let tapada = null; | |
| 31 | + if (r.height) { let e = document.elementFromPoint(r.left + r.width / 2, r.top + r.height / 2); tapada = true; while (e) { if (e === t) { tapada = false; break; } e = e.parentElement; } } | |
| 32 | + return { ciudad: !document.getElementById('view-overlay').hidden, consola: !t.hidden, consolaInerte: t.inert, consolaTapada: tapada, editorInerte: document.getElementById('editor').inert }; | |
| 33 | +}); | |
| 34 | +const abreCiudad = async () => { await p.click('#act-city'); await p.waitForFunction(() => !document.getElementById('view-overlay').hidden, null, { timeout: 10000 }); await p.waitForTimeout(600); }; | |
| 35 | +const limpia = () => p.evaluate(() => { | |
| 36 | + if (!document.getElementById('view-overlay').hidden) document.getElementById('view-close').click(); | |
| 37 | + if (!document.getElementById('terminal-panel').hidden) document.getElementById('term-close').click(); | |
| 38 | + document.getElementById('settings-panel').hidden = true; | |
| 39 | + document.getElementById('palette')?.setAttribute('hidden', ''); | |
| 40 | +}); | |
| 41 | + | |
| 42 | +// control: sin tocar nada, la ciudad no se cierra sola | |
| 43 | +await abreCiudad(); | |
| 44 | +await p.waitForTimeout(1500); | |
| 45 | +ok('⊕ control: sin hacer nada, la ciudad sigue abierta', (await estado()).ciudad); | |
| 46 | +await limpia(); await p.waitForTimeout(300); | |
| 47 | + | |
| 48 | +// la consola convive con la vista y NADA la tapa | |
| 49 | +for (const [nombre, accion] of [ | |
| 50 | + ['el botón', () => p.click('#act-term')], | |
| 51 | + ['Ctrl+`', () => p.keyboard.press('Control+`')], | |
| 52 | +]) { | |
| 53 | + await abreCiudad(); | |
| 54 | + await accion(); | |
| 55 | + await p.waitForTimeout(700); | |
| 56 | + const e = await estado(); | |
| 57 | + ok(`con la ciudad abierta, la consola (${nombre}) se ve entera y usable, y la ciudad sigue`, e.ciudad && e.consola && !e.consolaInerte && e.consolaTapada === false, JSON.stringify(e)); | |
| 58 | + await limpia(); await p.waitForTimeout(300); | |
| 59 | +} | |
| 60 | +// y al revés: con la consola abierta, abrir la ciudad tampoco la tapa | |
| 61 | +await p.click('#act-term'); await p.waitForTimeout(600); | |
| 62 | +await abreCiudad(); | |
| 63 | +{ const e = await estado(); ok('con la consola abierta, abrir la ciudad no la tapa', e.ciudad && e.consola && !e.consolaInerte && e.consolaTapada === false, JSON.stringify(e)); } | |
| 64 | +await limpia(); await p.waitForTimeout(300); | |
| 65 | + | |
| 66 | +for (const [nombre, accion] of [ | |
| 67 | + ['la paleta de búsqueda', () => p.keyboard.press(process.platform === 'darwin' ? 'Meta+p' : 'Control+p')], | |
| 68 | + ['los ajustes', () => p.click('#act-settings')], | |
| 69 | + ['las extensiones', () => p.click('#act-ext')], | |
| 70 | + ['un fichero del árbol', async () => { | |
| 71 | + // el explorador alterna: se abre solo si está cerrado | |
| 72 | + await p.evaluate(() => { const sb = document.getElementById('sidebar'); if (getComputedStyle(sb).display === 'none') document.getElementById('act-files').click(); }); | |
| 73 | + await p.locator('#tree .file').first().click(); | |
| 74 | + }], | |
| 75 | +]) { | |
| 76 | + await abreCiudad(); | |
| 77 | + await accion(); | |
| 78 | + await p.waitForTimeout(700); | |
| 79 | + const e = await estado(); | |
| 80 | + ok(`con la ciudad abierta, abrir ${nombre} la cierra`, !e.ciudad, JSON.stringify(e)); | |
| 81 | + await limpia(); await p.waitForTimeout(300); | |
| 82 | +} | |
| 83 | + | |
| 84 | +ok('sin errores de página', !errs.length, errs.join(' | ')); | |
| 85 | +await b.close(); | |
| 86 | +console.log(fails ? `\n❌ ${fails} FALLO(S)` : '\nTodo en verde'); | |
| 87 | +process.exit(fails ? 1 : 0); |
modified web/css/code.css +2 −1
| @@ -651,7 +651,8 @@ | ||
| 651 | 651 | .model-card.disabled:hover { border-color: var(--line); } |
| 652 | 652 | |
| 653 | 653 | /* ---------- vistas Arquitectura / Ciudad 3D (overlay sobre el editor) ---------- */ |
| 654 | -#view-overlay { position: absolute; inset: 34px 0 22px 0; z-index: 30; background: #0b0d12; overflow: hidden; } | |
| 654 | +/* termina encima de la consola: si está abierta, nada la tapa (--term-h, de main.js) */ | |
| 655 | +#view-overlay { position: absolute; inset: 34px 0 calc(22px + var(--term-h, 0px)) 0; z-index: 30; background: #0b0d12; overflow: hidden; } | |
| 655 | 656 | /* Lo que hay en la vista 3D, como lista que se puede buscar y recorrer con el teclado */ |
| 656 | 657 | .view-list { position: absolute; top: 48px; right: 12px; bottom: 12px; width: 280px; z-index: 31; display: flex; flex-direction: column; background: #0d1117e6; border: 1px solid var(--line); border-radius: 8px; padding: 8px; } |
| 657 | 658 | .view-list .vl-filter { width: 100%; box-sizing: border-box; background: var(--bg3); color: var(--fg); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; font: inherit; font-size: .78rem; } |
modified web/js/city.js +5 −0
| @@ -140,6 +140,10 @@ | ||
| 140 | 140 | camera.aspect = w / h; camera.updateProjectionMatrix(); |
| 141 | 141 | }; |
| 142 | 142 | window.addEventListener('resize', onResize); |
| 143 | + // …y cuando cambia el CONTENEDOR sin que cambie la ventana: abrir, cerrar o | |
| 144 | + // arrastrar la consola, que ahora convive con la vista debajo de ella. | |
| 145 | + const ro = 'ResizeObserver' in window ? new ResizeObserver(() => onResize()) : null; | |
| 146 | + ro?.observe(container); | |
| 143 | 147 | |
| 144 | 148 | let raf = null; |
| 145 | 149 | const loop = () => { raf = requestAnimationFrame(loop); controls.update(); composer.render(); }; |
| @@ -209,6 +213,7 @@ | ||
| 209 | 213 | clearTimeout(apaga); |
| 210 | 214 | if (raf) cancelAnimationFrame(raf); |
| 211 | 215 | window.removeEventListener('resize', onResize); |
| 216 | + ro?.disconnect(); | |
| 212 | 217 | canvas.removeEventListener('pointermove', onMove); |
| 213 | 218 | canvas.removeEventListener('pointerdown', onDown); |
| 214 | 219 | canvas.removeEventListener('pointerup', onUp); |
modified web/js/main.js +20 −3
| @@ -1875,14 +1875,15 @@ | ||
| 1875 | 1875 | $('act-arch').innerHTML = UI.graph || UI.code; |
| 1876 | 1876 | $('act-city').innerHTML = UI.city || UI.code; |
| 1877 | 1877 | let viewRenderSeq = 0; |
| 1878 | -// La vista tapa el editor (y el terminal, si está abierto): mientras se ve, lo | |
| 1879 | -// de debajo queda INERTE y el foco entra en ella. Antes el foco se quedaba en el | |
| 1878 | +// La vista tapa el editor (la consola NO: si está abierta, la vista acaba encima | |
| 1879 | +// de ella y la consola sigue a mano). Mientras se ve, el editor queda INERTE y el | |
| 1880 | +// foco entra en ella. Antes el foco se quedaba en el | |
| 1880 | 1881 | // botón que la abría, y el Tab, tras la barra de actividad, el árbol y la |
| 1881 | 1882 | // pestaña del editor, caía en el editor TAPADO: cada Tab sangraba el fichero |
| 1882 | 1883 | // abierto sin que se viera, y la lista de la vista no se alcanzaba nunca. (La |
| 1883 | 1884 | // Mente usa modal.js porque tapa la página entera; la vista solo tapa el |
| 1884 | 1885 | // editor, y la barra de actividad, el árbol y el chat siguen a mano.) |
| 1885 | -const TAPADO_POR_VISTA = ['editor', 'terminal-panel']; | |
| 1886 | +const TAPADO_POR_VISTA = ['editor']; | |
| 1886 | 1887 | const tapaVista = si => { for (const id of TAPADO_POR_VISTA) { const e = $(id); if (e) e.inert = si; } }; |
| 1887 | 1888 | let abridorVista = null; |
| 1888 | 1889 | function seVe(e) { return !!e && e !== document.body && e.isConnected && e.getClientRects().length > 0; } |
| @@ -2009,6 +2010,21 @@ | ||
| 2009 | 2010 | $('act-arch').addEventListener('click', () => openView('arch')); |
| 2010 | 2011 | $('act-city').addEventListener('click', () => openView('city')); |
| 2011 | 2012 | $('view-close').addEventListener('click', () => closeView({ foco: true })); |
| 2013 | +// La vista tapa el editor. Si con ella abierta el usuario abre OTRA cosa (un | |
| 2014 | +// botón de la barra, la paleta, un fichero del árbol), se cierra primero: antes | |
| 2015 | +// esa otra cosa se abría DEBAJO, inerte, y parecía rota. La consola es la | |
| 2016 | +// excepción: convive con la vista, que termina encima de ella. | |
| 2017 | +// No se cierra cuando es el agente quien abre algo: la ciudad sirve para seguir | |
| 2018 | +// lo que hace. | |
| 2019 | +const vistaAbierta = () => !$('view-overlay').hidden; | |
| 2020 | +const cierraVistaSiAbierta = () => { if (vistaAbierta()) closeView(); }; | |
| 2021 | +$('activity').addEventListener('click', e => { | |
| 2022 | + const b = e.target.closest('button'); | |
| 2023 | + // (la consola no: convive con la vista, debajo de ella y sin que nada la tape) | |
| 2024 | + if (b && b.id !== 'act-arch' && b.id !== 'act-city' && b.id !== 'act-term') cierraVistaSiAbierta(); | |
| 2025 | +}, true); | |
| 2026 | +$('tree').addEventListener('click', e => { if (e.target.closest('.file')) cierraVistaSiAbierta(); }, true); | |
| 2027 | +$('tree').addEventListener('keydown', e => { if (e.key === 'Enter' && e.target.closest('.file')) cierraVistaSiAbierta(); }, true); | |
| 2012 | 2028 | |
| 2013 | 2029 | // ── Cerebro CEO autónomo + Mente de Elffuss ─────────────────────────────── |
| 2014 | 2030 | // Cuando NO estás pidiendo nada, la elfa trabaja: revisa el proyecto y propone |
| @@ -3018,6 +3034,7 @@ | ||
| 3018 | 3034 | // aria-activedescendant), así un lector de pantalla sigue la selección. |
| 3019 | 3035 | let volverDePaleta = null; |
| 3020 | 3036 | function openPalette(prefix = '') { |
| 3037 | + cierraVistaSiAbierta(); | |
| 3021 | 3038 | if ($('palette').hidden) volverDePaleta = document.activeElement; |
| 3022 | 3039 | $('palette').hidden = false; |
| 3023 | 3040 | const inp = $('pal-input'); |