utopia-ia/elffuss-code public
Changesets · Branches · Tags · Compare
| Changeset | db6defa10cbcdadc97cd3191f56c071dc5c02969212e5c749fe025b74bb9b3b9 |
|---|---|
| Author | KikoCis <kikocisneros@gmail.com> · 2026-10-12 09:48 +02:00 |
| Committer | KikoCis <kikocisneros@gmail.com> · 2026-10-12 09:48 +02:00 |
| Parents | 5f5bc6bf966c |
4 files changed
added tests/skills-panel-layout.mjs +103 −0
| @@ -0,0 +1,103 @@ | ||
| 1 | +// El panel de Skills (el mismo sitio que Ajustes y Extensiones) ocupa entero su | |
| 2 | +// hueco y convive con la barra de actividad y el explorador. | |
| 3 | +// | |
| 4 | +// 1. Ocupa de la cabecera al pie de la ventana y del borde del explorador al | |
| 5 | +// de la ventana. Antes era una persiana de la altura de su contenido: por | |
| 6 | +// debajo asomaban el editor y el chat («no se abre al 100 %»). | |
| 7 | +// 2. Con Skills abierto, el icono de ficheros oculta y enseña el árbol, el | |
| 8 | +// panel se ajusta al hueco y NO se cierra (antes el clic lo cerraba). | |
| 9 | +// 3. La barra de actividad marca Skills mientras está abierto, y pulsar otra | |
| 10 | +// vez el icono lo cierra (antes lo cerraba y lo volvía a abrir). Lo mismo | |
| 11 | +// con el engranaje: desde Skills abre Ajustes en vez de cerrar. | |
| 12 | +// 4. Al cambiar el tamaño de la ventana sigue lleno. | |
| 13 | +// 5. En el teléfono ocupa la pantalla bajo la cabecera, y el ☰ se abre encima | |
| 14 | +// con Skills marcado. | |
| 15 | +// | |
| 16 | +// BASE=http://127.0.0.1:8898 node tests/skills-panel-layout.mjs | |
| 17 | +import { chromium } from 'playwright'; | |
| 18 | +const BASE = process.env.BASE || 'http://localhost:8799'; | |
| 19 | +let fails = 0; const ok = (n, c, e = '') => { console.log((c ? '✅' : '❌') + ' ' + n + (e ? ' — ' + e : '')); if (!c) fails++; }; | |
| 20 | + | |
| 21 | +const b = await chromium.launch(); | |
| 22 | +async function abre(viewport, movil = false) { | |
| 23 | + const ctx = await b.newContext({ locale: 'es-ES', viewport, isMobile: movil, hasTouch: movil }); | |
| 24 | + await ctx.addInitScript(() => { try { localStorage.setItem('elffusscode.model', 'rules'); localStorage.removeItem('elffusscode.chatfull'); } catch {} }); | |
| 25 | + await ctx.route(/soundcloud|huggingface|hf\.co|api\.github|raw\.githubusercontent/, r => r.abort()); | |
| 26 | + const p = await ctx.newPage(); | |
| 27 | + p.errs = []; p.on('pageerror', e => p.errs.push(e.message.slice(0, 160))); | |
| 28 | + await p.goto(BASE + '/?test-opfs', { waitUntil: 'domcontentloaded' }); | |
| 29 | + await p.waitForFunction(() => window.elffussClaw?.conv?.getActive?.(), null, { timeout: 30000 }); | |
| 30 | + return { ctx, p }; | |
| 31 | +} | |
| 32 | +const geo = p => p.evaluate(() => { | |
| 33 | + const r = s => { const e = document.querySelector(s); const b = e.getBoundingClientRect(); return { x: Math.round(b.x), y: Math.round(b.y), r: Math.round(b.right), b: Math.round(b.bottom) }; }; | |
| 34 | + const panel = document.getElementById('settings-panel'); | |
| 35 | + return { vw: innerWidth, vh: innerHeight, abierto: !panel.hidden, kind: panel.dataset.kind, panel: panel.hidden ? null : r('#settings-panel'), | |
| 36 | + cab: Math.round(document.querySelector('#ide header').getBoundingClientRect().bottom), | |
| 37 | + arbol: getComputedStyle(document.getElementById('sidebar')).display !== 'none' ? r('#sidebar') : null, | |
| 38 | + on: [...document.querySelectorAll('#activity button.on')].map(b => b.id) }; | |
| 39 | +}); | |
| 40 | +const llena = (g, izq) => g.panel && g.panel.y === g.cab && g.panel.b === g.vh && g.panel.r === g.vw && g.panel.x === izq; | |
| 41 | + | |
| 42 | +// ── escritorio ── | |
| 43 | +for (const [w, h] of [[1280, 800], [1440, 900]]) { | |
| 44 | + const { ctx, p } = await abre({ width: w, height: h }); | |
| 45 | + await p.click('#act-skills'); | |
| 46 | + await p.waitForTimeout(250); | |
| 47 | + let g = await geo(p); | |
| 48 | + ok(`${w} · 1 · Skills ocupa todo el hueco a la derecha del explorador`, llena(g, g.arbol?.r), JSON.stringify(g)); | |
| 49 | + ok(`${w} · 3 · la barra de actividad marca Skills (y el árbol, que sigue a la vista)`, g.on.includes('act-skills') && g.on.includes('act-files') | |
| 50 | + && await p.getAttribute('#act-skills', 'aria-pressed') === 'true', JSON.stringify(g.on)); | |
| 51 | + await p.click('#act-files'); | |
| 52 | + await p.waitForTimeout(250); | |
| 53 | + g = await geo(p); | |
| 54 | + ok(`${w} · 2 · con Skills abierto, el icono de ficheros oculta el árbol y Skills sigue abierto`, g.abierto && g.kind === 'skills' && !g.arbol, JSON.stringify(g)); | |
| 55 | + ok(`${w} · 2 · …y el panel se ensancha hasta la barra de actividad`, llena(g, 46), JSON.stringify(g.panel)); | |
| 56 | + ok(`${w} · 2 · …y el icono de ficheros ya no está marcado`, !g.on.includes('act-files') && g.on.includes('act-skills'), JSON.stringify(g.on)); | |
| 57 | + await p.click('#act-files'); | |
| 58 | + await p.waitForTimeout(250); | |
| 59 | + g = await geo(p); | |
| 60 | + ok(`${w} · 2 · otra vez: vuelve el árbol y el panel se ajusta a su borde`, g.abierto && !!g.arbol && llena(g, g.arbol.r), JSON.stringify(g)); | |
| 61 | + await p.setViewportSize({ width: 960, height: 640 }); | |
| 62 | + await p.waitForTimeout(250); | |
| 63 | + g = await geo(p); | |
| 64 | + ok(`${w} · 4 · al cambiar el tamaño de la ventana sigue lleno`, llena(g, g.arbol?.r), JSON.stringify(g)); | |
| 65 | + await p.setViewportSize({ width: w, height: h }); | |
| 66 | + await p.click('#act-settings'); | |
| 67 | + await p.waitForTimeout(250); | |
| 68 | + g = await geo(p); | |
| 69 | + ok(`${w} · 3 · el engranaje, con Skills abierto, abre Ajustes`, g.abierto && g.kind === 'settings' && g.on.includes('act-settings') && !g.on.includes('act-skills'), JSON.stringify(g)); | |
| 70 | + await p.click('#act-skills'); | |
| 71 | + await p.waitForTimeout(250); | |
| 72 | + await p.click('#act-skills'); | |
| 73 | + await p.waitForTimeout(250); | |
| 74 | + g = await geo(p); | |
| 75 | + ok(`${w} · 3 · pulsar otra vez Skills lo cierra y lo desmarca`, !g.abierto && !g.on.includes('act-skills') && await p.getAttribute('#act-skills', 'aria-pressed') === 'false', JSON.stringify(g)); | |
| 76 | + ok(`${w} · sin errores de página`, !p.errs.length, p.errs.join(' | ')); | |
| 77 | + await ctx.close(); | |
| 78 | +} | |
| 79 | + | |
| 80 | +// ── teléfono ── | |
| 81 | +{ | |
| 82 | + const { ctx, p } = await abre({ width: 390, height: 844 }, true); | |
| 83 | + await p.tap('#btn-drawer'); | |
| 84 | + await p.waitForTimeout(200); | |
| 85 | + await p.tap('#act-skills'); | |
| 86 | + await p.waitForTimeout(300); | |
| 87 | + let g = await geo(p); | |
| 88 | + ok('390 · 5 · Skills ocupa la pantalla entera bajo la cabecera', llena(g, 0), JSON.stringify(g)); | |
| 89 | + await p.tap('#btn-drawer'); | |
| 90 | + await p.waitForTimeout(250); | |
| 91 | + g = await geo(p); | |
| 92 | + ok('390 · 5 · el ☰ se abre encima sin cerrar Skills, y lo marca', g.abierto && g.kind === 'skills' && g.on.includes('act-skills') | |
| 93 | + && await p.evaluate(() => document.body.classList.contains('drawer-open')), JSON.stringify(g)); | |
| 94 | + await p.tap('#act-skills'); | |
| 95 | + await p.waitForTimeout(250); | |
| 96 | + g = await geo(p); | |
| 97 | + ok('390 · 5 · y Skills en el cajón lo cierra (y cierra el cajón)', !g.abierto && !(await p.evaluate(() => document.body.classList.contains('drawer-open'))), JSON.stringify(g)); | |
| 98 | + ok('390 · sin errores de página', !p.errs.length, p.errs.join(' | ')); | |
| 99 | + await ctx.close(); | |
| 100 | +} | |
| 101 | +await b.close(); | |
| 102 | +console.log(fails ? `\n❌ ${fails} FALLO(S)` : '\n✅ panel de Skills: lleno y con la barra de actividad al día'); | |
| 103 | +process.exit(fails ? 1 : 0); |
modified web/css/code.css +15 −5
| @@ -509,11 +509,21 @@ | ||
| 509 | 509 | .sk-row input { flex: 1; background: var(--bg); border: 1px solid var(--line); color: var(--fg); border-radius: 6px; padding: 6px 9px; font-size: .78rem; } |
| 510 | 510 | .sk-row button.primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); border: none; color: #fff; border-radius: 6px; padding: 5px 11px; cursor: pointer; font-size: .76rem; } |
| 511 | 511 | .sk-row button.ghost { background: none; border: 1px solid var(--line); color: var(--muted); border-radius: 6px; padding: 5px 9px; cursor: pointer; font-size: .76rem; } |
| 512 | -#settings-panel { max-height: 55vh; overflow-y: auto; flex-direction: column; } | |
| 513 | - | |
| 514 | -/* el panel de ajustes/skills se SUPERPONE (no empuja el IDE) */ | |
| 515 | -#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); } | |
| 516 | -@media (max-width: 760px) { #settings-panel { left: 0; } } | |
| 512 | +/* El panel de Ajustes / Skills / Extensiones se SUPERPONE (no empuja el IDE) y | |
| 513 | + ocupa ENTERO el hueco de trabajo: de la cabecera al pie y del borde del | |
| 514 | + explorador al de la ventana. Antes era una persiana de la altura de su | |
| 515 | + contenido (top fijo a 46 px y max-height 78vh): por debajo asomaban el | |
| 516 | + editor y el chat, y empezaba 5 px por debajo de la cabecera. La barra de | |
| 517 | + actividad y el explorador quedan a la vista y funcionando; al ocultar el | |
| 518 | + árbol, el panel se ensancha hasta la barra. */ | |
| 519 | +#settings-panel { | |
| 520 | + position: fixed; top: var(--ide-top, 41px); left: 281px; right: 0; bottom: 0; z-index: 90; | |
| 521 | + max-height: none; overflow-y: auto; overscroll-behavior: contain; flex-direction: column; | |
| 522 | + border-left: 1px solid var(--line); border-bottom: none; | |
| 523 | +} | |
| 524 | +#settings-panel > * { flex-shrink: 0; } | |
| 525 | +body.hide-tree #settings-panel, body.chat-full #settings-panel { left: 46px; } | |
| 526 | +@media (max-width: 760px) { #settings-panel, body.hide-tree #settings-panel { left: 0; border-left: none; } } | |
| 517 | 527 | |
| 518 | 528 | /* ---------- móvil: cajón con el árbol y las herramientas ---------- |
| 519 | 529 | En el móvil la barra de actividad, el árbol y la barra de menús están |
modified web/js/ext/panel.js +1 −0
| @@ -174,6 +174,7 @@ | ||
| 174 | 174 | // aquí no existe), y si no, sin rol de diálogo. |
| 175 | 175 | box.setAttribute('role', 'dialog'); |
| 176 | 176 | box.setAttribute('aria-labelledby', 'ext-title'); |
| 177 | + box.dataset.kind = 'ext'; | |
| 177 | 178 | const cerrar = el('button', null, '✕'); |
| 178 | 179 | cerrar.id = 'settings-close'; |
| 179 | 180 | cerrar.type = 'button'; |
modified web/js/main.js +42 −10
| @@ -964,8 +964,9 @@ | ||
| 964 | 964 | // anuncia como tal, el foco entra en él al abrirse y vuelve a quien lo abrió |
| 965 | 965 | // al cerrarse (también con Escape). Antes el foco se quedaba en el engranaje. |
| 966 | 966 | let volverDeAjustes = null; |
| 967 | -function settingsShell(title) { | |
| 967 | +function settingsShell(title, kind = 'settings') { | |
| 968 | 968 | const box = $('settings-panel'); |
| 969 | + box.dataset.kind = kind; // qué hay dentro: lo enseña la barra de actividad | |
| 969 | 970 | const yaAbierto = !box.hidden && box.contains(document.activeElement); |
| 970 | 971 | if (box.hidden || !volverDeAjustes) volverDeAjustes = document.activeElement; |
| 971 | 972 | box.hidden = false; |
| @@ -1874,7 +1875,7 @@ | ||
| 1874 | 1875 | body.firstChild.textContent = t('viewBuilding'); |
| 1875 | 1876 | overlay.hidden = false; |
| 1876 | 1877 | tapaVista(true); |
| 1877 | - document.querySelectorAll('#activity button').forEach(b => b.classList.toggle('on', b.id === 'act-' + kind)); | |
| 1878 | + document.querySelectorAll('#act-arch, #act-city').forEach(b => b.classList.toggle('on', b.id === 'act-' + kind)); | |
| 1878 | 1879 | // esperar a que el layout dé tamaño real al overlay (si no, canvas 0×0/mal aspect) |
| 1879 | 1880 | await new Promise(r => requestAnimationFrame(() => requestAnimationFrame(r))); |
| 1880 | 1881 | if (seq !== viewRenderSeq) return; // el usuario cambió de vista mientras tanto |
| @@ -1965,7 +1966,7 @@ | ||
| 1965 | 1966 | tapaVista(false); |
| 1966 | 1967 | import('./city.js').then(m => m.disposeCity()).catch(() => {}); |
| 1967 | 1968 | import('./arch.js').then(m => m.disposeArch()).catch(() => {}); |
| 1968 | - document.querySelectorAll('#activity button').forEach(b => b.classList.toggle('on', b.id === 'act-files')); | |
| 1969 | + document.querySelectorAll('#act-arch, #act-city').forEach(b => b.classList.remove('on')); | |
| 1969 | 1970 | // El foco vuelve a quien la abrió si aún se ve; si no (un menú que ya se |
| 1970 | 1971 | // cerró), al botón de la vista en la barra de actividad; en el móvil, donde |
| 1971 | 1972 | // esos botones viven en el cajón cerrado, al ☰. |
| @@ -2231,13 +2232,40 @@ | ||
| 2231 | 2232 | $('act-settings').innerHTML = ACTIVITY.gear; |
| 2232 | 2233 | $('act-files').addEventListener('click', () => { |
| 2233 | 2234 | document.body.classList.toggle('hide-tree'); |
| 2234 | - $('act-files').classList.toggle('on'); | |
| 2235 | + pintaActividad(); | |
| 2235 | 2236 | }); |
| 2236 | 2237 | // Lo que promete su título: buscar ficheros (la paleta, como Cmd/Ctrl+P). Antes |
| 2237 | 2238 | // escribía «busca » en el chat. Buscar DENTRO del código es «#» en la paleta. |
| 2238 | 2239 | $('act-search').addEventListener('click', (e) => { e.stopPropagation(); openPalette(''); }); |
| 2239 | 2240 | $('act-settings').addEventListener('click', () => $('btn-settings').click()); |
| 2240 | 2241 | |
| 2242 | +// La barra de actividad dice qué está abierto. El explorador (☰ del árbol) y el | |
| 2243 | +// panel grande (Ajustes, Skills o Extensiones) son independientes: con Skills | |
| 2244 | +// abierto, ocultar o enseñar el árbol funciona y el panel se ajusta al hueco | |
| 2245 | +// que queda (antes el clic cerraba Skills y, al ocultar el árbol, el editor | |
| 2246 | +// desaparecía). Pulsar otra vez el icono del panel abierto lo cierra. | |
| 2247 | +const panelAbierto = () => { const p = $('settings-panel'); return p.hidden ? '' : (p.dataset.kind || 'settings'); }; | |
| 2248 | +function pintaActividad() { | |
| 2249 | + const tree = !document.body.classList.contains('hide-tree'); | |
| 2250 | + $('act-files').classList.toggle('on', tree); | |
| 2251 | + $('act-files').setAttribute('aria-pressed', String(tree)); | |
| 2252 | + const abierto = panelAbierto(); | |
| 2253 | + for (const k of ['skills', 'ext', 'settings']) { | |
| 2254 | + const b = $('act-' + k); | |
| 2255 | + b.classList.toggle('on', abierto === k); | |
| 2256 | + b.setAttribute('aria-pressed', String(abierto === k)); | |
| 2257 | + } | |
| 2258 | +} | |
| 2259 | +new MutationObserver(pintaActividad).observe($('settings-panel'), { attributes: true, attributeFilter: ['hidden', 'data-kind'] }); | |
| 2260 | +// El panel empieza justo debajo de la cabecera, mida lo que mida (en el móvil | |
| 2261 | +// la cabecera ocupa dos líneas). | |
| 2262 | +{ | |
| 2263 | + const cab = document.querySelector('#ide header'); | |
| 2264 | + const mide = () => { const y = Math.round(cab.getBoundingClientRect().bottom); if (y > 0) document.documentElement.style.setProperty('--ide-top', y + 'px'); }; | |
| 2265 | + new ResizeObserver(mide).observe(cab); | |
| 2266 | + addEventListener('resize', mide); | |
| 2267 | +} | |
| 2268 | + | |
| 2241 | 2269 | $('btn-history').addEventListener('click', () => { |
| 2242 | 2270 | const panel = $('history-panel'); |
| 2243 | 2271 | if (!panel.hidden) return cierraHistorial(); |
| @@ -2259,8 +2287,9 @@ | ||
| 2259 | 2287 | cierraHistorial({ foco: false }); |
| 2260 | 2288 | }, true); |
| 2261 | 2289 | $('btn-settings').addEventListener('click', () => { |
| 2262 | - const p = $('settings-panel'); | |
| 2263 | - if (!p.hidden) return cierraAjustes(); | |
| 2290 | + // Con Skills o Extensiones abiertos, el engranaje abre Ajustes (antes los | |
| 2291 | + // cerraba y había que pulsar dos veces). | |
| 2292 | + if (panelAbierto() === 'settings') return cierraAjustes(); | |
| 2264 | 2293 | renderSettings(); |
| 2265 | 2294 | }); |
| 2266 | 2295 | // clic fuera del panel (o ir a Archivo/chat) lo cierra — antes solo la X lo hacía. |
| @@ -2270,7 +2299,10 @@ | ||
| 2270 | 2299 | document.addEventListener('pointerdown', e => { |
| 2271 | 2300 | const p = $('settings-panel'); |
| 2272 | 2301 | if (p.hidden) return; |
| 2273 | - if (p.contains(e.target) || e.target.closest('#btn-settings, #act-settings, #model-dot, #ext-themepick')) return; | |
| 2302 | + // Los botones que abren o cierran el panel (y el explorador y el cajón del | |
| 2303 | + // móvil, que conviven con él) no cuentan como «fuera»: si no, el clic lo | |
| 2304 | + // cerraba y su propio manejador lo volvía a abrir. | |
| 2305 | + if (p.contains(e.target) || e.target.closest('#btn-settings, #act-settings, #act-skills, #act-ext, #act-files, #btn-drawer, #drawer-scrim, #model-dot, #ext-themepick')) return; | |
| 2274 | 2306 | p.hidden = true; |
| 2275 | 2307 | volverDeAjustes = null; |
| 2276 | 2308 | }, true); |
| @@ -2725,7 +2757,7 @@ | ||
| 2725 | 2757 | // de persona y con «Reintentar» (antes: «⚠️ FAILED TO FETCH» en mayúsculas, y |
| 2726 | 2758 | // un alert() del navegador al añadir un repo que no valía o al instalar). |
| 2727 | 2759 | async function openSkillsPanel() { |
| 2728 | - const box = settingsShell(t('skTitle')); | |
| 2760 | + const box = settingsShell(t('skTitle'), 'skills'); | |
| 2729 | 2761 | const wrap = document.createElement('div'); |
| 2730 | 2762 | wrap.className = 'skills-panel'; |
| 2731 | 2763 | const intro = document.createElement('p'); |
| @@ -3151,7 +3183,7 @@ | ||
| 3151 | 3183 | |
| 3152 | 3184 | // icono de skills en la barra de actividad |
| 3153 | 3185 | $('act-skills').innerHTML = UI.puzzle; |
| 3154 | -$('act-skills').addEventListener('click', () => openSkillsPanel()); | |
| 3186 | +$('act-skills').addEventListener('click', () => (panelAbierto() === 'skills' ? cierraAjustes() : openSkillsPanel())); | |
| 3155 | 3187 | |
| 3156 | 3188 | // Extensiones de VS Code (temas, gramáticas, snippets, lenguajes): js/ext/. |
| 3157 | 3189 | // Nada de eso se carga hasta que se usa; el panel y el host llegan al pulsar. |
| @@ -3165,7 +3197,7 @@ | ||
| 3165 | 3197 | } |
| 3166 | 3198 | $('act-ext').innerHTML = ACTIVITY.extensions; |
| 3167 | 3199 | $('act-ext').title = extTexto('Extensiones (temas, gramáticas, snippets)', 'Extensions (themes, grammars, snippets)'); |
| 3168 | -$('act-ext').addEventListener('click', () => openExtensions()); | |
| 3200 | +$('act-ext').addEventListener('click', () => (panelAbierto() === 'ext' && panelExt ? panelExt.close() : openExtensions())); | |
| 3169 | 3201 | |
| 3170 | 3202 | rebuildSelect(); |
| 3171 | 3203 | skills.initSkills(); |