Elffuss BraidHub

utopia-ia/elffuss-code public

Readable errors with Retry, inline Skills errors, English that is English

- The model progress pill is a polite live region. A failed load says
  what happened in plain words (no connection, no WebGPU adapter, no
  storage left, not enough memory) instead of "Failed to fetch", stays
  visible, and offers Retry (which calls changeModel again) and a close
  button; the technical error is still in the console.
- Skills: the panel uses the Settings dialog shell; "Explorar" without a
  connection says so inside the panel with a Retry button (it showed
  "⚠️ FAILED TO FETCH"), a repo that does not parse and a failed install are
  reported inline instead of with alert(), and its texts are localized.
- ?notif=open|execute (set by sw.js when a notification is clicked with
  the app closed) opens the Mind once the project is open and is removed
  from the URL.
- Strings that stayed Spanish under en-US: the send/stop button title, the
  terminal's "limpiar", the Goal and Feedback sections of Settings, the 3D
  view's loading and error text and the mobile Chat/Editor switch.

tests/messages-ux.mjs (model and GitHub intercepted, nothing reaches the
network): the Basic-mode help, the plain-words failure with a working
Retry, Skills offline and an invalid repo without alert(), ?notif=open,
and the en-US strings. Against the previous code it fails from the first
check.

64a1b57 had already localized the send and stop labels as send/stop: the
duplicate sendBtn/stopBtn keys are dropped and #btn-send keeps its entry in
the titles map next to #term-clear.
Changeset27f8f5c38db4620bd9e9850c472f1b2c4afdfc5f9335073b64a67624760c0649
AuthorKikoCis <kikocisneros@gmail.com> · 2026-10-10 16:44 +02:00
CommitterKikoCis <kikocisneros@gmail.com> · 2026-10-11 14:15 +02:00
Parents7aca986db587

Browse the files at this changeset

5 files changed

added tests/messages-ux.mjs +101 −0
@@ -0,0 +1,101 @@
1+// Avisos que se entienden y textos en el idioma de la interfaz.
2+//
3+// 1. Fallo al cargar el modelo: en palabras de persona («sin conexión…», no
4+// «Failed to fetch»), en una región viva, con «Reintentar» que reintenta.
5+// 2. Skills: sin conexión, «Explorar» lo dice dentro del panel con
6+// «Reintentar»; un repo que no vale se dice en línea, sin alert().
7+// 3. El modo Básico manda a ⚙️ Ajustes → Cerebro, no a un «selector 🧠» que
8+// no existe.
9+// 4. Abierto desde una notificación con la app cerrada (?notif=open), la
10+// Mente aparece y la URL queda limpia.
11+// 5. En inglés: Enviar/Parar, «limpiar» del terminal, Modo Objetivo y
12+// Feedback de Ajustes, y la barra de menús, ya no salen en español.
13+// Nada sale a la red: el modelo y GitHub van interceptados.
14+//
15+// BASE=http://127.0.0.1:8898 node tests/messages-ux.mjs
16+import { chromium } from 'playwright';
17+const BASE = process.env.BASE || 'http://localhost:8799';
18+let fails = 0; const ok = (n, c, e = '') => { console.log((c ? '✅' : '❌') + ' ' + n + (e ? ' — ' + e : '')); if (!c) fails++; };
19+
20+const FALLA = `window.__cargas = (window.__cargas || 0);
21+export const name = 'onnx que falla'; export function configure() {}
22+export async function load() { window.__cargas++; throw new TypeError('Failed to fetch'); }
23+export async function chat() { return ''; }`;
24+
25+const b = await chromium.launch();
26+const errs = [];
27+const abre = async (locale, query = '') => {
28+ const ctx = await b.newContext({ locale });
29+ await ctx.addInitScript(() => { try { localStorage.setItem('elffusscode.model', 'rules'); } catch {} window.__alerts = 0; window.alert = () => { window.__alerts++; }; });
30+ await ctx.route('**/js/providers/onnx.js*', r => r.fulfill({ status: 200, contentType: 'text/javascript', body: FALLA }));
31+ await ctx.route(/api\.github\.com|raw\.githubusercontent\.com/, r => r.abort());
32+ await ctx.route(/soundcloud/, r => r.abort());
33+ const p = await ctx.newPage({ viewport: { width: 1400, height: 900 } });
34+ p.on('pageerror', e => errs.push(e.message.slice(0, 160)));
35+ await p.goto(BASE + '/?test-opfs' + query, { waitUntil: 'domcontentloaded' });
36+ await p.waitForFunction(() => window.elffussClaw?.conv?.getActive?.(), null, { timeout: 20000 });
37+ return { ctx, p };
38+};
39+
40+let { ctx, p } = await abre('es-ES');
41+
42+// 3 · ayuda del modo Básico
43+await p.fill('#prompt', 'hola');
44+await p.press('#prompt', 'Enter');
45+await p.waitForFunction(() => !window.elffussClaw.conv.isBusy(), null, { timeout: 8000 });
46+const ayuda = await p.evaluate(() => document.getElementById('chat-log').innerText);
47+ok('3 · el modo Básico manda a ⚙️ Ajustes → Cerebro', /Ajustes → Cerebro/.test(ayuda) && !/selector 🧠/.test(ayuda), ayuda.slice(-160));
48+
49+// 1 · fallo al cargar el modelo
50+await p.click('#btn-settings');
51+await p.locator('#settings-panel .model-card', { hasText: 'Qwen3.5-0.8B' }).first().click();
52+await p.waitForFunction(() => /No pude cargar/.test(document.getElementById('model-progress-text').textContent), null, { timeout: 8000 }).catch(() => {});
53+const pildora = await p.evaluate(() => ({ txt: document.getElementById('model-progress-text').textContent, rol: document.getElementById('model-progress').getAttribute('role'), reintentar: !!document.querySelector('#model-progress .mp-acciones button') }));
54+ok('1 · el fallo se dice en palabras de persona, no «Failed to fetch»', /no se pudo descargar/.test(pildora.txt) && !/Failed to fetch/.test(pildora.txt), JSON.stringify(pildora));
55+ok('1 · la píldora es una región viva con «Reintentar»', pildora.rol === 'status' && pildora.reintentar, JSON.stringify(pildora));
56+await p.locator('#model-progress .mp-acciones button', { hasText: 'Reintentar' }).click();
57+await p.waitForTimeout(600);
58+ok('1 · «Reintentar» vuelve a intentar la carga', await p.evaluate(() => window.__cargas) === 2, String(await p.evaluate(() => window.__cargas)));
59+
60+// 2 · skills sin conexión y repo que no vale
61+await p.evaluate(() => document.getElementById('settings-panel').hidden || document.getElementById('btn-settings').click());
62+await p.evaluate(() => window.elffussClaw.skills && document.getElementById('act-skills').click());
63+await p.waitForTimeout(500);
64+await p.locator('#settings-panel .sk-row button', { hasText: 'Explorar' }).first().click();
65+await p.waitForSelector('#settings-panel .sk-browse .sk-msg', { timeout: 8000 }).catch(() => {});
66+const skill = await p.evaluate(() => ({ msg: document.querySelector('#settings-panel .sk-browse .sk-msg')?.textContent || '', reintentar: !!document.querySelector('#settings-panel .sk-browse button') }));
67+ok('2 · sin conexión, «Explorar» lo dice dentro del panel con «Reintentar»', /sin conexión/.test(skill.msg) && skill.reintentar && !/FAILED TO FETCH/.test(skill.msg), JSON.stringify(skill));
68+await p.locator('#settings-panel input[aria-label="Añadir repo"]').fill('esto no es un repo');
69+await p.locator('#settings-panel button', { hasText: 'Añadir repo' }).click();
70+await p.waitForTimeout(300);
71+const repo = await p.evaluate(() => ({ alerts: window.__alerts, msg: [...document.querySelectorAll('#settings-panel .sk-msg')].map(n => n.textContent).join(' | ') }));
72+ok('2 · un repo que no vale se dice en línea, sin alert()', repo.alerts === 0 && /⚠️/.test(repo.msg), JSON.stringify(repo));
73+await ctx.close();
74+
75+// 4 · desde una notificación
76+({ ctx, p } = await abre('es-ES', '&notif=open'));
77+await p.waitForSelector('#mind-overlay', { timeout: 45000 }).catch(() => {});
78+const notif = await p.evaluate(() => ({ mente: !!document.getElementById('mind-overlay') && getComputedStyle(document.getElementById('mind-overlay')).display !== 'none', url: location.search }));
79+ok('4 · ?notif=open abre la Mente y limpia la URL', notif.mente && !/notif/.test(notif.url), JSON.stringify(notif));
80+await ctx.close();
81+
82+// 5 · en inglés
83+({ ctx, p } = await abre('en-US'));
84+await p.click('#btn-settings');
85+await p.waitForTimeout(400);
86+const en = await p.evaluate(() => ({
87+ enviar: document.getElementById('btn-send').title,
88+ limpiar: document.getElementById('term-clear').textContent,
89+ menus: [...document.querySelectorAll('#menubar button')].map(b => b.textContent).join(','),
90+ goal: document.querySelector('#perm-goalmode').closest('label').textContent.trim(),
91+ tel: document.querySelector('#tel-enabled').closest('label').textContent.trim(),
92+ enviarFeedback: document.getElementById('tel-send').textContent,
93+}));
94+ok('5 · en inglés, nada de lo de antes sale en español', en.enviar === 'Send' && en.limpiar === 'clear' && en.menus === 'File,Edit,View,Git' && /^Treat the next message/.test(en.goal) && /^Automatically send/.test(en.tel) && en.enviarFeedback === 'Send', JSON.stringify(en));
95+await ctx.close();
96+
97+console.log('\n errores JS:', errs[0] || 'ninguno');
98+ok('sin errores de página', errs.length === 0, errs.join(' | '));
99+console.log(fails ? `\n❌ ${fails} FALLO(S)` : '\n✅ AVISOS QUE SE ENTIENDEN, EN SU IDIOMA');
100+await b.close();
101+process.exit(fails ? 1 : 0);
modified web/css/code.css +4 −0
@@ -289,6 +289,10 @@
289289 #model-progress span { font-size: .82rem; color: var(--fg); }
290290 #model-progress .track { height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; }
291291 #model-bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent2)); transition: width .25s; }
292+#model-progress .mp-acciones { display: flex; gap: 6px; }
293+#model-progress .mp-acciones button { background: var(--bg2); color: var(--fg); border: 1px solid var(--line); border-radius: 7px; padding: 4px 10px; font: inherit; font-size: .78rem; cursor: pointer; }
294+.sk-msg { font-size: .74rem; }
295+.sk-msg.err { color: #ff8fb0; }
292296
293297 /* ---------- chat ---------- */
294298 #chat { display: flex; flex-direction: column; border-left: 1px solid var(--line); background: var(--bg2); min-height: 0; }
modified web/index.html +2 −2
@@ -114,7 +114,7 @@
114114 <div id="term-head">
115115 <span class="term-title">TERMINAL</span>
116116 <span id="term-caps"></span>
117- <button id="term-clear" class="term-btn" title="limpiar">limpiar</button>
117+ <button id="term-clear" class="term-btn" title="limpiar la pantalla del terminal">limpiar</button>
118118 <button id="term-close" class="term-btn" title="cerrar (Ctrl+`)">✕</button>
119119 </div>
120120 <div id="terminal-host"></div>
@@ -154,7 +154,7 @@
154154
155155 <button id="code-flip" title="cambiar entre chat y editor"></button>
156156
157-<div id="model-progress" hidden>
157+<div id="model-progress" role="status" aria-live="polite" hidden>
158158 <img src="img/elffuss-code.svg" alt="">
159159 <div class="mp-body">
160160 <span id="model-progress-text">Preparando el cerebro local…</span>
modified web/js/i18n.js +32 −0
@@ -207,6 +207,21 @@
207207 ctxFull: "Contexto casi lleno ({pct}%). Los mensajes viejos se comprimen solos; para empezar limpio, abre una conversación nueva con «+».",
208208 ctxUse: "Contexto: {tok} de ~{max} tokens ({free}% libre)",
209209 openPathTitle: "abrir {path} en el editor", proposalSent: "▶ enviado a la cola…",
210+ retry: "Reintentar",
211+ modelLoadFailed: "⚠️ No pude cargar el modelo: {e}",
212+ errNet: "no se pudo descargar (¿sin conexión, o un bloqueador?)", errGpu: "este navegador no da acceso a una GPU (WebGPU); prueba el modelo ligero o el modo Básico",
213+ errQuota: "no queda espacio en el navegador para guardarlo (libera con 💾)", errMem: "no cabe en la memoria de esta máquina; prueba uno más pequeño", errUnknown: "error desconocido",
214+ skTitle: "🧩 Skills de Claude Code", skIntro: "Instala instrucciones especializadas (formato SKILL.md) desde repos públicos. Todo se guarda en tu navegador. Se ve el repo y lo que se inyecta.",
215+ skInstalled: "Instaladas ({n})", skNone: "Ninguna todavía.", skCatalogs: "Catálogos (repos)", skRemoveNamed: "Quitar {name}", skRemoveRepo: "Quitar el catálogo {repo}",
216+ skLoading: "Cargando {repo}…", skFound: "{repo} — {n} skills", skInstall: "Instalar", skInstalledOne: "Instalada ✓",
217+ skNoNet: "No pude consultar {repo}: sin conexión con GitHub (o límite de peticiones). Prueba otra vez en un momento.", skLoadFailed: "No pude listar {repo}: {e}",
218+ setGoalLabel: "Tratar el próximo mensaje como un objetivo: lo descompone en tareas y las ejecuta una a una",
219+ setGoalNote: "Igual que 🎯 Goal en «Modos»: un planificador crea la lista de tareas y un ejecutor las va cumpliendo, marcando cada una como hecha o fallida (si una falla, las siguientes se saltan en vez de seguir a ciegas).",
220+ setTelAuto: "Enviar automáticamente los errores técnicos que ocurran, para poder arreglarlos",
221+ setTelNote: "Apagado por defecto — tu código y el contenido de tus proyectos NUNCA se incluyen, solo el mensaje de error técnico, la pila y datos del navegador.",
222+ setTelManual: "O manda algo tú directamente (un fallo que viste, algo que eches en falta…)",
223+ viewBuilding: "Construyendo…", viewFailed: "No pude construir la vista: {e}", flipChat: "Chat", flipEditor: "Editor",
224+ termClear: "limpiar", tTermClear: "limpiar la pantalla del terminal",
210225 clearModelsConfirm: "Vas a borrar {size} de modelos guardados en este navegador.\n\nNo se pierde nada tuyo: solo los pesos descargados. La próxima vez habrá que bajarlos otra vez.\n\n¿Seguir?",
211226 clearModelsShared: "Ojo: el almacén compartido de Elffuss no se pudo consultar desde aquí; puede quedar algo guardado ahí.",
212227 clearModelsDone: "💾 Liberados {size}.", clearModelsFailed: "No se pudo vaciar: {what}.",
@@ -415,6 +430,21 @@
415430 ctxFull: "Context almost full ({pct}%). Old messages are compressed automatically; to start clean, open a new conversation with “+”.",
416431 ctxUse: "Context: {tok} of ~{max} tokens ({free}% free)",
417432 openPathTitle: "open {path} in the editor", proposalSent: "▶ sent to the queue…",
433+ retry: "Retry",
434+ modelLoadFailed: "⚠️ Couldn't load the model: {e}",
435+ errNet: "it couldn't be downloaded (offline, or a blocker?)", errGpu: "this browser gives no access to a GPU (WebGPU); try the light model or Basic mode",
436+ errQuota: "there is no room left in the browser to store it (free some with 💾)", errMem: "it doesn't fit in this machine's memory; try a smaller one", errUnknown: "unknown error",
437+ skTitle: "🧩 Claude Code skills", skIntro: "Install specialised instructions (SKILL.md format) from public repos. Everything is stored in your browser. You can see the repo and what gets injected.",
438+ skInstalled: "Installed ({n})", skNone: "None yet.", skCatalogs: "Catalogs (repos)", skRemoveNamed: "Remove {name}", skRemoveRepo: "Remove the {repo} catalog",
439+ skLoading: "Loading {repo}…", skFound: "{repo} — {n} skills", skInstall: "Install", skInstalledOne: "Installed ✓",
440+ skNoNet: "Couldn't reach {repo}: no connection to GitHub (or rate limited). Try again in a moment.", skLoadFailed: "Couldn't list {repo}: {e}",
441+ setGoalLabel: "Treat the next message as a goal: break it into tasks and run them one by one",
442+ setGoalNote: "Same as 🎯 Goal under “Modes”: a planner writes the task list and an executor works through it, marking each one done or failed (if one fails, the next ones are skipped instead of carrying on blindly).",
443+ setTelAuto: "Automatically send technical errors when they happen, so they can be fixed",
444+ setTelNote: "Off by default — your code and your projects' content are NEVER included, only the technical error message, the stack and browser data.",
445+ setTelManual: "Or send something yourself (a bug you saw, something you miss…)",
446+ viewBuilding: "Building…", viewFailed: "Couldn't build the view: {e}", flipChat: "Chat", flipEditor: "Editor",
447+ termClear: "clear", tTermClear: "clear the terminal screen",
418448 clearModelsConfirm: "You are about to delete {size} of models stored in this browser.\n\nNothing of yours is lost: only the downloaded weights. Next time they will be downloaded again.\n\nContinue?",
419449 clearModelsShared: "Note: Elffuss's shared store could not be checked from here; something may remain stored there.",
420450 clearModelsDone: "💾 Freed {size}.", clearModelsFailed: "Couldn't clear: {what}.",
@@ -450,6 +480,7 @@
450480 set('#clone-btn', 'textContent', 'cloneOpen');
451481 set('#clone-url', 'placeholder', 'clonePh');
452482 set('#try-browser', 'textContent', 'tryBrowser');
483+ set('#term-clear', 'textContent', 'termClear');
453484 set('#pal-input', 'placeholder', 'searchPh');
454485 const titles = {
455486 '#act-files': 'tFiles', '#act-search': 'tSearch', '#act-arch': 'tArch', '#act-city': 'tCity',
@@ -459,6 +490,7 @@
459490 '#btn-plus': 'tPlus', '#btn-autoedit': 'tAutoedit', '#btn-goal': 'tGoal',
460491 '#btn-hardwork': 'tHardwork',
461492 '#code-flip': 'tFlip', '#btn-slash': 'tSlash', '#btn-send': 'send',
493+ '#term-clear': 'tTermClear',
462494 };
463495 for (const [sel, key] of Object.entries(titles)) set(sel, 'title', key);
464496 }
modified web/js/main.js +94 −39
@@ -719,12 +719,24 @@
719719 sel.value = activeModel;
720720 }
721721
722-// progreso del modelo: píldora prominente visible sobre landing e IDE
723-function showModelProgress(text, pct = null) {
722+// progreso del modelo: píldora prominente visible sobre landing e IDE.
723+// Es una región viva (role=status en el HTML). Con `reintentar`, un fallo deja
724+// un botón para volver a intentarlo y otro para cerrar, y no se esconde solo.
725+function showModelProgress(text, pct = null, { reintentar = null } = {}) {
724726 const box = $('model-progress');
727+ box.querySelector('.mp-acciones')?.remove();
725728 if (text == null) { box.hidden = true; return; }
726729 box.hidden = false;
727730 $('model-progress-text').textContent = text;
731+ if (reintentar) {
732+ const acc = document.createElement('div'); acc.className = 'mp-acciones';
733+ const r = document.createElement('button'); r.type = 'button'; r.textContent = t('retry');
734+ r.onclick = () => { acc.remove(); reintentar(); };
735+ const x = document.createElement('button'); x.type = 'button'; x.textContent = '✕'; x.setAttribute('aria-label', t('close'));
736+ x.onclick = () => showModelProgress(null);
737+ acc.append(r, x);
738+ box.querySelector('.mp-body').appendChild(acc);
739+ }
728740 const bar = $('model-bar');
729741 if (pct == null) {
730742 bar.classList.add('indet'); // sin % conocido → barra animada
@@ -748,6 +760,15 @@
748760 d.setAttribute('aria-label', txt);
749761 }
750762
763+function errorHumano(e) {
764+ const m = String(e?.message || e || '');
765+ if (/Failed to fetch|NetworkError|network|ERR_/i.test(m)) return t('errNet');
766+ if (/adaptador WebGPU|No available adapters|webgpu|requestAdapter/i.test(m)) return t('errGpu');
767+ if (/quota|QuotaExceeded/i.test(m)) return t('errQuota');
768+ if (/out of memory|memory|OOM|Aborted/i.test(m)) return t('errMem');
769+ return m || t('errUnknown');
770+}
771+
751772 let loadingId = null;
752773 async function changeModel(id) {
753774 if (id === 'rules') {
@@ -813,8 +834,10 @@
813834 conv.setProvider(rules);
814835 activeModel = 'rules';
815836 pintaDot('error', id);
816- showModelProgress('⚠️ No pude cargar el modelo: ' + (e?.message || e));
817- setTimeout(() => showModelProgress(null), 6000);
837+ // En palabras de persona («sin conexión», «sin GPU», «sin espacio»…), con
838+ // el detalle técnico en la consola, y un botón para reintentar.
839+ showModelProgress(t('modelLoadFailed', { e: errorHumano(e) }), null, { reintentar: () => changeModel(id) });
840+ $('model-bar').classList.remove('indet');
818841 rebuildSelect();
819842 return false;
820843 } finally {
@@ -1180,9 +1203,9 @@
11801203 goalCard.innerHTML =
11811204 `<label style="display:flex;align-items:center;gap:8px;cursor:pointer">` +
11821205 `<input type="checkbox" id="perm-goalmode"> ` +
1183- `<span>Tratar el próximo mensaje como un objetivo: lo descompone en tareas y las ejecuta una a una</span>` +
1206+ `<span>${escapeHtml(t('setGoalLabel'))}</span>` +
11841207 `</label>` +
1185- `<p class="muted" style="font-size:.7rem;margin:6px 0 0">Igual que el botón 🎯 Goal de la barra — un planificador crea la lista de tareas y un ejecutor las va cumpliendo, marcando cada una como hecha o fallida (si una falla, las siguientes se saltan en vez de seguir a ciegas).</p>`;
1208+ `<p class="muted" style="font-size:.7rem;margin:6px 0 0">${escapeHtml(t('setGoalNote'))}</p>`;
11861209 box.appendChild(goalCard);
11871210 const goalCheckbox = goalCard.querySelector('#perm-goalmode');
11881211 goalCheckbox.checked = goalMode;
@@ -1198,10 +1221,10 @@
11981221 telCard.innerHTML =
11991222 `<label style="display:flex;align-items:center;gap:8px;cursor:pointer">` +
12001223 `<input type="checkbox" id="tel-enabled"> ` +
1201- `<span>Enviar automáticamente los errores técnicos que ocurran, para poder arreglarlos</span>` +
1224+ `<span>${escapeHtml(t('setTelAuto'))}</span>` +
12021225 `</label>` +
1203- `<p class="muted" style="font-size:.7rem;margin:6px 0 10px">Apagado por defecto — tu código y el contenido de tus proyectos NUNCA se incluyen, solo el mensaje de error técnico, la pila y datos del navegador.</p>` +
1204- `<label class="muted" style="font-size:.68rem">O manda algo tú directamente (un fallo que viste, algo que eches en falta…)</label>` +
1226+ `<p class="muted" style="font-size:.7rem;margin:6px 0 10px">${escapeHtml(t('setTelNote'))}</p>` +
1227+ `<label for="tel-feedback" class="muted" style="font-size:.68rem">${escapeHtml(t('setTelManual'))}</label>` +
12051228 `<textarea id="tel-feedback" rows="2" style="width:100%;margin-top:4px;resize:vertical;background:var(--bg2);border:1px solid var(--line);border-radius:8px;color:var(--fg);padding:6px 8px;font:inherit" placeholder="${t('setFeedbackPh')}"></textarea>` +
12061229 `<button id="tel-send" class="prov-use" style="margin-top:6px">${escapeHtml(t('setTelSend'))}</button>` +
12071230 `<span id="tel-msg" class="muted" role="status" aria-live="polite" style="font-size:.7rem;margin-left:8px"></span>`;
@@ -1293,6 +1316,16 @@
12931316 renderActiveLog();
12941317 addMsg('sys', t('welcome', { name }));
12951318 abreDesdeHash();
1319+ // Abierto desde una notificación con la app cerrada (sw.js → ?notif=…):
1320+ // la propuesta está en la Mente, que se abre ya con el proyecto cargado.
1321+ try {
1322+ const u = new URL(location.href);
1323+ if (u.searchParams.has('notif')) {
1324+ u.searchParams.delete('notif');
1325+ history.replaceState(null, '', u.pathname + u.search + u.hash);
1326+ mind.openMind();
1327+ }
1328+ } catch { /* — */ }
12961329 refreshGit();
12971330 preloadModel(); // por si el arranque en la landing no llegó a dispararse
12981331 }
@@ -1577,7 +1610,8 @@
15771610 // nueva no cargaba bien). Ambas, no solo la del mismo tipo.
15781611 try { (await import('./city.js')).disposeCity(); } catch { /* */ }
15791612 try { (await import('./arch.js')).disposeArch(); } catch { /* */ }
1580- body.innerHTML = '<div class="view-loading">Construyendo…</div>';
1613+ body.innerHTML = '<div class="view-loading" role="status"></div>';
1614+ body.firstChild.textContent = t('viewBuilding');
15811615 overlay.hidden = false;
15821616 document.querySelectorAll('#activity button').forEach(b => b.classList.toggle('on', b.id === 'act-' + kind));
15831617 // esperar a que el layout dé tamaño real al overlay (si no, canvas 0×0/mal aspect)
@@ -1586,7 +1620,7 @@
15861620 try {
15871621 if (kind === 'arch') { const m = await import('./arch.js'); await m.renderArchitecture(body, p => { closeView(); openFile(p); }); }
15881622 else { const m = await import('./city.js'); await m.renderCity(body, p => { closeView(); openFile(p); }); }
1589- } catch (e) { body.innerHTML = '<div class="view-loading">No pude construir la vista: ' + (e?.message || e) + '</div>'; }
1623+ } catch (e) { body.innerHTML = '<div class="view-loading" role="status"></div>'; body.firstChild.textContent = t('viewFailed', { e: e?.message || e }); }
15901624 }
15911625 function closeView({ foco = false } = {}) {
15921626 const abierta = [...document.querySelectorAll('#act-arch.on, #act-city.on')][0];
@@ -1811,7 +1845,7 @@
18111845 $('btn-send').innerHTML = UI.send;
18121846 $('btn-plus').innerHTML = UI.add;
18131847 $('btn-slash').innerHTML = UI.slash;
1814-const paintFlip = editor => { $('code-flip').innerHTML = (editor ? UI.chat : UI.editor) + `<span>${editor ? 'Chat' : 'Editor'}</span>`; };
1848+const paintFlip = editor => { $('code-flip').innerHTML = (editor ? UI.chat : UI.editor) + `<span>${editor ? t('flipChat') : t('flipEditor')}</span>`; };
18151849 paintFlip(false);
18161850
18171851 // barra de actividad estilo VS Code
@@ -2256,46 +2290,48 @@
22562290 };
22572291
22582292 // ---------- panel de skills (transparente: repo + lista + SKILL.md) ----------
2293+// Mismo diálogo que Ajustes. Los fallos se dicen DENTRO del panel, en palabras
2294+// de persona y con «Reintentar» (antes: «⚠️ FAILED TO FETCH» en mayúsculas, y
2295+// un alert() del navegador al añadir un repo que no valía o al instalar).
22592296 async function openSkillsPanel() {
2260- const box = $('settings-panel');
2261- box.hidden = false;
2262- box.replaceChildren();
2263- const close = document.createElement('button');
2264- close.id = 'settings-close'; close.textContent = '✕'; close.onclick = () => { box.hidden = true; };
2265- box.appendChild(close);
2266-
2297+ const box = settingsShell(t('skTitle'));
22672298 const wrap = document.createElement('div');
22682299 wrap.className = 'skills-panel';
2269- wrap.innerHTML = `<h3>🧩 Skills de Claude Code</h3>
2270- <p class="muted">Instala instrucciones especializadas (formato SKILL.md) desde repos públicos.
2271- Todo se guarda en tu navegador. Se ve el repo y lo que se inyecta.</p>`;
2300+ const intro = document.createElement('p');
2301+ intro.className = 'muted';
2302+ intro.textContent = t('skIntro');
2303+ wrap.appendChild(intro);
22722304 box.appendChild(wrap);
22732305
22742306 // instaladas
22752307 const inst = skills.installed();
22762308 const instBox = document.createElement('div');
2277- instBox.innerHTML = `<div class="sk-h">Instaladas (${inst.length})</div>`;
2309+ instBox.append(el('div', 'sk-h', t('skInstalled', { n: inst.length })));
22782310 for (const s of inst) {
22792311 const row = document.createElement('div');
22802312 row.className = 'sk-row';
2281- row.innerHTML = `<b>${s.name}</b><span class="muted">${s.repo || 'local'}</span>`;
2313+ row.append(el('b', null, s.name), el('span', 'muted', s.repo || 'local'));
22822314 const rm = document.createElement('button');
22832315 rm.className = 'ghost'; rm.textContent = t("skRemove");
2316+ rm.setAttribute('aria-label', t('skRemoveNamed', { name: s.name }));
22842317 rm.onclick = async () => { await skills.remove(s.name); openSkillsPanel(); };
22852318 row.appendChild(rm);
22862319 instBox.appendChild(row);
22872320 }
2288- if (!inst.length) instBox.innerHTML += '<p class="muted">Ninguna todavía.</p>';
2321+ if (!inst.length) instBox.append(el('p', 'muted', t('skNone')));
22892322 box.appendChild(instBox);
22902323
22912324 // fuentes + añadir repo
22922325 const srcs = await skills.sources();
22932326 const srcBox = document.createElement('div');
2294- srcBox.innerHTML = `<div class="sk-h">Catálogos (repos)</div>`;
2327+ srcBox.append(el('div', 'sk-h', t('skCatalogs')));
22952328 for (const s of srcs) {
22962329 const row = document.createElement('div');
22972330 row.className = 'sk-row';
2298- row.innerHTML = `<b>${s.label}</b><a href="https://github.com/${s.repo}" target="_blank" rel="noopener">${s.repo} ↗</a>`;
2331+ const a = document.createElement('a');
2332+ a.href = `https://github.com/${s.repo}`; a.target = '_blank'; a.rel = 'noopener noreferrer';
2333+ a.textContent = s.repo + ' ↗';
2334+ row.append(el('b', null, s.label), a);
22992335 const browse = document.createElement('button');
23002336 browse.className = 'primary'; browse.textContent = t("skBrowse");
23012337 browse.onclick = () => browseRepo(s.repo, box);
@@ -2303,6 +2339,7 @@
23032339 if (!s.official) {
23042340 const rm = document.createElement('button');
23052341 rm.className = 'ghost'; rm.textContent = '🗑';
2342+ rm.setAttribute('aria-label', t('skRemoveRepo', { repo: s.repo }));
23062343 rm.onclick = async () => { await skills.removeSource(s.repo); openSkillsPanel(); };
23072344 row.appendChild(rm);
23082345 }
@@ -2312,46 +2349,64 @@
23122349 addRow.className = 'sk-row';
23132350 const inp = document.createElement('input');
23142351 inp.placeholder = t("skAddRepoPh");
2352+ inp.setAttribute('aria-label', t('skAddRepo'));
23152353 const add = document.createElement('button');
23162354 add.className = 'primary'; add.textContent = t("skAddRepo");
2355+ const addMsg2 = el('div', 'muted sk-msg'); addMsg2.setAttribute('role', 'status');
23172356 add.onclick = async () => {
2357+ addMsg2.textContent = '';
23182358 try { await skills.addSource(inp.value); openSkillsPanel(); }
2319- catch (e) { alert(e.message); }
2359+ catch (e) { addMsg2.textContent = '⚠️ ' + (e?.message || e); addMsg2.classList.add('err'); inp.focus(); }
23202360 };
2361+ inp.addEventListener('keydown', e => { if (e.key === 'Enter') add.click(); });
23212362 addRow.append(inp, add);
2322- srcBox.appendChild(addRow);
2363+ srcBox.append(addRow, addMsg2);
23232364 box.appendChild(srcBox);
23242365 }
23252366
23262367 async function browseRepo(repo, box) {
2368+ box.querySelector(`.sk-browse[data-repo="${CSS.escape(repo)}"]`)?.remove();
23272369 const list = document.createElement('div');
2328- list.innerHTML = `<div class="sk-h">Cargando ${repo}…</div>`;
2370+ list.className = 'sk-browse';
2371+ list.dataset.repo = repo;
2372+ list.setAttribute('aria-live', 'polite');
2373+ list.append(el('div', 'sk-h', t('skLoading', { repo })));
23292374 box.appendChild(list);
23302375 try {
23312376 const found = await skills.listFromRepo(repo);
2332- list.innerHTML = `<div class="sk-h">${repo} — ${found.length} skills</div>`;
2377+ list.replaceChildren(el('div', 'sk-h', t('skFound', { repo, n: found.length })));
23332378 for (const sk of found.slice(0, 120)) {
23342379 const row = document.createElement('div');
23352380 row.className = 'sk-row';
2336- row.innerHTML = `<b>${sk.name}</b><span class="muted">${sk.dir}</span>`;
2381+ row.append(el('b', null, sk.name), el('span', 'muted', sk.dir));
23372382 const btn = document.createElement('button');
23382383 const on = skills.isInstalled(sk.repo, sk.path);
23392384 btn.className = on ? 'ghost' : 'primary';
2340- btn.textContent = on ? 'Instalada ✓' : 'Instalar';
2385+ btn.textContent = on ? t('skInstalledOne') : t('skInstall');
2386+ btn.setAttribute('aria-label', (on ? t('skInstalledOne') : t('skInstall')) + ': ' + sk.name);
23412387 btn.onclick = async () => {
2342- btn.textContent = '…';
2388+ btn.textContent = '…'; btn.disabled = true;
23432389 try {
23442390 const entry = await skills.installFromRepo(sk);
2345- btn.textContent = 'Instalada ✓'; btn.className = 'ghost';
2346- $('settings-panel').hidden = true; // cierra el panel
2347- addMsg('assistant', skills.usageMessage(entry)); // «cómo usarla» en el chat
2348- } catch (e) { btn.textContent = 'Instalar'; alert(e.message); }
2391+ btn.textContent = t('skInstalledOne'); btn.className = 'ghost';
2392+ cierraAjustes(); // cierra el panel
2393+ addMsg('assistant', skills.usageMessage(entry)); // «cómo usarla» en el chat
2394+ } catch (e) {
2395+ btn.textContent = t('skInstall'); btn.disabled = false;
2396+ row.append(el('span', 'muted sk-msg err', '⚠️ ' + (e?.message || e)));
2397+ }
23492398 };
23502399 row.appendChild(btn);
23512400 list.appendChild(row);
23522401 }
23532402 } catch (e) {
2354- list.innerHTML = `<div class="sk-h">⚠️ ${e.message}</div>`;
2403+ const msg = /Failed to fetch|NetworkError|network/i.test(String(e?.message)) ? t('skNoNet', { repo }) : t('skLoadFailed', { repo, e: e?.message || e });
2404+ const retry = document.createElement('button');
2405+ retry.className = 'primary'; retry.textContent = t('retry');
2406+ retry.onclick = () => browseRepo(repo, box);
2407+ const fila = el('div', 'sk-row');
2408+ fila.append(el('span', 'sk-msg err', '⚠️ ' + msg), retry);
2409+ list.replaceChildren(el('div', 'sk-h', repo), fila);
23552410 }
23562411 }
23572412