fix(core): add authored render readiness gate - #1543
Merged
Conversation
jrusso1020
force-pushed
the
codex/render-ready-assets
branch
from
June 17, 2026 22:44
5e9adc0 to
5104bcf
Compare
miguel-heygen
approved these changes
Jun 18, 2026
miguel-heygen
left a comment
Collaborator
There was a problem hiding this comment.
Reviewed — authored render readiness gate via window.__hyperframesReady promise. Clean promise-identity tracking, correct script-stripping fix for regex-only flag assignments. LGTM.
… flag Per consensus thread (Miguel/Magi/James + me): instead of a public `window.__hyperframesReady` promise authors / LLMs are expected to set, the framework auto-detects async asset loading and gates render readiness internally. Authors keep writing plain HTML; the framework just waits. What changed - `RuntimeDeterministicAdapter.getReadyPromise?: () => PromiseLike | null` — new optional adapter contract for async readiness. Runtime collects promises from every adapter on each `maybePublishRenderReady()` cycle and waits for them to settle before publishing `__renderReady = true`. - `adapters/three.ts` — hooks `THREE.DefaultLoadingManager.onStart` / `onLoad`. Items queued at discover-time AND any items queued later (the common case — user composition scripts run after the runtime mounts) both arm a wait. The wrapped `onLoad` restores the user's own callback so composition-side load handlers still fire. - `runtime/init.ts` — replaces the authored-promise polling (`getAuthoredRenderReadyPromise` / `isAuthoredRenderReadySettled` / `window.__hyperframesReady` checks) with adapter-aware `isAdapterReadinessSettled()`. Discover is re-run inside `maybePublishRenderReady` so adapters can refresh their state from the current DOM (e.g. THREE may have just finished loading). - `runtime/window.d.ts` — removes the public `__hyperframesReady` type declaration. The flag was the only authored-facing surface from the earlier draft; gone, no LLM/skill teaching required. - `runtime/init.test.ts` — replaces the authored-readiness test with a Three.js LoadingManager test that simulates an in-flight load, asserts render-ready is held while pending, and resolves on `mgr.onLoad()`. Kept from the earlier draft - The `htmlDocument.ts` script-stripping refactor (substring → regex for `__playerReady` / `__renderReady` simple-flag assignments) is independent of the readiness-gate question and stays as-is. It fixes a separate bug where authored scripts that *reference* the flags (e.g. `if (window.__renderReady) ...`) were being stripped despite never assigning them. Verification - bun run --cwd packages/core test src/runtime/init.test.ts src/compiler/htmlDocument.test.ts — 33/33 pass - bun run --cwd packages/core typecheck — clean - bunx oxlint / bunx oxfmt --check on changed files — clean
miguel-heygen
approved these changes
Jun 18, 2026
miguel-heygen
left a comment
Collaborator
There was a problem hiding this comment.
Re-reviewed after rework — public __hyperframesReady dropped, replaced with internal getReadyPromise adapter contract. Three.js adapter auto-hooks LoadingManager. Zero authoring burden. Script-stripping regex fix retained. LGTM.
miguel-heygen
approved these changes
Jun 18, 2026
miguel-heygen
added a commit
that referenced
this pull request
Jun 18, 2026
Add readiness-only runtime adapters for Mapbox GL JS, Leaflet, Google Maps, MapLibre GL JS, and D3. Each adapter gates `__renderReady` until the library's async initialization completes, preventing the renderer from capturing blank or half-loaded frames. Built on the `getReadyPromise` adapter contract from #1543. A shared `createReadinessAdapter()` helper in `_readiness.ts` owns the settled-tracking WeakSet, promise-identity stability, and `Promise.allSettled` gate — each adapter provides only its type, window global name, and `waitFor` callback. Readiness signals per library: - Mapbox / MapLibre: `map.loaded()` + `map.on('load', ...)` - Leaflet: `map.whenReady(cb)` - Google Maps: `map.addListener('tilesloaded', cb)` with handle cleanup - D3: `transition.end()` promise 50 unit tests across 5 test files covering happy path, no-instances, stable promise identity, post-settle drain, loaded-before-subscribe race, and listener cleanup. 5 producer regression tests with Docker-generated baselines for end-to-end render verification.
miguel-heygen
added a commit
that referenced
this pull request
Jun 18, 2026
#1548) Add readiness-only runtime adapters for Mapbox GL JS, Leaflet, Google Maps, MapLibre GL JS, and D3. Each adapter gates `__renderReady` until the library's async initialization completes, preventing the renderer from capturing blank or half-loaded frames. Built on the `getReadyPromise` adapter contract from #1543. A shared `createReadinessAdapter()` helper in `_readiness.ts` owns the settled-tracking WeakSet, promise-identity stability, and `Promise.allSettled` gate — each adapter provides only its type, window global name, and `waitFor` callback. Readiness signals per library: - Mapbox / MapLibre: `map.loaded()` + `map.on('load', ...)` - Leaflet: `map.whenReady(cb)` - Google Maps: `map.addListener('tilesloaded', cb)` with handle cleanup - D3: `transition.end()` promise 50 unit tests across 5 test files covering happy path, no-instances, stable promise identity, post-settle drain, loaded-before-subscribe race, and listener cleanup. 5 producer regression tests with Docker-generated baselines for end-to-end render verification.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
window.__hyperframesReadyso authored compositions can delay render readiness until async assets settle__renderReadyfalse while authored readiness, external compositions, or GSAP batching are still pendingVerification
bun run --cwd packages/core test src/compiler/htmlDocument.test.ts src/runtime/init.test.tsbun run --cwd packages/core typecheck