Elffuss BraidHub

utopia-ia/elffuss-code public

run-modes: say when extension mode was never exercised; add stop_ide

A suite that never opens the IDE cannot start the sandbox, yet its
extension-mode column said PASS. x2-mode now prints "not exercised" when
no page opened the IDE, and run-modes shows "PASS, no IDE" and lists those
suites at the end (14 today, among them stop). stop_ide is stop.mjs with a
project open in the IDE, so the agent's stop button is checked with the
sandbox running beside it. x2_deploy joins the level 2 suites.

The real-Bridge suites stay out of both modes: the Bridge only accepts
Code on port 8799 and listens on 8765, and these runs use random ports.

Changesetfc9a8dba96f6f1da1ca3a2e0f25b11fc1245945010cfb128af6e9045909e2ecf
AuthorKikoCis <kikocisneros@gmail.com> · 2026-10-11 21:51 +02:00
CommitterKikoCis <kikocisneros@gmail.com> · 2026-10-12 09:38 +02:00
Parentsfe3c92114feb

Browse the files at this changeset

4 files changed

modified tests/lib/x2-mode.mjs +8 −1
@@ -33,7 +33,9 @@
3333 // · no level 2 errors: the bridge never in "error", no [x2] warnings, no page
3434 // error from js/ext2/;
3535 // · nothing requested from the sandbox site but its two documents.
36-// A failed check makes the suite exit 1 whatever it said itself.
36+// A failed check makes the suite exit 1 whatever it said itself. When no page
37+// opened the IDE at all, the suite says "x2-mode: not exercised" and
38+// run-modes.sh shows that instead of a plain PASS.
3739 //
3840 // X2_SEEDED (set here) names the two seeded extensions, for the one suite
3941 // that counts installed extensions itself (extensions.mjs).
@@ -93,6 +95,7 @@
9395
9496 const browsers = []; // { id, contexts: [] }
9597 let anyBrowser = false;
98+let ideSeen = 0; // páginas que abrieron el IDE (con el código encendido)
9699
97100 async function track(browserRec, ctx) {
98101 const st = {
@@ -207,6 +210,7 @@
207210 say(!ran.length, `with ?noext or ?noext2 the sandbox stayed off (${switched.length} pages)` + (ran.length ? ' — it ran in: ' + ran.map(d => d.at).join(', ') : ''));
208211 }
209212 const ide = [...st.docs.values()].filter(d => d.ide && !off(d));
213+ ideSeen += ide.length;
210214 if (!st.seeded.size && !ide.length) { note('this context never opened Code'); continue; }
211215 if (!ide.length) { note('no page opened the IDE in this context'); }
212216 else {
@@ -272,6 +276,9 @@
272276 finished = true;
273277 for (const rec of browsers) if (!rec.reported) { rec.reported = true; report(rec); }
274278 if (!anyBrowser) note('no browser in this suite');
279+ // Sin ninguna página que abriera el IDE, el recinto nunca corrió: la suite
280+ // pasó, pero el modo extensiones no la ha probado. run-modes.sh lo enseña así.
281+ if (!ideSeen) console.log(' x2-mode: not exercised: no page opened the IDE, so the sandbox never ran in this suite');
275282 }
276283 process.exit = code => { finish(); return origExit(failed ? 1 : code); };
277284 process.on('exit', code => { finish(); if (failed && !code) process.exitCode = 1; });
modified tests/run-modes.sh +9 −5
@@ -80,22 +80,24 @@
8080 BAD=$(( $(grep -c '❌' "$log") + $(grep -c '^ *✗ ' "$log") ))
8181 SKIP=$(grep -c 'NOT RUN' "$log")
8282 }
83-verdict() { # → PASS | FAIL | NOT RUN
84- if [ "$RC" -eq 0 ] && [ "$BAD" -eq 0 ] && [ "$OKS" -gt 0 ]; then echo PASS
83+verdict() { # → PASS | FAIL | NOT RUN, and "no IDE" when extension mode was not exercised
84+ if [ "$RC" -eq 0 ] && [ "$BAD" -eq 0 ] && [ "$OKS" -gt 0 ]; then
85+ if [ "${2:-}" = ext ] && grep -q 'x2-mode: not exercised' "$LOGS/$1.ext.log"; then echo "PASS, no IDE"; else echo PASS; fi
8586 elif [ "$RC" -eq 0 ] && [ "$BAD" -eq 0 ] && [ "$SKIP" -gt 0 ]; then echo "NOT RUN"
8687 else echo FAIL; fi
8788 }
8889
89-fails=0 suites=0
90-printf '\n%-24s %-22s %-22s\n' suite default extension
90+fails=0 suites=0 noide=""
91+printf '\n%-24s %-22s %-30s\n' suite default extension
9192 for n in $BOTH; do
9293 suites=$((suites + 1))
9394 cols=""
9495 for m in default ext; do
9596 if [ "$MODE" != both ] && [ "$MODE" != "$m" ]; then cols="$cols$(printf '%-22s ' '-')"; continue; fi
9697 run "$n" "$m"
97- v=$(verdict)
98+ v=$(verdict "$n" "$m")
9899 [ "$v" = FAIL ] && fails=$((fails + 1))
100+ [ "$v" = "PASS, no IDE" ] && noide="$noide $n"
99101 cols="$cols$(printf '%-22s ' "$v $OKS ok $BAD bad")"
100102 done
101103 printf '%-24s %s\n' "$n" "$cols"
@@ -115,5 +117,7 @@
115117 done
116118
117119 echo
120+# (sin IDE el recinto no corrió: pasan, pero el modo extensiones no las probó)
121+if [ -n "$noide" ]; then echo "ℹ️ extension mode not exercised (no page opened the IDE, the sandbox never ran):$noide"; fi
118122 if [ "$fails" -eq 0 ]; then echo "✅ run-modes: $suites suites, no failures"; else echo "❌ run-modes: $fails failing runs in $suites suites (logs: $LOGS)"; fi
119123 [ "$fails" -eq 0 ]
added tests/stop_ide.mjs +50 −0
@@ -0,0 +1,50 @@
1+// stop.mjs con el IDE abierto: el botón de parar del agente para de verdad
2+// también con un proyecto abierto en el editor (y, en el modo extensiones de
3+// run-modes.sh, con el recinto de extensiones corriendo al lado, que stop.mjs
4+// nunca llega a arrancar porque se queda en la portada).
5+//
6+// BASE=http://127.0.0.1:<port> node tests/stop_ide.mjs
7+import { chromium } from 'playwright';
8+const BASE = process.env.BASE || 'http://localhost:8799';
9+const b = await chromium.launch();
10+const ctx = await b.newContext();
11+// Modo Básico: sin esto, main.js se pone a cargar el modelo local por defecto
12+await ctx.addInitScript(() => { try { localStorage.setItem('elffusscode.model', 'rules'); } catch {} });
13+const p = await ctx.newPage();
14+await p.goto(BASE + '/', { waitUntil: 'domcontentloaded' });
15+await p.evaluate(async () => {
16+ const o = await navigator.storage.getDirectory();
17+ const f = await o.getFileHandle('app.js', { create: true });
18+ const s = await f.createWritable(); await s.write('function a() { return 1; }\n'); await s.close();
19+});
20+await p.goto(BASE + '/?test-opfs', { waitUntil: 'domcontentloaded' });
21+await p.waitForFunction(() => !!window.monaco?.editor?.getEditors?.().length, null, { timeout: 60000 });
22+await p.evaluate(async () => { await (await import('/js/ide.js')).openFile('app.js'); });
23+const ide = await p.evaluate(() => !!document.querySelector('#editor .monaco-editor') && window.monaco.editor.getEditors()[0].getModel().getValue().includes('function a'));
24+const r = await p.evaluate(async () => {
25+ const { Agent } = await import('/js/agent.js?v=' + Date.now());
26+ const eventos = [];
27+ let llamadas = 0;
28+ // proveedor que SIEMPRE pide una tool y respeta la señal (espera y comprueba)
29+ const lento = { chat: async (h, s, cb, signal) => {
30+ llamadas++;
31+ for (let i = 0; i < 20; i++) { if (signal?.aborted) break; await new Promise(r => setTimeout(r, 50)); }
32+ return '```tool\n{"tool":"code.tree","args":{}}\n```';
33+ }};
34+ const ag = new Agent(lento);
35+ const run = ag.handle('haz algo largo', ev => eventos.push(ev.type));
36+ await new Promise(r => setTimeout(r, 300)); // deja arrancar
37+ const llamadasAntes = llamadas;
38+ ag.stop(); // ← PARAR a mitad
39+ await run; // debe terminar pronto, no agotar MAX_STEPS
40+ return { eventos: [...new Set(eventos)], llamadasAntes, llamadasTotal: llamadas, abortado: eventos.includes('aborted') };
41+});
42+console.log('parada del agente con el IDE abierto:');
43+console.log(' eventos:', r.eventos.join(', '));
44+console.log(' llamadas al modelo antes de parar:', r.llamadasAntes, '· total tras parar:', r.llamadasTotal);
45+const ok = ide && r.abortado && r.llamadasTotal <= r.llamadasAntes + 1;
46+console.log(ide ? '✅ el IDE está abierto con el proyecto' : '❌ el IDE no se abrió');
47+console.log(ok ? '✅ para de verdad: emite «aborted» y no sigue el bucle'
48+ : '❌ no paró bien');
49+await b.close();
50+process.exit(ok ? 0 : 1);
modified tests/suites.txt +2 −0
@@ -59,6 +59,7 @@
5959 run-bateria
6060 sendfeedback
6161 stop
62+stop_ide
6263 streampreview
6364 swe_bench
6465 swe_style
@@ -72,6 +73,7 @@
7273 [once]
7374 x2_unit
7475 x2_headers
76+x2_deploy
7577 x2_smoke
7678 x2_bytes
7779 x2_canary