utopia-ia/elffuss-code public
Changesets · Branches · Tags · Compare
| Changeset | 2ffc410530e54772fe0a3b9c2c77072786fe8abda5ef4085492a4146239d6cfa |
|---|---|
| Author | KikoCis <kikocisneros@gmail.com> · 2026-10-13 13:12 +02:00 |
| Committer | KikoCis <kikocisneros@gmail.com> · 2026-10-13 13:12 +02:00 |
| Parents | 1b46672e7cf9 |
6 files changed
added tests/busqueda-arriba.mjs +56 −0
| @@ -0,0 +1,56 @@ | ||
| 1 | +// La búsqueda vive fija en la cabecera (como el «command center» de VS Code) y | |
| 2 | +// no detrás de una lupa en la barra lateral. Pulsarla o escribir en ella abre | |
| 3 | +// la paleta justo debajo. | |
| 4 | +import { chromium } from 'playwright'; | |
| 5 | +const BASE = process.env.BASE || 'http://localhost:8799'; | |
| 6 | +let fails = 0; | |
| 7 | +const ok = (n, c, e = '') => { console.log((c ? '✅' : '❌') + ' ' + n + (e ? ' — ' + e : '')); if (!c) fails++; }; | |
| 8 | + | |
| 9 | +const b = await chromium.launch(); | |
| 10 | +const errs = []; | |
| 11 | +async function abre(width) { | |
| 12 | + const ctx = await b.newContext({ viewport: { width, height: 800 }, locale: 'es-ES' }); | |
| 13 | + await ctx.addInitScript(() => { try { localStorage.setItem('elffusscode.model', 'rules'); } catch {} }); | |
| 14 | + const p = await ctx.newPage(); | |
| 15 | + p.on('pageerror', e => errs.push(e.message.slice(0, 160))); | |
| 16 | + await p.goto(BASE + '/?test-opfs'); | |
| 17 | + await p.waitForFunction(() => !!document.querySelector('#editor .monaco-editor'), null, { timeout: 30000 }); | |
| 18 | + await p.waitForTimeout(400); | |
| 19 | + return { ctx, p }; | |
| 20 | +} | |
| 21 | +const paleta = p => p.evaluate(() => ({ abierta: !document.getElementById('palette').hidden, texto: document.getElementById('pal-input').value })); | |
| 22 | + | |
| 23 | +{ | |
| 24 | + const { ctx, p } = await abre(1280); | |
| 25 | + ok('la lupa de la barra lateral ya no existe', !(await p.$('#act-search'))); | |
| 26 | + const r = await p.evaluate(() => { const s = document.getElementById('top-search'); const box = s?.getBoundingClientRect(); return { enCabecera: !!s?.closest('header'), visible: !!box?.width, texto: s?.querySelector('.ts-txt')?.textContent, kbd: s?.querySelector('.ts-kbd')?.textContent }; }); | |
| 27 | + ok('la búsqueda está fija en la cabecera, a la vista', r.enCabecera && r.visible, JSON.stringify(r)); | |
| 28 | + ok('…dice qué busca y su atajo', /Buscar archivos/.test(r.texto || '') && /P$/.test(r.kbd || ''), JSON.stringify(r)); | |
| 29 | + ok('⊕ control: antes de tocarla, la paleta está cerrada', !(await paleta(p)).abierta); | |
| 30 | + await p.click('#top-search'); | |
| 31 | + await p.waitForTimeout(250); | |
| 32 | + ok('pulsarla abre la paleta (y se queda abierta)', (await paleta(p)).abierta); | |
| 33 | + const debajo = await p.evaluate(() => { const s = document.getElementById('top-search').getBoundingClientRect(), q = document.getElementById('palette').getBoundingClientRect(); return { centroBarra: Math.round(s.left + s.width / 2), centroPaleta: Math.round(q.left + q.width / 2), barraAbajo: Math.round(s.bottom), paletaArriba: Math.round(q.top) }; }); | |
| 34 | + ok('…justo debajo de la barra y con su mismo centro', Math.abs(debajo.centroBarra - debajo.centroPaleta) <= 2 && debajo.paletaArriba >= debajo.barraAbajo && debajo.paletaArriba - debajo.barraAbajo <= 12, JSON.stringify(debajo)); | |
| 35 | + await p.keyboard.press('Escape'); | |
| 36 | + await p.waitForTimeout(200); | |
| 37 | + await p.focus('#top-search'); | |
| 38 | + await p.keyboard.press('a'); | |
| 39 | + await p.waitForTimeout(250); | |
| 40 | + const t = await paleta(p); | |
| 41 | + ok('con el foco en ella, escribir ya busca (la letra pasa a la paleta)', t.abierta && t.texto === 'a', JSON.stringify(t)); | |
| 42 | + await ctx.close(); | |
| 43 | +} | |
| 44 | +{ | |
| 45 | + const { ctx, p } = await abre(390); | |
| 46 | + const r = await p.evaluate(() => { const s = document.getElementById('top-search'); const box = s.getBoundingClientRect(); return { visible: box.width > 0, ancho: Math.round(box.width), texto: getComputedStyle(s.querySelector('.ts-txt')).display, scrollX: document.documentElement.scrollWidth > innerWidth }; }); | |
| 47 | + ok('en el móvil queda como icono y sin desbordar la cabecera', r.visible && r.texto === 'none' && !r.scrollX, JSON.stringify(r)); | |
| 48 | + await p.click('#top-search'); | |
| 49 | + await p.waitForTimeout(250); | |
| 50 | + ok('…y también abre la paleta', (await paleta(p)).abierta); | |
| 51 | + await ctx.close(); | |
| 52 | +} | |
| 53 | +ok('sin errores de página', !errs.length, errs.join(' | ')); | |
| 54 | +await b.close(); | |
| 55 | +console.log(fails ? `\n❌ ${fails} FALLO(S)` : '\nTodo en verde'); | |
| 56 | +process.exit(fails ? 1 : 0); |
modified tests/keyboard-ux.mjs +2 −2
| @@ -147,9 +147,9 @@ | ||
| 147 | 147 | await p.waitForTimeout(500); |
| 148 | 148 | const abierto = await p.evaluate(() => ({ activa: document.querySelector('#tabs-bar .tab.active')?.dataset.path, linea: window.monaco?.editor?.getEditors?.()[0]?.getPosition()?.lineNumber })); |
| 149 | 149 | ok('7 · Enter abre el fichero en esa línea', abierto.activa === 'src/app.js' && abierto.linea === 2, JSON.stringify(abierto)); |
| 150 | -await p.click('#act-search'); | |
| 150 | +await p.click('#top-search'); | |
| 151 | 151 | await p.waitForTimeout(200); |
| 152 | -ok('7 · la lupa de la barra abre la paleta (y se queda abierta)', await p.evaluate(() => !document.getElementById('palette').hidden)); | |
| 152 | +ok('7 · la búsqueda fija de arriba abre la paleta (y se queda abierta)', await p.evaluate(() => !document.getElementById('palette').hidden)); | |
| 153 | 153 | await p.keyboard.press('Escape'); |
| 154 | 154 | |
| 155 | 155 | // 8 · detalles |
modified web/css/code.css +12 −0
| @@ -591,6 +591,18 @@ | ||
| 591 | 591 | #menubar button:hover, #menubar button.open { color: var(--fg); background: #ffffff10; } |
| 592 | 592 | @media (max-width: 900px) { #menubar { display: none; } } |
| 593 | 593 | |
| 594 | +/* la búsqueda fija arriba: parece un campo, abre la paleta debajo */ | |
| 595 | +.top-search { flex: 0 1 440px; margin: 0 auto; display: flex; align-items: center; gap: 8px; min-width: 0; | |
| 596 | + height: 28px; padding: 0 10px; background: var(--bg); border: 1px solid var(--line); border-radius: 7px; | |
| 597 | + color: var(--muted); font-size: .8rem; cursor: text; text-align: left; } | |
| 598 | +.top-search:hover { border-color: var(--accent2); color: var(--fg); } | |
| 599 | +.top-search:focus-visible { outline: 2px solid var(--accent2); outline-offset: 1px; } | |
| 600 | +.top-search .ts-ico { display: inline-flex; flex: none; } | |
| 601 | +.top-search .ts-ico svg { width: 14px; height: 14px; } | |
| 602 | +.top-search .ts-txt { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; } | |
| 603 | +.top-search .ts-kbd { flex: none; font: inherit; font-size: .72rem; padding: 1px 6px; border: 1px solid var(--line); border-radius: 4px; background: var(--bg3); } | |
| 604 | +@media (max-width: 760px) { .top-search { flex: 0 0 auto; width: 34px; padding: 0; justify-content: center; } .top-search .ts-txt, .top-search .ts-kbd { display: none; } } | |
| 605 | + | |
| 594 | 606 | /* dropdown del menú (fixed, anclado al botón) */ |
| 595 | 607 | #topmenu { position: fixed; z-index: 110; min-width: 220px; background: var(--bg3); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 10px 34px rgba(0,0,0,.55); padding: 4px; } |
| 596 | 608 | #topmenu[hidden] { display: none; } |
modified web/index.html +5 −1
| @@ -68,6 +68,11 @@ | ||
| 68 | 68 | <button data-menu="view">View</button> |
| 69 | 69 | <button data-menu="git">Git</button> |
| 70 | 70 | </nav> |
| 71 | + <!-- La búsqueda, siempre a la vista (como el «command center» de VS Code): | |
| 72 | + al pulsarla o escribir, abre la paleta justo debajo. --> | |
| 73 | + <button id="top-search" type="button" class="top-search" aria-keyshortcuts="Meta+P Control+P"> | |
| 74 | + <span class="ts-ico" aria-hidden="true"></span><span class="ts-txt">Buscar archivos, símbolos y comandos</span><kbd class="ts-kbd" aria-hidden="true">⌘P</kbd> | |
| 75 | + </button> | |
| 71 | 76 | <div class="controls"> |
| 72 | 77 | <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> |
| 73 | 78 | <button id="git-branch" class="chip" title="rama actual" hidden></button> |
| @@ -91,7 +96,6 @@ | ||
| 91 | 96 | <main> |
| 92 | 97 | <nav id="activity"> |
| 93 | 98 | <button id="act-files" class="on" title="Explorador"></button> |
| 94 | - <button id="act-search" title="Buscar (Cmd/Ctrl+P)"></button> | |
| 95 | 99 | <button id="act-arch" title="Arquitectura (grafo de dependencias)"></button> |
| 96 | 100 | <button id="act-city" title="Ciudad 3D"></button> |
| 97 | 101 | <button id="act-term" title="Terminal (Ctrl+`)"></button> |
modified web/js/i18n.js +4 −3
| @@ -17,7 +17,7 @@ | ||
| 17 | 17 | openProject: '📁 Abrir carpeta de código', resume: 'Reanudar', discard: 'Descartar', cloneOpen: 'Descargar y abrir', |
| 18 | 18 | clonePh: 'pega la URL de un repo público (GitHub/Bitbucket)…', |
| 19 | 19 | searchPh: 'Buscar archivos por nombre (: ir a línea, @ símbolo, > comandos, # buscar en el código)', |
| 20 | - tFiles: 'Explorador', tSearch: 'Buscar (Cmd/Ctrl+P)', tArch: 'Arquitectura (grafo de dependencias)', | |
| 20 | + tFiles: 'Explorador', tSearch: 'Buscar (Cmd/Ctrl+P)', tSearchBar: 'Buscar archivos, símbolos y comandos', tArch: 'Arquitectura (grafo de dependencias)', | |
| 21 | 21 | tCity: 'Ciudad 3D', tTerm: 'Terminal (Ctrl+`)', tSkills: 'Skills', tActSettings: 'Ajustes y modelo', |
| 22 | 22 | tGitBranch: 'rama actual', tHistory: 'Historial de conversaciones', tTopSettings: 'Ajustes, modelo y API keys', |
| 23 | 23 | tTermClose: 'cerrar (Ctrl+`)', tTermResize: 'arrastra para redimensionar', |
| @@ -268,7 +268,7 @@ | ||
| 268 | 268 | openProject: '📁 Open code folder', resume: 'Resume', discard: 'Discard', cloneOpen: 'Download & open', |
| 269 | 269 | clonePh: 'paste the URL of a public repo (GitHub/Bitbucket)…', |
| 270 | 270 | searchPh: 'Search files by name (: go to line, @ symbol, > commands, # search in code)', |
| 271 | - tFiles: 'Explorer', tSearch: 'Search (Cmd/Ctrl+P)', tArch: 'Architecture (dependency graph)', | |
| 271 | + tFiles: 'Explorer', tSearch: 'Search (Cmd/Ctrl+P)', tSearchBar: 'Search files, symbols and commands', tArch: 'Architecture (dependency graph)', | |
| 272 | 272 | tCity: '3D City', tTerm: 'Terminal (Ctrl+`)', tSkills: 'Skills', tActSettings: 'Settings & model', |
| 273 | 273 | tGitBranch: 'current branch', tHistory: 'Conversation history', tTopSettings: 'Settings, model & API keys', |
| 274 | 274 | tTermClose: 'close (Ctrl+`)', tTermResize: 'drag to resize', |
| @@ -536,8 +536,9 @@ | ||
| 536 | 536 | set('#try-browser', 'textContent', 'tryBrowser'); |
| 537 | 537 | set('#term-clear', 'textContent', 'termClear'); |
| 538 | 538 | set('#pal-input', 'placeholder', 'searchPh'); |
| 539 | + set('#top-search .ts-txt', 'textContent', 'tSearchBar'); | |
| 539 | 540 | const titles = { |
| 540 | - '#act-files': 'tFiles', '#act-search': 'tSearch', '#act-arch': 'tArch', '#act-city': 'tCity', | |
| 541 | + '#act-files': 'tFiles', '#top-search': 'tSearch', '#act-arch': 'tArch', '#act-city': 'tCity', | |
| 541 | 542 | '#act-term': 'tTerm', '#act-skills': 'tSkills', '#act-settings': 'tActSettings', |
| 542 | 543 | '#git-branch': 'tGitBranch', '#btn-history': 'tHistory', '#btn-settings': 'tTopSettings', |
| 543 | 544 | '#term-close': 'tTermClose', '#term-resize': 'tTermResize', '#ctx-meter': 'tCtx', |
modified web/js/main.js +14 −2
| @@ -2284,7 +2284,9 @@ | ||
| 2284 | 2284 | |
| 2285 | 2285 | // barra de actividad estilo VS Code |
| 2286 | 2286 | $('act-files').innerHTML = ACTIVITY.files; |
| 2287 | -$('act-search').innerHTML = ACTIVITY.search; | |
| 2287 | +// La búsqueda fija de la cabecera (sustituye a la lupa de la barra lateral). | |
| 2288 | +$('top-search').querySelector('.ts-ico').innerHTML = ACTIVITY.search; | |
| 2289 | +$('top-search').querySelector('.ts-kbd').textContent = /Mac|iPhone|iPad/.test(navigator.platform || navigator.userAgent) ? '⌘P' : 'Ctrl+P'; | |
| 2288 | 2290 | $('act-settings').innerHTML = ACTIVITY.gear; |
| 2289 | 2291 | $('act-files').addEventListener('click', () => { |
| 2290 | 2292 | document.body.classList.toggle('hide-tree'); |
| @@ -2292,7 +2294,11 @@ | ||
| 2292 | 2294 | }); |
| 2293 | 2295 | // Lo que promete su título: buscar ficheros (la paleta, como Cmd/Ctrl+P). Antes |
| 2294 | 2296 | // escribía «busca » en el chat. Buscar DENTRO del código es «#» en la paleta. |
| 2295 | -$('act-search').addEventListener('click', (e) => { e.stopPropagation(); openPalette(''); }); | |
| 2297 | +$('top-search').addEventListener('click', (e) => { e.stopPropagation(); openPalette(''); }); | |
| 2298 | +// Con el foco en ella, escribir ya busca: la primera letra pasa a la paleta. | |
| 2299 | +$('top-search').addEventListener('keydown', (e) => { | |
| 2300 | + if (e.key.length === 1 && !e.ctrlKey && !e.metaKey && !e.altKey) { e.preventDefault(); openPalette(e.key); } | |
| 2301 | +}); | |
| 2296 | 2302 | $('act-settings').addEventListener('click', () => $('btn-settings').click()); |
| 2297 | 2303 | |
| 2298 | 2304 | // La barra de actividad dice qué está abierto. El explorador (☰ del árbol) y el |
| @@ -3036,6 +3042,12 @@ | ||
| 3036 | 3042 | function openPalette(prefix = '') { |
| 3037 | 3043 | cierraVistaSiAbierta(); |
| 3038 | 3044 | if ($('palette').hidden) volverDePaleta = document.activeElement; |
| 3045 | + // Debajo de la búsqueda fija y con su mismo centro (como en VS Code). Si la | |
| 3046 | + // barra es solo un icono (móvil), se queda centrada en la ventana como antes. | |
| 3047 | + const barra = $('top-search')?.getBoundingClientRect(); | |
| 3048 | + const pal = $('palette'); | |
| 3049 | + if (barra && barra.width > 200) { pal.style.left = Math.round(barra.left + barra.width / 2) + 'px'; pal.style.top = Math.round(barra.bottom + 6) + 'px'; } | |
| 3050 | + else { pal.style.left = ''; pal.style.top = ''; } | |
| 3039 | 3051 | $('palette').hidden = false; |
| 3040 | 3052 | const inp = $('pal-input'); |
| 3041 | 3053 | inp.setAttribute('role', 'combobox'); |