Repository navigation
Give widget controllers and clock paints the one return rule, and cut two leftovers - #2565
Merged
Merged
Conversation
… two leftovers A controller-driven widget now draws on return by the rule data and projection watchers already follow (`readingPaint`): only a reading that changed while it was away draws again, so a `renderState` that failed is reported once. Before, the controller cleared its rendered reading on departure and redrew on every return, reporting a failure again each time. A return to an unchanged reading still settles its presentation ticket. Time readings in the controller's render now subscribe to the shared clock, as module-authoring.md already said they did; a tick claims a fresh draw through the controller's own publish, so it respects a deferral. `clocked` now follows its owner's lifetime itself: its readings pause while the owner is away and resume when it returns. Before, the tick dropped a departed owner's paint for good, so lf-pr-brief stopped and resumed its clock by hand; that code is gone, with `render.resume()`. `readingPaint` moves from arrivals.js to presence.js beside `clocked`, which now imports `watchOwner`, so there is no import cycle. The optional Thread panel path (`required: false`), whose only caller was a test, is deleted with that test; every registered panel is the required kind. The thread list's `openThreads()` returned every card with the panel open and the open cards in page order with it shut. It is now two readings named for what they return: `threadCards()` and `openThreadsInPageOrder()`. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…rts no subscription mid-connect Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
approved these changes
Oct 12, 2026
max-sixty
added a commit
that referenced
this pull request
Oct 12, 2026
…rule (#2568) The last two places that kept their own return rule now paint through `readingPaint`, the one rule #2565 settled: on return, a paint draws again only when its reading changed while away, or when the departure cut a paint short. These are items 66 and 67 of the Lit survey follow-up review, numbered in that review rather than as GitHub issues. ## Behaviour that changed - **Item 66: a comparison watcher survives a throw.** `watchComparison` (version.js) read on every return inside `whileConnected`'s `start`. A callback that threw there made `watchOwner` retire the subscription for good, so a tab's or settled ask's Δ marks stopped following the comparison. Comparisons now carry a generation, advanced by `announceComparison()` at each of the two places the comparison changes. `watchComparison` keys `readingPaint` on it: each `lf-comparison` event reads at once, and a connection reads on the following microtask, outside the connection. A return to an unchanged comparison reads nothing. A throw is reported once and the next comparison change reads again. module-authoring.md "Reading version changes" says so. - **Item 67: lf-diff's inline patch uses the shared rule.** `readingPaint` is now exported from `widget-api.js` and documented under "Connection lifetimes". lf-diff's inline patch paints through it, keyed by the patch text, and its `settled` flag from #2503 is gone. No other package or example widget keeps a copy of the rule. lf-file-editor re-reads its file on each connection, but that is an external re-read with no reading key, not a copy. ## Measured Hand-written source excludes tests and Markdown. | Item | Source | Tests | |---|---|---| | 66 | version.js +23 / −11 | +50 / −0 | | 67 | widget-api.js +8 / −1, lf-diff.js +12 / −6 | 0 | | Total | +43 / −18 | +50 / −0 | ## Validation - `test_a_comparison_mark_that_failed_on_return_keeps_following_the_comparison` fails on `main`: the decision tab's mark stays empty after a later comparison. It passes here, and checks the throw is reported once. - These pass: all of `test_render_options_settled.py` and `test_render_diff_controls.py`, including #2503's `test_a_patch_that_failed_stays_failed_when_its_diff_returns`; the `diff or tab` selection of `test_render_widgets.py` (66 tests); the margin comparison test and two comparison-selection tests in `test_render_anchors.py`; and `pnpm run test:runtime`. > _This was written by Claude Code on behalf of max-sixty_ --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
max-sixty
added a commit
that referenced
this pull request
Oct 12, 2026
…2573) A revision that replaces a primary Thread reader with another one no longer throws "The page already has a Thread presentation". The thread draft, its selection and the frozen widgets carry across to the replacement again. This fixes review item #70: `test_primary_reader_revision_replaces_owner_without_losing_thread_draft` was failing on `main`. ## Cause Bisect over `main` (781f2da..6b1210e, running only that test) names #2503 (d57bf19) as the first bad commit; its parent bb47f5f passes. #2503 moved `lf-conversation-workspace`'s registrations off `connectedCallback`/`disconnectedCallback` and onto `whileConnected`. `whileConnected`'s connect runs synchronously, but `watchOwner` decides a departure only at the next arrival mutation batch. `patchTree` evicts the replaced element and then inserts its replacement in the same task, so the replacement's `start` ran while the evicted element still held its registration. The single-holder registries (`thread/destination.js` `register`, `thread/presentation.js` `registerPrimary`) then refused it. `dom-move.js` appears in the stack only because it is the insertion that connects the element. #2545, #2552 and #2565 did not cause it; #2552's PR notes that the test already failed without it. ## Fix This is fixed in the lifetime primitive, not in each registry. Two changes in `arrivals.js`: - The `offer` that `watchArrivals` returns now reads the pending mutation records (`takeRecords`) before it decides its element. A decision made now therefore never runs ahead of a departure already made. `watchOwner` offers every owner as it connects, so whatever left before has released first. - `offerMany` now decides every departure in a batch before any arrival in it. Each mutation record lists its added nodes before its removed ones, so before this, an owner returning through the batch (`old.replaceWith(returning)`) started before `old` released. A move within one batch still keeps its resources. An element that is removed, and then re-added after another owner connected in between, now leaves and comes back, which is what `disconnectedCallback` did before #2503. The `arrivals.js` header and `module-authoring.md` ("Connection lifetimes") now state this rule. The single-holder checks in the registries stay as they are, since they guard a real invariant: two primary readers standing at once. ## Why CI didn't catch it The test is in the `nightly` tier (`tests/cost_tiers.json`: it costs more than 8 s on CI's runner). A pull request's gate adds later-tier tests only when the change edits their own lines (`--changed-since`), and #2503 did not edit this one. The last scheduled run started on 2026-10-11 at 10:53 UTC, before #2503 landed, so no nightly run has executed the test since the break. The three most recent scheduled runs (10-09, 10-10 and 10-11) were all cancelled, so the nightly tier has not reported for three days. ## Measured (item #70) - Hand-written source: `arrivals.js` +26 / −16. Of that, code is +15 / −12 and the header comment is +11 / −4. The Markdown change is excluded. - Tests: +35 / −0. That is one Node runtime test, `an owner replaced within one batch releases before its replacement starts`, with two cases. The case of a new owner fails on `main` with "already held". The case of a returning owner fails the same way with only the `takeRecords` change applied. Both pass here. ## Validation - The failing browser test passes. - `pnpm run test:runtime` passes (368 tests). - 55 focused primary-reader, presentation, draft and workspace tests in `test_render_application_boundary.py` and `test_render_threads.py` pass, across all tiers. - I ran 332 lifetime, return, mirror, carry, workspace, reading-region and code-copy tests across `tests/`, in all tiers (`-k "returns or returning or lifecycle or lifetime or disconnect or mirror or revision_replaces or retains or carry or primary_reader or workspace or external_link or reading_region or code_copy"`). All pass except `test_render_anchors.py::test_code_copy_enter_leaves_nested_links_usable`, which this change does not cause. Under `-n 4` that test fails 2 runs in 6 with `copyAtPresentation == 2`, both with `main`'s `arrivals.js` and with this branch's. > _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.
A widget driven by
widgetControllernow draws on return by the same rule aswatchDataandwatchProjection: only a reading that changed while it was away draws again, so arenderStatethat failed is reported once.clockednow follows its owner's lifetime, so no widget pauses and resumes its clock by hand. Two leftovers go: an optional Thread panel path nothing used, and the misleadingopenThreads. These are items 60–63 of the Lit survey follow-up review, numbered in that review rather than as GitHub issues.Behaviour that changed
widget-controller.jscleared its rendered reading on departure, so every return ranrenderStateand its subscribers again, and a failing render was reported again each time. It now paints throughreadingPaint, keyed by the reading. A return to an unchanged reading draws nothing and settles its presentation ticket; a reading that changed while away draws as before.defer(), an ancestor'srefreshand the last unsubscribe owe a fresh draw (forget()). Time readings inrenderStateor a subscriber now subscribe to the shared clock, which module-authoring.md already said they did. A tick claims the draw through the controller's ownpublish, so it waits out a deferral or drag like any other reading.clockedfollows its owner.clockedholds awatchOwnerlifetime from construction. Its readings pause while the owner is away, and the next tick after a return repaints what aged. Before, the tick dropped a departed owner's paint for good, so lf-pr-brief stopped and resumed it by hand; that code andrender.resume()are gone.stop()takes a paint off the clock until it paints again.tickClocknow skips, rather than drops, an owner removed before its departure reaches the arrival batch. To avoid an import cycle,readingPaintmoves from arrivals.js to presence.js besideclocked. presence.js importswatchOwner, and arrivals.js no longer imports presence.js. No other caller managed a clock's lifetime by hand.registerPanel({required: false})nested its ownclockedpaint insidewatchThreadsand discarded its promise. Its only caller wastest_two_standard_thread_lists_share_updates_but_not_local_state, so that test goes too.requiredis gone fromregisterPanelandregisterThreadPanel: every panel joins the thread presentation.openThreadsis split into two functions named for what they return. It returned every card with the panel open, and the open cards in page order with it shut. The t/T walk with the panel shut now callsopenThreadsInPageOrder(). The queue walk's arrival by id looks amongthreadCards()when the panel is open and amongopenThreadsInPageOrder()when it is shut. The comment Walk one list of threads in the Threads panel, and report one position #2551 added to explain the old function is gone.clockedparagraph no longer tells authors to call.stop()and.resume().Measured
Hand-written source excludes tests, Markdown and the generated
corpus.pagecopy.invalidatepassed throughreadingPaint(≈ +3 / −2)readingPaintmoving files.Validation
test_a_returning_controller_widget_draws_again_only_a_changed_readingfailed onmainin both of its halves. An unchanged return redrew the widget. After a failingrenderState, a return ran it again and reported the failure again. It passes here.main([0]where[0, 1]was expected): with no manual resume, the returned paint never ticked. It passes here.test_page_owned_registry_and_widget_use_the_captured_public_apiasserted the old unconditional redraw after another widget's action. It now asserts that the unchanged return draws nothing.pnpm run test:runtimepasses. These browser runs pass: all oftest_render_application_boundary.py, the data and projection return tests, the clock paint tests, the required-panel startup tests, the PR brief clock and remount tests, report narration, the thread and queue walk tests, and the widget, options and controls lifetime selections.test_primary_reader_revision_replaces_owner_without_losing_thread_draftfails ("The page already has a Thread presentation") as it did before this change, per Give returning data and projection watchers one rule, so a failed projection paint is reported once #2552.Not changed
watchComparison(version.js) re-reads on every return throughwhileConnected. A callback that throws retires its subscription, so nothing is reported twice. Moving it ontoreadingPaintwould need a comparison generation to key on. lf-diff's inline patch keeps the same rule in its ownsettledflag. Moving it ontoreadingPaintmeans exportingreadingPaintto packages, which adds a public API.