Repository navigation
Seat a widget declaring x-thread-surface without its module registering it - #2571
Merged
Merged
Conversation
…tering
`x-thread-surface` only gated `placeThreads`: the module registered in
connectedCallback and unregistered in disconnectedCallback, and `requireSurface`
refused the call unless the tag declared the key, so the declaration added
nothing the call did not. The declaration now does the work.
- The runtime registers each instance of a declaring tag once its module has
defined it and retires it when it leaves, over the arrival lifetime every
element owner holds (`watchArrivals`), so a move within one batch keeps it.
An element standing before its module loaded is offered again once the
definition resolves. The watch starts once the registry that names the tags
has loaded.
- On each reconciliation pass the runtime calls the element's own
`threadOutlets(targets, {signal, collection})`, with the same batch, outlet
array and failure handling the callback had.
- The widget reaches its registration through `threadSurface(element)` from
widget-api.js: `update()` and `open(datum, {origin})`. Before registration or
after the widget leaves, `update` does nothing and `open` returns false.
- `placeThreads` and `requireSurface` go. `placePageThreads` stays for
page-owned annotations.
lf-diff and lf-visual-review implement `threadOutlets` and stop registering;
lf-diff's outlet map, which held that name, is now `threadSeats`. The registry
description, module-authoring.md, docs/registry.html and the two eval cases that
named `placeThreads` describe the new contract.
Behavior changes in tests: a widget can no longer withdraw its surface while it
stands, so the adapter-isolation test drops its two unregister cases, and the
widget-before-page and cohort tests withhold seats by returning null outlets
instead of registering late or unregistering.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
previously approved these changes
Oct 12, 2026
… upgrade A declaring widget whose constructor throws stays undefined after its definition has resolved, so re-offering it on each resolution and waiting again looped microtasks forever and froze the page. The watch now waits only while no definition stands; an element still undefined after that failed to upgrade, and its module's failure report is the outcome the user sees. tests/runtime/thread-surfaces.test.mjs holds it: the old code waited 21 times before the test's cap, the new one not at all. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
previously approved these changes
Oct 12, 2026
# Conflicts: # skills/leaf/packages/diff/widgets/lf-diff.js # skills/leaf/references/module-authoring.md
leaf-agent
approved these changes
Oct 12, 2026
max-sixty
added a commit
that referenced
this pull request
Oct 12, 2026
A widget's thread surface `open(node, { origin })` passed `origin` to
the composition surface, whose `open` forwards to `commentOnTarget` and
reads only its first argument. #2020 (b11e278) removed `origin` there
on purpose, so Escape resolves the same structural parent for every
route into a comment. This deletes what that left behind: the option on
the registration's `open()` and on the `threadSurface(owner)` wrapper
#2571 added, lf-diff's two `{ origin: ... }` arguments, the
module-authoring sentence promising Escape returns to that control, and
the `{origin}` that #2571 wrote into the `surfaces.js` header and the
`x-thread-surface` registry entry (with `docs/registry.html`, which
`leaf-dev keydocs` derives from it). Module-authoring now states the
contract that holds instead: Escape from a datum's draft returns focus
to the datum element when it can take focus, otherwise to the page.
Lit follow-up review item 76 (the review's own numbering, not a GitHub
issue):
- Behaviour changed: none. A probe on pr-walkthrough (click a file's
comment button, press Escape) lands on the `.lf-diff-file` element on
both the merge base and this branch.
- Hand-written source line delta: +6 / −7 (`surfaces.js` +4/−5,
`lf-diff.js` +2/−2), net −1.
- Test line delta: 0.
Ran: `test_render_diff_controls.py`, the inline-diff comment test in
`test_render_widgets.py`, the two diff thread tests in
`test_render_threads.py`, the data-bound diff aim test in
`test_render_anchors.py`, the panel-cover navigation test, the
registry/keydocs product tests, and
`tests/runtime/thread-surfaces.test.mjs`.
> _This was written by Claude Code on behalf of max-sixty_
Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
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.
Why
x-thread-surfaceonly gatedplaceThreads. A widget's module registered its surface inconnectedCallbackand unregistered it indisconnectedCallback, andrequireSurfacerefused the call unless the tag declared the key. The declaration added nothing the call did not, so every surface widget carried the same registration code. The user decided (#29) that the declaration should do the work.What changed
x-thread-surfaceonce its module has defined it, and retires it when it leaves the page. This uses the arrival lifetime every element owner already holds (watchArrivals), so a move within one batch keeps the registration. The watch starts once the registry that names the tags has loaded. It waits for a tag's definition only while none stands, so an element whose constructor threw is not retried; its module's failure report is the outcome.threadOutlets(targets, {signal, collection, onCommit}). The batch, the returned outlet array, the commit-time work Keep a retained editor in the document through a diff's new patch and a file editor's move #2570 added (onCommit) and the failure handling are those the callback had;lf-difflays its outlets out in the method and retires unused ones on commit.threadSurface(element)fromwidget-api.jsgivesupdate()andopen(datum, {origin}). Before registration, or after the widget leaves,updatedoes nothing andopenreturnsfalse.placeThreadsandrequireSurfaceare gone.placePageThreadsstays for page-owned annotations.lf-diffandlf-visual-reviewimplementthreadOutletsand no longer register or unregister;lf-diff's outlet map, which used that name, is nowthreadSeats. The$keysdescription,module-authoring.md("Widget-local Thread placement"),docs/registry.htmland the two eval cases that namedplaceThreadsdescribe the new contract.Behavior change
A package widget that declares
x-thread-surfacemust implementthreadOutlets. CallingplaceThreadsnow fails, because the export no longer exists. A widget can no longer withdraw its surface while it stands: to offer no seats, it returnsnullfor each target. Tests changed to match:nulloutlets, instead of registering late or unregistering.Tests
pnpm run test:runtime(369, includingthread-surfaces.test.mjsfor the failed-constructor case) andpnpm run checkpass.-n 2: 52 passed. These cover the diff, visual-review, read-state, startup adapter-failure, widget-before-page and cohort tests.widget-apiexport tests pass.