diff --git a/app/pubspec.lock b/app/pubspec.lock index b36726e5..370b4079 100644 --- a/app/pubspec.lock +++ b/app/pubspec.lock @@ -374,7 +374,7 @@ packages: source: hosted version: "15.4.0" web: - dependency: transitive + dependency: "direct main" description: name: web sha256: "868d88a33d8a87b18ffc05f9f030ba328ffefba92d6c127917a2ba740f9cfe4a" diff --git a/app/pubspec.yaml b/app/pubspec.yaml index fa4a079a..ec8624bf 100644 --- a/app/pubspec.yaml +++ b/app/pubspec.yaml @@ -38,6 +38,7 @@ dependencies: shared_preferences: ^2.5.6 flutter_web_plugins: sdk: flutter + web: ^1.1.1 dev_dependencies: flutter_test: diff --git a/app/tool/chat_composer_probe.mjs b/app/tool/chat_composer_probe.mjs index 95932f4e..c5988ac4 100644 --- a/app/tool/chat_composer_probe.mjs +++ b/app/tool/chat_composer_probe.mjs @@ -82,6 +82,9 @@ try { if (msg.method?.includes('detached') || msg.method?.includes('crashed')) { console.error('CDP event', JSON.stringify(msg)); } + if (msg.method === 'Runtime.exceptionThrown') { + console.error('PAGE EXCEPTION', JSON.stringify(msg.params?.exceptionDetails?.exception?.description ?? msg.params?.exceptionDetails?.text)); + } if (msg.id && pending.has(msg.id)) { pending.get(msg.id)(msg); pending.delete(msg.id); } }); const send = (method, params = {}, sessionId) => new Promise(resolve => { @@ -101,7 +104,12 @@ try { if (response.error) throw new Error(`Runtime.evaluate failed: ${JSON.stringify(response)}`); return response.result?.result?.value; }; - await delay(3500); + // A cold bundle can need longer than a fixed delay before Flutter publishes + // its semantics placeholder; wait for it instead of sampling a blank page. + for (let i = 0; i < 120; i++) { + if (await evaluate("Boolean(document.querySelector('flt-semantics-placeholder'))")) break; + await delay(100); + } await evaluate("document.querySelector('flt-semantics-placeholder')?.click()"); await delay(1800); @@ -111,7 +119,7 @@ try { const assertSemantics = async (text, what) => { const read = await semanticText(); if (!read.toLowerCase().replace(/\s+/g, ' ').includes(text.toLowerCase())) { - throw new Error(`${what}: semantics lacks ${JSON.stringify(text)}:\n${read.slice(0, 3000)}`); + throw new Error(`${what}: semantics lacks ${JSON.stringify(text)}\nbody: ${(await evaluate('document.body?.innerText ?? \"\"') || '').slice(0, 800)}\n${read.slice(0, 2000)}`); } }; const clickLabel = async (label, { contains = false } = {}) => {