Elffuss BraidHub

utopia-ia/elffuss-code public

Screen-reader names: Modes says Auto, editor tabs have their own name, the terminal splitter its value

- With Auto on (the default) the Modes button was announced as "Modos:
  ninguno activo" while its menu showed Auto checked. Its accessible name now
  lists every mode that is on, Auto or "revisar antes de escribir" first.
- Editor tabs had no aria-label, so a tab's name joined the file name with its
  nested close button ("app.js Cerrar app.js"). A tab is now named after its
  file, plus "(cambios sin guardar)" when dirty and the deleted-from-disk note
  when that applies; the close button keeps its own name.
- The terminal splitter (role=separator) had no aria-valuenow until the first
  drag and never an aria-valuemax. Both are set when the panel opens, on
  resize and as it is dragged or moved with the arrow keys.

tests/a11y-names.mjs checks the three: Modes with Auto on, off, and with Goal
added; the tab's name clean and then dirty after typing; the splitter's value
and maximum on open, and its value after ArrowUp.
Changesetd7571aecdc4a0ebc084ec38b8de849a1747bd3df4f62a040b2bf0143cde0c52f
AuthorKikoCis <kikocisneros@gmail.com> · 2026-10-11 15:10 +02:00
CommitterKikoCis <kikocisneros@gmail.com> · 2026-10-11 15:10 +02:00
Parentsb68cefab2bf2

Browse the files at this changeset

4 files changed

added tests/a11y-names.mjs +70 −0
@@ -0,0 +1,70 @@
1+// Nombres y valores que oye un lector de pantalla, en tres controles que los
2+// tenían mal:
3+// 1. «Modos» con Auto encendido (el de por defecto) decía «Modos: ninguno
4+// activo» mientras el menú lo enseñaba marcado.
5+// 2. Una pestaña del editor se llamaba «app.js Cerrar app.js»: sin nombre
6+// propio, el del botón × que lleva dentro se sumaba al suyo.
7+// 3. El separador del terminal no tenía aria-valuenow hasta el primer
8+// arrastre, ni aria-valuemax nunca.
9+//
10+// BASE=http://localhost:8799 node tests/a11y-names.mjs
11+import { chromium } from 'playwright';
12+const BASE = process.env.BASE || 'http://localhost:8799';
13+let fails = 0; const ok = (n, c, e = '') => { console.log((c ? '✅' : '❌') + ' ' + n + (e ? ' — ' + e : '')); if (!c) fails++; };
14+
15+const b = await chromium.launch();
16+const ctx = await b.newContext({ locale: 'es-ES' });
17+await ctx.addInitScript(() => { try { localStorage.setItem('elffusscode.model', 'rules'); localStorage.removeItem('elffusscode.autoedit'); } catch {} });
18+const p = await ctx.newPage({ viewport: { width: 1400, height: 900 } });
19+const errs = []; p.on('pageerror', e => errs.push(e.message.slice(0, 160)));
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('app.js', { create: true })).createWritable(); await w.write('export const a = 1;\n'); await w.close();
24+});
25+await p.goto(BASE + '/?test-opfs', { waitUntil: 'domcontentloaded' });
26+await p.waitForFunction(() => window.elffussClaw?.conv?.getActive?.(), null, { timeout: 20000 });
27+
28+// 1 · Modos
29+const nombreModos = () => p.evaluate(() => document.getElementById('btn-modos').getAttribute('aria-label'));
30+const conAuto = await nombreModos();
31+ok('1 · con Auto encendido, «Modos» lo dice (no «ninguno activo»)', /Auto/.test(conAuto) && !/ninguno/.test(conAuto), conAuto);
32+await p.click('#btn-modos'); await p.click('#btn-autoedit');
33+const conRevisar = await nombreModos();
34+ok('1 · con Auto apagado dice «revisar antes de escribir»', /revisar antes de escribir/.test(conRevisar) && !/Auto/.test(conRevisar), conRevisar);
35+await p.click('#btn-goal');
36+const conObjetivo = await nombreModos();
37+ok('1 · y suma los demás modos encendidos', /revisar antes de escribir/.test(conObjetivo) && /objetivo/.test(conObjetivo), conObjetivo);
38+await p.click('#btn-goal'); await p.click('#btn-autoedit'); await p.keyboard.press('Escape');
39+
40+// 2 · pestaña del editor
41+await p.locator('#tree .file', { hasText: 'app.js' }).first().click();
42+await p.waitForSelector('#tabs-bar .tab.active');
43+const pestana = () => p.evaluate(() => { const t = document.querySelector('#tabs-bar .tab.active'); return { nombre: t.getAttribute('aria-label'), x: t.querySelector('.tab-x')?.getAttribute('aria-label') }; });
44+const limpia = await pestana();
45+ok('2 · la pestaña se llama como el fichero, sin el «Cerrar…» del ×', limpia.nombre === 'app.js', JSON.stringify(limpia));
46+ok('2 · …y el × conserva su propio nombre', limpia.x === 'Cerrar app.js', JSON.stringify(limpia));
47+// una edición de verdad en el editor (como teclear)
48+await p.evaluate(() => window.monaco.editor.getEditors()[0]?.trigger('teclado', 'type', { text: '// cambio\n' }));
49+await p.waitForTimeout(300);
50+const sucia = await pestana();
51+ok('2 · con cambios sin guardar, el nombre lo dice', sucia.nombre === 'app.js (cambios sin guardar)', JSON.stringify(sucia));
52+
53+// 3 · separador del terminal
54+await p.keyboard.press('Control+`');
55+await p.waitForFunction(() => !document.getElementById('terminal-panel').hidden, null, { timeout: 5000 }).catch(() => {});
56+await p.waitForTimeout(300);
57+const sep = await p.evaluate(() => { const h = document.getElementById('term-resize'); const panel = document.getElementById('terminal-panel');
58+ return { now: h.getAttribute('aria-valuenow'), min: h.getAttribute('aria-valuemin'), max: h.getAttribute('aria-valuemax'), alto: panel.offsetHeight, ventana: innerHeight }; });
59+ok('3 · el separador dice su altura al abrir (sin arrastrarlo antes)', sep.now !== null && +sep.now === sep.alto, JSON.stringify(sep));
60+ok('3 · …y su máximo', sep.max !== null && +sep.max === Math.max(120, sep.ventana - 160) && +sep.max >= +sep.now && +sep.min <= +sep.now, JSON.stringify(sep));
61+await p.focus('#term-resize');
62+await p.keyboard.press('ArrowUp');
63+const tras = await p.evaluate(() => ({ now: +document.getElementById('term-resize').getAttribute('aria-valuenow'), alto: document.getElementById('terminal-panel').offsetHeight }));
64+ok('3 · con ↑ crece y el valor lo sigue', tras.now === tras.alto && tras.now > +sep.now, JSON.stringify(tras));
65+
66+console.log('\n errores JS:', errs[0] || 'ninguno');
67+ok('sin errores de página', errs.length === 0, errs.join(' | '));
68+console.log(fails ? `\n❌ ${fails} FALLO(S)` : '\n✅ NOMBRES ACCESIBLES OK — Modos, pestañas y separador');
69+await b.close();
70+process.exit(fails ? 1 : 0);
modified web/js/i18n.js +6 −6
@@ -140,7 +140,7 @@
140140 openFailed: "No pude abrir {path}: {e}",
141141 dirtyTitle: "¿Guardar los cambios de «{name}»?", dirtyBody: "Si no los guardas, se pierden.",
142142 dirtySave: "Guardar", dirtyDiscard: "No guardar", dirtyCancel: "Cancelar",
143- editorTabs: "Ficheros abiertos", closeFile: "Cerrar {name}", closeFileDirty: "Cerrar {name} (cambios sin guardar)",
143+ editorTabs: "Ficheros abiertos", closeFile: "Cerrar {name}", closeFileDirty: "Cerrar {name} (cambios sin guardar)", tabUnsaved: "(cambios sin guardar)",
144144 fileDeletedDirty: "borrado del disco; guárdalo para recrearlo",
145145 tmClose: "Cerrar", tmCloseOthers: "Cerrar otras", tmCloseRight: "Cerrar las de la derecha", tmCloseAll: "Cerrar todas",
146146 tmCopyPath: "Copiar ruta", tmViewSource: "Ver código fuente", tmPreview: "Vista previa",
@@ -200,8 +200,8 @@
200200 // teclado, menús y pestañas
201201 menubarLabel: "Menú", menu_file: "Archivo", menu_edit: "Editar", menu_view: "Ver", menu_git: "Git",
202202 gNoRemote: "sin remoto",
203- modesLabel: "Modos de trabajo", modesBtn: "Modos", modesNone: "ninguno activo",
204- modeReview: "revisar antes de escribir", modeGoal: "objetivo", modeHard: "Hard Work",
203+ modesLabel: "Modos de trabajo", modesBtn: "Modos",
204+ modeReview: "revisar antes de escribir", modeAuto: "Auto, escribe sin preguntar", modeGoal: "objetivo", modeHard: "Hard Work",
205205 goalPlaceholder: "🎯 Describe el objetivo: lo descompongo en tareas y las hago una a una…",
206206 convTabs: "Conversaciones abiertas", convBusy: "trabajando", tabCloseNamed: "Cerrar la pestaña «{title}» (no borra la conversación)",
207207 convRename: "Renombrar…", convRenamePrompt: "Nombre de la conversación (vacío = el automático):",
@@ -369,7 +369,7 @@
369369 openFailed: "Couldn't open {path}: {e}",
370370 dirtyTitle: "Save the changes to “{name}”?", dirtyBody: "If you don't save them, they are lost.",
371371 dirtySave: "Save", dirtyDiscard: "Don't save", dirtyCancel: "Cancel",
372- editorTabs: "Open files", closeFile: "Close {name}", closeFileDirty: "Close {name} (unsaved changes)",
372+ editorTabs: "Open files", closeFile: "Close {name}", closeFileDirty: "Close {name} (unsaved changes)", tabUnsaved: "(unsaved changes)",
373373 fileDeletedDirty: "deleted from disk; save it to recreate it",
374374 tmClose: "Close", tmCloseOthers: "Close others", tmCloseRight: "Close to the right", tmCloseAll: "Close all",
375375 tmCopyPath: "Copy path", tmViewSource: "View source", tmPreview: "Preview",
@@ -429,8 +429,8 @@
429429 // keyboard, menus and tabs
430430 menubarLabel: "Menu", menu_file: "File", menu_edit: "Edit", menu_view: "View", menu_git: "Git",
431431 gNoRemote: "no remote",
432- modesLabel: "Work modes", modesBtn: "Modes", modesNone: "none on",
433- modeReview: "review before writing", modeGoal: "goal", modeHard: "Hard Work",
432+ modesLabel: "Work modes", modesBtn: "Modes",
433+ modeReview: "review before writing", modeAuto: "Auto, writes without asking", modeGoal: "goal", modeHard: "Hard Work",
434434 goalPlaceholder: "🎯 Describe the goal: I'll break it into tasks and do them one by one…",
435435 convTabs: "Open conversations", convBusy: "working", tabCloseNamed: "Close the “{title}” tab (doesn't delete the conversation)",
436436 convRename: "Rename…", convRenamePrompt: "Conversation name (empty = automatic):",
modified web/js/ide.js +3 −0
@@ -361,6 +361,9 @@
361361 // <div> sin foco. La activa entra con Tab; ←/→ se mueven entre ellas.
362362 el.setAttribute('role', 'tab');
363363 el.setAttribute('aria-selected', on ? 'true' : 'false');
364+ // Nombre propio: sin él, el de la pestaña era el fichero MÁS el botón × que
365+ // lleva dentro («app.js Cerrar app.js»).
366+ el.setAttribute('aria-label', baseOf(tb.path) + (tb.dirty ? ' ' + t('tabUnsaved') : '') + (tb.deleted ? ' — ' + t('fileDeletedDirty') : ''));
364367 el.tabIndex = on ? 0 : -1;
365368 const ico = document.createElement('span');
366369 ico.className = 'tab-ico';
modified web/js/main.js +19 −2
@@ -1900,8 +1900,13 @@
19001900 pintaCapacidades();
19011901 await terminal.mount($('terminal-host'));
19021902 terminal.refit();
1903+ pintaSeparadorTerminal();
19031904 }
19041905 }
1906+// El separador que cambia la altura del terminal dice su valor y su rango
1907+// desde que se abre (antes aria-valuenow no existía hasta el primer arrastre, y
1908+// aria-valuemax nunca). Lo pone en marcha el bloque del separador, más abajo.
1909+let pintaSeparadorTerminal = () => {};
19051910 // La etiqueta del terminal sigue al bridge: antes solo se pintaba al abrir el
19061911 // panel y se quedaba vieja si el bridge conectaba o caía con él abierto.
19071912 function pintaCapacidades() {
@@ -1921,12 +1926,20 @@
19211926 const panel = $('terminal-panel'), handle = $('term-resize');
19221927 let sy = 0, sh = 0;
19231928 // También con el teclado: es un separador con foco, ↑/↓ cambian la altura.
1929+ const maxAlto = () => Math.max(120, window.innerHeight - 160);
19241930 const ajusta = h => {
1925- h = Math.max(120, Math.min(window.innerHeight - 160, h));
1931+ h = Math.max(120, Math.min(maxAlto(), h));
19261932 panel.style.height = h + 'px';
19271933 handle.setAttribute('aria-valuenow', String(Math.round(h)));
1934+ handle.setAttribute('aria-valuemax', String(maxAlto()));
19281935 terminal.refit();
19291936 };
1937+ pintaSeparadorTerminal = () => {
1938+ handle.setAttribute('aria-valuemax', String(maxAlto()));
1939+ if (!panel.hidden && panel.offsetHeight) handle.setAttribute('aria-valuenow', String(Math.round(panel.offsetHeight)));
1940+ };
1941+ pintaSeparadorTerminal();
1942+ window.addEventListener('resize', () => pintaSeparadorTerminal());
19301943 handle.setAttribute('role', 'separator');
19311944 handle.setAttribute('aria-orientation', 'horizontal');
19321945 handle.setAttribute('aria-label', t('termResizeLabel'));
@@ -2299,7 +2312,11 @@
22992312 if (goalMode) activos.push(['🎯', t('modeGoal')]);
23002313 if (hardMode) activos.push(['⛏', t('modeHard')]);
23012314 b.textContent = '⚙︎ ' + t('modesBtn') + (activos.length ? ' · ' + activos.map(a => a[0] === 'Revisar' ? t('reviewTxt') : a[0]).join(' ') : '') + ' ▾';
2302- b.setAttribute('aria-label', t('modesBtn') + (activos.length ? ': ' + activos.map(a => a[1]).join(', ') : ': ' + t('modesNone')));
2315+ // El nombre accesible dice TODOS los modos encendidos, también Auto, que es el
2316+ // de por defecto: con Auto encendido decía «Modos: ninguno activo» mientras el
2317+ // menú lo mostraba marcado.
2318+ const nombres = [autoEdit ? t('modeAuto') : t('modeReview'), ...activos.filter(a => a[0] !== 'Revisar').map(a => a[1])];
2319+ b.setAttribute('aria-label', t('modesBtn') + ': ' + nombres.join(', '));
23032320 b.classList.toggle('on', activos.length > 0);
23042321 $('btn-autoedit')?.setAttribute('aria-checked', autoEdit ? 'true' : 'false');
23052322 $('btn-goal')?.setAttribute('aria-checked', goalMode ? 'true' : 'false');