Repository navigation
Name a page by its first startup fault, and draw a late widget subscriber through its paint - #2585
Conversation
…re consuming its refusals, and draw a late subscriber through its paint A page whose module stages bare text is refused by every reader of its words, not only by presentation: each repaint's touch controls read the reading block and throw the same refusal, uncaught, before the page presents. Each of those reached the prepaint's fault handler, which wrote the same `data-lf-startup-error` again, a write that changes nothing. The prepaint now names the page by its first fault, as the bootstrap's report already did; a later fault only takes the interactive mark off where it is incomplete. The bare-text refusal test consumed its errors while repaints were still throwing, so under load a later refusal and the repeated write arrived after the consume and failed teardown. It now closes the page first, as tests/AGENTS.md says for a recurring fault. The same late errors occur on the runtime before #2575, so that change did not cause them. A subscriber added to a widget controller after its first render was drawn by a separate path that bypassed `readingPaint`, so its failure was reported as "Presentation failed". It now redraws the standing reading through the paint, which runs `renderState` and every subscriber again with the same reading, as a refresh does, and reports a failure once as that paint's. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…tup test's fixed faults without closing Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
left a comment
There was a problem hiding this comment.
The “Left for a decision” section leaves the refused-page behavior unresolved: its repaint still stops at the touch controls, and the startup notice waits for a server update that cannot correct the module. Choosing whether that page presents would change the bare-text refusal contract. I’m withholding approval until that decision is settled.
|
@leaf-agent The refused page's repaint behaviour is unchanged by this PR: the late refusals from the touch controls occur identically on the runtime from before #2575 and on
|
…d say the page has the problem (#2594) This closes issue 81 of the Lit follow-up review (that review's numbering, not a GitHub issue). ## What was wrong A page whose module stages bare text into a shadow root is refused by `elementOver` (`runtime/passages.js`). Every later reader of the page's words then raised the refusal again: each repaint frame (`paintTouchControls` → `standing` → `walkOrigin` → `pageReadingBlock` → … → `elementOver`), each key through the keyboard dispatch, a resize through version.js's reading-region restore, and a selection through the composing surface's listeners. Each was an uncaught error and another report. A wheel, a resize and three presses took one page from 6 errors to 25. The "Leaf couldn't start" notice meanwhile waited for a server update, which can't fix a module's mistake. #2585 made the prepaint record only the first fault, but the loop kept throwing. Stopping each reader that rereads the page would have meant keeping a list of readers, and a first version that stopped the rendering loop and the page keys still missed selection. So the fix sits where every reader passes: the walk. ## Behaviour that changed - **The walk refuses a root's bare text once.** Before crossing into a declared shadow root, the walk checks it for bare text (`refusesBareText`). A root that has some is refused for good (`refuseShadowRoot`, `runtime/shadow.js`). From then on every walk, and the list of declared roots that `getComposedRanges` is handed (`shadowRootsIn`), reads that host by its own children, the way an undeclared root reads. Those children are the words the file holds. No reader throws, so the agent gets one report, made at that point with `reportPageError`. - **Before presentation, the refusal is the page's own startup failure.** It goes through the existing path as `lf-startup-failed` marked `page: true`. The prepaint takes `data-lf-interactive` off, so the readable fallback shows at once. `presentPage` never stamps a page declared failed, because a later state answer would otherwise present the reading without those words. The recorded decision stands: such a page does not present. - **The notice says the page has the problem.** A fault marked `page` reaches the bootstrap through `lf-startup-fault`. The notice reads "Leaf couldn't start: this page has a problem its author needs to fix.", and the bootstrap no longer polls for a replacement server. - **After presentation,** a refusal leaves the page running without those words and is reported once. - `elementOver` is a plain throw again, kept as the assertion for any node handed to it directly. ## Measured | | Added | Removed | |---|---|---| | Source (`leaf.js`, `bootstrap.js`, `passages.js`, `prepaint.js`, `shadow.js`) | 91 | 25 | | Tests | 46 | 8 | About two thirds of the added source lines are comments. ## Validation - `test_a_module_that_stages_bare_text_is_refused_in_its_own_name` now also asserts the notice's wording, the readable fallback, and exactly one console error and one `error` event in the log across a wheel, a resize, two key presses, a click, a drag-select and a double-click. It fails on `main`, where the notice waits for the server. `leaf-dev flake` ran it, and `test_the_first_startup_fault_names_the_page`, 18 times each with no failures. - A probe that appends bare text to a presented page and then scrolls, resizes, presses keys and selects gets one report. The page keeps `data-lf-interactive` and `data-lf-presented`. - These pass: `test_render_projection.py` and `test_render_startup.py` in full, the startup and layer-mismatch tests in `test_site.py` and `test_widget_quality.py`, the sample tests in `test_render_controls.py`, the shadow and editor tests in `test_render_anchors.py` and `test_render_files.py`, and `pnpm run test:runtime` (371). - `test_a_window_sample_is_a_whole_leaf_window_that_scrolls_inside` fails locally on `main` as well (`scrollY` 444 against 408), so this change doesn't cause it. > _This was written by Claude Code on behalf of max-sixty_ --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
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_nameerrored at teardown in 2 of 5 local full-file runs after #2575, with latereadingBlockpage errors and a repeated write ofdata-lf-startup-error. The mechanism: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.fault, which wrote the same reason todata-lf-startup-erroragain, a write that changes nothing (write_watch.js).#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
prepaint.jsnow writesdata-lf-startup-errorandlfStartupException, and dispatcheslf-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 itsrecoveralready ignored every fault after the first.readingPaint. It used to draw on a separate path that ran only the new callback, so a failure was reported asPresentation failed: …. It now redraws the standing reading through the widget's paint, asrefresh()does, which runsrenderStateand every subscriber again with the same reading. A failure is reported once, aspaint failed for <tag>#<id>: …, and the widget shows its fail-soft box.presentRenderloses itsdrawparameter and its try/catch, becausereadingPaint's paint never throws. Every shipped widget subscribes once, so only a second subscription reaches this path.Measured
prepaint.js,widget-controller.js)Validation
test_the_first_startup_fault_names_the_page(new) fails onmain, where the root names the last fault, a declared one. It also checks that an incomplete fault after an uncaught one still takes offdata-lf-interactive.test_a_subscriber_added_after_the_first_render_fails_by_the_paint_rule(new) fails onmain: the report readsPresentation failed: late subscriber failure.page.close(), the bare-text test passes.leaf-dev flakeran the three tests 18 times each with no failures. The fulltest_render_projection.pypasses (179), as dotest_render_application_boundary.pyand the startup-fault tests intest_render_startup.py,test_site.py,test_render_pages.py,test_render_sample_delivery.pyandtest_widget_quality.py.pnpm run test:runtimepasses (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.