From a2c758e34378cfe56a113e85eb3e22e3b78b56fb Mon Sep 17 00:00:00 2001 From: "prompt.ac/@jeffrey" Date: Mon, 21 Sep 2026 13:22:07 -0700 Subject: [PATCH] Wait for requested piece before reporting boot success --- system/public/aesthetic.computer/bios.mjs | 13 +++++++------ system/tests/boot-telemetry.test.mjs | 20 ++++++++++++++++++++ 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/system/public/aesthetic.computer/bios.mjs b/system/public/aesthetic.computer/bios.mjs index 0ea850a365..67521d0adb 100644 --- a/system/public/aesthetic.computer/bios.mjs +++ b/system/public/aesthetic.computer/bios.mjs @@ -19353,12 +19353,13 @@ async function boot(parsed, bpm = 60, resolution, debug) { } if (type === "disk-loaded-and-booted") { - perf.markBoot("disk-loaded-and-booted"); - - // ๐Ÿงพ Boot telemetry: the disk loaded and ran its boot lifecycle โ€” the real - // "boot succeeded" moment, fired for every piece whether or not it defines - // a custom paint. Idempotent in boot.mjs, so later navigations are no-ops. - window.acBOOT_SUCCESS?.(); + // The worker also boots a blank init disk before the requested piece + // loads. Its ready signal cannot finish page telemetry or freeze timings. + // A real piece need not define paint; its completed boot is sufficient. + if (currentPiece !== null) { + perf.markBoot("disk-loaded-and-booted"); + window.acBOOT_SUCCESS?.(); // Idempotent across later navigations. + } // Skip preload marker on default init piece, and toggle it if necessary. if (currentPiece !== null && !window.waitForPreload) diff --git a/system/tests/boot-telemetry.test.mjs b/system/tests/boot-telemetry.test.mjs index 73bdbe4f3a..e748531451 100644 --- a/system/tests/boot-telemetry.test.mjs +++ b/system/tests/boot-telemetry.test.mjs @@ -130,3 +130,23 @@ test("malformed boot metadata is rejected before opening a database connection", assert.equal(result.statusCode,400); } }); + +test("blank init disk cannot finish boot telemetry before the requested piece",()=>{ + const source=readFileSync(new URL("../public/aesthetic.computer/bios.mjs",import.meta.url),"utf8"); + const start=source.indexOf(' if (type === "disk-loaded-and-booted") {'); + const handler=source.slice(start,source.indexOf(' // ๐ŸŽจ Hide boot canvas',start)); + const marks=[],timers=[];let successes=0; + const context=vm.createContext({type:"disk-loaded-and-booted",currentPiece:null, + perf:{markBoot:mark=>marks.push(mark),printReport(){}}, + window:{acBOOT_SUCCESS:()=>successes++,waitForPreload:false}, + restoreWalletSession:async()=>{},setTimeout:fn=>timers.push(fn)}); + vm.runInContext(handler,context); + assert.equal(successes,0);assert.equal(marks.length,0);assert.equal(timers.length,0); + assert.equal(context.window.preloaded,undefined); + // No custom paint or preload signal is needed to recognize the real boot. + context.currentPiece="aesthetic.computer/disks/synthetic"; + context.window.waitForPreload=true; + vm.runInContext(handler,context); + assert.equal(successes,1);assert.deepEqual(marks,["disk-loaded-and-booted"]); + assert.equal(timers.length,1); +}); -- 2.51.2