Elffuss BraidHub

utopia-ia/elffuss-code public

La consola ya no queda tapada, y un tema claro no se aplica solo

Consola: el aviso de «sin ficheros» y la vista previa de Markdown se estiraban
hasta la barra de estado y tapaban la consola abierta. Ahora terminan encima:
main.js publica su altura real en --term-h con un ResizeObserver (0 cerrada,
y sigue al arrastrar). La vista de ciudad la sigue tapando a propósito.
Test consola-visible.mjs con control negativo.

Temas: al instalar una extensión de solo temas se aplicaba el PRIMERO, y si
era claro el editor quedaba blanco dentro de un IDE oscuro. Ahora se aplica
solo una variante oscura; si no hay, ninguna. «Aplicar ahora» también
prefiere la oscura.
Changeset272c2a41bf73601d0c7fd5df7b9a26bd5a9528d121423191efe66f8e8d4bd254
AuthorKikoCis <kikocisneros@gmail.com> · 2026-10-13 10:10 +02:00
CommitterKikoCis <kikocisneros@gmail.com> · 2026-10-13 10:10 +02:00
Parents35d8f2574892

Browse the files at this changeset

4 files changed

added tests/consola-visible.mjs +47 −0
@@ -0,0 +1,47 @@
1+// La consola no puede quedar tapada por las capas del editor. El aviso de «sin
2+// ficheros» y la vista previa de Markdown se estiraban hasta la barra de estado
3+// y, con la consola abierta, el clic en la consola caía en el aviso.
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 ctx = await b.newContext({ viewport: { width: 1280, height: 760 } });
11+await ctx.addInitScript(() => { try { localStorage.setItem('elffusscode.model', 'rules'); } catch {} });
12+const p = await ctx.newPage();
13+p.on('pageerror', e => { console.log('❌ pageerror: ' + e.message); fails++; });
14+await p.goto(BASE + '/?test-opfs');
15+await p.waitForFunction(() => !!document.querySelector('#editor .monaco-editor'), null, { timeout: 30000 });
16+await p.waitForTimeout(500);
17+
18+const aviso = () => p.evaluate(() => {
19+ const e = document.getElementById('editor-empty'), w = document.getElementById('editor-wrap');
20+ return { visible: getComputedStyle(e).display !== 'none', fondo: Math.round(w.getBoundingClientRect().bottom - e.getBoundingClientRect().bottom) };
21+});
22+const a0 = await aviso();
23+ok('⊕ control: el aviso vacío está a la vista (es la capa que tapaba)', a0.visible);
24+
25+await p.click('#act-term');
26+await p.waitForTimeout(800);
27+const r = await p.evaluate(() => {
28+ const t = document.getElementById('terminal-panel').getBoundingClientRect();
29+ const quien = (x, y) => { let el = document.elementFromPoint(x, y); while (el) { if (el.id === 'terminal-panel') return true; el = el.parentElement; } return false; };
30+ return {
31+ alto: Math.round(t.height),
32+ centro: quien(t.left + t.width / 2, t.top + t.height / 2),
33+ arriba: quien(t.left + t.width / 2, t.top + 12),
34+ };
35+});
36+ok('⊕ control: la consola se ha abierto con altura', r.alto > 50, `${r.alto}px`);
37+ok('el centro de la consola es la consola, no una capa encima', r.centro);
38+ok('su cabecera también', r.arriba);
39+
40+await p.click('#term-close');
41+await p.waitForTimeout(400);
42+const a1 = await aviso();
43+ok('al cerrarla, el aviso vuelve a llegar hasta la barra de estado', a1.visible && a1.fondo <= 23, `deja ${a1.fondo}px abajo`);
44+
45+await b.close();
46+console.log(fails ? `\n❌ ${fails} FALLO(S)` : '\nTodo en verde');
47+process.exit(fails ? 1 : 0);
modified web/css/code.css +5 −2
@@ -160,7 +160,7 @@
160160 #dirty-dialog button.dd-primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; border: none; }
161161 #dirty-dialog button:focus-visible { outline: 2px solid var(--accent2); outline-offset: 2px; }
162162 #editor { flex: 1; min-height: 0; }
163-#editor-empty { position: absolute; inset: 34px 0 22px 0; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 14px; background: var(--bg); color: var(--muted); z-index: 2; text-align: center; }
163+#editor-empty { position: absolute; inset: 34px 0 calc(22px + var(--term-h, 0px)) 0; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 14px; background: var(--bg); color: var(--muted); z-index: 2; text-align: center; }
164164 #editor-empty img { width: 84px; opacity: .5; }
165165 #editor-empty p { font-size: .9rem; line-height: 1.5; }
166166
@@ -257,7 +257,7 @@
257257 .tm-sep { height: 1px; background: var(--line); margin: 4px 2px; }
258258
259259 /* vista previa de markdown (pestaña en modo Vista previa, en vez del código fuente) */
260-#md-preview-pane { position: absolute; inset: 34px 0 22px 0; overflow-y: auto; background: var(--bg); padding: 18px 26px; z-index: 2; }
260+#md-preview-pane { position: absolute; inset: 34px 0 calc(22px + var(--term-h, 0px)) 0; overflow-y: auto; background: var(--bg); padding: 18px 26px; z-index: 2; }
261261 #md-preview-pane h1, #md-preview-pane h2, #md-preview-pane h3 { color: #fff; margin: 18px 0 8px; }
262262 #md-preview-pane code { background: var(--bg3); padding: 1px 5px; border-radius: 4px; font-size: .88em; }
263263 #md-preview-pane pre { background: var(--bg3); border: 1px solid var(--line); border-radius: 8px; padding: 10px; overflow-x: auto; }
@@ -266,6 +266,9 @@
266266 #md-preview-pane.html-preview iframe { display: block; width: 100%; height: 100%; border: none; background: #fff; }
267267
268268 /* panel del terminal (abajo del editor, estilo VS Code) */
269+/* Las capas del editor (aviso vacío, vista previa) terminan encima de la consola:
270+ --term-h la pone main.js con su altura real, 0 si está cerrada. Antes se
271+ estiraban hasta la barra de estado y tapaban la consola entera. */
269272 #terminal-panel { display: flex; flex-direction: column; height: 260px; flex: 0 0 auto; background: #0b0d12; border-top: 1px solid var(--line); position: relative; }
270273 #terminal-panel[hidden] { display: none; }
271274 #term-resize { position: absolute; top: -3px; left: 0; right: 0; height: 6px; cursor: ns-resize; z-index: 3; }
modified web/js/ext/panel.js +13 −4
@@ -11,6 +11,9 @@
1111 import { uiLang } from '../i18n.js';
1212 import { describe, lista, listaO, works, languageName, languageExts, factsFromManifest, factsFromRecord } from './verdict.js';
1313
14+// Las bases de Monaco que son oscuras. El resto del IDE no tiene modo claro.
15+const esOscuro = t => t?.uiTheme === 'vs-dark' || t?.uiTheme === 'hc-black';
16+
1417 const $ = id => document.getElementById(id);
1518 const el = (tag, cls, txt) => { const e = document.createElement(tag); if (cls) e.className = cls; if (txt != null) e.textContent = txt; return e; };
1619 const CATS = [['', 'catAll'], ['Themes', 'catThemes'], ['Snippets', 'catSnippets'], ['Programming Languages', 'catLangs']];
@@ -628,13 +631,19 @@
628631 // una extensión que solo trae temas se ve al instante: se aplica el primero
629632 // (con «Deshacer» en el aviso)
630633 const soloTemas = rec.themes?.length && !rec.grammars?.length && !rec.snippets?.length && !(rec.languages || []).some(l => l.configKey && !host.builtinLanguage?.(l.id));
634+ // Solo se aplica sola una variante OSCURA. El IDE es oscuro y un tema claro
635+ // solo repinta el editor: quedaba un rectángulo blanco en medio de todo lo
636+ // demás, y bastaba con que el paquete listara primero su variante clara
637+ // (GitHub Theme y compañía). Si no trae ninguna oscura, no se aplica nada y
638+ // queda el botón «Aplicar ahora».
639+ const oscuro = rec.themes?.find(esOscuro);
631640 let auto = false;
632- if (soloTemas && !rec.themes.some(t => t.themeId === host.currentTheme()) && rec.enabled !== false && !host.paused) {
633- await host.setTheme(rec.themes[0].themeId);
641+ if (soloTemas && oscuro && !rec.themes.some(t => t.themeId === host.currentTheme()) && rec.enabled !== false && !host.paused) {
642+ await host.setTheme(oscuro.themeId);
634643 auto = true;
635644 }
636645 const nAvisos = avisosVisibles(rec.warnings).length;
637- const primera = auto ? ' ' + tx('cThemeApplied', { name: rec.themes[0].label }) : '';
646+ const primera = auto ? ' ' + tx('cThemeApplied', { name: oscuro.label }) : '';
638647 aviso(tx('installedMsg', { name: rec.displayName || nombre }) + primera + (nAvisos ? ' ' + tx('warnSummary', { n: nAvisos }) + '.' : ''));
639648 await pintaTarjeta(rec, { previo: auto ? temaAntes : null });
640649 pintaInstaladas();
@@ -728,7 +737,7 @@
728737 : rec.themes.length === 1 ? tx('cThemeReady', { name: rec.themes[0].label }) : tx('cThemesReady', { n: rec.themes.length, list: lista(rec.themes.map(t => cita(t.label))) })));
729738 const fila = botones(p);
730739 if (activo && previo && previo !== activo.themeId) boton(fila, tx('bUndo'), 'undo-theme', async () => { await host.setTheme(previo); pinta('apply-theme'); pintaInstaladas(); });
731- if (!activo) boton(fila, tx('bApplyNow'), 'apply-theme', async () => { await host.setTheme(rec.themes[0].themeId); pinta('undo-theme'); pintaInstaladas(); });
740+ if (!activo) boton(fila, tx('bApplyNow'), 'apply-theme', async () => { await host.setTheme((rec.themes.find(esOscuro) || rec.themes[0]).themeId); pinta('undo-theme'); pintaInstaladas(); });
732741 boton(fila, tx('bPickTheme'), 'pick-theme', () => openThemePicker(host));
733742 if (enfoca) (fila.querySelector(`[data-act="${enfoca}"]`) || fila.querySelector('button'))?.focus();
734743 };
modified web/js/main.js +8 −0
@@ -2192,6 +2192,14 @@
21922192 // desde que se abre (antes aria-valuenow no existía hasta el primer arrastre, y
21932193 // aria-valuemax nunca). Lo pone en marcha el bloque del separador, más abajo.
21942194 let pintaSeparadorTerminal = () => {};
2195+// Altura real de la consola como variable CSS, para que el aviso vacío y la
2196+// vista previa de Markdown acaben encima de ella y no la tapen. Un
2197+// ResizeObserver la sigue al abrir, cerrar (display:none → 0) y arrastrar.
2198+{
2199+ const panel = $('terminal-panel'), wrap = $('editor-wrap');
2200+ if (panel && wrap && 'ResizeObserver' in window)
2201+ new ResizeObserver(() => wrap.style.setProperty('--term-h', panel.offsetHeight + 'px')).observe(panel);
2202+}
21952203 // La etiqueta del terminal sigue al bridge: antes solo se pintaba al abrir el
21962204 // panel y se quedaba vieja si el bridge conectaba o caía con él abierto.
21972205 function pintaCapacidades() {