Repository navigation
Renderer protocol: rendered echoes the init it answers, and the host drops stale ones - #172
Merged
Merged
Conversation
…drops stale ones The host numbers each init it sends (generation), the SDK's client echoes the latest it received on rendered, and the frame's message gate drops an acknowledgement of an earlier init. A paint of the previous document that arrives after a new init no longer counts as painting the new one. Both fields are optional: hosts that send no generation get none back, and renderers that echo none are taken at their word, as before. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
A critical race allows an old deferred paint callback to acknowledge a newer init, falsely reporting the new document as painted; acknowledgements must retain their originating init token, with regression coverage.
1 open issue
What changed in this PR
Adds generation tracking to Projections’ renderer protocol so the host can reject stale paint acknowledgements. This follows #147’s pane lifecycle work and aims to prevent premature paint and snapshot readiness.
Changes:
- Adds optional, validated generations to
initandrendered, with SDK echoing and legacy compatibility. - Numbers host initializations and filters mismatched acknowledgements before progress, reveal, and pane updates.
- Adds protocol and frame tests, updates the contract, and regenerates API references.
| File | Description |
|---|---|
packages/renderers/sdk/test/protocol.test.mjs |
Tests generation validation, echoing, and handler isolation. |
packages/renderers/sdk/src/protocol/validation.ts |
Adds non-negative safe-integer validation. |
packages/renderers/sdk/src/protocol/renderer-messages.ts |
Parses optional acknowledgement generations. |
packages/renderers/sdk/src/protocol/messages.ts |
Defines and documents both generation fields. |
packages/renderers/sdk/src/protocol/host-messages.ts |
Validates initialization generations. |
packages/renderers/sdk/src/client/host-messages.ts |
Extracts generations for echoing and hides them from init handlers. |
packages/renderers/sdk/src/client.ts |
Echoes the latest init generation in acknowledgements. |
packages/host/core/test/frame-generation.test.mjs |
Tests stale filtering and unnumbered compatibility. |
packages/host/core/src/pane.tsx |
Clarifies acknowledgement attribution in a comment. |
packages/host/core/src/frame/replay.ts |
Includes generations in initialization and replay messages. |
packages/host/core/src/frame/admission.ts |
Adds stale acknowledgement admission filtering. |
packages/host/core/src/frame.ts |
Advances generations and keeps them out of pane events. |
docs/reference/renderer-sdk.md |
Regenerates SDK signatures with generation fields. |
docs/reference/renderer-messages.md |
Regenerates protocol type references. |
docs/contracts/renderer-frames.md |
Documents generation exchange and stale filtering. |
Review effort: Balanced
… init it painted rendered(progress, init) echoes the generation of the init payload it painted, which the client records as it hands each init to the renderer; the SDK's React hooks pass it. A paint of the previous document that finishes after a new init arrives is then dropped by the host. Without the init, the latest is assumed. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…t painted 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.

Follow-up to a Copilot thread on #147. A renderer's
renderedacknowledgement of the previous document could arrive after the host sent a newinit. The pane then recorded it as painting the new document, sopaintState(and the Inspector's snapshot readiness) could report painted too early.Protocol (
renderers/sdk/src/protocol):initmay carrygeneration, a non-negative safe integer the host gives eachinitit sends.renderedmay carrygeneration, the latest the renderer had received when it reported.SDK client:
rendered()echoes the latestinit's generation, read from the init the client already keeps for replay.inithandler never sees the field.Host:
RendererFramenumbers eachsetInit, and sends the number withinit, including the one replayed at ready.MessageGatedrops arenderedfor an earlier generation (a newstaleadmission), before it reaches progress flow control, the reveal or the pane.setInitin the same step, so its tagging is now correct.Compatibility:
renderedfield, because the client only echoes what the host sent.Docs:
contracts/renderer-frames.mddescribes both fields, and the generated reference pages are regenerated.Tests:
renderers/sdk/test/protocol.test.mjs: parsing, the client's echo, and the init handler not seeing the field.host/core/test/frame-generation.test.mjs: a realRendererFramewith a fake window drops an earlier generation's acknowledgement and takes an unnumbered one.