Repository navigation
Refuse a module's bare text once, end the page before it presents, and say the page has the problem - #2594
Merged
Conversation
…s the problem A page whose module stages bare text into a shadow root was refused by every reader of its words, again and again: each repaint frame threw the refusal at the touch controls, each key threw it from the keyboard dispatch, and a resize threw it from the reading-region restore. 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 cannot fix a module's mistake. Behaviour that changed: - passages.js `elementOver`, which every reader of the page's words passes through, is the one point that ends the page. Its first refusal declares the page failed (`lf-startup-failed`, marked `page: true`), so the readable fallback shows at once, and every later call throws the same refusal, which `reportCarried` drops. - A page declared failed stops rendering and taking page keys: leaf.js calls the new `stopRendering` (rendering.js), which retires every queued and future rendering callback, and unmounts the keyboard controller. Each of those read the page again. This applies to every declared startup failure, not only the refusal. - A fault that is the page's own reaches the bootstrap as `page`, and the notice reads "Leaf couldn't start: this page has a problem its author needs to fix." It no longer polls for a replacement server. - The page still does not present, as the bare-text test records. It now reports one error, to the console and to the agent's log, across a wheel, a resize and three presses; the test asserts that, the notice, and the readable fallback. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…en on Review of the previous commit found the stop list incomplete: a selection still threw the refusal from the composing surface's listeners, each an uncaught error and a second report to the agent, and a refusal after presentation tore down a page the user was working in. Stopping each reader that rereads the page was a list of readers; the deeper fix is that no reader can meet the bare text twice. Behaviour that changed: - The walk asks a declared root for bare text before crossing in (`refusesBareText`, passages.js). A root that holds some is refused for good (`refuseShadowRoot`, shadow.js), so from then on every walk, and every list of declared roots (`shadowRootsIn`, which `getComposedRanges` is handed), reads its host by the host's own children, as an undeclared root reads. No reader throws. - The one refusal is reported to the agent there, once, and before the page presents it is declared the page's own startup failure as before: readable fallback at once, the page-problem notice, and now `presentPage` never stamps a page declared failed, since a later state answer would otherwise present the reading without those words. - A refusal after presentation leaves the page running without those words and reports once; it no longer takes the interactive mark off a page in use. - `stopRendering` and the keyboard unmount are gone: nothing reads the refused text again, so nothing needs stopping. - The bare-text test now also drags a selection and double-clicks. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…, and say what a late refusal leaves behind Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
approved these changes
Oct 12, 2026
leaf-agent
added a commit
that referenced
this pull request
Nov 5, 2026
…n the page is read (#5569) A page whose x-shadow widget stages bare text into its shadow root is supposed to be refused before it presents: the readable fallback shows, the notice says the page has a problem, and the agent gets one error naming the widget (#2594). That refusal only fired because some walk of the page's words met the root first, and before #5371 the margin's points (`placePoints`) read the whole page on every document pass. #5371 made that read lazy, which was the point: a pass where every point still stands reads nothing. Now a page with no comment to find again presents without reading itself at all, so the module's bare text is never refused, the page presents, and the console stays silent. That is why `test_a_module_that_stages_bare_text_is_refused_in_its_own_name` timed out waiting for the error. This change makes the check explicit. Just before the page marks itself upgraded, startup asks every declared shadow root the page reading would cross into (`refuseBareText` in `passages.js`, called from `leaf.js`). That is the moment the refusal's contract already names. Like the reading's walk, it crosses into each root it admits and on into the stages inside that one, so a malformed widget nested in another widget's root is refused too. It skips hosts inside Leaf's own surfaces, as `readPage` does. #5371's lazy reading stays as it is. The added startup work is one look at each stage's direct children. **Verification** - Restoring the eager `pageText()` in `placePoints` makes the test pass on main, which confirms the cause. - With this change the test fails on main and passes on this branch. - A runtime case in `tests/runtime/passage-boundaries.test.mjs` stages bare text inside another stage's root; it fails with a sweep of the body's stages alone and passes with this change. - `tests/browser/projection/test_widget_actions.py` and `tests/browser/test_shadow_stage.py` pass (17 tests), as do `pnpm run test:runtime` (822), `pnpm run check:browser` and the pre-commit hooks. The issue's other test, `test_a_comment_on_a_closed_tab_s_document_never_reads_as_earlier_data`, is already fixed on main. #5371 added it with the `.lf-fp-quote` locator, while #5454 renamed that quote's class to `.lf-thread-quote` and updated the test. It failed through run [42010431285](https://github.com/max-sixty/leaf/actions/runs/42010431285), has passed in every `ci` push run since [42029761182](https://github.com/max-sixty/leaf/actions/runs/42029761182), and passes locally. Closes #5487 — automated triage --------- 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.
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
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 thatgetComposedRangesis 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 withreportPageError.lf-startup-failedmarkedpage: true. The prepaint takesdata-lf-interactiveoff, so the readable fallback shows at once.presentPagenever 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.pagereaches the bootstrap throughlf-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.elementOveris a plain throw again, kept as the assertion for any node handed to it directly.Measured
leaf.js,bootstrap.js,passages.js,prepaint.js,shadow.js)About two thirds of the added source lines are comments.
Validation
test_a_module_that_stages_bare_text_is_refused_in_its_own_namenow also asserts the notice's wording, the readable fallback, and exactly one console error and oneerrorevent in the log across a wheel, a resize, two key presses, a click, a drag-select and a double-click. It fails onmain, where the notice waits for the server.leaf-dev flakeran it, andtest_the_first_startup_fault_names_the_page, 18 times each with no failures.data-lf-interactiveanddata-lf-presented.test_render_projection.pyandtest_render_startup.pyin full, the startup and layer-mismatch tests intest_site.pyandtest_widget_quality.py, the sample tests intest_render_controls.py, the shadow and editor tests intest_render_anchors.pyandtest_render_files.py, andpnpm run test:runtime(371).test_a_window_sample_is_a_whole_leaf_window_that_scrolls_insidefails locally onmainas well (scrollY444 against 408), so this change doesn't cause it.