Skip to content

fix: fit the margin card's size outside box-motion's size delivery - #6727

Merged
leaf-agent merged 2 commits into
mainfrom
fix/issue-6604
Nov 22, 2026
Merged

leaf-agent merged 2 commits into
mainfrom
fix/issue-6604

Conversation

@leaf-agent

Copy link
Copy Markdown
Collaborator

When a part of the margin thread card changes size, box-motion's shared observer (placedParts) asks the card's placement for a fit, and that placement lands in the observer's delivery. A fit that wrote the card's width or max-height there resized #lf-margin-preview. Reading-regions and Floating UI also observe that box, and it sits shallower than the parts being delivered, so Firefox reported ResizeObserver loop completed with undelivered notifications in the thread-panel gallery. #6604 records the sequence. A placement the delivery asks for now leaves the card's width and cap as they are and schedules another fit for the next frame, which runs before layout and outside any delivery. Placements from every other path, such as opening, scrolling or a window resize, still write in place.

The cost is at most one frame at the card's earlier size. That frame is still placed and followed by box-motion's tween, which then retargets to the new fit. Resting states don't change.

Verification, run locally on Linux:

  • uv run leaf-dev suite flake --copies 18 --workers 4 --load 8 'tests/journeys/test_render_gate.py::test_page_fixture_opens_without_firefox_console_warnings[thread-panel-gallery]': 3 of 12 copies errored with the loop on main (fac415460) and 18 of 18 passed with this change.
  • The test that broke under the earlier attempts recorded on the issue, tests/browser/margin/test_card_reply.py::test_a_card_a_scroll_moves_onto_or_off_the_windows_foot_as_it_resizes_only_resizes, passes in both browsers. So do the 113 card fit, growth and scroll tests selected from tests/browser/margin, threads/test_layout.py and threads/test_arrivals.py.
  • pnpm run check:framework and pnpm run test:runtime pass.

The comment box beside a passage (composing/floating-response.js) also gives box-motion a placement. Nothing has shown it resizing an observed box in the delivery, so it is unchanged here.

Closes #6604 — automated triage

box-motion's shared observer asks the card's placement for a fit when a
part of the card changes size, and the placement lands in that delivery.
A fit that wrote the card's width or max-height there resized the aside
that reading-regions and Floating UI also observe, so Firefox reported a
ResizeObserver loop in the thread-panel gallery. A placement the delivery
asks for now keeps the card's size and fits it again in the next frame.

Closes #6604

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The delivered-fit guard compares the rounded offsetWidth with the fractional room, so a delivered fit whose room moved by less than half a pixel from the last written width still writes width on #lf-margin-preview inside box-motion's delivery. That is the resize-in-delivery this PR moves out, only at sub-pixel scale. ResizeObserver reports fractional sizes, so the aside's other observers would miss it the same way. Comparing with the width the last fit wrote, at the precision layoutPx writes it, makes "leaves the card's width as it is" exact. I'll push this.

The rounded offsetWidth let a sub-pixel change of the room pass the guard,
so a delivered fit could still write the card's width inside box-motion's
size delivery.
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.

test_page_fixture_opens_without_firefox_console_warnings[thread-panel-gallery]: Firefox reports a ResizeObserver loop on macOS

1 participant