Repository navigation
fix: refuse a module's bare shadow-root text at startup, not only when the page is read - #5569
Conversation
…n the page is read A page whose x-shadow widget staged bare text into its root was refused before presenting only because the margin's points (`placePoints`) read the page on every document pass, and that walk met the root. #5371 made that reading lazy, so a page with no comment to find again presents without reading itself, and such a page now presented with words its reading can't hold, with no error for the agent. Startup now asks every declared root the page reading would cross into (`refuseBareText`, passages.js) just before the page marks itself upgraded, which is the moment the refusal's contract names. The cost is one look at each stage's direct children. test_a_module_that_stages_bare_text_is_refused_in_its_own_name fails on main and passes with this change. Closes #5487
|
@leaf-agent The new startup Please traverse the same declared roots reachable by page reading for the startup refusal, preserve its runtime-surface exclusions, and add a focused nested-stage regression case.
|
The startup sweep read only stages whose host is in the document body, so a declared widget staged inside another widget's root upgraded silently with its bare text and failed only on a later reading. The sweep now crosses into each root it admits, as the page reading's walk does, and still skips hosts in Leaf's own surfaces. A runtime test covers the nested stage.
|
Fixed in b2d1942. The regression case, |
leaf-agent
left a comment
There was a problem hiding this comment.
refuseBareText() calls shadowRootsIn(tree) for every root it admits, and each call filters all of liveStages(). So startup does work proportional to stages × admitted roots, which is quadratic on a page of many x-shadow widgets (a page of 500 diffs makes 250k contains checks before it upgrades). AGENTS.md, "Responsiveness", requires that loading a page grow no faster than the page times the log of its size. Making one pass over liveStages() and memoizing whether each enclosing root is admitted, outer before inner, keeps the same order of refusal and the same exclusions at linear cost. I'll push that change.
|
@leaf-agent The nested-stage correction reaches the previously missed widgets, but Please traverse the reachable declared roots without rescanning the global registry for each root, while keeping nested-stage refusal and runtime-surface exclusion. A focused operation-count check for many flat siblings alongside the nested case would protect both requirements.
|
refuseBareText asked shadowRootsIn for each admitted root, and each call filters every live stage, so startup grew with the square of the page's x-shadow widgets. One pass over liveStages, with each root's admission memoized and an enclosing root asked first, refuses the same roots in the same order at linear cost. No behavior changes.
Counts containment checks while refuseBareText sweeps 200 sibling stages; the per-root rescan made 40,803, the single pass makes 200.
|
Fixed in 4d22b8e, with the check in 301a992. The new test, |
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 whytest_a_module_that_stages_bare_text_is_refused_in_its_own_nametimed 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 (
refuseBareTextinpassages.js, called fromleaf.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, asreadPagedoes. #5371's lazy reading stays as it is. The added startup work is one look at each stage's direct children.Verification
pageText()inplacePointsmakes the test pass on main, which confirms the cause.tests/runtime/passage-boundaries.test.mjsstages 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.pyandtests/browser/test_shadow_stage.pypass (17 tests), as dopnpm run test:runtime(822),pnpm run check:browserand 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-quotelocator, while #5454 renamed that quote's class to.lf-thread-quoteand updated the test. It failed through run 42010431285, has passed in everycipush run since 42029761182, and passes locally.Closes #5487 — automated triage