utopia-ia/elffuss-code public
Changesets · Branches · Tags · Compare
| Changeset | fc9a8dba96f6f1da1ca3a2e0f25b11fc1245945010cfb128af6e9045909e2ecf |
|---|---|
| Author | KikoCis <kikocisneros@gmail.com> · 2026-10-11 21:51 +02:00 |
| Committer | KikoCis <kikocisneros@gmail.com> · 2026-10-12 09:38 +02:00 |
| Parents | fe3c92114feb |
4 files changed
modified tests/lib/x2-mode.mjs +8 −1
| @@ -33,7 +33,9 @@ | ||
| 33 | 33 | // · no level 2 errors: the bridge never in "error", no [x2] warnings, no page |
| 34 | 34 | // error from js/ext2/; |
| 35 | 35 | // · 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. | |
| 37 | 39 | // |
| 38 | 40 | // X2_SEEDED (set here) names the two seeded extensions, for the one suite |
| 39 | 41 | // that counts installed extensions itself (extensions.mjs). |
| @@ -93,6 +95,7 @@ | ||
| 93 | 95 | |
| 94 | 96 | const browsers = []; // { id, contexts: [] } |
| 95 | 97 | let anyBrowser = false; |
| 98 | +let ideSeen = 0; // páginas que abrieron el IDE (con el código encendido) | |
| 96 | 99 | |
| 97 | 100 | async function track(browserRec, ctx) { |
| 98 | 101 | const st = { |
| @@ -207,6 +210,7 @@ | ||
| 207 | 210 | 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(', ') : '')); |
| 208 | 211 | } |
| 209 | 212 | const ide = [...st.docs.values()].filter(d => d.ide && !off(d)); |
| 213 | + ideSeen += ide.length; | |
| 210 | 214 | if (!st.seeded.size && !ide.length) { note('this context never opened Code'); continue; } |
| 211 | 215 | if (!ide.length) { note('no page opened the IDE in this context'); } |
| 212 | 216 | else { |
| @@ -272,6 +276,9 @@ | ||
| 272 | 276 | finished = true; |
| 273 | 277 | for (const rec of browsers) if (!rec.reported) { rec.reported = true; report(rec); } |
| 274 | 278 | 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'); | |
| 275 | 282 | } |
| 276 | 283 | process.exit = code => { finish(); return origExit(failed ? 1 : code); }; |
| 277 | 284 | process.on('exit', code => { finish(); if (failed && !code) process.exitCode = 1; }); |
modified tests/run-modes.sh +9 −5
| @@ -80,22 +80,24 @@ | ||
| 80 | 80 | BAD=$(( $(grep -c '❌' "$log") + $(grep -c '^ *✗ ' "$log") )) |
| 81 | 81 | SKIP=$(grep -c 'NOT RUN' "$log") |
| 82 | 82 | } |
| 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 | |
| 85 | 86 | elif [ "$RC" -eq 0 ] && [ "$BAD" -eq 0 ] && [ "$SKIP" -gt 0 ]; then echo "NOT RUN" |
| 86 | 87 | else echo FAIL; fi |
| 87 | 88 | } |
| 88 | 89 | |
| 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 | |
| 91 | 92 | for n in $BOTH; do |
| 92 | 93 | suites=$((suites + 1)) |
| 93 | 94 | cols="" |
| 94 | 95 | for m in default ext; do |
| 95 | 96 | if [ "$MODE" != both ] && [ "$MODE" != "$m" ]; then cols="$cols$(printf '%-22s ' '-')"; continue; fi |
| 96 | 97 | run "$n" "$m" |
| 97 | - v=$(verdict) | |
| 98 | + v=$(verdict "$n" "$m") | |
| 98 | 99 | [ "$v" = FAIL ] && fails=$((fails + 1)) |
| 100 | + [ "$v" = "PASS, no IDE" ] && noide="$noide $n" | |
| 99 | 101 | cols="$cols$(printf '%-22s ' "$v $OKS ok $BAD bad")" |
| 100 | 102 | done |
| 101 | 103 | printf '%-24s %s\n' "$n" "$cols" |
| @@ -115,5 +117,7 @@ | ||
| 115 | 117 | done |
| 116 | 118 | |
| 117 | 119 | 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 | |
| 118 | 122 | 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 |
| 119 | 123 | [ "$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 @@ | ||
| 59 | 59 | run-bateria |
| 60 | 60 | sendfeedback |
| 61 | 61 | stop |
| 62 | +stop_ide | |
| 62 | 63 | streampreview |
| 63 | 64 | swe_bench |
| 64 | 65 | swe_style |
| @@ -72,6 +73,7 @@ | ||
| 72 | 73 | [once] |
| 73 | 74 | x2_unit |
| 74 | 75 | x2_headers |
| 76 | +x2_deploy | |
| 75 | 77 | x2_smoke |
| 76 | 78 | x2_bytes |
| 77 | 79 | x2_canary |