Elffuss BraidHub

utopia-ia/elffuss-claw public

Panel actions keep keyboard focus; Browse lists say what is installed

Many actions in the reworked panels dropped keyboard focus to <body>,
either by disabling the focused button or by re-rendering the panel
under it, so keyboard and screen-reader users had to start again from
the top after each one.

Buttons that go busy or are done (Browse while loading, Install, clear
model cache, feedback Send, wipe, the phone gate) are now marked with
aria-disabled and ignore clicks instead of being disabled, so focus
stays on them. After a re-render, focus moves to the same control of
the row that now takes the removed row's place, or of the previous row,
or to the section heading or the panel's input: Apps delete and Undo,
Tasks Run now, delete and automation remove, Permissions revoke and
remove folder, Vault delete, Memory forget and Undo, Skills remove, Undo
and repo remove, Free the model and the workspace buttons. Focus is only
moved when it was lost. The Tasks and Permissions panels now repaint one
at a time, so a concurrent repaint cannot drop the focused button again
(Permissions could also list folders twice).

An installed skill's button in a Browse list is now named "Installed ✓:
<name>" instead of "Install: <name>". Removing the skill turns the
button back into Install, Undo turns it back into Installed, and
reopening the list no longer shows a stale state.

The ux-paneles, ux-boveda, ux-skills, ux-ajustes and ux-modelos suites
drive these actions with the keyboard and check where focus lands, plus
the installed button's name and the list state after Remove and Undo.
On the previous code 14 of the new checks fail.
Changeset7a8506ddd5be2ca1d1e6fe5298f250f44de57ce7995f604a7db1b2e667d6dc9c
AuthorKikoCis <kikocisneros@gmail.com> · 2026-10-11 20:42 +02:00
CommitterKikoCis <kikocisneros@gmail.com> · 2026-10-11 20:42 +02:00
Parents7185ee918ff9

Browse the files at this changeset

7 files changed

modified tests/ux-ajustes.mjs +20 −4
@@ -6,6 +6,8 @@
66 // · El feedback dice si llegó: si falla, lo dice y el texto se queda.
77 // · «Acerca de» enlaza el código, la comunidad, las incidencias y la licencia;
88 // el sello del build enlaza su commit solo si es un commit limpio.
9+// · Con el teclado el foco no cae a <body>: «Enviar» lo conserva mientras
10+// envía, y olvidar un hecho (o deshacerlo) lo lleva al ✕ que toca.
911 //
1012 // BASE=http://localhost:8743 node tests/ux-ajustes.mjs
1113 import { navegador, contexto, pagina, ok, hasta, avisos, fin, BASE } from './ux-comun.mjs';
@@ -15,6 +17,10 @@
1517 extraInit: { 'elffuss.providers': JSON.stringify({ server: { enabled: true, baseURL: 'https://claw.elffuss.com/v1', model: 'ornith-9b', apiKey: '' } }) },
1618 });
1719 const { p, errores } = await pagina(ctx);
20+const foco = () => p.evaluate(() => {
21+ const a = document.activeElement;
22+ return !a || a === document.body ? 'BODY' : (a.getAttribute('aria-label') || a.textContent || a.id).trim().slice(0, 80);
23+});
1824 const abrirAjustes = async () => { await p.click('#tabs button[data-tab="ajustes"]'); await p.locator('#panel-ajustes .ext-block').waitFor(); };
1925 await abrirAjustes();
2026 await p.click('#panel-ajustes .ext-block > summary');
@@ -38,9 +44,11 @@
3844 await p.route('**/proxy/report', async route => { recibido = route.request().postDataJSON(); await route.fulfill({ status: estado, body: estado === 200 ? '{"ok":true}' : 'caído' }); });
3945 await abrirAjustes();
4046 await p.fill('#tel-feedback', 'el botón X no hace nada');
41-await p.click('#panel-ajustes button:has-text("Enviar")');
47+await p.locator('#panel-ajustes button:has-text("Enviar")').focus();
48+await p.keyboard.press('Enter');
4249 ok('si el envío falla, lo dice y el texto se queda', await hasta(async () => (await avisos(p)).some(t => /No ha llegado/.test(t)))
4350 && (await p.inputValue('#tel-feedback')) === 'el botón X no hace nada' && !(await avisos(p)).some(t => /gracias/.test(t)));
51+ok('…y con el teclado el foco sigue en «Enviar» (no cae a <body>)', (await foco()) === 'Enviar', await foco());
4452 ok('…y ofrece el sitio público de incidencias', await p.locator('#toasts .toast', { hasText: 'No ha llegado' }).locator('.toast-accion').innerText() === 'Abrir incidencias');
4553 estado = 200;
4654 await p.click('#panel-ajustes button:has-text("Enviar")');
@@ -67,17 +75,25 @@
6775 document.querySelector('#panel-ajustes [data-ruta="acerca"]')?.classList.contains('resaltado'))));
6876
6977 // ── memoria: se ve y se olvida hecho a hecho ────────────────────────────────
70-await p.evaluate(async () => (await import('/js/db.js')).set('memory', 'mprueba', { id: 'mprueba', fact: 'le gusta el té verde', at: Date.now() }));
78+await p.evaluate(async () => {
79+ const db = await import('/js/db.js');
80+ await db.set('memory', 'mprueba', { id: 'mprueba', fact: 'le gusta el té verde', at: Date.now() });
81+ await db.set('memory', 'mprueba2', { id: 'mprueba2', fact: 'vive en Madrid', at: Date.now() + 1 });
82+});
7183 await p.goto(BASE + '/#/memoria/mprueba', { waitUntil: 'domcontentloaded' });
7284 await p.waitForFunction(() => !!window.elffuss?.agent);
7385 const hecho = p.locator('#panel-ajustes [data-ruta="mprueba"]');
7486 ok('#/memoria/<id> abre Ajustes y señala ese hecho (sin el texto en la URL)', await hasta(async () =>
7587 await hecho.evaluate(e => e.classList.contains('resaltado')).catch(() => false)) && !/t%C3%A9|té/.test(await p.evaluate(() => location.href)));
76-await hecho.locator('button[aria-label="Olvidar «le gusta el té verde»"]').click();
88+await hecho.locator('button[aria-label="Olvidar «le gusta el té verde»"]').focus();
89+await p.keyboard.press('Enter');
7790 ok('✕ lo olvida…', await hasta(async () => await hecho.count() === 0)
7891 && !(await p.evaluate(async () => (await (await import('/js/db.js')).get('memory', 'mprueba')))));
79-await p.locator('#toasts .toast', { hasText: 'Olvidado' }).locator('.toast-accion').click();
92+ok('…con el teclado, el foco va al ✕ del hecho que queda en su sitio', await hasta(async () => (await foco()) === 'Olvidar «vive en Madrid»'), await foco());
93+await p.locator('#toasts .toast', { hasText: 'Olvidado' }).locator('.toast-accion').focus();
94+await p.keyboard.press('Enter');
8095 ok('…y «Deshacer» lo devuelve', await hasta(async () => await hecho.count() === 1));
96+ok('…con el foco en su ✕', await hasta(async () => (await foco()) === 'Olvidar «le gusta el té verde»'), await foco());
8197 ok('el lema de la cabecera sale en español', (await p.locator('.brand .claim').first().innerText()) === 'las apps no existen: se crean');
8298
8399 // ── el modo básico señala el selector de modelo, no el 🧠 ───────────────────
modified tests/ux-boveda.mjs +17 −2
@@ -4,7 +4,8 @@
44 // · 👁 enseña y vuelve a tapar (aria-pressed); el autobloqueo repinta el panel
55 // y tapa lo revelado; 🗑 pide confirmación con el nombre del secreto.
66 // · Un solo nombre por idioma: «Bóveda» en español.
7-// · «Bloquear ahora» con el teclado deja el foco en la contraseña.
7+// · «Bloquear ahora» con el teclado deja el foco en la contraseña; 🗑 con el
8+// teclado lo deja en el 🗑 del secreto que queda, o en el nombre de uno nuevo.
89 //
910 // BASE=http://localhost:8743 node tests/ux-boveda.mjs
1011 import { navegador, contexto, pagina, ok, hasta, espera, avisos, fin, OUT } from './ux-comun.mjs';
@@ -66,9 +67,23 @@
6667 await p.fill('#vault-master', 'clave-de-prueba-1');
6768 await p.press('#vault-master', 'Enter');
6869 await hasta(() => p.evaluate(() => !!document.getElementById('vault-name')));
70+// otro secreto detrás, para ver adónde va el foco al borrar el primero
71+await p.fill('#vault-name', 'banco2');
72+await p.fill('#panel-vault input[type=password]', 'pin-1234');
73+await p.press('#panel-vault input[type=password]', 'Enter');
74+await hasta(async () => (await p.locator('#panel-vault .card b').allTextContents()).includes('banco2'));
75+const foco = () => p.evaluate(() => {
76+ const a = document.activeElement;
77+ return !a || a === document.body ? 'BODY' : (a.getAttribute('aria-label') || a.textContent || a.id).trim().slice(0, 60);
78+});
6979 p.__aceptar = true;
70-await p.locator('#panel-vault .card', { hasText: 'correo' }).locator('button[aria-label^="Borrar"]').click();
80+await p.locator('#panel-vault .card', { hasText: 'correo' }).locator('button[aria-label^="Borrar"]').focus();
81+await p.keyboard.press('Enter');
7182 ok('y si dices que sí, se borra', await hasta(async () => !(await p.locator('#panel-vault .card b').allTextContents()).includes('correo')));
83+ok('…y con el teclado el foco va al 🗑 del secreto que queda (no a <body>)', await hasta(async () => (await foco()) === 'Borrar «banco2»'), await foco());
84+await p.keyboard.press('Enter');
85+ok('borrar el último deja el foco en el nombre de uno nuevo', await hasta(async () =>
86+ (await p.locator('#panel-vault .card b').count()) === 0 && (await foco()) === 'Nombre del secreto'), await foco());
7287
7388 // ── «Bloquear ahora» con el teclado: el foco va a la contraseña, no a <body> ─
7489 await p.locator('#panel-vault button', { hasText: 'Bloquear ahora' }).focus();
modified tests/ux-modelos.mjs +10 −5
@@ -79,14 +79,19 @@
7979 ok('Ajustes cuenta los pesos (no el origen entero)', await hasta(async () => /0\.01 GB en caché/.test(await card.innerText())), await card.innerText());
8080 const boton = card.locator('button', { hasText: 'Vaciar caché del modelo' });
8181 await p.evaluate(() => {
82- // ver el botón desactivado mientras trabaja
82+ // ver el botón ocupado mientras trabaja (aria-disabled: con disabled el foco
83+ // caía a <body> nada más pulsarlo)
8384 const b = [...document.querySelectorAll('#panel-ajustes button')].find(x => /Vaciar caché del modelo/.test(x.textContent));
8485 window.__visto = [];
85- new MutationObserver(() => window.__visto.push(b.disabled)).observe(b, { attributes: true, attributeFilter: ['disabled'] });
86+ new MutationObserver(() => window.__visto.push(b.getAttribute('aria-disabled'))).observe(b, { attributes: true, attributeFilter: ['aria-disabled'] });
8687 });
87-await boton.click();
88-ok('el botón se desactiva mientras vacía y dice cuánto liberó', await hasta(async () => (await avisos(p)).filter(t => /Liberados 6 MB/.test(t)).length >= 1)
89- && (await p.evaluate(() => window.__visto)).includes(true));
88+await boton.focus();
89+await p.keyboard.press('Enter');
90+ok('el botón queda ocupado mientras vacía y dice cuánto liberó', await hasta(async () => (await avisos(p)).filter(t => /Liberados 6 MB/.test(t)).length >= 1)
91+ && (await p.evaluate(() => window.__visto)).includes('true'));
92+ok('…y con el teclado el foco sigue en él al terminar (no cae a <body>)', await hasta(() => p.evaluate(() =>
93+ /Vaciar caché del modelo/.test(document.activeElement?.textContent || '') && !document.activeElement.hasAttribute('aria-disabled'))),
94+ await p.evaluate(() => document.activeElement?.textContent || document.activeElement?.tagName));
9095 ok('y después cuenta cero', await hasta(async () => /Nada cacheado todavía/.test(await card.innerText())));
9196
9297 ok('sin errores de página', errores.length === 0, errores.slice(0, 3).join(' | '));
modified tests/ux-paneles.mjs +37 −4
@@ -6,6 +6,9 @@
66 // · Automatizaciones de carpetas con su lista y ✕ (no tenían interfaz).
77 // · Quitar una carpeta pide confirmación, dice qué automatizaciones arrastra y
88 // dónde escribe la Mente.
9+// · Con el teclado, el foco no cae a <body> tras borrar, «Deshacer»,
10+// «Ejecutar ahora», revocar o quitar: va al mismo botón de la fila que queda
11+// en su sitio, al de lo devuelto, o al título de la sección.
912 //
1013 // BASE=http://localhost:8743 node tests/ux-paneles.mjs
1114 import { navegador, contexto, pagina, ok, hasta, espera, escribir, reposo, avisos, fin, BASE } from './ux-comun.mjs';
@@ -13,6 +16,11 @@
1316 const b = await navegador();
1417 const { ctx } = await contexto(b, { grants: ['apps', 'tasks', 'fs'] });
1518 const { p, errores } = await pagina(ctx);
19+const foco = () => p.evaluate(() => {
20+ const a = document.activeElement;
21+ return !a || a === document.body ? 'BODY' : (a.getAttribute('aria-label') || a.textContent || a.id || a.tagName).trim().slice(0, 80);
22+});
23+const conTeclado = async loc => { await loc.focus(); await p.keyboard.press('Enter'); };
1624
1725 // ── Apps ────────────────────────────────────────────────────────────────────
1826 await escribir(p, 'hazme un reloj');
@@ -22,14 +30,16 @@
2230 await p.click('#tabs button[data-tab="apps"]');
2331 const borrar = p.locator('#panel-apps button[aria-label="Borrar la app «reloj»"]');
2432 ok('🗑 se llama «Borrar la app «reloj»»', await borrar.count() === 1);
25-await borrar.click();
33+await conTeclado(borrar);
2634 ok('borrarla vacía el visor y el modelo ya no la cree abierta', await hasta(() => p.evaluate(async () =>
2735 document.getElementById('appframe').hidden && !document.getElementById('vista-empty').hidden
2836 && (await import('/js/tools/apps.js')).currentApp() === null)));
37+ok('…el foco no cae a <body>: va al título de Apps (no queda ninguna)', await hasta(async () => (await foco()) === 'Apps creadas'), await foco());
2938 const deshacer = p.locator('#toasts .toast', { hasText: 'eliminada' }).locator('.toast-accion');
3039 ok('…y ofrece «Deshacer»', await deshacer.count() === 1);
31-await deshacer.click();
40+await conTeclado(deshacer);
3241 ok('«Deshacer» la devuelve a la lista', await hasta(async () => await p.locator('#panel-apps .card', { hasText: 'reloj' }).count() === 1));
42+ok('…y el foco va a su 🗑', await hasta(async () => (await foco()) === 'Borrar la app «reloj»'), await foco());
3343
3444 // ── Tareas ──────────────────────────────────────────────────────────────────
3545 const id = await p.evaluate(async () => {
@@ -39,11 +49,19 @@
3949 await p.click('#tabs button[data-tab="tareas"]');
4050 const tarjeta = p.locator(`#panel-tareas [data-ruta="${id}"]`);
4151 ok('la tarea enseña su id (el que nombran los avisos)', (await tarjeta.locator('code').innerText()) === id);
42-await tarjeta.locator('button', { hasText: 'Ejecutar ahora' }).click();
52+await conTeclado(tarjeta.locator('button', { hasText: 'Ejecutar ahora' }));
4353 ok('«Ejecutar ahora» la manda al chat y la marca hecha', await hasta(async () =>
4454 /\[tarea programada\] estirar la espalda/.test(await p.locator('#log').innerText()) && /✅/.test(await tarjeta.innerText())));
4555 ok('…y deja de ofrecer «Ejecutar ahora»', await tarjeta.locator('button', { hasText: 'Ejecutar ahora' }).count() === 0);
56+ok('…con el foco en el 🗑 de esa tarea (no en <body>)', await hasta(async () => (await foco()) === 'Borrar la tarea «estirar la espalda»'), await foco());
4657 await reposo(p);
58+// 🗑 de una tarea: el foco va al 🗑 de la que queda en su sitio.
59+await p.evaluate(async () => (await import('/js/db.js')).set('tasks', 'tsigue1', { id: 'tsigue1', when: Date.now() + 3600e3, prompt: 'regar las plantas', done: false }));
60+await p.click('#tabs button[data-tab="apps"]');
61+await p.click('#tabs button[data-tab="tareas"]');
62+await conTeclado(tarjeta.locator('button[aria-label^="Borrar la tarea"]'));
63+ok('borrar una tarea con el teclado deja el foco en el 🗑 de la que queda en su sitio', await hasta(async () =>
64+ await tarjeta.count() === 0 && (await foco()) === 'Borrar la tarea «regar las plantas»'), await foco());
4765
4866 // una tarea que vence con el panel abierto
4967 await p.evaluate(async () => (await import('/js/db.js')).set('tasks', 'tvence1', { id: 'tvence1', when: Date.now() - 1000, prompt: 'beber agua', done: false }));
@@ -71,6 +89,13 @@
7189 await seccion.evaluate(e => e.classList.contains('resaltado')).catch(() => false)));
7290 ok('…que enseña «entrada → salida» con su ✕', /entrada → salida/.test(await seccion.innerText())
7391 && await seccion.locator('button[aria-label="Quitar la automatización entrada → salida"]').count() === 1);
92+await p.evaluate(async () => (await import('/js/tools/watch.js')).add({ from: 'salida', to: 'entrada' }));
93+await p.click('#tabs button[data-tab="apps"]');
94+await p.click('#tabs button[data-tab="tareas"]');
95+await conTeclado(seccion.locator('button[aria-label="Quitar la automatización salida → entrada"]'));
96+ok('quitar una automatización con el teclado deja el foco en el ✕ de la que queda', await hasta(async () =>
97+ await seccion.locator('button[aria-label="Quitar la automatización salida → entrada"]').count() === 0
98+ && (await foco()) === 'Quitar la automatización entrada → salida'), await foco());
7499
75100 await p.click('#tabs button[data-tab="permisos"]');
76101 ok('Permisos dice dónde escribe la Mente', await hasta(async () =>
@@ -83,10 +108,18 @@
83108 ok('quitar una carpeta pregunta y nombra las automatizaciones que arrastra', /«entrada»/.test(pregunta) && /entrada → salida/.test(pregunta), pregunta);
84109 ok('si dices que no, sigue ahí', await p.locator('#panel-permisos [data-ruta="entrada"]').count() === 1);
85110 p.__aceptar = true;
86-await p.locator('#panel-permisos button[aria-label="Quitar la carpeta «entrada»"]').click();
111+await conTeclado(p.locator('#panel-permisos button[aria-label="Quitar la carpeta «entrada»"]'));
87112 ok('si dices que sí, se quita con su automatización', await hasta(async () => await p.locator('#panel-permisos [data-ruta="entrada"]').count() === 0)
88113 && (await p.evaluate(async () => (await (await import('/js/tools/watch.js')).allWatches()).length)) === 0
89114 && (await avisos(p)).some(t => /automatización/.test(t)));
115+ok('…y el foco va al «Quitar» de la carpeta que queda (no a <body>)', await hasta(async () => (await foco()) === 'Quitar la carpeta «salida»'), await foco());
116+
117+// Revocar un permiso: el foco va al «Revocar» del que queda en su sitio.
118+const revocables = () => p.locator('#panel-permisos .card[data-permiso]').count();
119+const antes = await revocables();
120+await conTeclado(p.locator('#panel-permisos .card[data-permiso] button').first());
121+ok('revocar con el teclado deja el foco en el «Revocar» del permiso que queda en su sitio', await hasta(async () =>
122+ await revocables() === antes - 1 && (await foco()) === 'Revocar'), await foco());
90123
91124 ok('sin errores de página', errores.length === 0, errores.slice(0, 3).join(' | '));
92125 await fin(b, 'PANELES: apps con «Deshacer», tareas vivas, automatizaciones a la vista, carpetas que avisan');
modified tests/ux-skills.mjs +36 −5
@@ -7,6 +7,11 @@
77 // al momento y deja «Deshacer»; se puede ver lo que se le da al modelo.
88 // · «Añadir repo» lo enseña al momento, vacía el campo y se puede quitar (✕).
99 // · #/skills/<nombre> señala la skill y abre su texto.
10+// · Con el teclado el foco no cae a <body>: «Explorar» e «Instalar» lo
11+// conservan (ocupados con aria-disabled, no disabled), y tras «Quitar», ✕ o
12+// «Deshacer» va al botón de lo que queda en su sitio o de lo devuelto.
13+// · El botón de una skill instalada se llama «Instalada ✓: <nombre>», y al
14+// quitarla la lista abierta vuelve a ofrecer «Instalar» (y al deshacer, no).
1015 //
1116 // BASE=http://localhost:8743 node tests/ux-skills.mjs
1217 import { navegador, contexto, pagina, ok, hasta, avisos, fin, BASE } from './ux-comun.mjs';
@@ -30,15 +35,22 @@
3035 },
3136 });
3237 const { p, errores } = await pagina(ctx);
38+const foco = () => p.evaluate(() => {
39+ const a = document.activeElement;
40+ return !a || a === document.body ? 'BODY' : (a.getAttribute('aria-label') || a.textContent || a.id).trim().slice(0, 80);
41+});
42+const conTeclado = async loc => { await loc.focus(); await p.keyboard.press('Enter'); };
3343 await p.click('#tabs button[data-tab="skills"]');
3444 const contador = () => p.locator('#panel-skills .skills-instaladas > .muted').first().innerText();
3545 ok('empieza con «Instaladas: 0»', (await contador()) === 'Instaladas: 0');
3646
3747 const tarjeta = p.locator(`#panel-skills [data-ruta="repo:${REPO}"]`);
3848 const explorar = tarjeta.locator('button', { hasText: /Explorar|Ocultar/ });
39-await explorar.click();
49+await conTeclado(explorar);
4050 ok('«Explorar» abre la lista DENTRO de la tarjeta del repo', await hasta(async () =>
4151 /reloj-bonito/.test(await tarjeta.locator('.repo-skills').innerText()) && await explorar.getAttribute('aria-expanded') === 'true'));
52+ok('…y con el teclado el foco sigue en el botón cuando acaba de cargar', await hasta(async () =>
53+ (await foco()) === 'Ocultar' && await explorar.getAttribute('aria-busy') === null), await foco());
4254 const md = tarjeta.locator('.repo-skills a', { hasText: 'SKILL.md' }).first();
4355 ok('cada skill enlaza a su SKILL.md (pestaña nueva, sin referrer)', /github\.com\/KikoCis\/elffuss-claw-skills\/blob\/main\/skills\/(notas|reloj-bonito)\/SKILL\.md/.test(await md.getAttribute('href'))
4456 && await md.getAttribute('rel') === 'noopener noreferrer');
@@ -49,9 +61,17 @@
4961
5062 const tarjetaSkill = tarjeta.locator('.repo-skills .card', { hasText: 'reloj-bonito' });
5163 const instalar = tarjetaSkill.locator('button', { hasText: 'Instala' });
52-await instalar.click();
64+ok('antes de instalar, el botón se llama «Instalar: reloj-bonito»', await instalar.getAttribute('aria-label') === 'Instalar: reloj-bonito');
65+await conTeclado(instalar);
5366 ok('«Instalar» deja el botón desactivado en «Instalada ✓»', await hasta(async () =>
5467 (await instalar.innerText()) === 'Instalada ✓' && await instalar.isDisabled()));
68+ok('…su nombre accesible dice lo mismo («Instalada ✓: reloj-bonito»)', await instalar.getAttribute('aria-label') === 'Instalada ✓: reloj-bonito',
69+ await instalar.getAttribute('aria-label'));
70+ok('…y con el teclado el foco sigue en él (no cae a <body>)', (await foco()) === 'Instalada ✓: reloj-bonito', await foco());
71+await instalar.click({ force: true });
72+await p.waitForTimeout(150);
73+ok('…ya instalada, pulsarlo no hace nada', (await instalar.innerText()) === 'Instalada ✓'
74+ && (await p.evaluate(async () => (await (await import('/js/db.js')).get('kv', 'skills')) || [])).length === 1);
5575 ok('…el contador sube y la skill aparece en lo instalado', (await contador()) === 'Instaladas: 1'
5676 && await p.locator('#panel-skills .skills-instaladas [data-ruta="reloj-bonito"]').count() === 1);
5777 ok('…y el chat explica cómo usarla', /Skill «reloj-bonito» instalada/.test(await p.locator('#log').innerText()));
@@ -66,13 +86,22 @@
6686 await inst.locator('summary').click();
6787 ok('se puede ver lo que se le da al modelo', /Crea un reloj grande/.test(await inst.locator('.skill-text').innerText()));
6888
69-await inst.locator('button[aria-label="Quitar la skill «reloj-bonito»"]').click();
89+await conTeclado(inst.locator('button[aria-label="Quitar la skill «reloj-bonito»"]'));
7090 ok('«Quitar» la quita al momento y el contador baja', await hasta(async () =>
7191 await p.locator('#panel-skills .skills-instaladas [data-ruta="reloj-bonito"]').count() === 0 && (await contador()) === 'Instaladas: 0'));
7292 ok('…sin tocar las demás skills guardadas', (await p.evaluate(async () => (await (await import('/js/db.js')).get('kv', 'skills')) || [])).length === 0);
93+ok('…con el foco en el contador (no queda ninguna), no en <body>', (await foco()) === 'Instaladas: 0', await foco());
94+ok('…y la lista abierta vuelve a ofrecer «Instalar» (antes seguía «Instalada ✓» y desactivado)', await hasta(async () =>
95+ (await instalar.innerText()) === 'Instalar' && !(await instalar.isDisabled()) && await instalar.getAttribute('aria-label') === 'Instalar: reloj-bonito'),
96+ JSON.stringify({ texto: await instalar.innerText(), aria: await instalar.getAttribute('aria-label') }));
7397 const deshacer = p.locator('#toasts .toast', { hasText: 'quitada' }).locator('.toast-accion');
74-await deshacer.click();
98+await conTeclado(deshacer);
7599 ok('«Deshacer» la devuelve', await hasta(async () => await p.locator('#panel-skills .skills-instaladas [data-ruta="reloj-bonito"]').count() === 1));
100+ok('…con el foco en su «Quitar»', await hasta(async () => (await foco()) === 'Quitar la skill «reloj-bonito»'), await foco());
101+ok('…y la lista vuelve a decir «Instalada ✓»', (await instalar.innerText()) === 'Instalada ✓' && await instalar.isDisabled());
102+await explorar.click();
103+await explorar.click();
104+ok('cerrar y reabrir la lista no la deja vieja', (await instalar.innerText()) === 'Instalada ✓' && await instalar.isDisabled());
76105
77106 // ── añadir y quitar un repo ─────────────────────────────────────────────────
78107 await p.fill('#panel-skills form input', 'https://github.com/alguien/sus-skills');
@@ -80,8 +109,10 @@
80109 const nueva = p.locator('#panel-skills [data-ruta="repo:alguien/sus-skills"]');
81110 ok('«Añadir repo» lo enseña al momento y vacía el campo', await hasta(async () => await nueva.count() === 1)
82111 && (await p.inputValue('#panel-skills form input')) === '' && (await avisos(p)).some(t => /añadido/.test(t)));
83-await nueva.locator('button[aria-label="Quitar el repo alguien/sus-skills"]').click();
112+await conTeclado(nueva.locator('button[aria-label="Quitar el repo alguien/sus-skills"]'));
84113 ok('✕ quita un repo añadido', await hasta(async () => await nueva.count() === 0));
114+ok('…con el foco en el «Explorar» del repo que queda en su sitio (no en <body>)', await hasta(async () =>
115+ (await foco()) === 'Explorar' && await p.evaluate(() => !!document.activeElement.closest('#panel-skills .skills-fuentes .card'))), await foco());
85116 ok('los repos de serie no tienen ✕', await tarjeta.locator('button[aria-label^="Quitar el repo"]').count() === 0);
86117
87118 // ── dirección de una skill ──────────────────────────────────────────────────
modified web/css/elffuss.css +4 −0
@@ -370,6 +370,10 @@
370370 border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; cursor: pointer; font-size: .85rem;
371371 }
372372 button.ghost:hover { color: var(--fg); border-color: var(--accent); }
373+/* Ocupado o ya hecho (una skill instalada): aria-disabled en vez de disabled,
374+ para que el botón no pierda el foco (ver btn en ui.js). */
375+.panel button[aria-disabled="true"], .mobile-gate button[aria-disabled="true"] { opacity: .6; cursor: default; }
376+.panel button[aria-busy="true"], .mobile-gate button[aria-busy="true"] { cursor: progress; }
373377 h3 { margin: 6px 0 12px; font-size: .95rem; }
374378
375379 /* ---------- modal de permisos ---------- */
modified web/js/ui.js +224 −53
@@ -487,11 +487,39 @@
487487 if (text != null) e.textContent = text;
488488 return e;
489489 };
490+// Un botón ocupado (o ya hecho, como una skill instalada) se marca con
491+// aria-disabled y NO con disabled: desactivar el botón que tiene el foco lo saca
492+// del foco y el teclado cae a <body> (lo mismo que hace ■, ver setStopping).
493+// Mientras está marcado, su clic no hace nada.
490494 const btn = (label, cls, onClick) => {
491495 const b = el('button', cls, label);
492- b.onclick = onClick;
496+ b.onclick = e => { if (b.getAttribute('aria-disabled') === 'true') { e.preventDefault(); return; } return onClick(e); };
493497 return b;
494498 };
499+function ocupado(b, on, { hecho = false } = {}) {
500+ if (!b) return;
501+ if (on) b.setAttribute('aria-disabled', 'true'); else b.removeAttribute('aria-disabled');
502+ if (on && !hecho) b.setAttribute('aria-busy', 'true'); else b.removeAttribute('aria-busy');
503+}
504+// Tras repintar una lista, el foco va al mismo control de la fila que ocupa
505+// ahora el sitio de la que se fue (la siguiente), o de la anterior si era la
506+// última; sin filas, a `respaldo` (el título de la sección, un campo…). Antes
507+// caía a <body> y quien usa el teclado o un lector de pantalla volvía a empezar
508+// desde arriba tras cada acción. Solo si el foco se perdió: si ya está en otra
509+// parte (otro panel, el chat), no se toca; y solo si el destino está a la vista.
510+const focoPerdido = () => !document.activeElement || document.activeElement === document.body;
511+function enfocar(destino) {
512+ if (!destino?.isConnected || !destino.getClientRects().length) return false;
513+ if (!destino.matches('button, a[href], input, select, textarea, summary') && !destino.hasAttribute('tabindex')) destino.tabIndex = -1;
514+ try { destino.focus(); } catch { return false; }
515+ return document.activeElement === destino;
516+}
517+function enfocarFila(filas, i, selector, respaldo) {
518+ if (!focoPerdido()) return;
519+ const lista = [...filas];
520+ const fila = lista.length ? lista[Math.max(0, Math.min(i, lista.length - 1))] : null;
521+ if (!enfocar(fila && (selector ? fila.querySelector(selector) : fila))) enfocar(respaldo);
522+}
495523
496524 // ---------- panel apps ----------
497525 export async function refreshApps() {
@@ -503,26 +531,37 @@
503531 return;
504532 }
505533 for (const app of list) {
506- panel.appendChild(card(
534+ const c = card(
507535 el('b', null, app.name),
508536 el('span', 'muted', new Date(app.created).toLocaleString(uiLang())),
509537 // Por apps.open(): así la app abierta es ESTA también para el modelo
510538 // (CONTEXTO AHORA), no solo en pantalla.
511539 btn(tr('open'), 'primary', () => { aperturaManualT = Date.now(); apps.open({ name: app.name }).catch(e => toast('⚠️ ' + e.message)); }),
512540 botonBorrarApp(app),
513- ));
541+ );
542+ c.dataset.app = app.name;
543+ panel.appendChild(c);
514544 }
515545 }
516546 // 🗑 con nombre propio y «Deshacer» (borraba al instante, sin vuelta atrás). Si
517-// era la app abierta, el visor se vacía (ver apps.setOnRemoved en init).
547+// era la app abierta, el visor se vacía (ver apps.setOnRemoved en init). El foco
548+// va al 🗑 de la app que queda en su sitio y, tras «Deshacer», al de la devuelta.
518549 function botonBorrarApp(app) {
519550 const b = btn('🗑', 'ghost', async () => {
551+ const panel = $('panel-apps');
552+ const i = [...panel.querySelectorAll('.card[data-app]')].indexOf(b.closest('.card'));
520553 await apps.removeApp({ name: app.name });
521- refreshApps();
554+ await refreshApps();
555+ enfocarFila(panel.querySelectorAll('.card[data-app]'), i, '.borrar-app', panel.querySelector('h3'));
522556 toast(tr('appRemoved', { name: app.name }), { accion: { label: tr('undo'), run: async () => {
523- try { await apps.restoreApp(app); refreshApps(); } catch (e) { toast('⚠️ ' + e.message); }
557+ try {
558+ await apps.restoreApp(app);
559+ await refreshApps();
560+ enfocarFila(panel.querySelectorAll(`.card[data-app="${CSS.escape(app.name)}"]`), 0, '.borrar-app');
561+ } catch (e) { toast('⚠️ ' + e.message); }
524562 } } });
525563 });
564+ b.classList.add('borrar-app');
526565 b.title = tr('appDelL', { name: app.name });
527566 b.setAttribute('aria-label', tr('appDelL', { name: app.name }));
528567 return b;
@@ -538,7 +577,36 @@
538577 }
539578
540579 // ---------- panel tareas ----------
541-export async function refreshTasks() {
580+// Un repintado a la vez: «Ejecutar ahora» repinta, y la tarea que lanza también
581+// (tareasCambiaron). Dos a la vez se pisaban, y el último en llegar tiraba los
582+// botones en los que ya se había puesto el foco. Quien llama mientras uno está
583+// en marcha espera a ese, que repinta otra vez al terminar.
584+let tareasPintando = null, tareasOtraVez = false;
585+export function refreshTasks() {
586+ if (tareasPintando) { tareasOtraVez = true; return tareasPintando; }
587+ tareasPintando = (async () => {
588+ do { tareasOtraVez = false; await pintarTareas(); } while (tareasOtraVez);
589+ })().finally(() => { tareasPintando = null; });
590+ return tareasPintando;
591+}
592+// Tras quitar una tarea o una automatización, el foco va al mismo botón de la
593+// fila que queda en su sitio; tras «Ejecutar ahora», al 🗑 de esa tarea (ya no
594+// tiene «Ejecutar ahora»). Dónde estaba la fila se mira AL PULSAR, antes de
595+// esperar nada: si otro repintado llega entretanto, la fila ya no está.
596+function posicionEnTareas(boton) {
597+ const fila = boton.closest('[data-ruta]');
598+ const auto = !!fila?.closest('.automatizaciones');
599+ const grupo = auto ? '.automatizaciones .card[data-ruta]' : '.card[data-tarea]';
600+ return { auto, grupo, i: [...$('panel-tareas').querySelectorAll(grupo)].indexOf(fila), ruta: fila?.dataset.ruta };
601+}
602+async function repintarTareasYEnfocar({ auto, grupo, i, ruta }, { misma = false } = {}) {
603+ const panel = $('panel-tareas');
604+ await refreshTasks();
605+ const titulo = panel.querySelector(auto ? '.automatizaciones h3' : 'h3');
606+ if (misma) enfocarFila(panel.querySelectorAll(`.card[data-ruta="${CSS.escape(ruta || '')}"]`), 0, '.borrar-tarea', titulo);
607+ else enfocarFila(panel.querySelectorAll(grupo), i, auto ? '.quitar-auto' : '.borrar-tarea', titulo);
608+}
609+async function pintarTareas() {
542610 const [list, watches] = await Promise.all([
543611 db.all('tasks').then(l => l.sort((a, b) => a.when - b.when)),
544612 watch.allWatches().catch(() => []),
@@ -555,20 +623,28 @@
555623 const fila = [estado, el('b', null, t.prompt), el('span', 'muted', new Date(t.when).toLocaleString(uiLang())), id];
556624 if (!t.done) {
557625 const ya = btn(tr('taskRunNow'), 'ghost', async () => {
558- ya.disabled = true;
626+ const pos = posicionEnTareas(ya);
627+ ocupado(ya, true);
559628 const hecha = await tasks.marcarHecha(t.id);
560629 if (hecha) onRunTaskCb(hecha);
561- refreshTasks();
630+ await repintarTareasYEnfocar(pos, { misma: true });
562631 });
563632 ya.setAttribute('aria-label', tr('taskRunNowL', { prompt: t.prompt }));
564633 fila.push(ya);
565634 }
566- const borrar = btn('🗑', 'ghost', async () => { await tasks.removeTask({ id: t.id }); toast(tr('taskDeleted', { id: t.id })); refreshTasks(); });
635+ const borrar = btn('🗑', 'ghost', async () => {
636+ const pos = posicionEnTareas(borrar);
637+ await tasks.removeTask({ id: t.id });
638+ toast(tr('taskDeleted', { id: t.id }));
639+ await repintarTareasYEnfocar(pos);
640+ });
641+ borrar.className = 'ghost borrar-tarea';
567642 borrar.title = tr('taskDelL', { prompt: t.prompt });
568643 borrar.setAttribute('aria-label', tr('taskDelL', { prompt: t.prompt }));
569644 fila.push(borrar);
570645 const c = card(...fila);
571646 c.dataset.ruta = t.id; // #/tareas/<id>
647+ c.dataset.tarea = '1';
572648 panel.appendChild(c);
573649 }
574650 // Automatizaciones de carpetas (fs.watch): antes no tenían interfaz; solo se
@@ -578,7 +654,13 @@
578654 sec.appendChild(el('h3', null, tr('watchTitle')));
579655 if (!watches.length) sec.appendChild(el('p', 'muted', tr('watchEmpty')));
580656 for (const w of watches) {
581- const x = btn('✕', 'ghost', async () => { await watch.removeWatch({ id: w.id }); toast(tr('watchRemoved', { id: w.id })); refreshTasks(); });
657+ const x = btn('✕', 'ghost', async () => {
658+ const pos = posicionEnTareas(x);
659+ await watch.removeWatch({ id: w.id });
660+ toast(tr('watchRemoved', { id: w.id }));
661+ await repintarTareasYEnfocar(pos);
662+ });
663+ x.className = 'ghost quitar-auto';
582664 x.title = tr('watchDelL', { from: w.from, to: w.to });
583665 x.setAttribute('aria-label', x.title);
584666 const c = card(el('span', null, '👁'), el('b', null, `${w.from} → ${w.to}`),
@@ -704,32 +786,60 @@
704786 ver.setAttribute('aria-pressed', 'false');
705787 ver.title = tr('vaultShow', { name: n });
706788 ver.setAttribute('aria-label', tr('vaultShowL', { name: n }));
789+ // Tras borrar, el foco va al 🗑 del secreto que queda en su sitio o, si no
790+ // queda ninguno, al nombre de uno nuevo.
707791 const borrar = btn('🗑', 'ghost', async () => {
708792 if (!window.confirm(tr('vaultDelConfirm', { name: n }))) return;
793+ const i = [...panel.querySelectorAll('.card[data-secreto]')].indexOf(borrar.closest('.card'));
709794 try { await vault.removeSecret({ name: n }); toast(tr('vaultDeleted', { name: n })); }
710795 catch (err) { toast('⚠️ ' + err.message); }
711- refreshVault();
796+ await refreshVault();
797+ enfocarFila(panel.querySelectorAll('.card[data-secreto]'), i, '.borrar-secreto', panel.querySelector('#vault-name, #vault-master'));
712798 });
799+ borrar.className = 'ghost borrar-secreto';
713800 borrar.title = tr('vaultDel', { name: n });
714801 borrar.setAttribute('aria-label', tr('vaultDel', { name: n }));
715- panel.appendChild(card(el('b', null, n), val, ver, borrar));
802+ const c = card(el('b', null, n), val, ver, borrar);
803+ c.dataset.secreto = n;
804+ panel.appendChild(c);
716805 }
717806 }
718807
719808 // ---------- panel permisos ----------
720-export async function refreshPerms() {
809+// Un repintado a la vez, como en Tareas: el panel se pinta en dos tiempos (los
810+// permisos, y tras leer las carpetas, las carpetas), y dos a la vez —revocar
811+// mientras se cierra un diálogo de permiso— duplicaban las carpetas.
812+let permisosPintando = null, permisosOtraVez = false;
813+export function refreshPerms() {
814+ if (permisosPintando) { permisosOtraVez = true; return permisosPintando; }
815+ permisosPintando = (async () => {
816+ do { permisosOtraVez = false; await pintarPermisos(); } while (permisosOtraVez);
817+ })().finally(() => { permisosPintando = null; });
818+ return permisosPintando;
819+}
820+async function pintarPermisos() {
721821 const panel = $('panel-permisos');
722822 panel.replaceChildren(el('h3', null, tr('permsTitle')));
723823 const g = perms.grants();
724824 if (!g.length)
725825 panel.appendChild(el('p', 'muted', tr('permsEmpty')));
826+ // Tras revocar (o quitar una carpeta), el foco va al mismo botón de la fila
827+ // que queda en su sitio, o al título si ya no queda ninguna.
726828 for (const scope of g) {
727829 const meta = perms.SCOPES[scope] || {};
728- panel.appendChild(card(
830+ const revocar = btn(tr('revoke'), 'ghost', async () => {
831+ const i = [...panel.querySelectorAll('.card[data-permiso]')].indexOf(revocar.closest('.card'));
832+ perms.revoke(scope);
833+ await refreshPerms();
834+ enfocarFila(panel.querySelectorAll('.card[data-permiso]'), i, 'button', panel.querySelector('h3'));
835+ });
836+ const c = card(
729837 el('b', null, `${meta.icon || ''} ${meta.label || scope}`),
730838 el('span', 'muted', meta.desc || ''),
731- btn(tr('revoke'), 'ghost', () => { perms.revoke(scope); refreshPerms(); }),
732- ));
839+ revocar,
840+ );
841+ c.dataset.permiso = scope;
842+ panel.appendChild(c);
733843 }
734844 const folders = await fs.folders();
735845 if (folders.length) {
@@ -737,10 +847,16 @@
737847 // Dónde escribe la Mente: en la primera carpeta (ceo-adapter.js).
738848 panel.appendChild(el('p', 'muted', tr('folderSoulNote', { name: folders[0] })));
739849 for (const f of folders) {
740- const quitar = btn(tr('remove'), 'ghost', () => quitarCarpeta(f, folders));
850+ const quitar = btn(tr('remove'), 'ghost', async () => {
851+ const i = [...panel.querySelectorAll('.card[data-carpeta]')].indexOf(quitar.closest('.card'));
852+ if (!(await quitarCarpeta(f, folders))) return;
853+ enfocarFila(panel.querySelectorAll('.card[data-carpeta]'), i, 'button',
854+ panel.querySelector('.card[data-permiso] button') || panel.querySelector('h3'));
855+ });
741856 quitar.setAttribute('aria-label', tr('folderRemoveL', { name: f }));
742857 const c = card(el('b', null, '📁 ' + f), quitar);
743858 c.dataset.ruta = f; // #/permisos/<carpeta>
859+ c.dataset.carpeta = '1';
744860 panel.appendChild(c);
745861 }
746862 }
@@ -753,11 +869,12 @@
753869 let txt = tr('folderRemoveConfirm', { name: f });
754870 if (dependientes.length) txt += '\n\n' + tr('folderRemoveWatches', { list: dependientes.map(w => `${w.from} → ${w.to}`).join(', ') });
755871 if (folders[0] === f) txt += '\n\n' + (folders[1] ? tr('folderRemoveSoulNext', { next: folders[1] }) : tr('folderRemoveSoulNone'));
756- if (!window.confirm(txt)) return;
872+ if (!window.confirm(txt)) return false;
757873 for (const w of dependientes) await watch.removeWatch({ id: w.id }).catch(() => {});
758874 await db.del('fs', f);
759875 toast(tr('folderRemoved', { name: f }) + (dependientes.length ? ' · ' + tr('folderRemovedWatches', { n: dependientes.length }) : ''));
760- refreshPerms();
876+ await refreshPerms();
877+ return true;
761878 }
762879
763880 // ---------- progreso y estado del modelo ----------
@@ -975,7 +1092,11 @@
9751092 a.setAttribute('aria-label', a.title);
9761093 vBrain.appendChild(a);
9771094 }
978- freeBtn.style.display = (sel && sel.value !== 'rules') ? '' : 'none';
1095+ // Sin modelo cargado el botón se esconde; si tenía el foco (acaba de
1096+ // pulsarse), el foco pasa al título de la tarjeta y no cae a <body>.
1097+ const sinModelo = !(sel && sel.value !== 'rules');
1098+ if (sinModelo && document.activeElement === freeBtn) enfocar(card.querySelector(':scope > b'));
1099+ freeBtn.style.display = sinModelo ? 'none' : '';
9791100 // refrescar solo mientras se está viendo
9801101 clearTimeout(timer);
9811102 if (document.querySelector('#tabs button.active')?.dataset.tab === 'ajustes') timer = setTimeout(paint, 4000);
@@ -1001,6 +1122,9 @@
10011122 const inv = el('div', 'col');
10021123 card.append(state, row, inv);
10031124
1125+ // Repintar tira los botones de la fila: si el foco estaba en uno, va al primero
1126+ // de la fila nueva («Guardar ahora», «Elegir carpeta»…), no a <body>.
1127+ const repintar = async () => { await paint(); if (focoPerdido()) enfocar(row.querySelector('button')); };
10041128 const paint = async () => {
10051129 const st = workspace.status();
10061130 row.replaceChildren();
@@ -1011,22 +1135,22 @@
10111135
10121136 if (st.supported.pick) {
10131137 if (!st.folder) row.appendChild(btn(tr('wsPick'), 'primary', async () => {
1014- try { await workspace.pick(); toast(tr('wsPicked')); await paint(); } catch (e) { toast('⚠️ ' + e.message); }
1138+ try { await workspace.pick(); toast(tr('wsPicked')); await repintar(); } catch (e) { toast('⚠️ ' + e.message); }
10151139 }));
10161140 else if (!st.ready) row.appendChild(btn(tr('wsRegrant'), 'primary', async () => {
1017- try { await workspace.regrant(); toast(tr('wsPicked')); await paint(); } catch (e) { toast('⚠️ ' + e.message); }
1141+ try { await workspace.regrant(); toast(tr('wsPicked')); await repintar(); } catch (e) { toast('⚠️ ' + e.message); }
10181142 }));
10191143 else {
10201144 row.appendChild(btn(tr('wsSaveNow'), 'primary', async () => {
1021- try { const r = await workspace.save({ reason: 'manual' }); toast(r.ok ? tr('wsSaved', { n: r.wrote.length }) : '⚠️ ' + (r.errors[0]?.error || '')); await paint(); }
1022- catch (e) { toast('⚠️ ' + (e.message === 'needs-regrant' ? tr('wsNeedsPerm', { name: st.folder }) : e.message)); await paint(); }
1145+ try { const r = await workspace.save({ reason: 'manual' }); toast(r.ok ? tr('wsSaved', { n: r.wrote.length }) : '⚠️ ' + (r.errors[0]?.error || '')); await repintar(); }
1146+ catch (e) { toast('⚠️ ' + (e.message === 'needs-regrant' ? tr('wsNeedsPerm', { name: st.folder }) : e.message)); await repintar(); }
10231147 }));
10241148 const auto = el('label', 'row');
10251149 const chk = el('input'); chk.type = 'checkbox'; chk.checked = workspace.autosaveEnabled();
10261150 chk.onchange = () => { workspace.autosave({ enabled: chk.checked }); toast(chk.checked ? tr('wsAutoOn') : tr('wsAutoOff')); };
10271151 auto.append(chk, el('span', 'muted', tr('wsAuto')));
10281152 row.appendChild(auto);
1029- row.appendChild(btn(tr('wsForget'), 'ghost', async () => { await workspace.forget(); await paint(); }));
1153+ row.appendChild(btn(tr('wsForget'), 'ghost', async () => { await workspace.forget(); await repintar(); }));
10301154 }
10311155 }
10321156 // copia descargable: funciona en TODOS los navegadores (Safari/Firefox incluidos)
@@ -1050,13 +1174,13 @@
10501174 const danger = el('div', 'row');
10511175 const wipe = btn(tr('wsWipe'), 'ghost', async () => {
10521176 if (!window.confirm(tr('wsWipeConfirm'))) return;
1053- wipe.disabled = true;
1177+ ocupado(wipe, true); // aria-disabled: sin perder el foco (ver btn)
10541178 // Lo hace el kernel: para el turno en marcha, borra y RECARGA. Borrar solo
10551179 // el IndexedDB dejaba la conversación en pantalla y en memoria, y el
10561180 // siguiente mensaje la volvía a guardar entera; skills, bóveda abierta y
10571181 // app actual también seguían vivas hasta recargar.
10581182 try { await onWipeCb(); }
1059- catch (e) { wipe.disabled = false; toast('⚠️ ' + (e?.message || e)); }
1183+ catch (e) { ocupado(wipe, false); toast('⚠️ ' + (e?.message || e)); }
10601184 });
10611185 danger.appendChild(wipe);
10621186 inv.appendChild(danger);
@@ -1141,14 +1265,14 @@
11411265 // Lo mismo que el chip 💾 (model-storage.js): cuenta solo pesos, y vacía los de
11421266 // este origen y los del almacén compartido de CADA broker con modelos (antes
11431267 // el modelo grande, guardado en los brokers de sus hosts, no se tocaba).
1268+ // Ocupado con aria-disabled, no disabled: con disabled el foco caía a <body>
1269+ // nada más pulsarlo (ver btn).
11441270 const clearBtn = btn(tr('storeClear'), 'ghost', async () => {
1145- clearBtn.disabled = true;
1146- clearBtn.setAttribute('aria-busy', 'true');
1271+ ocupado(clearBtn, true);
11471272 info.textContent = tr('storeClearing');
11481273 try { avisarLiberado(await modelos.vaciar()); }
11491274 catch (e) { toast(tr('diskFail', { err: e?.message || e })); }
1150- clearBtn.disabled = false;
1151- clearBtn.removeAttribute('aria-busy');
1275+ ocupado(clearBtn, false);
11521276 await paintStore();
11531277 });
11541278 store.appendChild(clearBtn);
@@ -1182,14 +1306,14 @@
11821306 const ta = telCard.querySelector('#tel-feedback');
11831307 const text = ta.value.trim();
11841308 if (!text) { toast(tr('writeSomething')); ta.focus(); return; }
1185- telSendBtn.disabled = true;
1309+ ocupado(telSendBtn, true); // aria-disabled: el foco se queda en «Enviar»
11861310 const wasEnabled = telemetry.isEnabled();
11871311 if (!wasEnabled) telemetry.setEnabled(true); // envío manual es explícito, se permite aunque el automático esté apagado
11881312 let llego = false;
11891313 try { llego = await telemetry.sendFeedback(text); }
11901314 finally {
11911315 if (!wasEnabled) telemetry.setEnabled(false); // no activa el automático de fondo si no lo pidió
1192- telSendBtn.disabled = false;
1316+ ocupado(telSendBtn, false);
11931317 }
11941318 if (llego) { ta.value = ''; toast(tr('sentThanks')); }
11951319 else toast(tr('sendFailed'), { accion: { label: tr('openIssues'), run: () => window.open(ISSUES_URL, '_blank', 'noopener,noreferrer') } });
@@ -1216,6 +1340,8 @@
12161340 pintarMemoria(c);
12171341 return c;
12181342 }
1343+// Tras olvidar un hecho, el foco va al ✕ del que queda en su sitio (o al título
1344+// de la sección) y, tras «Deshacer», al del hecho devuelto.
12191345 async function pintarMemoria(c) {
12201346 const hechos = (await db.all('memory').catch(() => [])).sort((a, b) => a.at - b.at);
12211347 c.replaceChildren(el('b', null, tr('memTitle')), el('span', 'muted', tr('memDesc')));
@@ -1224,9 +1350,15 @@
12241350 const fila = el('div', 'row between');
12251351 fila.dataset.ruta = f.id; // #/memoria/<id>
12261352 const x = btn('✕', 'ghost', async () => {
1353+ const i = [...c.querySelectorAll('.row[data-ruta]')].indexOf(fila);
12271354 await memory.forget({ id: f.id });
1228- pintarMemoria(c);
1229- toast(tr('memForgotten'), { accion: { label: tr('undo'), run: async () => { await db.set('memory', f.id, f); pintarMemoria(c); } } });
1355+ await pintarMemoria(c);
1356+ enfocarFila(c.querySelectorAll('.row[data-ruta]'), i, 'button', c.querySelector(':scope > b'));
1357+ toast(tr('memForgotten'), { accion: { label: tr('undo'), run: async () => {
1358+ await db.set('memory', f.id, f);
1359+ await pintarMemoria(c);
1360+ enfocarFila(c.querySelectorAll(`.row[data-ruta="${CSS.escape(f.id)}"]`), 0, 'button');
1361+ } } });
12301362 });
12311363 x.title = tr('memForgetL', { fact: String(f.fact).slice(0, 60) });
12321364 x.setAttribute('aria-label', x.title);
@@ -1301,11 +1433,21 @@
13011433 const fila = el('div', 'row between');
13021434 const desdeRepo = s.repo && s.path && !String(s.path).startsWith('local/');
13031435 const origen = desdeRepo ? enlaceSkillMd(s.repo, s.path) : el('span', 'muted', s.repo || 'local');
1304- const quitar = btn(tr('remove'), 'ghost', async () => {
1436+ // Quitar: el foco va al «Quitar» de la skill que queda en su sitio (o al
1437+ // contador), y las listas de «Explorar» abiertas vuelven a ofrecer instalarla.
1438+ const quitar = btn(tr('remove'), 'ghost quitar-skill', async () => {
1439+ const i = [...box.querySelectorAll('.card[data-ruta]')].indexOf(c);
13051440 await skills.remove(s.name);
13061441 pintarInstaladas(box);
1442+ actualizarListas();
1443+ enfocarFila(box.querySelectorAll('.card[data-ruta]'), i, '.quitar-skill', box.firstElementChild);
13071444 toast(tr('skillRemoved', { name: s.name }), { accion: { label: tr('undo'), run: async () => {
1308- try { await skills.install(s); pintarInstaladas(box); } catch (e) { toast('⚠️ ' + e.message); }
1445+ try {
1446+ await skills.install(s);
1447+ pintarInstaladas(box);
1448+ actualizarListas();
1449+ enfocarFila(box.querySelectorAll(`.card[data-ruta="${CSS.escape(s.name)}"]`), 0, '.quitar-skill');
1450+ } catch (e) { toast('⚠️ ' + e.message); }
13091451 } } });
13101452 });
13111453 quitar.setAttribute('aria-label', tr('skillRemoveL', { name: s.name }));
@@ -1336,15 +1478,19 @@
13361478 lista.id = 'repo-' + src.repo.replace(/[^\w-]/g, '-');
13371479 lista.hidden = true;
13381480 lista.setAttribute('aria-live', 'polite');
1339- const explorar = btn(tr('browse'), 'primary', () => explorarRepo(src.repo, lista, explorar, instaladas));
1481+ const explorar = btn(tr('browse'), 'primary explorar-repo', () => explorarRepo(src.repo, lista, explorar, instaladas));
13401482 explorar.setAttribute('aria-expanded', 'false');
13411483 explorar.setAttribute('aria-controls', lista.id);
13421484 fila.append(el('b', null, src.label), link, explorar);
13431485 if (!src.official) { // las que añadiste tú se pueden quitar
1486+ // El foco va al «Explorar» del repo que queda en su sitio (o al campo
1487+ // para añadir otro).
13441488 const x = btn('✕', 'ghost', async () => {
1489+ const i = [...box.querySelectorAll('.card[data-ruta]')].indexOf(c);
13451490 await skills.removeSource(src.repo);
13461491 toast(tr('repoRemoved', { repo: src.repo }));
13471492 await pintarFuentes(box, instaladas);
1493+ enfocarFila(box.querySelectorAll('.card[data-ruta]'), i, '.explorar-repo', box.querySelector('form input'));
13481494 });
13491495 x.title = tr('repoRemoveL', { repo: src.repo });
13501496 x.setAttribute('aria-label', tr('repoRemoveL', { repo: src.repo }));
@@ -1372,7 +1518,29 @@
13721518 box.appendChild(form);
13731519 }
13741520
1521+// El botón de una skill en la lista de «Explorar»: «Instalar», o «Instalada ✓»
1522+// sin poder pulsarse. Su nombre accesible dice lo mismo que se ve (se quedaba en
1523+// «Instalar: <nombre>» ya instalada). aria-disabled y no disabled: el foco no
1524+// cae a <body> al instalar con el teclado (ver btn).
1525+function pintarBotonInstalar(b, instalada, nombre) {
1526+ b.textContent = instalada ? tr('installedOk') : tr('install');
1527+ b.className = (instalada ? 'ghost' : 'primary') + ' instalar-skill';
1528+ ocupado(b, instalada, { hecho: true });
1529+ b.setAttribute('aria-label', (instalada ? tr('installedOk') : tr('install')) + ': ' + nombre);
1530+}
1531+// Las listas de «Explorar» ya pintadas dicen la verdad de lo instalado: al quitar
1532+// una skill (o devolverla con «Deshacer») su botón vuelve a «Instalar» (o a
1533+// «Instalada ✓»). Antes seguía «Instalada ✓» y desactivado, también al volver a
1534+// abrir la lista, que no se repinta.
1535+function actualizarListas() {
1536+ for (const b of document.querySelectorAll('#panel-skills .repo-skills button.instalar-skill')) {
1537+ if (b.getAttribute('aria-busy') === 'true') continue; // instalándose ahora mismo
1538+ pintarBotonInstalar(b, skills.isInstalled(b.dataset.repo, b.dataset.path), b.dataset.nombre);
1539+ }
1540+}
1541+
13751542 // La lista de un repo va DENTRO de su tarjeta y el botón la abre y la cierra.
1543+// Mientras carga, el botón está ocupado (aria-disabled): el foco se queda en él.
13761544 async function explorarRepo(repo, lista, boton, instaladas) {
13771545 if (!lista.hidden) {
13781546 lista.hidden = true;
@@ -1383,8 +1551,8 @@
13831551 lista.hidden = false;
13841552 boton.setAttribute('aria-expanded', 'true');
13851553 boton.textContent = tr('hideList');
1386- if (lista.dataset.cargada) return;
1387- boton.disabled = true;
1554+ if (lista.dataset.cargada) { actualizarListas(); return; }
1555+ ocupado(boton, true);
13881556 lista.setAttribute('aria-busy', 'true');
13891557 lista.replaceChildren(el('div', 'muted', tr('loadingRepo', { repo })));
13901558 try {
@@ -1392,22 +1560,25 @@
13921560 lista.replaceChildren(el('div', 'muted', tr('repoSkills', { repo, n: found.length })));
13931561 for (const sk of found.slice(0, 120)) {
13941562 const c = el('div', 'card');
1395- const on = skills.isInstalled(sk.repo, sk.path);
1396- const b = btn(on ? tr('installedOk') : tr('install'), on ? 'ghost' : 'primary', async () => {
1397- b.disabled = true;
1563+ const b = btn('', '', async () => {
1564+ if (skills.isInstalled(sk.repo, sk.path)) return;
1565+ ocupado(b, true);
13981566 b.textContent = '…';
13991567 try {
14001568 const entry = await skills.installFromRepo(sk);
1401- b.textContent = tr('installedOk');
1402- b.className = 'ghost';
1569+ pintarBotonInstalar(b, true, sk.name);
14031570 pintarInstaladas(instaladas);
1571+ actualizarListas();
14041572 const msg = onSkillInstalledCb(entry); // → mensaje «cómo usarla» en el chat
14051573 // …y desde la tarjeta se llega a ese mensaje (antes había que buscarlo).
1406- if (msg) c.append(btn(tr('skillSeeChat'), 'ghost', () => irAlMensaje(msg)));
1407- } catch (e) { b.disabled = false; b.textContent = tr('install'); toast('⚠️ ' + e.message); }
1574+ if (msg) {
1575+ c.querySelector('.ver-en-chat')?.remove();
1576+ c.append(btn(tr('skillSeeChat'), 'ghost ver-en-chat', () => irAlMensaje(msg)));
1577+ }
1578+ } catch (e) { pintarBotonInstalar(b, false, sk.name); toast('⚠️ ' + e.message); }
14081579 });
1409- b.disabled = on;
1410- b.setAttribute('aria-label', (on ? tr('installedOk') : tr('install')) + ': ' + sk.name);
1580+ b.dataset.repo = sk.repo; b.dataset.path = sk.path; b.dataset.nombre = sk.name;
1581+ pintarBotonInstalar(b, skills.isInstalled(sk.repo, sk.path), sk.name);
14111582 c.append(el('b', null, sk.name), el('span', 'muted', sk.dir), enlaceSkillMd(sk.repo, sk.path, sk.branch || 'HEAD'), b);
14121583 lista.appendChild(c);
14131584 }
@@ -1415,7 +1586,7 @@
14151586 } catch (e) {
14161587 lista.replaceChildren(el('div', 'muted', '⚠️ ' + e.message));
14171588 } finally {
1418- boton.disabled = false;
1589+ ocupado(boton, false);
14191590 lista.removeAttribute('aria-busy');
14201591 }
14211592 }
@@ -1797,14 +1968,14 @@
17971968 estado.setAttribute('role', 'status');
17981969 const boton = btn(tr('mobAnyway', { size: sizeText }), 'ghost', async () => {
17991970 try { localStorage.setItem('elffuss.movil.ok', '1'); } catch { /* — */ }
1800- boton.disabled = true;
1971+ ocupado(boton, true); // aria-disabled: el foco se queda en el botón
18011972 estado.textContent = tr('mobLoading');
18021973 let cargo = false;
18031974 try { cargo = await onAccept(); } catch { cargo = false; }
18041975 if (cargo) { box.remove(); return; }
18051976 estado.textContent = tr('mobFailed');
18061977 boton.textContent = tr('mobRetry');
1807- boton.disabled = false;
1978+ ocupado(boton, false);
18081979 });
18091980 box.append(estado, boton);
18101981 (document.getElementById('log') || document.body).appendChild(box);