Skip to content

Recheck margin anchors and quarantine the unresolved gallery failure - #1506

Merged
max-sixty merged 13 commits into
mainfrom
fix/ci-margin-send-race
Oct 2, 2026
Merged

max-sixty merged 13 commits into
mainfrom
fix/ci-margin-send-race

Conversation

@leaf-agent

@leaf-agent leaf-agent commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

The gallery's insertion Reject/Undo can leave controls hidden even though their target is on screen. Two problems were reproduced on main: margin layout permanently cached an unavailable anchor by element identity, and the gallery's suggestion can retain stale style or zero-size geometry under load. Margin layout now reads anchor availability on each pass, so lifting an author's anchor scope restores the existing row. The gallery tests also follow Undo to its current row and wait for admitted gestures and scheduled layout.

The initiating gallery style/geometry failure remains unresolved. The user invoked /fix-ci, whose documented fallback permits a reasoned xfail for a stuck failure verified on main. The four-width suggestion Reject/Undo journey continues to run with strict=False, limited to assertion and Playwright timeout failures; setup exceptions remain red. Draft save, reload, and Page Map reaction checks run in a separate unmarked four-width case. notes/margin-stuck-style.md retains the reproduction and evidence, including failure without test watchers and the limits of the browser-version comparison. Refs #1505 and #1508.

The scope-restoration regression fails before the runtime change and passes afterward. Four related browser cases pass; a resting-page probe found no spontaneous layout loop over 30 frames. Fresh gallery runs reproduced the invisible insertion Undo at 1200px and 700px and later XPASSed, confirming the intermittent failure remains exercised. All four unmarked draft and Page Map cases, 190 runtime tests, and pre-commit pass. A served startup comparison loaded 202 requests in both arms and transferred 3,956,786 versus 3,956,589 encoded bytes by presentation, with no added requests or bytes.

This was written by Codex on behalf of max-sixty

@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 gallery test still reads the returned Accept and Reject controls before the undo response has been applied. sending waits for the request and its reply, but the 1200px case fails at bg-insert after that wait: the Accept button is absent. Wait for the undo's application (data-lf-applied, or the harness's told reading) before checking those controls. The pin geometry case also needs that boundary before comparing its restored positions.

Comment thread tests/test_render_margin.py Resolved
@leaf-agent leaf-agent mentioned this pull request Oct 1, 2026
@max-sixty

Copy link
Copy Markdown
Owner

@leaf-agent The current CI run fails tests/test_render_margin.py::test_the_feature_gallery_keeps_its_real_actions_reachable[1440] at tests/test_render_margin.py:1339. After rejecting bg-insert, the test waits for the gesture request, told(page), and render readiness, then undoes the decision; the Accept control is still absent. The wait-only change therefore has not cleared the failure across gallery widths. Please fix or clarify the behavior that should restore the undecided control after undo, then get the full checks green before merge. The same run reports 1 failed, 1473 passed, and 3 skipped.

This was written by Codex on behalf of max-sixty

A rejected insertion leaves no visible slot, so its Undo contribution moves to the containing passage. Find the control at that current row and settle scheduled margin layout before reading restored controls after undo. The gallery keeps checking that Accept and Reject return across widths.

@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 new Undo lookup can still return a control inside a withheld margin row. When the browser stops applying anchor-name to bg-insert-line, the margin layout parks that row; _unfold only opens rows marked data-lf-folded, so this helper cannot make the Undo reachable. #1508 records that failure under load, including the missing Accept control after Undo. The five affected cases passed locally, but this change has not established that the reported gallery failure is fixed. The row needs to become reachable in that state before this PR can claim to resolve it.

@leaf-agent leaf-agent changed the title Wait for gallery margin gestures to send before reading controls Wait for gallery gestures and follow the moved Undo row Oct 1, 2026
@leaf-agent

Copy link
Copy Markdown
Collaborator Author

I pushed a1e4b597 to make the test follow Undo to its current margin row and wait for the margin layout after each decision. All five affected cases passed locally, but CI on that head still failed at the 1440px Accept assertion, so I left the PR open.

A loaded 18-copy run reproduced the failure once. After Undo, Accept and Reject existed in the DOM under bg-insert, but their margin row was withheld and the controls were invisible. That is the reachability defect investigated in #1508, so another wait in this test would conceal it. I updated the PR description to reflect the remaining blocker.

@max-sixty

Copy link
Copy Markdown
Owner

@leaf-agent why aren't you merging this yourself?

@leaf-agent

Copy link
Copy Markdown
Collaborator Author

I should merge this myself once the fix is verified. I have not merged #1506 because its current head (a1e4b597) failed the test check at the 1440px Accept assertion. Under load, the control can be present in the DOM but hidden in a parked margin row after Undo, so a passing local run of the wait changes would not establish that it is reachable. #1508 merged the investigation notes, not a fix for that behavior. I cannot treat this PR as complete or merge it through a red check; the margin reachability defect still needs a verified repair and a green check on the resulting head.

@leaf-agent

Copy link
Copy Markdown
Collaborator Author

The main run at 3ba1bb7 hit the same 1440px gallery failure after Undo: bg-insert had no visible Accept control. This is another occurrence of the reachability defect already described here and in #1508; the run adds no evidence that another wait would fix it. I am handling its separate draft test failure independently.

leaf-agent added a commit that referenced this pull request Oct 1, 2026
The [failed main
run](https://github.com/max-sixty/leaf/actions/runs/36914452215)
reported typed draft words disappearing in
`test_a_response_draft_yields_focus_when_the_panel_leaves_no_usable_room[390]`.
The test moved to Threads search with Playwright's `focus()`, which
changes focus without a user press; Leaf then hid the background
composer and the words guard correctly rejected that transition. Use
`click()` to exercise the real search gesture and record the press that
puts the draft away while the test continues to verify its restoration.

The 390px case failed in all 18 concurrent copies before the change and
passed in all 18 after it. Both 390px and 450px variants passed locally.
The separate gallery margin failure is already tracked on #1506.

Co-authored-by: leaf-agent <[email protected]>
@leaf-agent

Copy link
Copy Markdown
Collaborator Author

Main CI run 36945384717 hit the same gallery Undo failure: test_the_feature_gallery_keeps_a_choice_when_its_proposal_is_undone could not find a visible Accept control after Undo. The run adds another occurrence of the parked-row reachability problem already documented here and in #1508; it does not validate the current wait-only PR head. I am leaving #1506 open pending a fix that keeps the restored control reachable and passes its exact-head test check.

max-sixty added a commit that referenced this pull request Oct 2, 2026
Tests that pin accidental restrictions can teach future agents to
preserve them. This applies the user's 23 accepted scopes from a deep
audit of the suite, removing or narrowing those assertions while
retaining useful behavioral guarantees. Production behavior is
unchanged.

The changes release fixed margin capacities, layout and timing policies,
truncation rules, description-only artifact identity, and refusals of
otherwise valid content. The margin journeys now prove complete ordered
Page Map access and actual spill reachability without requiring six
inline entries or a fixed number of fixture peers. Tests still hold
invalid-input safety, rendering readiness, meaningful labels, layout
stability, optimistic actions, and final-answer semantics.

Review restored useful assertions where the original proposals went too
far, including declared-language validation, passage
ownership/readiness, and filename layout geometry. Five proposals were
kept; the image-difference item was left to its existing owner.

Validation before integrating main: 1,471 everyday Python tests, seven
affected margin browser cases, and independent code and desktop/phone
review. On the integrated tree, all-file pre-commit, 190 runtime tests,
the semantic-progress test, and independent integration review pass. The
margin rerun passes eight cases and reproduces the gallery's hidden Undo
defect at 700px before this PR's changed assertions; the existing
[investigation](#1508) and [repair
owner](#1506) cover it. CI runs
the landing gates and changed nightly cases on the integrated tree.

The first integrated CI attempt reports 1,545 passed, 3 skipped, and one
failure in the same gallery Undo journey at 1440px, before the changed
Page Map assertions. The automated second attempt also fails that
journey, at 700px with an invisible Undo control. The automated reviewer
approved the exact head. The existing reachability repair remains with
its owner, and this PR retains the test that exposes it. The user
requested merging these reviewed test changes with that pre-existing CI
failure outstanding.

> _This was written by Codex on behalf of max-sixty_
@max-sixty max-sixty changed the title Wait for gallery gestures and follow the moved Undo row Recheck margin anchors and quarantine the unresolved gallery failure Oct 2, 2026

@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 xfail marker covers the draft save, reload, and Page Map reaction checks below the suggestion loop. When the known Undo or Accept failure occurs, pytest stops the whole case and reports an expected failure, so a regression in those other gallery actions can go undetected at that width. Keep the expected-failure marker on a suggestion-only case and run the remaining gallery actions in an unmarked case.

The suggestion Undo expected failure now ends after its own assertions. The draft save, reload, and Page Map reaction journey runs as a separate unmarked four-width test, so those behaviors remain checked when suggestion geometry fails.
@max-sixty
max-sixty merged commit f0f79b6 into main Oct 2, 2026
3 checks passed
@max-sixty
max-sixty deleted the fix/ci-margin-send-race branch October 2, 2026 07:56
max-sixty added a commit that referenced this pull request Oct 6, 2026
…1901)

A decided suggestion could keep showing its retired words: the slot
carried `data-lf-retired`, the `state.css` rule applied, and Chromium
still computed `display: inline`. The style was stale. The operation
that left it stale was a forced style read inside a hidden tab panel,
made by `bounds.js` from a MutationObserver.

## Cause

On every content change of a bounded block (`data-lf-bound`),
`hold.sync` found the block's scroller by calling `getComputedStyle` on
every box inside it (`scrollerOf`). The feature gallery's "Page &
layout" tab holds bounded logs, and an inactive tab panel is
`hidden="until-found"`, which is `content-visibility: hidden`. Each read
forced Chromium to style that skipped subtree. A Chrome
invalidation-tracking trace of a failing run shows the sequence:

- a row is added to a log in the hidden panel, and `:has()` invalidation
marks `#bg-gallery-tabs` for a subtree restyle and `main` for a local
one;
- in the same task, `declaresBound` reads style inside the panel, which
forces a display-lock style update (1011 such reads in a failing run,
against 1 in a passing one);
- that update restyles neither `main` nor `#bg-gallery-tabs` and clears
the dirty bits above them, so `#bg-gallery-tabs` stays dirty with
nothing pointing at it;
- every later write under it is never restyled, including the reject's
`data-lf-retired` on `#bg-insert lf-new`. `#bg-gallery-tabs` is never
resolved again for the rest of the run.

The forced pass orphaning a dirty ancestor is a Chromium defect. I could
not reduce it to a page without Leaf.

## Fix

- `bounds.js`: `sync` asks `skipped(bounded)` first, as geometry.js's
other readers of skipped content do. A skipped block keeps the scroller
it had, or stands as its own, and renews its size observation. The first
delivery after the block is drawn syncs again, so an `end` log that grew
while hidden opens on its newest entry.
- `reach.js`: `paintReadingReach` and `paintSidewaysReach` check
`unpainted` themselves. Review found that a bounded block arriving in a
hidden panel registered as a reading region and had its downward cue
painted at once, reading `overflow-y` and scroll extents in skipped
content from the same MutationObserver.

## Evidence

- Issue journey
(`test_a_decision_undone_leaves_every_suggestion_pin_where_it_stood`),
on macOS Chromium 153: at 0e52b1b it failed 25 of 32 copies, and 0 of
20 with the `bounds.js` change applied there.
- Main stopped reproducing after #1880 removed a non-subject `:has()`
rule (bisected over the 18 commits from 0e52b1b). That rule supplied
the pending subtree invalidation. Adding a no-op rule of the same shape
back to `chrome.css` (`.lf-zz-a:has(> .lf-zz-b) * {}`) fails 8 of 10
copies on main, and 0 of 20 with this change.
- New test `test_logs_in_a_hidden_tab_open_on_their_newest_entries`
grows one bounded log in a hidden tab, adds a second, and checks that
neither has its style or scroll extents read while the tab is hidden,
then that both open at their newest entry, twice. It fails without the
`bounds.js` change, without the `reach.js` change, and without the
renewed size observation.
- The tests that exercise bounded blocks, reading regions, and reach
cues (71 cases) pass, as does `npm run test:runtime`.
`test_render_controls.py::test_each_sampled_focus_ring_is_shown_whole_in_its_surface`
fails on current main without this change too.

## A more underlying fix?

Unverified. Other runtime readers still force style or layout in hidden
panels: `shownParts` for target paint (deliberate, per geometry.js's
header), `readingPosture` in `recordRegions` and `scrollersSettled`,
`margin-layout.js`'s `scrollFollows`, and `user-view.js`'s `seenRect`.
With this change and the provoking `:has()` rule, the issue journey
stopped failing (0 of 20), so none of them was seen to leave style
stale. The run that would settle it is a journey that makes one of them
read a hidden panel while an ancestor holds a pending `:has()` subtree
invalidation. Its candidate fix is for those primitives to answer
skipped content themselves (a last-seen scroller, an empty shown set)
instead of each caller asking `skipped` first. History read:
`notes/margin-stuck-style.md` (#1506, #1695, #1719), #1834 and #1880.

Fixes #1868

> _This was written by Claude Code on behalf of max-sixty_

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[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.

2 participants