Repository navigation
Wait across a sample departure for its next document - #2534
Merged
Merged
Conversation
…llery Reset A departed sample now keeps one `ready` for its next document instead of rejecting. `sample.js` used to reject `ready` with `SampleDepartedError` when the child document left, and a reload then announced a fresh one, so every owner had to tell a departure from a failure and re-subscribe: `lf-sample.showThread` rejected (an unhandled rejection where the examples call it with `void`), and the interaction gallery's first configuration ended at the departure, counting the page as arrived while the demo still said "Loading…". Now a departure, and the reload after it, share one pending presentation; Reset or destroy cancels it with `AbortError`. Commands in flight still reject with `SampleDepartedError`, since they belong to one document. - `lf-sample` follows one `ready` per host presentation, so a departure and its reload are one wait, and `showThread` re-sends a selection the child left before presenting. It returns false only when a newer selection, Reset or removal supersedes it. - The gallery runs one configuration at a time and follows a departure or Reset to the next document; the page arrives when that ends. - While a gallery demo has no document to play (departed, or failed), the row offers Reset, as `lf-sample` does. It stays, unpressable, while the replacement loads, then hands focus to the toggle. - `sample.js`'s header and page-authoring's "Live samples" state the contract. Tests: a reload interrupting a selection now lands it in the next document; the gallery's arrival waits for a reloaded document's configuration; a reload to a non-Leaf document leaves Reset, which plays again from the keyboard; a failed first document resets to Play. The native-departure test expects `ready` and selections to wait until Reset rather than reject. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
lf-sample's selection race and sample.js's load-queue wait each built a promise from an abort signal by hand. They now use aborted(signal) from abort.js (#2521), which widget-api.js exports for package modules and module-authoring.md names. The queue wait keeps a slot handed over before the abort, as before. The host's showThread keeps its listener: it removes it when the call settles, so a later abort cannot cancel a newer view. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ument wait quiet Review follow-ups: the wait a departure starts is handled like an operation's, so a host nobody awaits drops its rejection; begin's comment and rendering.js name the one open-ended hold; lf-sample.showThread is async again; the reload-selection test now selects a panel view only the next document can present. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
#2505 and #2506 landed together: the contract still described protocol 1 with the task names, so check:browser failed on main and on every PR. This is build:browser's output from the merged source. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
previously approved these changes
Oct 12, 2026
# Conflicts: # skills/leaf/references/page-authoring.md
leaf-agent
reviewed
Oct 12, 2026
leaf-agent
left a comment
Collaborator
There was a problem hiding this comment.
The Contract paragraph says a departure “no longer ends the operation that Reset coalesces with.” The departed handler in mountSample sets operation = null, so Reset starts a new replace() instead of coalescing with the interrupted load. Please correct that sentence; the PR description becomes the squash commit message, and the current wording reverses the mechanism that makes Reset work.
# Conflicts: # skills/leaf/assets/runtime/interaction-gallery.js # tests/test_render_controls.py # tests/test_site.py
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.
When a sample's child document departs, the sample now keeps one
readypromise for its next document, and owners wait on it rather than rejecting. #2501 gave departure its own error (SampleDepartedError). It still rejectedreadyon every departure, though, and minted a fresh promise on the reload, so each owner had to tell a departure from a failure and start over.Review item 47 (Lit follow-up round). What changed:
lf-sample.showThreadacross a reload. It used to reject when the child left, so the examples'void sample.showThread(…)calls infeature-gallery.htmlandcorpus.htmllogged an unhandled rejection. Now a selection the child leaves before presenting waits for the next document and lands there. It returns false only when a newer selection, Reset or removal supersedes it, as Reset already did.lf-samplefollows onereadyper host presentation, so a departure and its reload are one wait, andlf-sample-readyfires once the next document presents.maindrops them.sample.js,readyis the presentation of the next document. A departure, and the reload after it, share one pending presentation. Reset or destroy cancels it withAbortError, and a successor that fails to start rejects it with its failure. Commands in flight still reject withSampleDepartedError, since they belong to one document. A departure clears the in-flight operation Reset would otherwise coalesce with, so Reset during the wait starts a fresh allocation. The module header and page-authoring's "Live samples" state this.aborted(signal).lf-sample's selection race andsample.js's load-queue wait now await aborts through the helper Have the presentation handle mint and release each completion ticket, and await aborts through one helper #2521 added.widget-api.jsexports it for package modules, andmodule-authoring.mdnames it. The host's ownshowThreadkeeps its listener and removes it when the call settles, so a later abort cannot cancel a newer view.Tests, written first, failed on
main:showThreadlands the selection in the next document: a panel view only the next document's own command can present resolvestrue. Onmainit rejected withSampleDepartedError.readyand selections to wait until Reset, rather than reject. After Reset, the waiting selection returns false.Line deltas, from
git diff --numstatagainstmain: hand-written source +83 / −60 (net +23) acrosssample.js,lf-sample.js,rendering.jsandwidget-api.js. Tests +50 / −11 (net +39).One behaviour changes: a departure during a sample's first load now keeps that load pending until a next document arrives or the user presses Reset. A reload, the common case, presents and settles it. An external destination before the first presentation, such as an authored template script that navigates during startup, leaves the
lf-samplewidget's presentation pending until Reset. The parent cannot tell that case from a reload.lf-sample.jsandrendering.jsrecord it as the one open-ended rendering hold.