utopia-ia/elffuss-code public
Changesets · Branches · Tags · Compare
| Changeset | 27f8f5c38db4620bd9e9850c472f1b2c4afdfc5f9335073b64a67624760c0649 |
|---|---|
| Author | KikoCis <kikocisneros@gmail.com> · 2026-10-10 16:44 +02:00 |
| Committer | KikoCis <kikocisneros@gmail.com> · 2026-10-11 14:15 +02:00 |
| Parents | 7aca986db587 |
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', '¬if=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 @@ | ||
| 289 | 289 | #model-progress span { font-size: .82rem; color: var(--fg); } |
| 290 | 290 | #model-progress .track { height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; } |
| 291 | 291 | #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; } | |
| 292 | 296 | |
| 293 | 297 | /* ---------- chat ---------- */ |
| 294 | 298 | #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 @@ | ||
| 114 | 114 | <div id="term-head"> |
| 115 | 115 | <span class="term-title">TERMINAL</span> |
| 116 | 116 | <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> | |
| 118 | 118 | <button id="term-close" class="term-btn" title="cerrar (Ctrl+`)">✕</button> |
| 119 | 119 | </div> |
| 120 | 120 | <div id="terminal-host"></div> |
| @@ -154,7 +154,7 @@ | ||
| 154 | 154 | |
| 155 | 155 | <button id="code-flip" title="cambiar entre chat y editor"></button> |
| 156 | 156 | |
| 157 | -<div id="model-progress" hidden> | |
| 157 | +<div id="model-progress" role="status" aria-live="polite" hidden> | |
| 158 | 158 | <img src="img/elffuss-code.svg" alt=""> |
| 159 | 159 | <div class="mp-body"> |
| 160 | 160 | <span id="model-progress-text">Preparando el cerebro local…</span> |
modified web/js/i18n.js +32 −0
| @@ -207,6 +207,21 @@ | ||
| 207 | 207 | ctxFull: "Contexto casi lleno ({pct}%). Los mensajes viejos se comprimen solos; para empezar limpio, abre una conversación nueva con «+».", |
| 208 | 208 | ctxUse: "Contexto: {tok} de ~{max} tokens ({free}% libre)", |
| 209 | 209 | 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", | |
| 210 | 225 | 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?", |
| 211 | 226 | clearModelsShared: "Ojo: el almacén compartido de Elffuss no se pudo consultar desde aquí; puede quedar algo guardado ahí.", |
| 212 | 227 | clearModelsDone: "💾 Liberados {size}.", clearModelsFailed: "No se pudo vaciar: {what}.", |
| @@ -415,6 +430,21 @@ | ||
| 415 | 430 | ctxFull: "Context almost full ({pct}%). Old messages are compressed automatically; to start clean, open a new conversation with “+”.", |
| 416 | 431 | ctxUse: "Context: {tok} of ~{max} tokens ({free}% free)", |
| 417 | 432 | 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", | |
| 418 | 448 | 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?", |
| 419 | 449 | clearModelsShared: "Note: Elffuss's shared store could not be checked from here; something may remain stored there.", |
| 420 | 450 | clearModelsDone: "💾 Freed {size}.", clearModelsFailed: "Couldn't clear: {what}.", |
| @@ -450,6 +480,7 @@ | ||
| 450 | 480 | set('#clone-btn', 'textContent', 'cloneOpen'); |
| 451 | 481 | set('#clone-url', 'placeholder', 'clonePh'); |
| 452 | 482 | set('#try-browser', 'textContent', 'tryBrowser'); |
| 483 | + set('#term-clear', 'textContent', 'termClear'); | |
| 453 | 484 | set('#pal-input', 'placeholder', 'searchPh'); |
| 454 | 485 | const titles = { |
| 455 | 486 | '#act-files': 'tFiles', '#act-search': 'tSearch', '#act-arch': 'tArch', '#act-city': 'tCity', |
| @@ -459,6 +490,7 @@ | ||
| 459 | 490 | '#btn-plus': 'tPlus', '#btn-autoedit': 'tAutoedit', '#btn-goal': 'tGoal', |
| 460 | 491 | '#btn-hardwork': 'tHardwork', |
| 461 | 492 | '#code-flip': 'tFlip', '#btn-slash': 'tSlash', '#btn-send': 'send', |
| 493 | + '#term-clear': 'tTermClear', | |
| 462 | 494 | }; |
| 463 | 495 | for (const [sel, key] of Object.entries(titles)) set(sel, 'title', key); |
| 464 | 496 | } |
modified web/js/main.js +94 −39
| @@ -719,12 +719,24 @@ | ||
| 719 | 719 | sel.value = activeModel; |
| 720 | 720 | } |
| 721 | 721 | |
| 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 } = {}) { | |
| 724 | 726 | const box = $('model-progress'); |
| 727 | + box.querySelector('.mp-acciones')?.remove(); | |
| 725 | 728 | if (text == null) { box.hidden = true; return; } |
| 726 | 729 | box.hidden = false; |
| 727 | 730 | $('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 | + } | |
| 728 | 740 | const bar = $('model-bar'); |
| 729 | 741 | if (pct == null) { |
| 730 | 742 | bar.classList.add('indet'); // sin % conocido → barra animada |
| @@ -748,6 +760,15 @@ | ||
| 748 | 760 | d.setAttribute('aria-label', txt); |
| 749 | 761 | } |
| 750 | 762 | |
| 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 | + | |
| 751 | 772 | let loadingId = null; |
| 752 | 773 | async function changeModel(id) { |
| 753 | 774 | if (id === 'rules') { |
| @@ -813,8 +834,10 @@ | ||
| 813 | 834 | conv.setProvider(rules); |
| 814 | 835 | activeModel = 'rules'; |
| 815 | 836 | 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'); | |
| 818 | 841 | rebuildSelect(); |
| 819 | 842 | return false; |
| 820 | 843 | } finally { |
| @@ -1180,9 +1203,9 @@ | ||
| 1180 | 1203 | goalCard.innerHTML = |
| 1181 | 1204 | `<label style="display:flex;align-items:center;gap:8px;cursor:pointer">` + |
| 1182 | 1205 | `<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>` + | |
| 1184 | 1207 | `</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>`; | |
| 1186 | 1209 | box.appendChild(goalCard); |
| 1187 | 1210 | const goalCheckbox = goalCard.querySelector('#perm-goalmode'); |
| 1188 | 1211 | goalCheckbox.checked = goalMode; |
| @@ -1198,10 +1221,10 @@ | ||
| 1198 | 1221 | telCard.innerHTML = |
| 1199 | 1222 | `<label style="display:flex;align-items:center;gap:8px;cursor:pointer">` + |
| 1200 | 1223 | `<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>` + | |
| 1202 | 1225 | `</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>` + | |
| 1205 | 1228 | `<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>` + |
| 1206 | 1229 | `<button id="tel-send" class="prov-use" style="margin-top:6px">${escapeHtml(t('setTelSend'))}</button>` + |
| 1207 | 1230 | `<span id="tel-msg" class="muted" role="status" aria-live="polite" style="font-size:.7rem;margin-left:8px"></span>`; |
| @@ -1293,6 +1316,16 @@ | ||
| 1293 | 1316 | renderActiveLog(); |
| 1294 | 1317 | addMsg('sys', t('welcome', { name })); |
| 1295 | 1318 | 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 { /* — */ } | |
| 1296 | 1329 | refreshGit(); |
| 1297 | 1330 | preloadModel(); // por si el arranque en la landing no llegó a dispararse |
| 1298 | 1331 | } |
| @@ -1577,7 +1610,8 @@ | ||
| 1577 | 1610 | // nueva no cargaba bien). Ambas, no solo la del mismo tipo. |
| 1578 | 1611 | try { (await import('./city.js')).disposeCity(); } catch { /* */ } |
| 1579 | 1612 | 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'); | |
| 1581 | 1615 | overlay.hidden = false; |
| 1582 | 1616 | document.querySelectorAll('#activity button').forEach(b => b.classList.toggle('on', b.id === 'act-' + kind)); |
| 1583 | 1617 | // esperar a que el layout dé tamaño real al overlay (si no, canvas 0×0/mal aspect) |
| @@ -1586,7 +1620,7 @@ | ||
| 1586 | 1620 | try { |
| 1587 | 1621 | if (kind === 'arch') { const m = await import('./arch.js'); await m.renderArchitecture(body, p => { closeView(); openFile(p); }); } |
| 1588 | 1622 | 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 }); } | |
| 1590 | 1624 | } |
| 1591 | 1625 | function closeView({ foco = false } = {}) { |
| 1592 | 1626 | const abierta = [...document.querySelectorAll('#act-arch.on, #act-city.on')][0]; |
| @@ -1811,7 +1845,7 @@ | ||
| 1811 | 1845 | $('btn-send').innerHTML = UI.send; |
| 1812 | 1846 | $('btn-plus').innerHTML = UI.add; |
| 1813 | 1847 | $('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>`; }; | |
| 1815 | 1849 | paintFlip(false); |
| 1816 | 1850 | |
| 1817 | 1851 | // barra de actividad estilo VS Code |
| @@ -2256,46 +2290,48 @@ | ||
| 2256 | 2290 | }; |
| 2257 | 2291 | |
| 2258 | 2292 | // ---------- 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). | |
| 2259 | 2296 | 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')); | |
| 2267 | 2298 | const wrap = document.createElement('div'); |
| 2268 | 2299 | 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); | |
| 2272 | 2304 | box.appendChild(wrap); |
| 2273 | 2305 | |
| 2274 | 2306 | // instaladas |
| 2275 | 2307 | const inst = skills.installed(); |
| 2276 | 2308 | 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 }))); | |
| 2278 | 2310 | for (const s of inst) { |
| 2279 | 2311 | const row = document.createElement('div'); |
| 2280 | 2312 | 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')); | |
| 2282 | 2314 | const rm = document.createElement('button'); |
| 2283 | 2315 | rm.className = 'ghost'; rm.textContent = t("skRemove"); |
| 2316 | + rm.setAttribute('aria-label', t('skRemoveNamed', { name: s.name })); | |
| 2284 | 2317 | rm.onclick = async () => { await skills.remove(s.name); openSkillsPanel(); }; |
| 2285 | 2318 | row.appendChild(rm); |
| 2286 | 2319 | instBox.appendChild(row); |
| 2287 | 2320 | } |
| 2288 | - if (!inst.length) instBox.innerHTML += '<p class="muted">Ninguna todavía.</p>'; | |
| 2321 | + if (!inst.length) instBox.append(el('p', 'muted', t('skNone'))); | |
| 2289 | 2322 | box.appendChild(instBox); |
| 2290 | 2323 | |
| 2291 | 2324 | // fuentes + añadir repo |
| 2292 | 2325 | const srcs = await skills.sources(); |
| 2293 | 2326 | 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'))); | |
| 2295 | 2328 | for (const s of srcs) { |
| 2296 | 2329 | const row = document.createElement('div'); |
| 2297 | 2330 | 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); | |
| 2299 | 2335 | const browse = document.createElement('button'); |
| 2300 | 2336 | browse.className = 'primary'; browse.textContent = t("skBrowse"); |
| 2301 | 2337 | browse.onclick = () => browseRepo(s.repo, box); |
| @@ -2303,6 +2339,7 @@ | ||
| 2303 | 2339 | if (!s.official) { |
| 2304 | 2340 | const rm = document.createElement('button'); |
| 2305 | 2341 | rm.className = 'ghost'; rm.textContent = '🗑'; |
| 2342 | + rm.setAttribute('aria-label', t('skRemoveRepo', { repo: s.repo })); | |
| 2306 | 2343 | rm.onclick = async () => { await skills.removeSource(s.repo); openSkillsPanel(); }; |
| 2307 | 2344 | row.appendChild(rm); |
| 2308 | 2345 | } |
| @@ -2312,46 +2349,64 @@ | ||
| 2312 | 2349 | addRow.className = 'sk-row'; |
| 2313 | 2350 | const inp = document.createElement('input'); |
| 2314 | 2351 | inp.placeholder = t("skAddRepoPh"); |
| 2352 | + inp.setAttribute('aria-label', t('skAddRepo')); | |
| 2315 | 2353 | const add = document.createElement('button'); |
| 2316 | 2354 | add.className = 'primary'; add.textContent = t("skAddRepo"); |
| 2355 | + const addMsg2 = el('div', 'muted sk-msg'); addMsg2.setAttribute('role', 'status'); | |
| 2317 | 2356 | add.onclick = async () => { |
| 2357 | + addMsg2.textContent = ''; | |
| 2318 | 2358 | 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(); } | |
| 2320 | 2360 | }; |
| 2361 | + inp.addEventListener('keydown', e => { if (e.key === 'Enter') add.click(); }); | |
| 2321 | 2362 | addRow.append(inp, add); |
| 2322 | - srcBox.appendChild(addRow); | |
| 2363 | + srcBox.append(addRow, addMsg2); | |
| 2323 | 2364 | box.appendChild(srcBox); |
| 2324 | 2365 | } |
| 2325 | 2366 | |
| 2326 | 2367 | async function browseRepo(repo, box) { |
| 2368 | + box.querySelector(`.sk-browse[data-repo="${CSS.escape(repo)}"]`)?.remove(); | |
| 2327 | 2369 | 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 }))); | |
| 2329 | 2374 | box.appendChild(list); |
| 2330 | 2375 | try { |
| 2331 | 2376 | 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 }))); | |
| 2333 | 2378 | for (const sk of found.slice(0, 120)) { |
| 2334 | 2379 | const row = document.createElement('div'); |
| 2335 | 2380 | 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)); | |
| 2337 | 2382 | const btn = document.createElement('button'); |
| 2338 | 2383 | const on = skills.isInstalled(sk.repo, sk.path); |
| 2339 | 2384 | 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); | |
| 2341 | 2387 | btn.onclick = async () => { |
| 2342 | - btn.textContent = '…'; | |
| 2388 | + btn.textContent = '…'; btn.disabled = true; | |
| 2343 | 2389 | try { |
| 2344 | 2390 | 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 | + } | |
| 2349 | 2398 | }; |
| 2350 | 2399 | row.appendChild(btn); |
| 2351 | 2400 | list.appendChild(row); |
| 2352 | 2401 | } |
| 2353 | 2402 | } 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); | |
| 2355 | 2410 | } |
| 2356 | 2411 | } |
| 2357 | 2412 |