Repository navigation
Host core: tell hosts when the renderer is ready and when the frames have painted - #122
Merged
Merged
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
A stale Animated pane acknowledgement can trigger onPainted before Diff is drawn and again afterward, causing hosts to capture or reveal the wrong frame.
1 open issue
What changed in this PR
Adds renderer-status and paint-readiness signals to the headless host core so hosts can wait for rendered content without observing DOM attributes. This builds on the playback state-machine work without changing its logic.
Changes:
- Adds
onRendererStatusChangeand paused-frameonPaintedcallbacks. - Exposes controller
paintstate and the purepaintStatehelper. - Documents the API and adds paint-state tests.
| File | Description |
|---|---|
packages/host/core/test/paint.test.mjs |
Tests readiness across modes and pane states. |
packages/host/core/src/projection/use-projection.ts |
Connects paint readiness and status events to the controller. |
packages/host/core/src/projection/types.ts |
Defines the new callback options and controller field. |
packages/host/core/src/projection/paint.ts |
Implements paint-state calculation and status callbacks. |
packages/host/core/src/index.ts |
Exports the paint helper and public types. |
docs/guides/host-core.md |
Documents status events and paint readiness. |
Review effort: Balanced
agorischek
force-pushed
the
renderer-status-events
branch
from
November 21, 2026 01:07
5bae76b to
8717cf9
Compare
agorischek
force-pushed
the
host-playback-machine
branch
from
November 21, 2026 01:40
08b201a to
78a9788
Compare
…have painted
Hosts that wait on the renderer read it from the view's DOM: the hosted site's carousel and the Playground's tour
observe `data-renderer-status` and `data-rendered-progress` with a MutationObserver, and a poster-to-live handover has
nothing else to go on. The core now says so itself:
- `onRendererStatusChange(status)`, with the first status too;
- `paint` on the controller and the pure `paintState(controller)`: `none`, `loading`, `failed`, `painting` or
`painted`, once every shown pane has acknowledged painting what it was sent;
- `onPainted({mode, progress})`, once each time the frames settle on what is shown while paused.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…as painted Switching a paused Animated view to Diff kept the Animated acknowledgement in `panes.main.rendered` for a render, so `paint` read `painted` and `onPainted` fired before Diff was drawn (and again after). A pane's `rendered` now records the init it answers (`renderedInit`), and `paintState` ignores one for an earlier init. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
agorischek
force-pushed
the
renderer-status-events
branch
from
November 21, 2026 15:19
8717cf9 to
e6a816e
Compare
This was referenced Nov 21, 2026
agorischek
added a commit
that referenced
this pull request
Nov 21, 2026
…#146) useProjection's onRendererStatusChange and onPainted (#122) weren't ProjectionView props, so a host using the prebuilt view still had to observe its data-renderer-status attribute. The view now takes both and forwards them. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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.

Stacked on #115 (the playback machine). I built it on #115 because the State machine survey session asked that
use-projection.tsbe left alone until #115 merges; building on it avoids the conflict instead. This is item G2 of the headless-host plan ("status events").Why
The controller had no way to say "the renderer is ready" or "the frames have drawn". Hosts read it from the view's DOM:
hosted/service/src/landing-carousel.tsx:81-95, private) puts a MutationObserver ondata-renderer-status;src/github/tour-playback.ts:93-106, private) observesdata-progress,data-comparison-mode,data-renderer-statusanddata-rendered-progress;So every UI had to hand-copy those data attributes as an informal contract.
What changed
ProjectionOptions.onRendererStatusChange(status)is called wheneverrendererStatuschanges, and with the first value.ProjectionController.paint(PaintState) and the purepaintState(controller):nonewithout a renderer;loadingorfailedwhile a shown pane is;paintinguntil every shown pane has acknowledged painting what it was sent: in two-pane modes the start (before pane) and the end (after pane), in Animated the current progress;painted.This generalises the Inspector snapshot page's private
paintedcheck.ProjectionOptions.onPainted({mode, progress})is called once each time the frames settle on what's shown while paused: after a load, a mode change, a seek or the end of playback.projection/paint.tsis new.use-projection.tsgains one hook call and thepaintfield, and doesn't touch Host core: playback's lifecycle as a state machine, with one stop path #115's playback code.The State machine survey session agreed these names. If the pane status becomes a machine later, they become its effects.
Follow-ups
onRendererStatusChangeandonPainted, which removes their MutationObservers.snapshotReadinesscan usepaintStatefor its painted check.Docs and tests
docs/guides/host-core.mdgains "Status events".packages/host/core/test/paint.test.mjs(node:test, 3 tests) coverspaintStatein Animated, two-pane modes, one extraction and diff.Run locally:
tools check --fast: pass.tscfor core: pass, withpackages/machinebuilt.node --test test/paint.test.mjs test/playback-lifecycle.test.mjs: 9/9.