Elffuss BraidHub

utopia-ia/elffuss-claw public

Basic mode does what a suggestion chip says in every language

The rules engine behind Basic mode understands Spanish commands only.
With the page in English, French or German, pressing a suggestion chip
mostly got the "I understand a few direct commands, written in Spanish"
help text instead of the suggested action (4 of 5 in English, 5 of 5 in
French and German).

i18n.js now maps the exact text of a chip in any language to the same
chip in Spanish (chipEnEspanol), and rules.js reads a chip that way. The
chat still shows the chip in the page language, a loaded model still
gets it unchanged, and text typed by hand is not touched.

ux-teclado.mjs presses every chip but the folder one in Basic mode on
en-US, fr-FR and de-DE pages, with the network cut, and checks that each
one calls the tool it suggests (clock and notes apps, skill.create,
web.images, web.fetch) and none answers with the help text. All three
locales fail on the previous code.
Changeset2bab9ca614db1c28fe5c2e229c6a9a3070202124ce1899e04402a3317bf04429
AuthorKikoCis <kikocisneros@gmail.com> · 2026-10-11 20:51 +02:00
CommitterKikoCis <kikocisneros@gmail.com> · 2026-10-11 20:51 +02:00
Parents94f3b5dab8d1

Browse the files at this changeset

3 files changed

modified tests/ux-teclado.mjs +31 −1
@@ -11,7 +11,9 @@
1111 // busca en lo que hace cada uno.
1212 // · «?» fuera de la caja enseña los atajos; «/» fuera de la caja abre el menú.
1313 // · Chips: botones, seis, sin repetidos, en el idioma de la página; «Autoriza
14-// una carpeta» abre el selector en el propio clic.
14+// una carpeta» abre el selector en el propio clic. En modo Básico, en inglés,
15+// francés y alemán cada chip hace lo que dice (antes casi todos caían en el
16+// texto de ayuda: el modo Básico entiende órdenes en español).
1517 //
1618 // BASE=http://localhost:8743 node tests/ux-teclado.mjs
1719 import { navegador, contexto, pagina, ok, hasta, espera, fin } from './ux-comun.mjs';
@@ -136,5 +138,33 @@
136138 await c2.close();
137139 }
138140
141+// ── chips en modo Básico, en otros idiomas ───────────────────────────────────
142+// La red se corta: example.com contesta aquí y el proxy del servidor no se usa.
143+const ESPERADO = [/app\.create \(name=reloj/, /app\.create \(name=notas/, null, /skill\.create/, /web\.images/, /web\.fetch \(url=https:\/\/example\.com/];
144+for (const locale of ['en-US', 'fr-FR', 'de-DE']) {
145+ const { ctx: c3 } = await contexto(b, { locale, grants: ['apps', 'web', 'fs', 'memory', 'tasks', 'vault'],
146+ rutas: async (url, route) => {
147+ if (!/^https:\/\/example\.com\//.test(url)) return false;
148+ await route.fulfill({ status: 200, contentType: 'text/html', body: '<h1>Example</h1>' }); return true;
149+ } });
150+ const { p: q, errores: err3 } = await pagina(c3);
151+ await q.route('**/proxy?url=**', r => r.fulfill({ status: 502, body: 'sin red en la prueba' }));
152+ const textos = await q.$$eval('#chips .chip', cs => cs.map(c => c.textContent.trim()));
153+ const malos = [];
154+ for (let i = 0; i < textos.length; i++) {
155+ if (!ESPERADO[i]) continue; // «Autoriza una carpeta» abre el selector
156+ const antes = await q.locator('#log .msg').count();
157+ await q.locator('#chips .chip').nth(i).click();
158+ await hasta(() => q.evaluate(n => document.querySelectorAll('#log .msg').length > n + 1
159+ && !document.querySelector('#log .msg.thinking') && !document.getElementById('send').classList.contains('is-stop'), antes));
160+ const nuevos = await q.evaluate(n => [...document.querySelectorAll('#log .msg')].slice(n).map(m => m.className + ' | ' + m.textContent.trim().slice(0, 90)), antes);
161+ const ayuda = nuevos.some(x => /Basic mode|mode Basique|Basismodus|modo básico/i.test(x));
162+ if (ayuda || !nuevos.some(x => /\btool\b/.test(x.split(' | ')[0]) && ESPERADO[i].test(x))) malos.push({ chip: textos[i], nuevos: nuevos.slice(0, 3) });
163+ }
164+ ok(`${locale}: en modo Básico cada chip hace lo que dice (ninguno cae en el texto de ayuda)`, !malos.length, JSON.stringify(malos).slice(0, 400));
165+ ok(`${locale}: …sin errores de página`, err3.length === 0, err3.slice(0, 3).join(' | '));
166+ await c3.close();
167+}
168+
139169 ok('sin errores de página', errores.length === 0, errores.slice(0, 3).join(' | '));
140170 await fin(b, 'TECLADO: menú «/» navegable y filtrable, atajos, chips que son botones');
modified web/js/i18n.js +14 −0
@@ -3063,6 +3063,20 @@
30633063
30643064 const CHIP_ACCIONES = [null, null, 'carpeta', null, null, null];
30653065
3066+// Una sugerencia (chip) tal cual, en cualquiera de los idiomas → la misma en
3067+// español, o null si no es una. El modo Básico (providers/rules.js) entiende
3068+// órdenes en español: en inglés, francés o alemán casi todos los chips caían en
3069+// su texto de ayuda en vez de hacer lo que dicen.
3070+export function chipEnEspanol(texto) {
3071+ const x = String(texto ?? '').trim().toLowerCase();
3072+ if (!x) return null;
3073+ for (const idioma of Object.values(L)) {
3074+ const i = (idioma.chips || []).findIndex(c => c.trim().toLowerCase() === x);
3075+ if (i >= 0) return L.es.chips[i];
3076+ }
3077+ return null;
3078+}
3079+
30663080 export function applyI18n() {
30673081 const code = uiLang();
30683082 const t = L[code] || L.en;
modified web/js/providers/rules.js +5 −2
@@ -1,7 +1,7 @@
11 // «Modo básico»: cerebro determinista sin modelo — cubre las demos clave sin
22 // descargar nada. Para lenguaje libre, carga un modelo en el selector de modelo.
33 // `tr` y no `t`: dentro de chat() `t` es el texto en minúsculas.
4-import { t as tr } from '../i18n.js';
4+import { t as tr, chipEnEspanol } from '../i18n.js';
55 export const name = 'Básico (sin modelo)';
66 export async function load() {}
77
@@ -81,7 +81,10 @@
8181
8282 export async function chat(history) {
8383 const last = history[history.length - 1];
84- const text = (last?.content || '').trim();
84+ // Una sugerencia de la página (chip) en otro idioma se entiende como la misma
85+ // en español, que es como entiende las órdenes este motor. Solo el texto exacto
86+ // de una sugerencia: lo que se escribe a mano sigue tal cual.
87+ const text = (chipEnEspanol(last?.content) || last?.content || '').trim();
8588
8689 // Tras una herramienta: convertir su resultado en la respuesta…
8790 if (text.startsWith('[resultado')) {