Repository navigation
Host core: a renderer pane's lifecycle as an explicit machine - #147
Merged
Merged
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Snapshot readiness can accept stale render acknowledgements or snapped progress, producing captures before the new document is painted or at the wrong revision.
3 open issues
What changed in this PR
This PR extracts renderer-pane lifecycle rules from React as the next step toward the headless projection store, while preserving the public PaneState shape.
Changes:
- Adds an explicit pane lifecycle machine and tests for transitions, invariants and resets.
- Integrates
useMachineintoRendererPaneand reuses corepaintStatefor Inspector snapshot readiness. - Updates the store plan to defer aggregate status effects until pane composition.
| File | Description |
|---|---|
| packages/host/inspector/src/snapshot/readiness.ts | Replaces the private painted check with core paintState. |
| packages/host/inspector/src/snapshot/page.tsx | Removes obsolete pane keys from the readiness input. |
| packages/host/core/test/pane-lifecycle.test.mjs | Tests lifecycle transitions, invariants and public state. |
| packages/host/core/src/pane.tsx | Replaces inline state updates with the lifecycle machine. |
| packages/host/core/src/pane-lifecycle.ts | Defines pane stages, report handling and reset rules. |
| docs/design/proposals/headless-store.md | Clarifies step 2 and the timing of aggregate status effects. |
Review effort: Balanced
The second step of the projection store (docs/design/proposals/headless-store.md). A pane's state was a `useState` updated by a switch over its frame's events. It is now `paneLifecycle`, defined with the machine package: loading until the frame is revealed, then ready; failed for good, as the frame itself is, until a new bundle loads; each state keeps what the renderer reported, and a new document drops what was painted and stepped for the old one. `RendererPane` runs it with `useMachine`, and `PaneState` is unchanged. The Inspector's snapshot page now judges paint with the core's `paintState`, which also ignores an acknowledgement of an earlier document. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
agorischek
force-pushed
the
pane-machine
branch
from
November 21, 2026 17:31
feb6c4d to
12a73ec
Compare
… the progress they asked for The pane lifecycle compares reported values, not the new copy each report arrives in, so a repeated report changes nothing; the painted init is compared by identity. The Inspector's snapshot readiness passes its requested progress to paintState, as it compared before, since a step can snap the controller's. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This was referenced Nov 21, 2026
Closed
agorischek
added a commit
that referenced
this pull request
Nov 21, 2026
…ge last showed (#153) * Renderer test helpers: bound each stage request, and say what the stage last showed A stage the renderer harness drives through openStage could stop answering: WebKit runs the sandboxed renderer frame in the host page's process, so a renderer stuck in its document stops the stage page with it, and the page's own waits (a probe measurement's 10 s, a frame's arrival at 60 s) never fire. diff.spec's graph test then waited the whole 360 s test timeout on a measure('settle'), or on a locator in the frame, twice on #147. Each request a StageHandle makes of the page (load, seek, measure, state, …) now fails after 90 s in the test process, naming the request, the scenario and the stage's last known state (status, renderer, mode, progress painted, height asked for, errors) and when the page last answered. The page's own bounds stay where they were; this one only catches a page that no longer runs. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> * Renderer test helpers: an unanswered stage request names both of its causes Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --------- 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 #145. This is step 2 of the projection store (G4), following
docs/design/proposals/headless-store.md.Why
A renderer pane's state was a
useStateinRendererPane, updated by a switch over the frame's events. Its lifecycle was implicit:setStateleft.The state-machine survey listed it (pane status aggregation, #16), and the store needs it framework-free.
What changed
src/pane-lifecycle.tsdefinespaneLifecyclewith@githubnext/projections-machine:loadinguntil the frame isrevealed, thenready;failed(with its message), which is final, asFrameLifecycleis, untilreloaded(a new bundle) starts the pane over.reinit(a new document) drops what was painted and stepped for the old one. An unchanged report returns the same state, so nothing re-renders.paneStateOfgives the publicPaneState, which is unchanged.RendererPaneruns it withuseMachine. The actor starts in a layout effect, before the frame (created in an effect) can send anything, and its changes render assetStatedid. Callback-only events (select, hover, anchor and the rest) are unchanged.paintStatein place of its privatepainted. They're equivalent for the progress it controls, andpaintStatealso ignores an acknowledgement of an earlier document (Host core: tell hosts when the renderer is ready and when the frames have painted #122).SnapshotState.keysgoes.Not here, and why
The design had #122's events (
onRendererStatusChangeandonPainted) as this machine's effects. They depend on every shown pane, not one, so they stay derived fromrendererStatusandpaintuntil the store composes the panes (step 4), where they become its effects with the same names. The design note's step 2 now says this.Tests
packages/host/core/test/pane-lifecycle.test.mjs:explorewithcomplete: true: every listed handler is reachable. Its invariants:Its transition properties:
reloaded;revealed.A walk through the public
PaneState: status, failure, reinit, an unchanged report keeping identity, and the reset on reload.Run locally:
tools check --fast: pass, with the machines gate and no baseline change.tscfor core: pass. The Inspector's snapshot files have no errors; the rest of its build needs renderers that aren't built here.node --testonpane-lifecycle,settings-store,paint,playback-lifecycle,hostandframe-reopen: 29/29.The browser suites run in CI.