Skip to content

Keep a docked margin row docked while the room it answered about holds - #373

Merged
max-sixty merged 4 commits into
mainfrom
todo-survey
Sep 7, 2026
Merged

max-sixty merged 4 commits into
mainfrom
todo-survey

Conversation

@max-sixty

@max-sixty max-sixty commented Sep 7, 2026 •

Copy link
Copy Markdown
Owner

main has been red on the nightly ring census since #365. The corpus walk waits for the page to stop moving and it never does: three CSS transitions on a reaction pill's tooltip label restart every frame, so the label never outlives its own 90ms delay — it is invisible for the page's whole life — and pageSettled can never go true.

The loop

A docked margin row is floated back into the rail every pass to ask whether it fits now, and docked again when it does not. That round trip runs through moveHost, which relocates a cluster that may hold the reader's focus: the move emits focusout and the restore emits focusin, both of which reach paintHere(), and the resulting paint runs syncLayout → dockSeats → another pass.

#365 made the cycle reachable from both ends. dockSeats schedules a pass whenever a reaction seat stands anywhere on the page, and the six emoji it moved into the margin mean one always does; and it put the focused control inside the host being moved, which is what turns a placement into focus traffic.

anchors.js's dockSeats comment records the same shape being cut once before — "a whole margin render every frame with nothing dispatched and nothing moving… ~350ms of main thread a frame". This is that cycle closing again through a consumer that did not exist then.

The change

A dock is an answer about a width, so it holds while the width it answered about holds. The pass remembers the room each row docked against and keeps that answer until the room changes or the row restates itself through registerMarginRow/updateMarginRow, whose own size is the other half of the answer. The measurement that could not have answered differently no longer moves the reader's focus to prove it.

The tooltip is user-facing, not only a probe: before this, focusing a reaction pill showed no label at all, and the page never stopped animating.

Verification

  • test_every_ring_the_layer_draws_is_shown_whole_somewhere_in_the_corpus passes; it failed five times running on main
  • Paired control: the same test passes at 5d571319 (the four merges before Make reactions direct agent feedback controls #365) and fails at 06daeef3, isolated -n0, same machine
  • uv run pytest tests/test_render_margin.py tests/test_render_controls.py tests/test_render_navigation.py --run-nightly on the merged tree: 250 passed, 5 failed
  • Four of those five are main's own, confirmed against a detached checkout of 8fbf925c carrying none of this branch: both test_an_unchanged_heartbeat_restates_no_margin_name cases and both test_the_small_screen_map_is_a_complete_accessible_sheet cases
  • The fifth, test_unchanged_margin_refresh_cost_is_bounded_by_refresh_count at 22 <= 20, was contention from -n 2; isolated it passes
  • uv run pre-commit run --files skills/leaf/assets/runtime/margin-layout.js clean

Review found one fault in the first version of this change and 41f940d0 folds it in: a row the posture read keeps docked reached the classification loop with hangs === true and its docked rect, so rect.right > room was false and it fell through to inMargin — counted as hanging in the margin while standing in flow. Every staysDocked member used to carry hangs === false and re-enter the docked branch on its own, which is the invariant the new member broke.

The other #365 red, and where it went

test_other_responses_can_turn_the_compact_field_into_a_suggestion was red on main for a second, unrelated reason: one Tab from the compact composer focuses the fab bar's Other responses trigger, which raises the margin surface, and .lf-fab-bar[data-lf-margin-raised] { display: none !important } then hides the bar the reader is standing in.

That was #365 moving where Other responses renders, not a fault, and #372 has since settled it: the case is now test_reactionless_other_responses_can_turn_the_compact_field_into_a_suggestion, which serves a layer with the reaction tokens stripped and asserts Suggest stays in the compact fallback there. Both readings pass on this branch with main merged in, so main goes green on the nightly ring census and on that case together.

Why nothing caught it

#340's gate runs the nightly modules a pull request edits. #365 edited twelve test modules, and neither of the two it broke was among them. The full nightly behind that gate has not completed on main since 934bfc4c: four of the six runs after it were cancelled by the next merge landing first.

This was written by Claude Code on behalf of max-sixty

🤖 Generated with Claude Code

max-sixty and others added 2 commits September 6, 2026 21:56
The nightly ring census has been red on main since #365: the corpus walk waits
for the page to stop moving and it never does. Three CSS transitions on a
reaction pill's tooltip label restart every frame, so the label never outlives
its own 90ms delay -- it is invisible for the page's whole life -- and
`pageSettled` can never go true.

The engine is a layout pass that measures the same thing forever. A docked row
is floated back into the rail to ask whether it fits now, and docked again when
it does not, every pass. That round trip goes through `moveHost`, which relocates
a cluster that may hold the reader's focus: the move emits focusout and the
restore emits focusin, both of which paint the standing chrome, and that paint
runs syncLayout -> dockSeats -> another pass.

#365 made the cycle reachable from two directions. `dockSeats` schedules a pass
whenever a reaction seat stands anywhere on the page, and the six emoji it moved
into the margin mean one always does; and it put the focused control inside the
host being moved, which is what turns a placement into focus traffic.

A dock is an answer about a width. Hold it while the width it answered about
holds, and re-measure when the room changes or when the row restates itself
through register/update, whose own size is the other half of that answer. The
pass that could not have answered differently no longer moves the reader's focus
to prove it.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The loop-break itself holds — I reproduced the guard engaging, and a row it keeps docked no longer round-trips through moveHost. One consequence of the new staysDocked member, though, is that those rows are then counted as hanging in the margin for the rest of the pass. Detail inline.

The one-line fix is on the classification line just above the hunk (else if (!hangs || rect.right > room)), so it isn't offerable as a suggestion here. Happy to push it if you'd like.

@leaf-agent

Copy link
Copy Markdown
Collaborator

I was dispatched on run 34079766897, the nightly ci failure this PR fixes, and reached the same cycle independently — moveHost's focus round trip → paintHere → syncLayout → dockSeats → the next pass, with the pill label's three transitions restarting at 15 passes per 30 frames. Nothing to add on the fix itself; the review above has it, and I'm not opening a competing PR.

One thing that bears on the claim that main goes green: it won't. At e0b25638 the nightly is red on fourteen more cases that have nothing to do with this loop. Each of them passes at 06daeef3 and fails at the commit named below — checked isolated, -n0, same machine, so the attribution is a paired control rather than a guess. CI hasn't said so for the reason your own body gives: the nightly on main keeps being cancelled by the next merge.

The fourteen, and where each starts

#354 (edd1c5a5, "Expand and contain the interaction gallery") — eleven

  • tests/test_render_navigation.py::test_the_feature_gallery_exercises_the_injected_core_surfaces — the gallery now draws 14 ask rows and the case expects 13
  • tests/test_render_margin.py::test_the_feature_gallery_keeps_its_real_actions_reachable[390|700|1200|1440] — all four widths red on main; the 390 case is the one I bisected
  • tests/test_render_margin.py::test_ask_addresses_follow_the_feature_gallery_s_visible_margin_controls[390|1200]
  • tests/test_render_margin.py::test_an_unchanged_heartbeat_restates_no_margin_name[gallery]
  • tests/test_render_margin.py::test_margin_target_hover_requires_pointer_movement
  • tests/test_render_controls.py::test_a_workspace_lands_one_responsive_layout_and_carries_the_column_to_it[1440|1600] — the gallery's Threads panel never reaches open

#371 (1de01fc2, "Leave the lifecycle mark to the one state that needs it") — three

  • tests/test_render_reactions.py::test_selected_reactions_keep_neutral_button_furniture[light|dark]
  • tests/test_render_reactions.py::test_a_copy_keeps_a_standing_reaction_as_a_mark_and_drops_the_press — the standing mark's ::after reads no painted box in the copy

The gallery group is the larger question: several of those cases are about controls being reachable at a width, not about a count, so I'd read them before assuming the fixtures merely need renumbering.

Separately, on the reactionless fallback in your last section — the case moved, but so did the capability. With the default vocabulary, a selected passage now has no route to Suggest at all: .lf-fab-suggest is display: none outside .lf-react-open, Tab raises the margin reactions and [data-lf-margin-raised] hides the bar behind them, the composer's own "Suggest replacement text" row is hidden inside the bar by the compact rule, and no register row runs setSuggestionMode — suggestHere has exactly one caller, that button's onclick. Measured on main at e0b25638: the control is never visible before or after Tab, and the key line offers comment, back, and the six reactions. test_reactionless_other_responses_can_turn_the_compact_field_into_a_suggestion is green because it strips the vocabulary, so nothing is red — but a reader on a default page can't propose replacement text for a passage. Where it should live looks like your call: reaction mode owns all six margin fittings by design, so the bar seems to be the only place left for it.

max-sixty pushed a commit that referenced this pull request Sep 7, 2026
…frame (#394)

## Problem

`ci` on main failed on [run
34084018735](https://github.com/max-sixty/leaf/actions/runs/34084018735)
with 19 nightly failures. Most of them are the interaction gallery's
contained frames taking the page's focus, which #383 fixes, and the
reaction readings #371 retired, which landed as #385. Two survive on
today's main (`e6adf0b2`) and neither is covered by either.


`test_every_ring_the_layer_draws_is_shown_whole_somewhere_in_the_corpus`
times out waiting for `pageSettled`, because the corpus never settles
once the ring walk stands on a control in a docked margin cluster:
`layoutMarginRows` floats that cluster out of static flow to read where
it can hang and docks it back, a document tree has one focus, so the
move blurs the control and the restore focuses it again — and
`keyboard/dispatch.js` answers that pair by painting the standing
chrome. That paint's layout asks for the next placement, so the page
laid its margin out, rebuilt its whole key line and refolded its banner
row on every frame for as long as the reader stood there. This is the
second time this cycle has closed on a different edge; #298 cut the
`dockSeats` one.

#373 cuts the other edge of this same loop, and has the same ring test
green: it keeps a docked row docked while the room it answered about
holds, so `moveHost` is never reached in the case that loops. The two
compose rather than compete — that one removes a caller's reason to move
the host, this one stops any placement move from painting the standing
chrome, so it also holds for the callers it does not touch (`float`, the
inline `target.after`, and both branches of the Page-map render). Either
can land alone and fixes the failing run; landing both is deliberate
belt-and-braces, and neither is based on the other.

`test_a_reload_mid_flight_never_wedges_round_trip` waits the corpus's
whole answer-all cascade out inside one 30-second budget, and the corpus
gained an ask in #354. The fact under test — that a ledger carried
across a navigation does not wedge the new document — has already
settled on that document's first trip.

## Solution

`runtime.placingChrome` says a chrome placement is in flight, `moveHost`
raises it around the move and the focus it hands straight back, and the
focus painters skip while it stands. `moveHost` asks for the paint
itself in the one case the placement really did move the reader: the
control they were standing on did not survive it. The flag lives in
`context.js` rather than beside `living-margin.js`'s existing
`settlingOptionsFocus` because what has to know is every reader of where
the reader stands, not just the options state machine.

The gate test now waits for the new document's first trip rather than
for its whole cascade, so the reading stops tracking how many asks the
corpus happens to carry. It waits on the press's own attempt leaving the
outbox's `pending`, which is delivery with retries folded in: `acked` is
counted in a `finally` around the fetch, so a post that throws counts
one and is retried, and an empty `pending` is only the momentary gap
between the cascade's trips.

## Testing

-
`test_every_ring_the_layer_draws_is_shown_whole_somewhere_in_the_corpus`:
red on `e6adf0b2`, green with this change. It is the gate — I could not
reduce the cycle to a small fixture, and dropped a candidate regression
test that passed with the change reverted rather than land coverage that
says nothing.
- `test_a_reload_mid_flight_never_wedges_round_trip`: red under `-n4` on
`e6adf0b2`, green with this change. Its new reading still fails on a
wedged first trip: with `/api/event` aborted on the reloaded document it
gives up on `sends=16 acked=16 pending=1`, the shape `acked > 0` would
have gone green on.
- `uv run pre-commit run --all-files`.
- The full `--run-nightly` run promised when this opened never got
posted — that session ended before it finished. CI runs the nightly
cases of `tests/test_render_gate.py` on this PR, the module it touches;
the rest of the nightly suite the runtime change drives runs after main
moves.

<details><summary>How the cycle was found</summary>

At the failing wait, `moving()` reported three running transitions on
one `.lf-margin-button-label`, restarting continuously. A document-wide
`MutationObserver` over one second on that page showed the whole chrome
rebuilding at frame rate with nothing dispatched: 125 `lf-key` inserts
and 125 removals, 52 `.lf-btn.lf-others` moves between
`lf-banner-actions` and `lf-banner-menu`, 50 same-value `style` writes
on `nav.lf-living-margin`, and 25 moves of one
`.lf-margin-item.lf-docked` between `MAIN` and its `SECTION`.

A stack captured inside a `focusout` listener named the mover:

```
at /runtime/living-margin.js:2073 | at moveHost (/runtime/living-margin.js:2379)
  | at moveExternalHost (/runtime/living-margin.js:2073) | at Object.float (/runtime/living-margin.js:1644)
```

with a second identical one from `Object.dock`, 50 focusouts per second
between them, and `requestAnimationFrame` stacks from `paintHere` and
from `layoutMarginRows`'s dispatch at 25 per second each.

</details>

---
Automated fix for [failed
run](https://github.com/max-sixty/leaf/actions/runs/34084018735)

---------

Co-authored-by: leaf-agent <[email protected]>
max-sixty pushed a commit that referenced this pull request Sep 7, 2026
…frame (#394)

## Problem

`ci` on main failed on [run
34084018735](https://github.com/max-sixty/leaf/actions/runs/34084018735)
with 19 nightly failures. Most of them are the interaction gallery's
contained frames taking the page's focus, which #383 fixes, and the
reaction readings #371 retired, which landed as #385. Two survive on
today's main (`e6adf0b2`) and neither is covered by either.


`test_every_ring_the_layer_draws_is_shown_whole_somewhere_in_the_corpus`
times out waiting for `pageSettled`, because the corpus never settles
once the ring walk stands on a control in a docked margin cluster:
`layoutMarginRows` floats that cluster out of static flow to read where
it can hang and docks it back, a document tree has one focus, so the
move blurs the control and the restore focuses it again — and
`keyboard/dispatch.js` answers that pair by painting the standing
chrome. That paint's layout asks for the next placement, so the page
laid its margin out, rebuilt its whole key line and refolded its banner
row on every frame for as long as the reader stood there. This is the
second time this cycle has closed on a different edge; #298 cut the
`dockSeats` one.

#373 cuts the other edge of this same loop, and has the same ring test
green: it keeps a docked row docked while the room it answered about
holds, so `moveHost` is never reached in the case that loops. The two
compose rather than compete — that one removes a caller's reason to move
the host, this one stops any placement move from painting the standing
chrome, so it also holds for the callers it does not touch (`float`, the
inline `target.after`, and both branches of the Page-map render). Either
can land alone and fixes the failing run; landing both is deliberate
belt-and-braces, and neither is based on the other.

`test_a_reload_mid_flight_never_wedges_round_trip` waits the corpus's
whole answer-all cascade out inside one 30-second budget, and the corpus
gained an ask in #354. The fact under test — that a ledger carried
across a navigation does not wedge the new document — has already
settled on that document's first trip.

## Solution

`runtime.placingChrome` says a chrome placement is in flight, `moveHost`
raises it around the move and the focus it hands straight back, and the
focus painters skip while it stands. `moveHost` asks for the paint
itself in the one case the placement really did move the reader: the
control they were standing on did not survive it. The flag lives in
`context.js` rather than beside `living-margin.js`'s existing
`settlingOptionsFocus` because what has to know is every reader of where
the reader stands, not just the options state machine.

The gate test now waits for the new document's first trip rather than
for its whole cascade, so the reading stops tracking how many asks the
corpus happens to carry. It waits on the press's own attempt leaving the
outbox's `pending`, which is delivery with retries folded in: `acked` is
counted in a `finally` around the fetch, so a post that throws counts
one and is retried, and an empty `pending` is only the momentary gap
between the cascade's trips.

## Testing

-
`test_every_ring_the_layer_draws_is_shown_whole_somewhere_in_the_corpus`:
red on `e6adf0b2`, green with this change. It is the gate — I could not
reduce the cycle to a small fixture, and dropped a candidate regression
test that passed with the change reverted rather than land coverage that
says nothing.
- `test_a_reload_mid_flight_never_wedges_round_trip`: red under `-n4` on
`e6adf0b2`, green with this change. Its new reading still fails on a
wedged first trip: with `/api/event` aborted on the reloaded document it
gives up on `sends=16 acked=16 pending=1`, the shape `acked > 0` would
have gone green on.
- `uv run pre-commit run --all-files`.
- The full `--run-nightly` run promised when this opened never got
posted — that session ended before it finished. CI runs the nightly
cases of `tests/test_render_gate.py` on this PR, the module it touches;
the rest of the nightly suite the runtime change drives runs after main
moves.

<details><summary>How the cycle was found</summary>

At the failing wait, `moving()` reported three running transitions on
one `.lf-margin-button-label`, restarting continuously. A document-wide
`MutationObserver` over one second on that page showed the whole chrome
rebuilding at frame rate with nothing dispatched: 125 `lf-key` inserts
and 125 removals, 52 `.lf-btn.lf-others` moves between
`lf-banner-actions` and `lf-banner-menu`, 50 same-value `style` writes
on `nav.lf-living-margin`, and 25 moves of one
`.lf-margin-item.lf-docked` between `MAIN` and its `SECTION`.

A stack captured inside a `focusout` listener named the mover:

```
at /runtime/living-margin.js:2073 | at moveHost (/runtime/living-margin.js:2379)
  | at moveExternalHost (/runtime/living-margin.js:2073) | at Object.float (/runtime/living-margin.js:1644)
```

with a second identical one from `Object.dock`, 50 focusouts per second
between them, and `requestAnimationFrame` stacks from `paintHere` and
from `layoutMarginRows`'s dispatch at 25 per second each.

</details>

---
Automated fix for [failed
run](https://github.com/max-sixty/leaf/actions/runs/34084018735)

---------

Co-authored-by: leaf-agent <[email protected]>
max-sixty and others added 2 commits September 7, 2026 10:20
A row the posture read keeps docked reached the classification loop with
`hangs === true` and its docked rect, which is measured where it stands, in
flow. `rect.right > room` is false there, so it fell through to `inMargin`:
counted as hanging in the margin while standing in the document.

Before the posture read grew its second reason, every `staysDocked` member had
`hangs === false` and re-entered the docked branch on its own, which is the
invariant the new member broke. Three readers of `inMargin` were wrong for it --
the band packer, which can write a `translateY` onto a static row that the clear
loop then never resets because it `continue`s on `staysDocked`; the
`[data-lf-wide]` sweep, which yields right-hand room for a row that is not
there; and `docked`, which stayed false while a docked row stood, skipping the
re-place of the targets that dock moved.

Found in review on #373.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@max-sixty
max-sixty merged commit b6393f0 into main Sep 7, 2026
13 checks passed
@max-sixty
max-sixty deleted the todo-survey branch September 7, 2026 18:09
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.

2 participants