Skip to content

fix: patch through main when a page module moved one of its children - #5505

Merged
leaf-agent merged 1 commit into
mainfrom
fix/issue-5475-revision-main
Nov 5, 2026
Merged

leaf-agent merged 1 commit into
mainfrom
fix/issue-5475-revision-main

Conversation

@leaf-agent

Copy link
Copy Markdown
Collaborator

Since #5228 made body the root of a live revision's patch, a page module that moves or replaces a direct child of main makes every revision rebuild the whole of main: words a script wrote, highlighted code spans and nodes a module built are taken back, and focus and open disclosures survive only through carry. This restores the pre-#5228 behavior for main's children, which is what #5228 meant to keep.

Cause. The patch rebuilds an element whole when one of its source children's live nodes no longer stands under it (atomic in browser/runtime/dom-children.js). That guards a pass that took an element's interior, such as the tokenizer replacing a code block's text with spans. The patch root is exempt, since it's walked into, never asked. Before #5228 that root was main, so a page module relocating #mv-moved into its own box, or replacing #cloned with a copy, was patched around. With body as the root, main is an ordinary child, and either move makes it atomic.

Change. A new patch rule, traversed(element), names a live element the patch walks through as it walks the root. The version controller names main (the direct child of body); setRenderedChildren names nothing. dom-children.js still knows no document. Everything else under main keeps the atomic rule.

Tests. These failed on main and pass with the change:

  • tests/browser/projection/test_revision_patches.py::test_a_revision_leaves_the_page_everything_it_did_not_write
  • tests/browser/startup/test_versions.py::test_the_diff_marks_what_the_author_changed_and_no_word_a_script_wrote[classic] and [module]

The rest of test_revision_patches.py passes, apart from test_a_revision_releases_the_served_markup_it_removes (3 cases), which fails the same way on unmodified main and isn't one of the tests #5475 tracks. pnpm run test:runtime (818 tests) and pnpm run check:framework pass.

#5475 lists twelve tests broken by #5228. This fixes two of them; the other ten are still being diagnosed under that issue.

Refs #5475 — automated triage

A revision rebuilds an element whole when a pass has moved or replaced one of
its children (`atomic` in dom-children.js); only the patch root is walked
through regardless. #5228 made `body` the patch root, so `main` became an
ordinary child, and a page module that relocated or replaced a direct child of
`main` now made every revision rebuild the whole page: script-written words,
highlighted code spans and nodes a module built were lost.

The version controller now names `main` as `traversed`, a new patch rule that
reads it as the root was read. The behavior restored: a page module's moves and
writes under `main` survive a revision that doesn't mention them, as before
#5228.

Refs #5475
@leaf-agent
leaf-agent merged commit bcd87c7 into main Nov 5, 2026
5 checks passed
@leaf-agent
leaf-agent deleted the fix/issue-5475-revision-main branch November 5, 2026 16:44
leaf-agent added a commit that referenced this pull request Nov 5, 2026
#5506)

Since #5228, a page whose `main` leads with an `<h1>` lends that title
to every element on the page with no name of its own. The `s` hints
announce `div: Split` for a wrapper whose words are its two paragraphs,
a chosen list is announced by the page title, and a draft's edit button
reads `Edit “Draft source”` instead of `Edit the draft`. This restores
the pre-#5228 naming.

**Cause.** `addressableLabel` (`browser/runtime/addressable-names.js`)
names an unnamed element by the nearest enclosing name, climbing "short
of the document it stands in (the page's column, or a message's body)".
The climb stops at `authoredScope`, which #5228 widened from `main` to
`body` so content beside `main` belongs to the page. That moved the stop
one level up, so the climb now asks `main` itself, and `main`'s leading
heading is the page's title.

**Change.** The climb also stops at `main`, the direct child of `body`.
Content beside `main`, such as a site header, still climbs to `body`,
and a message body is unaffected. The Python side
(`gesture_words.element_name`) doesn't climb, so it needs no change.

**Tests.** These failed on main and pass with the change:

-
`tests/browser/test_render_semantic_selection.py::test_a_boxless_target_is_read_where_it_paints`
-
`tests/browser/test_render_semantic_selection.py::test_dense_selection_hints_stay_short_and_reach_an_atomic_visual`
-
`tests/browser/test_render_pages.py::test_ship_review_summary_is_addressable_and_baseline_aligned`
-
`tests/browser/drafts/test_draft_editing.py::test_a_draft_uses_shared_editing_and_saves_exact_markdown_source`

A new case in `tests/runtime/addressable-name.test.mjs` puts a leading
`<h1>` in `main` and asserts that it names nothing `main` holds. It
fails without the fix and passes with it.

#5475 lists twelve tests broken by #5228. Together with #5505 (merged,
two tests) and the aim test update, this leaves five still under
diagnosis there.

Refs #5475 — automated triage

Co-authored-by: leaf-agent <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant