Repository navigation
Report a failing paint once in readingPaint, and keep every watcher's subscription - #2575
Merged
Merged
Conversation
… subscription readingPaint now owns what happens when a draw fails, for every caller and every route into the draw (a call, refresh(), or a clock repaint): a draw that throws or rejects while its owner stands is reported once, as a page error naming its owner, and never reaches the caller as a throw. The reading stands, failed, and the next changed reading draws again. A draw the owner's departure cut short is not reported, since its return draws it again. The call returns a rejected promise a caller may hand to a presentation or ignore. Behaviour that changed: - watchData: a callback that threw on its first reading of a connection, including a return after its source changed while the widget was away, ended the subscription for good, so the widget never drew a later source. It is now reported once and the next reading draws. Its own catch, `updateSafely`, the `mounting` flag and the stop-on-mount path are gone, and the comment that recorded the permanent stop as deliberate is rewritten to the new contract. Reports read "paint failed for lf-feed#id" in place of "data subscriber failed for ... input ... source ...". - watchProjection: a reading whose promise rejected was never reported; readingPaint's settle handler swallowed it. It is now reported like a throw, and a throw no longer escapes the microtask as an uncaught exception. - watchComparison reads on connection again; the microtask that kept a throw out of the connection is no longer needed. - widgetController: a failed renderState is reported by its paint and the region falls back to the same fail-soft box. The presentation coordinator now reports through reportCarried, so a failure a paint already reported is not reported a second time as "Presentation failed"; one it did not see still is. - Clock: a reading paint's clock repaint now fails by the same rule. The clock reports through reportCarried, so it reports only a failure no paint reported (a plain `clocked` paint's), still as "clock paint failed". module-authoring.md "Connection lifetimes", the watchData readiness paragraph and watchComparison's entry describe the new rule. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
reviewed
Oct 12, 2026
leaf-agent
left a comment
Collaborator
There was a problem hiding this comment.
A pending earlier paint can still report after its owner departs; the inline comment shows the overlapping sequence.
A draw overtaken by a later one lost its only marker, so if it rejected after the owner left and returned, readingPaint reported it, against its rule that a draw the departure cut short is not reported. The paint now keeps every running draw and marks them all cut on departure. 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
…iber through its paint (#2585) This closes issue 78 of the Lit follow-up review (that review's numbering, not a GitHub issue), in two parts. ## (a) The bare-text refusal test's teardown errors `test_a_module_that_stages_bare_text_is_refused_in_its_own_name` errored at teardown in 2 of 5 local full-file runs after #2575, with late `readingBlock` page errors and a repeated write of `data-lf-startup-error`. The mechanism: - A page whose module stages bare text is refused by every reader of its words, not only by presentation. On each repaint, the touch controls read the page's reading block (`paintTouchControls` → `standing` → `walkOrigin` → `pageReadingBlock` → `readingBlock` → `pageText` → `elementOver`) and throw the same refusal, uncaught. Every input adds more: a wheel, a resize and three key or pointer presses took one page from 6 errors to 25. - Each uncaught error before presentation reached the prepaint's `fault`, which wrote the same reason to `data-lf-startup-error` again, a write that changes nothing (`write_watch.js`). - The test consumed its errors right after the first refusal. Under load, a later refusal and the repeated write arrived after the consume and failed teardown. #2575 did not cause this. With a 3 s wait after the refusal, the runtime from before #2575 produces the same late errors and the same unchanged write. ## Behaviour that changed - **The first startup fault names the page.** `prepaint.js` now writes `data-lf-startup-error` and `lfStartupException`, and dispatches `lf-startup-fault`, for the first fault only. A later fault only takes the interactive mark off where it is incomplete. The bootstrap's report already kept the first fault (`fault ??= reason`), and its `recover` already ignored every fault after the first. - **The bare-text test closes its page before consuming,** as tests/AGENTS.md ("Browser errors") says for a recurring fault. - **A subscriber added after the first render draws through `readingPaint`.** It used to draw on a separate path that ran only the new callback, so a failure was reported as `Presentation failed: …`. It now redraws the standing reading through the widget's paint, as `refresh()` does, which runs `renderState` and every subscriber again with the same reading. A failure is reported once, as `paint failed for <tag>#<id>: …`, and the widget shows its fail-soft box. `presentRender` loses its `draw` parameter and its try/catch, because `readingPaint`'s paint never throws. Every shipped widget subscribes once, so only a second subscription reaches this path. ## Measured | | Added | Removed | |---|---|---| | Source (`prepaint.js`, `widget-controller.js`) | 17 | 23 | | Tests | 67 | 1 | ## Validation - `test_the_first_startup_fault_names_the_page` (new) fails on `main`, where the root names the last fault, a declared one. It also checks that an incomplete fault after an uncaught one still takes off `data-lf-interactive`. - `test_a_subscriber_added_after_the_first_render_fails_by_the_paint_rule` (new) fails on `main`: the report reads `Presentation failed: late subscriber failure`. - With a 3 s wait and user input before `page.close()`, the bare-text test passes. - `leaf-dev flake` ran the three tests 18 times each with no failures. The full `test_render_projection.py` passes (179), as do `test_render_application_boundary.py` and the startup-fault tests in `test_render_startup.py`, `test_site.py`, `test_render_pages.py`, `test_render_sample_delivery.py` and `test_widget_quality.py`. `pnpm run test:runtime` passes (371). ## Not in this change A refused page still runs its repaint frame, which throws at the touch controls on every frame, as it did before this PR. Whether the refusal should instead happen once, at the widget's upgrade, changes the bare-text test's decision that the page does not present, so it goes to the user as a separate item. > _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
…parison paint to one report (#2588) `main`'s push `ci` has not completed green since #2568. The last two completed runs ([38235572771](https://github.com/max-sixty/leaf/actions/runs/38235572771) on 1ace63b, [38244446941](https://github.com/max-sixty/leaf/actions/runs/38244446941) on e5aca3e) failed three `main`-tier tests. Two are already fixed on `main`; this PR fixes the third and tightens one of the fixed ones. ## Behaviour that changed - **`test_an_export_keeps_its_quiet_words_off_screen` runs again.** #2555 removed the `x-paints` key and the `state` property from `declared_reading_package`, but this test still wrote `<lf-reading state="done">`, so `page check` refused the page before the export ran (`Additional properties are not allowed ('state' was unexpected)`). The test is `main`-tier and lives in a file #2555 did not edit, so `--changed-since` never selected it. It now takes its quiet word from a highlighted `lf-code` line, which the default package draws, and drops the fixture. With `.lf-quiet`'s clip removed from the theme, the test fails, as it did before. - **A failed comparison paint must be reported exactly once.** `test_a_comparison_mark_that_failed_on_return_keeps_following_the_comparison` counted only `leaf:` reports, and its comment expected a second, uncaught record of the throw. Since #2575, `readingPaint` reports the failure once and nothing escapes. On current `main` the page records one error, `leaf: paint failed for lf-tabs#views: …`. The test now requires exactly that error. A paint that also rethrows from a microtask fails it. The other two failures need nothing more. `test_a_reaction_on_a_visual_part_names_that_part` was fixed by #2582, and the comparison test's arrangement by #2581. ## Evidence - On `main` 4f81e81, the export test fails with the refusal above. With this change it passes. - `leaf-dev flake` (18 copies, six at a time) passed 18/18 for the export test, the comparison test and the reaction test. A flake run of `tests/test_render_words_watch.py` also passed 18/18 for every test. That file's `TypeError: Cannot read properties of null (reading 'present')` did not reproduce on `main` and is not in either failed run's log. - The other two `declared_reading_package` tests still pass (`test_the_render_gate_catches_a_declared_word_that_never_reached_the_page`, `test_a_word_the_revision_adds_to_a_surviving_element_is_said`). Hand-written source delta: 0 lines. Test delta: +10 −12 (`tests/test_render_export.py` +8 −10, `tests/test_render_options_settled.py` +2 −2). > _This was written by Claude Code on behalf of max-sixty_ Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
added a commit
that referenced
this pull request
Oct 13, 2026
The [main CI run](https://github.com/max-sixty/leaf/actions/runs/38317918344) found that the diff recovery test triggers three intentional render errors but accepted only the two repeated-path reports. #2575 made a failed paint report its error once, so the initial invalid patch now correctly contributes an `empty diff` report. The test accepts that report and still requires exactly one report for the initial failure and two for the repeated-path failures. The failing node ID reproduced on current `main` and passes with this change (`uv run pytest -q -n0 tests/browser/test_render_widgets.py::test_a_diff_recovers_from_each_failure_on_the_next_good_source`). Other failures in the main run have separate causes. --------- Co-authored-by: leaf-agent <[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.
readingPaint(presence.js) now holds the one failure rule for every paint that goes through it, whether a call,refresh()or a clock repaint started the draw. A draw that throws or rejects while its owner stands is reported once, as a page error naming its owner. The failure never reaches the caller as a throw, so no subscription ends on it, and the next changed reading draws again. A draw that the owner's departure cut short is not reported, because the return draws it again. Before this, each caller handled a failed draw its own way, andwatchDataended its subscription for good. This closes issue 71 of the Lit follow-up review (that review's numbering, not a GitHub issue).Behaviour that changed
A data widget recovers from a callback that failed on its return. If a source changed while its widget was away and the
watchDatacallback threw on the return,stop()ended the subscription for good, and the widget never drew a later source. The failure is now reported once and the next reading draws. Removed from data.js: its catch-and-report,updateSafely, themountingflag, the stop-on-mount path, and the comment that recorded the permanent stop as deliberate. The new contract replaces that comment. Reports now readpaint failed for lf-feed#idin place ofdata subscriber failed for … input … source ….A projection reading that rejects is reported. Before,
readingPaint's settle handler swallowed the rejection, so an asyncwatchProjection/watchQuestions/watchReports/watchHistoryfailure never reached the agent. It is now reported like a throw. A throw also no longer escapes the microtask as an uncaught exception.watchComparisonreads synchronously on connection again. Put comparison watchers and lf-diff's inline patch on the one return rule #2568 added a microtask so that a throw could not fail the connection. A throw can no longer escape the paint, so that step is gone.Widget controller: one report and one box, as before. A failed
renderStateis reported by its paint. The region falls back to the same fail-soft box,failSoftUnreported. The presentation coordinator now reports throughreportCarried, so a failure the paint already reported is not reported again asPresentation failed. A failure no paint saw is still reported under that heading. The report's text changes topaint failed for lf-local#id: <lf-local> renderState threw: ….Clock repaints follow the same rule. A reading paint's clock repaint now goes through that guard.
tickClockreports throughreportCarried, so it reports only failures no paint has already reported, such as a plainclockedpaint's. Those still readclock paint failed.module-authoring.mdnow describes the rule in "Connection lifetimes", in thewatchDatareadiness paragraph, and in thewatchComparisonentry.Measured
Hand-written source covers the runtime JS. Tests and Markdown are excluded.
Validation
test_a_subscriber_that_failed_on_return_draws_the_next_readingfails onmain: the drawn readings stop atchanged-away. It passes here and checks for exactly one report.test_a_returning_projection_subscriber_reads_again_only_where_its_departure_cut_the_paintnow includes a rejecting reader (watchHistory). Onmainthat reader is never reported.arrivals.test.mjsfail on the first version of this change and pass here. One is a clock repaint that throws, which is now reported once and names its owner. The other is a paint abandoned on departure, including one a later draw had already overtaken. That paint is drawn again on return and not reported.node --test tests/runtime/*.test.mjs, 368 tests);test_render_startup.py,test_render_anchors.pyandtest_render_projection.pyselected on data, projection, subscriber, watch, comparison and clock (207 tests); the controller and coordinator failure tests intest_render_application_boundary.py,test_render_outbox.py,test_render_threads.py,test_render_widgets.py,test_render_controls.pyandtest_render_navigation.py; and the lf-diff, lf-tabs, lf-text-document and options-settled cases (90 tests).