Skip to content

Fix delayed diff disclosure shift and cover held preparation - #2390

Merged
max-sixty merged 10 commits into
mainfrom
repro/issue-2389
Oct 11, 2026
Merged

max-sixty merged 10 commits into
mainfrom
repro/issue-2389

Conversation

@leaf-agent

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

Copy link
Copy Markdown
Collaborator

Opening a collapsed diff file loads its lines asynchronously. The shift watcher previously ended the opening gesture before that load landed, so a 49px push of later controls could be reported as movement without input. This PR credits the landing to the input whose work opened the file, while continuing to report unrelated movement during the wait.

The preparation observer carries one identity from declaration to settlement. Input provenance follows a summary click into the browser's later toggle event, including a click dispatched by the input's work. The watcher tracks the resulting preparation separately from ordinary rendering; its rendering completion check can therefore finish while a preparation is held without granting that input ownership of unrelated page changes.

The held-tap diff test keeps the Markdown grammar blocked after the opening tap. Browser tests also cover movement during the hold, movement after settlement, and an independent response opening a diff during presses both outside and inside that widget. On the merged tree, those focused cases pass (5 tests), and the runtime suite passes (336 tests).

Fixes #2389.

@max-sixty

Copy link
Copy Markdown
Owner

@leaf-agent The held-preparation case reproduces the 49px passive shift, but this PR still has no production fix and its new test fails the shift watcher. Please complete the presentation-boundary repair on this branch while preserving lazy preparation and the watcher, then run the focused case and landing checks. Keep the test's hold after the opening tap; it captures the reported failure.

This was written by Codex on behalf of max-sixty

test_phone_diff_headers_keep_distinguishing_parent_folder_readable failed at
teardown on loaded CI runners: the second lf-diff file header "moved without
input by (0, 49)px" after the tap that opened the first file. Opening a closed
file loads its evidence in a promise (the Markdown grammar and Shiki
rendering) that lf-diff declares through `present`, so the page's
presentation proof stays pending until the lines land. The shift watch ended
a gesture's ownership on `lfRenderingSettled` alone, which by its contract
(runtime/rendering.js) cannot see promise-held work. On a slow machine the
loop settled before the file's lines arrived, so their growth read as
passive. The product behaved correctly: the files below moved because the
user opened the one above them.

The watch now ends a gesture's rendering once the page has also presented
its current publication (`lfReadiness(null, "presented")`), widget
preparations included, which is the declared completion `pageReadiness`
already states. Deferred arrivals stay outside that credit, so a late
arrival still fails as passive.

New test: test_an_input_owns_a_widget_preparation_it_began_until_presented
holds the Markdown grammar with page.route, so the loop settles while the
preparation is pending, and checks that the press owns the growth and that
a passive move after presentation still fails. With the old reading it
fails with the same 49 px report the CI runs showed.

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

@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 held case reproduces a 49px shift locally, but one_frame() does not settle the tap's declared widget preparation. lf-diff.attachDisclosure passes loadEntry() to controller.present(), whose presentation ticket remains pending while this test holds prepareEntry(). The shift watcher currently ends the tap's ownership on lfRenderingSettled() alone, so it calls that pending result passive.

I applied #2391's watcher change in a scratch checkout of this head. Both variants of this test passed, and #2391's test still detected a passive move after presentation. The two PRs overlap on the same failure; this reproduction does not establish a need to change the diff's inline layout. The PR's stated merge hold remains until the presentation boundary and CI are resolved.

max-sixty and others added 2 commits October 11, 2026 03:51
…readiness

The previous commit kept a gesture's shift credit open until the page's
`presented` readiness stage, so while any widget preparation was pending the
gesture owned every movement on the page. Review showed the cost: with the
diff's Markdown grammar held, moving an unrelated control 40 px went
unreported.

The runtime now publishes each widget preparation's lifecycle on its
validation seam (`lfObserveWidgetPreparations`, owned by
`attachWidgetPresentation` in semantic-state.js): "begin" when a widget
declares it and "settle" in the task that settles its completion. The shift
watch records a preparation declared while an input's rendering (or an
earlier landing's) runs. When that preparation settles, the watch opens a
rendering for the same input that runs until the loop settles again, as the
input's own rendering does. A preparation's wait owns nothing, and the
gesture's own rendering again ends on `lfRenderingSettled`.

test_an_input_owns_the_landing_of_a_widget_preparation_it_began now holds
the grammar and checks three things. A control moved while the preparation
waits is reported (the reviewer's case, which the page-wide version
missed). The landing's push on the files and control after it is the
press's. A move after the landing is reported. With landings uncredited it
fails at the landing.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@leaf-agent leaf-agent changed the title test: reproduce delayed diff disclosure shift Fix delayed diff disclosure shift and cover held preparation Oct 11, 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 new prepared handler assigns a preparation to open ?? [...landing].at(-1) even when that input was aimed outside the declaring widget. If the page's own response opens a diff file while an unrelated button press still has counted rendering, the file's later layout shift is credited to that press and the watcher misses a passive move. #2391 now has a test for this overlap and a causal check using the input target and preparation owner. This branch overlaps that repair, so the ownership check belongs here before it merges.

Review of 3106d41 found the credit still too broad. A preparation took as
its owner whichever input's rendering happened to be running, so a passive
timer that opened a diff file during an unrelated button's counted work gave
that file's landing to the button. Its 49 px push on a later control then
went unreported.

The runtime's preparation identity now names the declaring widget's element
(`owner`). Every input rendering the shift watch opens records the node it
was aimed at: the pointer or key event's composed target, or the typing
field. A preparation belongs to an input only if that target lies inside
the declaring widget in the rendered tree and the input's rendering, or a
landing it owns, is still running. A preparation started by a timer, by
news, or by input aimed at another widget lands passive.

New test: test_a_preparation_no_input_aimed_at_lands_passive opens a diff
file from a held response the page requested before an unrelated press,
while the press's counted work runs. The landing must be reported. With the
overlap-only watch from 3106d41 it is not.

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

@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 ownership check still treats overlap as cause when the press lands inside the same widget. If the page's earlier request opens a diff while its search field has counted rendering, aimedInside accepts that unrelated preparation and the later file load hides a passive move. I ran that variant of the new test on this head: it failed because consume_browser_errors received [] instead of the control's “moved without input” report. #2391 carries the provenance-based repair and includes both outside-widget and same-widget cases. This branch needs that causal ownership path before it can merge.

Use input-work provenance across the details toggle and preparation settlement. This replaces widget containment, which hid passive movement when an unrelated response opened the same diff during a press on its search field. Extend the passive shift test to keep that case covered.
@leaf-agent
leaf-agent requested a review from max-sixty as a code owner October 11, 2026 11:22
leaf-agent and others added 2 commits October 11, 2026 11:31
Main now counts registered preparation in renderingSettled. Let the shift watch read completion of the rendering pass while it separately follows the preparation's landing. The held-preparation tests wait for a frame while work is held, then use rendered after release.
Main's vulture hook, which arrived beside #2345, flags it; pluggy passes a hook
implementation only the arguments it names.

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

@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.

An activation that leaves a diff file closed can retain its input in opening. When the click listener opens the file and native activation closes it again, the browser announces a closed toggle; the handler ignores that toggle, so a later scripted open inherits the earlier input and its file load hides a passive shift. Expire the activation on the first toggle regardless of state, including when no page listener observes it. PR #2391 already carries this repair, so these branches still overlap.

A summary click can open then close its details before the browser emits a coalesced closed toggle. Clearing the activation only on an open toggle let a later scripted opening inherit the old input and conceal a passive shift. Observe the first toggle directly and clear the association for either state. The new regression checks the cancelled and closed-again routes; its held grammar wait crosses the landing without waiting for rendering to settle while the request is blocked.
# Conflicts:
#	dev/leaf_dev/suite_profile.py
#	tests/test_render_diff_controls.py
#	tests/test_render_shift_watch.py
@max-sixty
max-sixty merged commit 5d95f60 into main Oct 11, 2026
5 checks passed
@max-sixty
max-sixty deleted the repro/issue-2389 branch October 11, 2026 14:29
max-sixty added a commit that referenced this pull request Oct 11, 2026
Retain current dictation and dependency parsing changes. Replace #2390 preparation settlement tracing with the existing queued-work commit mechanism and application proof, rather than keeping two causes for the same rendering. Preserve native sample departure cancellation while reporting child errors named AbortError. Recapture and review merged thread appearance.
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.

Deferred diff file rendering moves later headers after a tap

2 participants