Elffuss BraidHub

utopia-ia/elffuss-code public

English UI without Spanish leaking in: Basic-mode help and its commands, the stop note, the OPFS folder

Spanish-only strings in the English UI, and what fixing them implied.

- Basic mode answered with a Spanish help that pointed to "Ajustes ->
  Cerebro" while the English UI says "Settings -> Brain". The help now comes
  from i18n. An English help that only understood "arbol" and "lee" would lie,
  so the rules engine also understands "tree", "read/open/show <file>",
  "search/find <text>", "write <file>: <content>" and "hello"; the Spanish
  commands work as before.
- "(Parado.)" is emitted by modules that do not know the interface language
  (the agent, goal mode, the queue, Hard Work); the chat renders it as
  "(Stopped.)" in English.
- The browser's private storage folder was always "OPFS (navegador)"; main.js
  now passes the localized name to the workspace module.

tests/english-ui.mjs: in en-US the Basic help is English and points to
Settings -> Brain, "tree" and "read notes.md" run their tools, a stopped turn
says "(Stopped.)", and the adopted OPFS folder is "OPFS (browser)"; in es-ES the
help and "arbol" are unchanged.
Changesetb68cefab2bf21b3377058974468bf805a65ef0d78d43b06a837d6acba6fe7e4f
AuthorKikoCis <kikocisneros@gmail.com> · 2026-10-11 15:10 +02:00
CommitterKikoCis <kikocisneros@gmail.com> · 2026-10-11 15:10 +02:00
Parents48f115f65832

Browse the files at this changeset

5 files changed

added tests/english-ui.mjs +89 −0
@@ -0,0 +1,89 @@
1+// Con la interfaz en inglés, nada en español colado:
2+// 1. La ayuda del modo Básico (era siempre en español y mandaba a «Ajustes →
3+// Cerebro» mientras la interfaz decía «Settings → Brain»), y las órdenes
4+// en inglés que esa ayuda promete («tree», «read <file>»…) funcionan.
5+// 2. Lo que se para dice «(Stopped.)», no «(Parado.)».
6+// 3. La carpeta del almacenamiento del navegador es «OPFS (browser)».
7+// Y en español sigue todo igual.
8+//
9+// BASE=http://localhost:8799 node tests/english-ui.mjs
10+import { chromium } from 'playwright';
11+const BASE = process.env.BASE || 'http://localhost:8799';
12+let fails = 0; const ok = (n, c, e = '') => { console.log((c ? '✅' : '❌') + ' ' + n + (e ? ' — ' + e : '')); if (!c) fails++; };
13+const b = await chromium.launch();
14+const errs = [];
15+
16+async function abre(locale) {
17+ const ctx = await b.newContext({ locale });
18+ await ctx.addInitScript(() => { try { localStorage.setItem('elffusscode.model', 'rules'); } catch {} });
19+ const p = await ctx.newPage({ viewport: { width: 1400, height: 900 } });
20+ p.on('pageerror', e => errs.push(e.message.slice(0, 160)));
21+ await p.goto(BASE + '/manifest.json');
22+ await p.evaluate(async () => {
23+ const root = await navigator.storage.getDirectory();
24+ const w = await (await root.getFileHandle('notes.md', { create: true })).createWritable(); await w.write('# notes\nhello\n'); await w.close();
25+ });
26+ await p.goto(BASE + '/?test-opfs', { waitUntil: 'domcontentloaded' });
27+ await p.waitForFunction(() => window.elffussClaw?.conv?.getActive?.(), null, { timeout: 20000 });
28+ return { ctx, p };
29+}
30+const di = async (p, texto) => {
31+ const antes = await p.locator('#chat-log .msg.assistant').count();
32+ await p.fill('#prompt', texto);
33+ await p.press('#prompt', 'Enter');
34+ await p.waitForFunction(n => document.querySelectorAll('#chat-log .msg.assistant').length > n && !window.elffussClaw.conv.isBusy(), antes, { timeout: 10000 }).catch(() => {});
35+ return p.evaluate(() => ({ ultima: [...document.querySelectorAll('#chat-log .msg.assistant')].at(-1)?.textContent || '',
36+ herramientas: [...document.querySelectorAll('#chat-log .msg.tool b')].map(b => b.textContent) }));
37+};
38+
39+// 1 · inglés
40+{
41+ const { ctx, p } = await abre('en-US');
42+ const hola = await di(p, 'hello');
43+ ok('1 · en inglés, la ayuda del modo Básico sale en inglés', /basic mode/.test(hola.ultima) && /Settings → Brain/.test(hola.ultima) && !/Ajustes|Cerebro|Entiendo/.test(hola.ultima), hola.ultima.slice(0, 160));
44+ const arbol = await di(p, 'tree');
45+ ok('1 · …y entiende las órdenes en inglés que promete («tree»)', arbol.herramientas.includes('code.tree'), JSON.stringify(arbol.herramientas));
46+ const lee = await di(p, 'read notes.md');
47+ ok('1 · …(«read <file>»)', lee.herramientas.includes('code.read'), JSON.stringify(lee.herramientas));
48+
49+ // 2 · parar
50+ await p.evaluate(() => {
51+ window.elffussClaw.conv.setProvider({ chat: async (h, s, cb, signal) => {
52+ for (let i = 0; i < 200; i++) { if (signal?.aborted) throw new DOMException('Stopped', 'AbortError'); cb('·'); await new Promise(r => setTimeout(r, 25)); }
53+ return 'done';
54+ } });
55+ });
56+ await p.fill('#prompt', 'a long job');
57+ await p.press('#prompt', 'Enter');
58+ await p.waitForFunction(() => document.getElementById('btn-send').classList.contains('is-stop'), null, { timeout: 5000 }).catch(() => {});
59+ await p.click('#btn-send');
60+ await p.waitForFunction(() => !window.elffussClaw.conv.isBusy(), null, { timeout: 8000 }).catch(() => {});
61+ const nota = await p.evaluate(() => [...document.querySelectorAll('#chat-log .msg.muted')].map(n => n.textContent).at(-1) || '');
62+ ok('2 · lo que se para dice «(Stopped.)»', nota === '(Stopped.)', JSON.stringify(nota));
63+
64+ // 3 · carpeta OPFS: el proyecto de prueba vive en la OPFS, y su carpeta es la
65+ // que se adopta como espacio de trabajo («Use the project's»)
66+ await p.click('#btn-settings');
67+ await p.waitForTimeout(400);
68+ await p.locator('#settings-panel button', { hasText: "Use the project's" }).click();
69+ await p.waitForTimeout(400);
70+ const ajustes = await p.evaluate(() => document.getElementById('settings-panel').textContent);
71+ ok('3 · la carpeta del navegador se llama «OPFS (browser)»', /OPFS \(browser\)/.test(ajustes) && !/navegador/.test(ajustes), (ajustes.match(/[^.]{0,40}OPFS[^.]{0,30}/) || [''])[0]);
72+ await ctx.close();
73+}
74+
75+// 4 · español: igual que antes
76+{
77+ const { ctx, p } = await abre('es-ES');
78+ const hola = await di(p, 'hola');
79+ ok('4 · en español, la ayuda sigue en español', /modo básico/.test(hola.ultima) && /Ajustes → Cerebro/.test(hola.ultima), hola.ultima.slice(0, 120));
80+ const arbol = await di(p, 'árbol');
81+ ok('4 · …y «árbol» sigue funcionando', arbol.herramientas.includes('code.tree'), JSON.stringify(arbol.herramientas));
82+ await ctx.close();
83+}
84+
85+console.log('\n errores JS:', errs[0] || 'ninguno');
86+ok('sin errores de página', errs.length === 0, errs.join(' | '));
87+console.log(fails ? `\n❌ ${fails} FALLO(S)` : '\n✅ INTERFAZ EN INGLÉS SIN ESPAÑOL COLADO');
88+await b.close();
89+process.exit(fails ? 1 : 0);
modified web/js/i18n.js +8 −0
@@ -112,6 +112,10 @@
112112 planStopped: "parado",
113113 stopping: "Parando…",
114114 stopped: "Parado.",
115+ stoppedNote: "(Parado.)",
116+ rulesHello: "¡Hola!",
117+ rulesHelp: "Estoy en modo básico (sin modelo). Entiendo:\n• «árbol» / «qué hay en el proyecto»\n• «lee <archivo>» · «abre <archivo>»\n• «busca <texto>»\n• «escribe <archivo>: <contenido>»\nPara programar de verdad, elige un modelo en ⚙️ Ajustes → Cerebro (o pulsa el punto de estado del modelo, arriba a la derecha).",
118+ wsOpfsName: "OPFS (navegador)",
115119 send: "Enviar",
116120 stop: "Parar",
117121 stModelLoadingAI: "Cargando el modelo IA…",
@@ -337,6 +341,10 @@
337341 planStopped: "stopped",
338342 stopping: "Stopping…",
339343 stopped: "Stopped.",
344+ stoppedNote: "(Stopped.)",
345+ rulesHello: "Hello!",
346+ rulesHelp: "I'm in basic mode (no model). I understand:\n• “tree” / “what's in the project”\n• “read <file>” · “open <file>”\n• “search <text>”\n• “write <file>: <content>”\nTo really code, pick a model in ⚙️ Settings → Brain (or press the model status dot, top right).",
347+ wsOpfsName: "OPFS (browser)",
340348 send: "Send",
341349 stop: "Stop",
342350 stModelLoadingAI: "Loading the AI model…",
modified web/js/main.js +4 −2
@@ -25,7 +25,7 @@
2525
2626 // Espacio de trabajo (core): qué de Code puede guardarse en tu disco.
2727 workspace.init({
28- app: 'code', ns: 'elffusscode', db,
28+ app: 'code', ns: 'elffusscode', db, opfsName: t('wsOpfsName'),
2929 stores: [
3030 { id: 'conversations', label: 'Conversaciones', icon: '💬', kind: 'idb-key', store: 'kv', key: 'conversations',
3131 files: { ext: '.json', name: c => c.title || c.id } },
@@ -372,7 +372,9 @@
372372 if (ev.type === 'tool_result') addToolResult(ev.result);
373373 if (ev.type === 'progress') activeThinking?.tool(ev.text);
374374 if (ev.type === 'error') addMsg('assistant err', ev.text);
375- if (ev.type === 'aborted') addMsg('assistant muted', ev.text);
375+ // «(Parado.)» lo emiten módulos que no saben de idiomas (agent, goal, la
376+ // cola…): se pinta en el de la interfaz.
377+ if (ev.type === 'aborted') addMsg('assistant muted', t('stoppedNote'));
376378 // 🎯 Modo Objetivo: la tarjeta de plan se crea con 'plan' y se repinta
377379 // in-place en cada 'plan_update'/'plan_complete' (mismo nodo, por id).
378380 if (ev.type === 'plan' || ev.type === 'plan_update' || ev.type === 'plan_complete') renderPlanCard(ev.plan);
modified web/js/providers/rules.js +12 −14
@@ -1,16 +1,14 @@
11 // Modo básico de Elffuss Code: órdenes deterministas sin modelo.
2+// La ayuda sale en el idioma de la interfaz (antes siempre en español, también
3+// con la interfaz en inglés, que decía «Settings → Brain» donde la ayuda decía
4+// «Ajustes → Cerebro»), y las órdenes se entienden en los dos idiomas: una
5+// ayuda en inglés que solo entendiera «árbol» mentiría.
6+import { t } from '../i18n.js';
27 export const name = 'Básico (sin modelo)';
38 export async function load() {}
49
510 const call = obj => '```tool\n' + JSON.stringify(obj) + '\n```';
611
7-const HELP = `Estoy en modo básico (sin modelo). Entiendo:
8-• «árbol» / «qué hay en el proyecto»
9-• «lee <archivo>» · «abre <archivo>»
10-• «busca <texto>»
11-• «escribe <archivo>: <contenido>»
12-Para programar de verdad, elige un modelo en ⚙️ Ajustes → Cerebro (o pulsa el punto de estado del modelo, arriba a la derecha).`;
13-
1412 export async function chat(history, systemPrompt) {
1513 const last = history[history.length - 1];
1614 const text = (last?.content || '').trim();
@@ -33,16 +31,16 @@
3331 return body.startsWith('ERROR:') ? 'No pude: ' + body.slice(6).trim() : body;
3432 }
3533
36- const t = text.toLowerCase();
37- if (/(árbol|arbol|estructura|qué hay|que hay)/.test(t))
34+ const low = text.toLowerCase();
35+ if (/(árbol|arbol|estructura|qué hay|que hay|\btree\b|\bstructure\b|what'?s in)/.test(low))
3836 return call({ tool: 'code.tree', args: {} });
39- const mRead = text.match(/(?:lee|abre|muestra|cat)\s+([\w./-]+\.\w+)/i);
37+ const mRead = text.match(/(?:lee|abre|muestra|cat|read|open|show)\s+([\w./-]+\.\w+)/i);
4038 if (mRead) return call({ tool: 'code.read', args: { path: mRead[1] } });
41- const mSearch = text.match(/busca(?:r)?\s+(?:d[oó]nde\s+)?(?:se\s+\w+\s+)?["«']?([^"»']{2,60})["»']?$/i);
39+ const mSearch = text.match(/(?:busca(?:r)?\s+(?:d[oó]nde\s+)?(?:se\s+\w+\s+)?|(?:search|find)\s+(?:for\s+)?)["«“']?([^"»”']{2,60})["»”']?$/i);
4240 if (mSearch) return call({ tool: 'code.search', args: { query: mSearch[1].trim() } });
43- const mWrite = text.match(/escribe\s+([\w./-]+\.\w+)\s*[:=]\s*([\s\S]+)/i);
41+ const mWrite = text.match(/(?:escribe|write)\s+([\w./-]+\.\w+)\s*[:=]\s*([\s\S]+)/i);
4442 if (mWrite) return call({ tool: 'code.write', args: { path: mWrite[1], content: mWrite[2] } });
4543
46- if (/^(hola|buenas|hey|hi)\b/.test(t)) return '¡Hola! ' + HELP;
47- return HELP;
44+ if (/^(hola|buenas|hey|hi|hello)\b/.test(low)) return t('rulesHello') + ' ' + t('rulesHelp');
45+ return t('rulesHelp');
4846 }
modified web/js/workspace.js +6 −2
@@ -24,8 +24,12 @@
2424 let autosaveCfg = { enabled: false, debounceMs: 3000 };
2525 let autosaveTimer = null;
2626
27-export function init({ app, ns, db, stores }) {
27+// `nombreOPFS`: cómo se llama, en el idioma de la interfaz, la carpeta del
28+// almacenamiento privado del navegador (no tiene nombre propio). Lo da la app.
29+let nombreOPFS = 'OPFS';
30+export function init({ app, ns, db, stores, opfsName }) {
2831 cfg = { app, ns, db, stores: stores || [] };
32+ if (opfsName) nombreOPFS = opfsName;
2933 }
3034
3135 export function supported() {
@@ -40,7 +44,7 @@
4044
4145 // La raíz del almacenamiento privado del navegador (OPFS) no tiene nombre: ''
4246 // se leía como «sin carpeta» y la carpeta elegida no se podía usar.
43-const nombreDe = h => h ? (h.name || 'OPFS (navegador)') : null;
47+const nombreDe = h => h ? (h.name || nombreOPFS) : null;
4448
4549 function statusSync() {
4650 return {