utopia-ia/elffuss-claw public
Changesets · Branches · Tags · Compare
| Changeset | 7a8506ddd5be2ca1d1e6fe5298f250f44de57ce7995f604a7db1b2e667d6dc9c |
|---|---|
| Author | KikoCis <kikocisneros@gmail.com> · 2026-10-11 20:42 +02:00 |
| Committer | KikoCis <kikocisneros@gmail.com> · 2026-10-11 20:42 +02:00 |
| Parents | 7185ee918ff9 |
7 files changed
modified tests/ux-ajustes.mjs +20 −4
| @@ -6,6 +6,8 @@ | ||
| 6 | 6 | // · El feedback dice si llegó: si falla, lo dice y el texto se queda. |
| 7 | 7 | // · «Acerca de» enlaza el código, la comunidad, las incidencias y la licencia; |
| 8 | 8 | // 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. | |
| 9 | 11 | // |
| 10 | 12 | // BASE=http://localhost:8743 node tests/ux-ajustes.mjs |
| 11 | 13 | import { navegador, contexto, pagina, ok, hasta, avisos, fin, BASE } from './ux-comun.mjs'; |
| @@ -15,6 +17,10 @@ | ||
| 15 | 17 | extraInit: { 'elffuss.providers': JSON.stringify({ server: { enabled: true, baseURL: 'https://claw.elffuss.com/v1', model: 'ornith-9b', apiKey: '' } }) }, |
| 16 | 18 | }); |
| 17 | 19 | 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 | +}); | |
| 18 | 24 | const abrirAjustes = async () => { await p.click('#tabs button[data-tab="ajustes"]'); await p.locator('#panel-ajustes .ext-block').waitFor(); }; |
| 19 | 25 | await abrirAjustes(); |
| 20 | 26 | await p.click('#panel-ajustes .ext-block > summary'); |
| @@ -38,9 +44,11 @@ | ||
| 38 | 44 | await p.route('**/proxy/report', async route => { recibido = route.request().postDataJSON(); await route.fulfill({ status: estado, body: estado === 200 ? '{"ok":true}' : 'caído' }); }); |
| 39 | 45 | await abrirAjustes(); |
| 40 | 46 | 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'); | |
| 42 | 49 | 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))) |
| 43 | 50 | && (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()); | |
| 44 | 52 | ok('…y ofrece el sitio público de incidencias', await p.locator('#toasts .toast', { hasText: 'No ha llegado' }).locator('.toast-accion').innerText() === 'Abrir incidencias'); |
| 45 | 53 | estado = 200; |
| 46 | 54 | await p.click('#panel-ajustes button:has-text("Enviar")'); |
| @@ -67,17 +75,25 @@ | ||
| 67 | 75 | document.querySelector('#panel-ajustes [data-ruta="acerca"]')?.classList.contains('resaltado')))); |
| 68 | 76 | |
| 69 | 77 | // ── 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 | +}); | |
| 71 | 83 | await p.goto(BASE + '/#/memoria/mprueba', { waitUntil: 'domcontentloaded' }); |
| 72 | 84 | await p.waitForFunction(() => !!window.elffuss?.agent); |
| 73 | 85 | const hecho = p.locator('#panel-ajustes [data-ruta="mprueba"]'); |
| 74 | 86 | ok('#/memoria/<id> abre Ajustes y señala ese hecho (sin el texto en la URL)', await hasta(async () => |
| 75 | 87 | 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'); | |
| 77 | 90 | ok('✕ lo olvida…', await hasta(async () => await hecho.count() === 0) |
| 78 | 91 | && !(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'); | |
| 80 | 95 | 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()); | |
| 81 | 97 | ok('el lema de la cabecera sale en español', (await p.locator('.brand .claim').first().innerText()) === 'las apps no existen: se crean'); |
| 82 | 98 | |
| 83 | 99 | // ── el modo básico señala el selector de modelo, no el 🧠 ─────────────────── |
modified tests/ux-boveda.mjs +17 −2
| @@ -4,7 +4,8 @@ | ||
| 4 | 4 | // · 👁 enseña y vuelve a tapar (aria-pressed); el autobloqueo repinta el panel |
| 5 | 5 | // y tapa lo revelado; 🗑 pide confirmación con el nombre del secreto. |
| 6 | 6 | // · 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. | |
| 8 | 9 | // |
| 9 | 10 | // BASE=http://localhost:8743 node tests/ux-boveda.mjs |
| 10 | 11 | import { navegador, contexto, pagina, ok, hasta, espera, avisos, fin, OUT } from './ux-comun.mjs'; |
| @@ -66,9 +67,23 @@ | ||
| 66 | 67 | await p.fill('#vault-master', 'clave-de-prueba-1'); |
| 67 | 68 | await p.press('#vault-master', 'Enter'); |
| 68 | 69 | 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 | +}); | |
| 69 | 79 | 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'); | |
| 71 | 82 | 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()); | |
| 72 | 87 | |
| 73 | 88 | // ── «Bloquear ahora» con el teclado: el foco va a la contraseña, no a <body> ─ |
| 74 | 89 | await p.locator('#panel-vault button', { hasText: 'Bloquear ahora' }).focus(); |
modified tests/ux-modelos.mjs +10 −5
| @@ -79,14 +79,19 @@ | ||
| 79 | 79 | ok('Ajustes cuenta los pesos (no el origen entero)', await hasta(async () => /0\.01 GB en caché/.test(await card.innerText())), await card.innerText()); |
| 80 | 80 | const boton = card.locator('button', { hasText: 'Vaciar caché del modelo' }); |
| 81 | 81 | 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) | |
| 83 | 84 | const b = [...document.querySelectorAll('#panel-ajustes button')].find(x => /Vaciar caché del modelo/.test(x.textContent)); |
| 84 | 85 | 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'] }); | |
| 86 | 87 | }); |
| 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)); | |
| 90 | 95 | ok('y después cuenta cero', await hasta(async () => /Nada cacheado todavía/.test(await card.innerText()))); |
| 91 | 96 | |
| 92 | 97 | 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 @@ | ||
| 6 | 6 | // · Automatizaciones de carpetas con su lista y ✕ (no tenían interfaz). |
| 7 | 7 | // · Quitar una carpeta pide confirmación, dice qué automatizaciones arrastra y |
| 8 | 8 | // 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. | |
| 9 | 12 | // |
| 10 | 13 | // BASE=http://localhost:8743 node tests/ux-paneles.mjs |
| 11 | 14 | import { navegador, contexto, pagina, ok, hasta, espera, escribir, reposo, avisos, fin, BASE } from './ux-comun.mjs'; |
| @@ -13,6 +16,11 @@ | ||
| 13 | 16 | const b = await navegador(); |
| 14 | 17 | const { ctx } = await contexto(b, { grants: ['apps', 'tasks', 'fs'] }); |
| 15 | 18 | 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'); }; | |
| 16 | 24 | |
| 17 | 25 | // ── Apps ──────────────────────────────────────────────────────────────────── |
| 18 | 26 | await escribir(p, 'hazme un reloj'); |
| @@ -22,14 +30,16 @@ | ||
| 22 | 30 | await p.click('#tabs button[data-tab="apps"]'); |
| 23 | 31 | const borrar = p.locator('#panel-apps button[aria-label="Borrar la app «reloj»"]'); |
| 24 | 32 | ok('🗑 se llama «Borrar la app «reloj»»', await borrar.count() === 1); |
| 25 | -await borrar.click(); | |
| 33 | +await conTeclado(borrar); | |
| 26 | 34 | ok('borrarla vacía el visor y el modelo ya no la cree abierta', await hasta(() => p.evaluate(async () => |
| 27 | 35 | document.getElementById('appframe').hidden && !document.getElementById('vista-empty').hidden |
| 28 | 36 | && (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()); | |
| 29 | 38 | const deshacer = p.locator('#toasts .toast', { hasText: 'eliminada' }).locator('.toast-accion'); |
| 30 | 39 | ok('…y ofrece «Deshacer»', await deshacer.count() === 1); |
| 31 | -await deshacer.click(); | |
| 40 | +await conTeclado(deshacer); | |
| 32 | 41 | 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()); | |
| 33 | 43 | |
| 34 | 44 | // ── Tareas ────────────────────────────────────────────────────────────────── |
| 35 | 45 | const id = await p.evaluate(async () => { |
| @@ -39,11 +49,19 @@ | ||
| 39 | 49 | await p.click('#tabs button[data-tab="tareas"]'); |
| 40 | 50 | const tarjeta = p.locator(`#panel-tareas [data-ruta="${id}"]`); |
| 41 | 51 | 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' })); | |
| 43 | 53 | ok('«Ejecutar ahora» la manda al chat y la marca hecha', await hasta(async () => |
| 44 | 54 | /\[tarea programada\] estirar la espalda/.test(await p.locator('#log').innerText()) && /✅/.test(await tarjeta.innerText()))); |
| 45 | 55 | 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()); | |
| 46 | 57 | 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()); | |
| 47 | 65 | |
| 48 | 66 | // una tarea que vence con el panel abierto |
| 49 | 67 | 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 @@ | ||
| 71 | 89 | await seccion.evaluate(e => e.classList.contains('resaltado')).catch(() => false))); |
| 72 | 90 | ok('…que enseña «entrada → salida» con su ✕', /entrada → salida/.test(await seccion.innerText()) |
| 73 | 91 | && 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()); | |
| 74 | 99 | |
| 75 | 100 | await p.click('#tabs button[data-tab="permisos"]'); |
| 76 | 101 | ok('Permisos dice dónde escribe la Mente', await hasta(async () => |
| @@ -83,10 +108,18 @@ | ||
| 83 | 108 | ok('quitar una carpeta pregunta y nombra las automatizaciones que arrastra', /«entrada»/.test(pregunta) && /entrada → salida/.test(pregunta), pregunta); |
| 84 | 109 | ok('si dices que no, sigue ahí', await p.locator('#panel-permisos [data-ruta="entrada"]').count() === 1); |
| 85 | 110 | 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»"]')); | |
| 87 | 112 | ok('si dices que sí, se quita con su automatización', await hasta(async () => await p.locator('#panel-permisos [data-ruta="entrada"]').count() === 0) |
| 88 | 113 | && (await p.evaluate(async () => (await (await import('/js/tools/watch.js')).allWatches()).length)) === 0 |
| 89 | 114 | && (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()); | |
| 90 | 123 | |
| 91 | 124 | ok('sin errores de página', errores.length === 0, errores.slice(0, 3).join(' | ')); |
| 92 | 125 | 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 @@ | ||
| 7 | 7 | // al momento y deja «Deshacer»; se puede ver lo que se le da al modelo. |
| 8 | 8 | // · «Añadir repo» lo enseña al momento, vacía el campo y se puede quitar (✕). |
| 9 | 9 | // · #/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). | |
| 10 | 15 | // |
| 11 | 16 | // BASE=http://localhost:8743 node tests/ux-skills.mjs |
| 12 | 17 | import { navegador, contexto, pagina, ok, hasta, avisos, fin, BASE } from './ux-comun.mjs'; |
| @@ -30,15 +35,22 @@ | ||
| 30 | 35 | }, |
| 31 | 36 | }); |
| 32 | 37 | 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'); }; | |
| 33 | 43 | await p.click('#tabs button[data-tab="skills"]'); |
| 34 | 44 | const contador = () => p.locator('#panel-skills .skills-instaladas > .muted').first().innerText(); |
| 35 | 45 | ok('empieza con «Instaladas: 0»', (await contador()) === 'Instaladas: 0'); |
| 36 | 46 | |
| 37 | 47 | const tarjeta = p.locator(`#panel-skills [data-ruta="repo:${REPO}"]`); |
| 38 | 48 | const explorar = tarjeta.locator('button', { hasText: /Explorar|Ocultar/ }); |
| 39 | -await explorar.click(); | |
| 49 | +await conTeclado(explorar); | |
| 40 | 50 | ok('«Explorar» abre la lista DENTRO de la tarjeta del repo', await hasta(async () => |
| 41 | 51 | /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()); | |
| 42 | 54 | const md = tarjeta.locator('.repo-skills a', { hasText: 'SKILL.md' }).first(); |
| 43 | 55 | 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')) |
| 44 | 56 | && await md.getAttribute('rel') === 'noopener noreferrer'); |
| @@ -49,9 +61,17 @@ | ||
| 49 | 61 | |
| 50 | 62 | const tarjetaSkill = tarjeta.locator('.repo-skills .card', { hasText: 'reloj-bonito' }); |
| 51 | 63 | 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); | |
| 53 | 66 | ok('«Instalar» deja el botón desactivado en «Instalada ✓»', await hasta(async () => |
| 54 | 67 | (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); | |
| 55 | 75 | ok('…el contador sube y la skill aparece en lo instalado', (await contador()) === 'Instaladas: 1' |
| 56 | 76 | && await p.locator('#panel-skills .skills-instaladas [data-ruta="reloj-bonito"]').count() === 1); |
| 57 | 77 | ok('…y el chat explica cómo usarla', /Skill «reloj-bonito» instalada/.test(await p.locator('#log').innerText())); |
| @@ -66,13 +86,22 @@ | ||
| 66 | 86 | await inst.locator('summary').click(); |
| 67 | 87 | ok('se puede ver lo que se le da al modelo', /Crea un reloj grande/.test(await inst.locator('.skill-text').innerText())); |
| 68 | 88 | |
| 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»"]')); | |
| 70 | 90 | ok('«Quitar» la quita al momento y el contador baja', await hasta(async () => |
| 71 | 91 | await p.locator('#panel-skills .skills-instaladas [data-ruta="reloj-bonito"]').count() === 0 && (await contador()) === 'Instaladas: 0')); |
| 72 | 92 | 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') })); | |
| 73 | 97 | const deshacer = p.locator('#toasts .toast', { hasText: 'quitada' }).locator('.toast-accion'); |
| 74 | -await deshacer.click(); | |
| 98 | +await conTeclado(deshacer); | |
| 75 | 99 | 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()); | |
| 76 | 105 | |
| 77 | 106 | // ── añadir y quitar un repo ───────────────────────────────────────────────── |
| 78 | 107 | await p.fill('#panel-skills form input', 'https://github.com/alguien/sus-skills'); |
| @@ -80,8 +109,10 @@ | ||
| 80 | 109 | const nueva = p.locator('#panel-skills [data-ruta="repo:alguien/sus-skills"]'); |
| 81 | 110 | ok('«Añadir repo» lo enseña al momento y vacía el campo', await hasta(async () => await nueva.count() === 1) |
| 82 | 111 | && (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"]')); | |
| 84 | 113 | 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()); | |
| 85 | 116 | ok('los repos de serie no tienen ✕', await tarjeta.locator('button[aria-label^="Quitar el repo"]').count() === 0); |
| 86 | 117 | |
| 87 | 118 | // ── dirección de una skill ────────────────────────────────────────────────── |
modified web/css/elffuss.css +4 −0
| @@ -370,6 +370,10 @@ | ||
| 370 | 370 | border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; cursor: pointer; font-size: .85rem; |
| 371 | 371 | } |
| 372 | 372 | 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; } | |
| 373 | 377 | h3 { margin: 6px 0 12px; font-size: .95rem; } |
| 374 | 378 | |
| 375 | 379 | /* ---------- modal de permisos ---------- */ |
modified web/js/ui.js +224 −53
| @@ -487,11 +487,39 @@ | ||
| 487 | 487 | if (text != null) e.textContent = text; |
| 488 | 488 | return e; |
| 489 | 489 | }; |
| 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. | |
| 490 | 494 | const btn = (label, cls, onClick) => { |
| 491 | 495 | 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); }; | |
| 493 | 497 | return b; |
| 494 | 498 | }; |
| 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 | +} | |
| 495 | 523 | |
| 496 | 524 | // ---------- panel apps ---------- |
| 497 | 525 | export async function refreshApps() { |
| @@ -503,26 +531,37 @@ | ||
| 503 | 531 | return; |
| 504 | 532 | } |
| 505 | 533 | for (const app of list) { |
| 506 | - panel.appendChild(card( | |
| 534 | + const c = card( | |
| 507 | 535 | el('b', null, app.name), |
| 508 | 536 | el('span', 'muted', new Date(app.created).toLocaleString(uiLang())), |
| 509 | 537 | // Por apps.open(): así la app abierta es ESTA también para el modelo |
| 510 | 538 | // (CONTEXTO AHORA), no solo en pantalla. |
| 511 | 539 | btn(tr('open'), 'primary', () => { aperturaManualT = Date.now(); apps.open({ name: app.name }).catch(e => toast('⚠️ ' + e.message)); }), |
| 512 | 540 | botonBorrarApp(app), |
| 513 | - )); | |
| 541 | + ); | |
| 542 | + c.dataset.app = app.name; | |
| 543 | + panel.appendChild(c); | |
| 514 | 544 | } |
| 515 | 545 | } |
| 516 | 546 | // 🗑 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. | |
| 518 | 549 | function botonBorrarApp(app) { |
| 519 | 550 | const b = btn('🗑', 'ghost', async () => { |
| 551 | + const panel = $('panel-apps'); | |
| 552 | + const i = [...panel.querySelectorAll('.card[data-app]')].indexOf(b.closest('.card')); | |
| 520 | 553 | await apps.removeApp({ name: app.name }); |
| 521 | - refreshApps(); | |
| 554 | + await refreshApps(); | |
| 555 | + enfocarFila(panel.querySelectorAll('.card[data-app]'), i, '.borrar-app', panel.querySelector('h3')); | |
| 522 | 556 | 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); } | |
| 524 | 562 | } } }); |
| 525 | 563 | }); |
| 564 | + b.classList.add('borrar-app'); | |
| 526 | 565 | b.title = tr('appDelL', { name: app.name }); |
| 527 | 566 | b.setAttribute('aria-label', tr('appDelL', { name: app.name })); |
| 528 | 567 | return b; |
| @@ -538,7 +577,36 @@ | ||
| 538 | 577 | } |
| 539 | 578 | |
| 540 | 579 | // ---------- 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() { | |
| 542 | 610 | const [list, watches] = await Promise.all([ |
| 543 | 611 | db.all('tasks').then(l => l.sort((a, b) => a.when - b.when)), |
| 544 | 612 | watch.allWatches().catch(() => []), |
| @@ -555,20 +623,28 @@ | ||
| 555 | 623 | const fila = [estado, el('b', null, t.prompt), el('span', 'muted', new Date(t.when).toLocaleString(uiLang())), id]; |
| 556 | 624 | if (!t.done) { |
| 557 | 625 | const ya = btn(tr('taskRunNow'), 'ghost', async () => { |
| 558 | - ya.disabled = true; | |
| 626 | + const pos = posicionEnTareas(ya); | |
| 627 | + ocupado(ya, true); | |
| 559 | 628 | const hecha = await tasks.marcarHecha(t.id); |
| 560 | 629 | if (hecha) onRunTaskCb(hecha); |
| 561 | - refreshTasks(); | |
| 630 | + await repintarTareasYEnfocar(pos, { misma: true }); | |
| 562 | 631 | }); |
| 563 | 632 | ya.setAttribute('aria-label', tr('taskRunNowL', { prompt: t.prompt })); |
| 564 | 633 | fila.push(ya); |
| 565 | 634 | } |
| 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'; | |
| 567 | 642 | borrar.title = tr('taskDelL', { prompt: t.prompt }); |
| 568 | 643 | borrar.setAttribute('aria-label', tr('taskDelL', { prompt: t.prompt })); |
| 569 | 644 | fila.push(borrar); |
| 570 | 645 | const c = card(...fila); |
| 571 | 646 | c.dataset.ruta = t.id; // #/tareas/<id> |
| 647 | + c.dataset.tarea = '1'; | |
| 572 | 648 | panel.appendChild(c); |
| 573 | 649 | } |
| 574 | 650 | // Automatizaciones de carpetas (fs.watch): antes no tenían interfaz; solo se |
| @@ -578,7 +654,13 @@ | ||
| 578 | 654 | sec.appendChild(el('h3', null, tr('watchTitle'))); |
| 579 | 655 | if (!watches.length) sec.appendChild(el('p', 'muted', tr('watchEmpty'))); |
| 580 | 656 | 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'; | |
| 582 | 664 | x.title = tr('watchDelL', { from: w.from, to: w.to }); |
| 583 | 665 | x.setAttribute('aria-label', x.title); |
| 584 | 666 | const c = card(el('span', null, '👁'), el('b', null, `${w.from} → ${w.to}`), |
| @@ -704,32 +786,60 @@ | ||
| 704 | 786 | ver.setAttribute('aria-pressed', 'false'); |
| 705 | 787 | ver.title = tr('vaultShow', { name: n }); |
| 706 | 788 | 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. | |
| 707 | 791 | const borrar = btn('🗑', 'ghost', async () => { |
| 708 | 792 | if (!window.confirm(tr('vaultDelConfirm', { name: n }))) return; |
| 793 | + const i = [...panel.querySelectorAll('.card[data-secreto]')].indexOf(borrar.closest('.card')); | |
| 709 | 794 | try { await vault.removeSecret({ name: n }); toast(tr('vaultDeleted', { name: n })); } |
| 710 | 795 | 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')); | |
| 712 | 798 | }); |
| 799 | + borrar.className = 'ghost borrar-secreto'; | |
| 713 | 800 | borrar.title = tr('vaultDel', { name: n }); |
| 714 | 801 | 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); | |
| 716 | 805 | } |
| 717 | 806 | } |
| 718 | 807 | |
| 719 | 808 | // ---------- 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() { | |
| 721 | 821 | const panel = $('panel-permisos'); |
| 722 | 822 | panel.replaceChildren(el('h3', null, tr('permsTitle'))); |
| 723 | 823 | const g = perms.grants(); |
| 724 | 824 | if (!g.length) |
| 725 | 825 | 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. | |
| 726 | 828 | for (const scope of g) { |
| 727 | 829 | 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( | |
| 729 | 837 | el('b', null, `${meta.icon || ''} ${meta.label || scope}`), |
| 730 | 838 | 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); | |
| 733 | 843 | } |
| 734 | 844 | const folders = await fs.folders(); |
| 735 | 845 | if (folders.length) { |
| @@ -737,10 +847,16 @@ | ||
| 737 | 847 | // Dónde escribe la Mente: en la primera carpeta (ceo-adapter.js). |
| 738 | 848 | panel.appendChild(el('p', 'muted', tr('folderSoulNote', { name: folders[0] }))); |
| 739 | 849 | 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 | + }); | |
| 741 | 856 | quitar.setAttribute('aria-label', tr('folderRemoveL', { name: f })); |
| 742 | 857 | const c = card(el('b', null, '📁 ' + f), quitar); |
| 743 | 858 | c.dataset.ruta = f; // #/permisos/<carpeta> |
| 859 | + c.dataset.carpeta = '1'; | |
| 744 | 860 | panel.appendChild(c); |
| 745 | 861 | } |
| 746 | 862 | } |
| @@ -753,11 +869,12 @@ | ||
| 753 | 869 | let txt = tr('folderRemoveConfirm', { name: f }); |
| 754 | 870 | if (dependientes.length) txt += '\n\n' + tr('folderRemoveWatches', { list: dependientes.map(w => `${w.from} → ${w.to}`).join(', ') }); |
| 755 | 871 | 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; | |
| 757 | 873 | for (const w of dependientes) await watch.removeWatch({ id: w.id }).catch(() => {}); |
| 758 | 874 | await db.del('fs', f); |
| 759 | 875 | toast(tr('folderRemoved', { name: f }) + (dependientes.length ? ' · ' + tr('folderRemovedWatches', { n: dependientes.length }) : '')); |
| 760 | - refreshPerms(); | |
| 876 | + await refreshPerms(); | |
| 877 | + return true; | |
| 761 | 878 | } |
| 762 | 879 | |
| 763 | 880 | // ---------- progreso y estado del modelo ---------- |
| @@ -975,7 +1092,11 @@ | ||
| 975 | 1092 | a.setAttribute('aria-label', a.title); |
| 976 | 1093 | vBrain.appendChild(a); |
| 977 | 1094 | } |
| 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' : ''; | |
| 979 | 1100 | // refrescar solo mientras se está viendo |
| 980 | 1101 | clearTimeout(timer); |
| 981 | 1102 | if (document.querySelector('#tabs button.active')?.dataset.tab === 'ajustes') timer = setTimeout(paint, 4000); |
| @@ -1001,6 +1122,9 @@ | ||
| 1001 | 1122 | const inv = el('div', 'col'); |
| 1002 | 1123 | card.append(state, row, inv); |
| 1003 | 1124 | |
| 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')); }; | |
| 1004 | 1128 | const paint = async () => { |
| 1005 | 1129 | const st = workspace.status(); |
| 1006 | 1130 | row.replaceChildren(); |
| @@ -1011,22 +1135,22 @@ | ||
| 1011 | 1135 | |
| 1012 | 1136 | if (st.supported.pick) { |
| 1013 | 1137 | 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); } | |
| 1015 | 1139 | })); |
| 1016 | 1140 | 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); } | |
| 1018 | 1142 | })); |
| 1019 | 1143 | else { |
| 1020 | 1144 | 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(); } | |
| 1023 | 1147 | })); |
| 1024 | 1148 | const auto = el('label', 'row'); |
| 1025 | 1149 | const chk = el('input'); chk.type = 'checkbox'; chk.checked = workspace.autosaveEnabled(); |
| 1026 | 1150 | chk.onchange = () => { workspace.autosave({ enabled: chk.checked }); toast(chk.checked ? tr('wsAutoOn') : tr('wsAutoOff')); }; |
| 1027 | 1151 | auto.append(chk, el('span', 'muted', tr('wsAuto'))); |
| 1028 | 1152 | 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(); })); | |
| 1030 | 1154 | } |
| 1031 | 1155 | } |
| 1032 | 1156 | // copia descargable: funciona en TODOS los navegadores (Safari/Firefox incluidos) |
| @@ -1050,13 +1174,13 @@ | ||
| 1050 | 1174 | const danger = el('div', 'row'); |
| 1051 | 1175 | const wipe = btn(tr('wsWipe'), 'ghost', async () => { |
| 1052 | 1176 | if (!window.confirm(tr('wsWipeConfirm'))) return; |
| 1053 | - wipe.disabled = true; | |
| 1177 | + ocupado(wipe, true); // aria-disabled: sin perder el foco (ver btn) | |
| 1054 | 1178 | // Lo hace el kernel: para el turno en marcha, borra y RECARGA. Borrar solo |
| 1055 | 1179 | // el IndexedDB dejaba la conversación en pantalla y en memoria, y el |
| 1056 | 1180 | // siguiente mensaje la volvía a guardar entera; skills, bóveda abierta y |
| 1057 | 1181 | // app actual también seguían vivas hasta recargar. |
| 1058 | 1182 | try { await onWipeCb(); } |
| 1059 | - catch (e) { wipe.disabled = false; toast('⚠️ ' + (e?.message || e)); } | |
| 1183 | + catch (e) { ocupado(wipe, false); toast('⚠️ ' + (e?.message || e)); } | |
| 1060 | 1184 | }); |
| 1061 | 1185 | danger.appendChild(wipe); |
| 1062 | 1186 | inv.appendChild(danger); |
| @@ -1141,14 +1265,14 @@ | ||
| 1141 | 1265 | // Lo mismo que el chip 💾 (model-storage.js): cuenta solo pesos, y vacía los de |
| 1142 | 1266 | // este origen y los del almacén compartido de CADA broker con modelos (antes |
| 1143 | 1267 | // 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). | |
| 1144 | 1270 | const clearBtn = btn(tr('storeClear'), 'ghost', async () => { |
| 1145 | - clearBtn.disabled = true; | |
| 1146 | - clearBtn.setAttribute('aria-busy', 'true'); | |
| 1271 | + ocupado(clearBtn, true); | |
| 1147 | 1272 | info.textContent = tr('storeClearing'); |
| 1148 | 1273 | try { avisarLiberado(await modelos.vaciar()); } |
| 1149 | 1274 | catch (e) { toast(tr('diskFail', { err: e?.message || e })); } |
| 1150 | - clearBtn.disabled = false; | |
| 1151 | - clearBtn.removeAttribute('aria-busy'); | |
| 1275 | + ocupado(clearBtn, false); | |
| 1152 | 1276 | await paintStore(); |
| 1153 | 1277 | }); |
| 1154 | 1278 | store.appendChild(clearBtn); |
| @@ -1182,14 +1306,14 @@ | ||
| 1182 | 1306 | const ta = telCard.querySelector('#tel-feedback'); |
| 1183 | 1307 | const text = ta.value.trim(); |
| 1184 | 1308 | if (!text) { toast(tr('writeSomething')); ta.focus(); return; } |
| 1185 | - telSendBtn.disabled = true; | |
| 1309 | + ocupado(telSendBtn, true); // aria-disabled: el foco se queda en «Enviar» | |
| 1186 | 1310 | const wasEnabled = telemetry.isEnabled(); |
| 1187 | 1311 | if (!wasEnabled) telemetry.setEnabled(true); // envío manual es explícito, se permite aunque el automático esté apagado |
| 1188 | 1312 | let llego = false; |
| 1189 | 1313 | try { llego = await telemetry.sendFeedback(text); } |
| 1190 | 1314 | finally { |
| 1191 | 1315 | if (!wasEnabled) telemetry.setEnabled(false); // no activa el automático de fondo si no lo pidió |
| 1192 | - telSendBtn.disabled = false; | |
| 1316 | + ocupado(telSendBtn, false); | |
| 1193 | 1317 | } |
| 1194 | 1318 | if (llego) { ta.value = ''; toast(tr('sentThanks')); } |
| 1195 | 1319 | else toast(tr('sendFailed'), { accion: { label: tr('openIssues'), run: () => window.open(ISSUES_URL, '_blank', 'noopener,noreferrer') } }); |
| @@ -1216,6 +1340,8 @@ | ||
| 1216 | 1340 | pintarMemoria(c); |
| 1217 | 1341 | return c; |
| 1218 | 1342 | } |
| 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. | |
| 1219 | 1345 | async function pintarMemoria(c) { |
| 1220 | 1346 | const hechos = (await db.all('memory').catch(() => [])).sort((a, b) => a.at - b.at); |
| 1221 | 1347 | c.replaceChildren(el('b', null, tr('memTitle')), el('span', 'muted', tr('memDesc'))); |
| @@ -1224,9 +1350,15 @@ | ||
| 1224 | 1350 | const fila = el('div', 'row between'); |
| 1225 | 1351 | fila.dataset.ruta = f.id; // #/memoria/<id> |
| 1226 | 1352 | const x = btn('✕', 'ghost', async () => { |
| 1353 | + const i = [...c.querySelectorAll('.row[data-ruta]')].indexOf(fila); | |
| 1227 | 1354 | 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 | + } } }); | |
| 1230 | 1362 | }); |
| 1231 | 1363 | x.title = tr('memForgetL', { fact: String(f.fact).slice(0, 60) }); |
| 1232 | 1364 | x.setAttribute('aria-label', x.title); |
| @@ -1301,11 +1433,21 @@ | ||
| 1301 | 1433 | const fila = el('div', 'row between'); |
| 1302 | 1434 | const desdeRepo = s.repo && s.path && !String(s.path).startsWith('local/'); |
| 1303 | 1435 | 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); | |
| 1305 | 1440 | await skills.remove(s.name); |
| 1306 | 1441 | pintarInstaladas(box); |
| 1442 | + actualizarListas(); | |
| 1443 | + enfocarFila(box.querySelectorAll('.card[data-ruta]'), i, '.quitar-skill', box.firstElementChild); | |
| 1307 | 1444 | 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); } | |
| 1309 | 1451 | } } }); |
| 1310 | 1452 | }); |
| 1311 | 1453 | quitar.setAttribute('aria-label', tr('skillRemoveL', { name: s.name })); |
| @@ -1336,15 +1478,19 @@ | ||
| 1336 | 1478 | lista.id = 'repo-' + src.repo.replace(/[^\w-]/g, '-'); |
| 1337 | 1479 | lista.hidden = true; |
| 1338 | 1480 | 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)); | |
| 1340 | 1482 | explorar.setAttribute('aria-expanded', 'false'); |
| 1341 | 1483 | explorar.setAttribute('aria-controls', lista.id); |
| 1342 | 1484 | fila.append(el('b', null, src.label), link, explorar); |
| 1343 | 1485 | 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). | |
| 1344 | 1488 | const x = btn('✕', 'ghost', async () => { |
| 1489 | + const i = [...box.querySelectorAll('.card[data-ruta]')].indexOf(c); | |
| 1345 | 1490 | await skills.removeSource(src.repo); |
| 1346 | 1491 | toast(tr('repoRemoved', { repo: src.repo })); |
| 1347 | 1492 | await pintarFuentes(box, instaladas); |
| 1493 | + enfocarFila(box.querySelectorAll('.card[data-ruta]'), i, '.explorar-repo', box.querySelector('form input')); | |
| 1348 | 1494 | }); |
| 1349 | 1495 | x.title = tr('repoRemoveL', { repo: src.repo }); |
| 1350 | 1496 | x.setAttribute('aria-label', tr('repoRemoveL', { repo: src.repo })); |
| @@ -1372,7 +1518,29 @@ | ||
| 1372 | 1518 | box.appendChild(form); |
| 1373 | 1519 | } |
| 1374 | 1520 | |
| 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 | + | |
| 1375 | 1542 | // 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. | |
| 1376 | 1544 | async function explorarRepo(repo, lista, boton, instaladas) { |
| 1377 | 1545 | if (!lista.hidden) { |
| 1378 | 1546 | lista.hidden = true; |
| @@ -1383,8 +1551,8 @@ | ||
| 1383 | 1551 | lista.hidden = false; |
| 1384 | 1552 | boton.setAttribute('aria-expanded', 'true'); |
| 1385 | 1553 | 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); | |
| 1388 | 1556 | lista.setAttribute('aria-busy', 'true'); |
| 1389 | 1557 | lista.replaceChildren(el('div', 'muted', tr('loadingRepo', { repo }))); |
| 1390 | 1558 | try { |
| @@ -1392,22 +1560,25 @@ | ||
| 1392 | 1560 | lista.replaceChildren(el('div', 'muted', tr('repoSkills', { repo, n: found.length }))); |
| 1393 | 1561 | for (const sk of found.slice(0, 120)) { |
| 1394 | 1562 | 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); | |
| 1398 | 1566 | b.textContent = '…'; |
| 1399 | 1567 | try { |
| 1400 | 1568 | const entry = await skills.installFromRepo(sk); |
| 1401 | - b.textContent = tr('installedOk'); | |
| 1402 | - b.className = 'ghost'; | |
| 1569 | + pintarBotonInstalar(b, true, sk.name); | |
| 1403 | 1570 | pintarInstaladas(instaladas); |
| 1571 | + actualizarListas(); | |
| 1404 | 1572 | const msg = onSkillInstalledCb(entry); // → mensaje «cómo usarla» en el chat |
| 1405 | 1573 | // …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); } | |
| 1408 | 1579 | }); |
| 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); | |
| 1411 | 1582 | c.append(el('b', null, sk.name), el('span', 'muted', sk.dir), enlaceSkillMd(sk.repo, sk.path, sk.branch || 'HEAD'), b); |
| 1412 | 1583 | lista.appendChild(c); |
| 1413 | 1584 | } |
| @@ -1415,7 +1586,7 @@ | ||
| 1415 | 1586 | } catch (e) { |
| 1416 | 1587 | lista.replaceChildren(el('div', 'muted', '⚠️ ' + e.message)); |
| 1417 | 1588 | } finally { |
| 1418 | - boton.disabled = false; | |
| 1589 | + ocupado(boton, false); | |
| 1419 | 1590 | lista.removeAttribute('aria-busy'); |
| 1420 | 1591 | } |
| 1421 | 1592 | } |
| @@ -1797,14 +1968,14 @@ | ||
| 1797 | 1968 | estado.setAttribute('role', 'status'); |
| 1798 | 1969 | const boton = btn(tr('mobAnyway', { size: sizeText }), 'ghost', async () => { |
| 1799 | 1970 | 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 | |
| 1801 | 1972 | estado.textContent = tr('mobLoading'); |
| 1802 | 1973 | let cargo = false; |
| 1803 | 1974 | try { cargo = await onAccept(); } catch { cargo = false; } |
| 1804 | 1975 | if (cargo) { box.remove(); return; } |
| 1805 | 1976 | estado.textContent = tr('mobFailed'); |
| 1806 | 1977 | boton.textContent = tr('mobRetry'); |
| 1807 | - boton.disabled = false; | |
| 1978 | + ocupado(boton, false); | |
| 1808 | 1979 | }); |
| 1809 | 1980 | box.append(estado, boton); |
| 1810 | 1981 | (document.getElementById('log') || document.body).appendChild(box); |