Skip to content

fix: retain bound diff errors across reconnect - #3987

Merged
leaf-agent merged 1 commit into
mainfrom
fix/issue-3986
Oct 25, 2026
Merged

leaf-agent merged 1 commit into
mainfrom
fix/issue-3986

Conversation

@leaf-agent

Copy link
Copy Markdown
Collaborator

A reconnect cleared a bound diff's completed refusal even though its source was unchanged: LeafElement.update() removed the error box, then lf-diff.updated() correctly skipped parsing the same source. The diff now skips the whole update for unchanged evidence. Leaf delivers bound properties before shouldUpdate, allowing that gate to read the current value while retaining its subscription to later deliveries. Interrupted preparation still retries, and a corrected bound patch replaces the refusal.

The reconnect regression fails on main and passes here. Extended coverage checks recovery after a new bound value, interrupted preparation for both inline and bound patches, and retained finished rows. The held-parser test now releases its response before awaiting completion, preserving #3982's guarantee that updateComplete includes asynchronous drawing. The runtime test checks gating on delivered values and subsequent delivery after a skipped draw.

Validation: five focused browser cases pass; pnpm run check passes, including all 559 runtime tests and the Worker checks. Rebuilt the committed kernel. A served worktree-diffs comparison against 4f51fe9fe50ad8d418cafcb5e78397b1604387bd reaches presentation with the same 53 code requests (50 JavaScript requests), 61 additional JavaScript bytes, and no layout shifts in either arm. The added code puts delivery before the update decision; it adds no resource dependency.

Closes #3986 — automated triage

Deliver bound values before a widget decides whether to update, so a diff can skip an unchanged source without losing its subscription. The shared failure lifecycle still clears a refusal on the next real draw.

Extend the reconnect regression to cover recovery on new bound data and interrupted bound preparation. Release the held parser before awaiting updateComplete, which now includes asynchronous drawing after #3982.

Closes #3986
@leaf-agent
leaf-agent merged commit 2148fd1 into main Oct 25, 2026
5 checks passed
@leaf-agent
leaf-agent deleted the fix/issue-3986 branch October 25, 2026 17:40
leaf-agent added a commit that referenced this pull request Oct 25, 2026
The datum-navigation fixture loaded its patch from a bound source after
the page presented. Its first drawing moved the Context paragraph down
137px before the navigation gesture, so shift-watch teardown failed even
though the navigation assertions passed. Use an inline patch, whose
initial renderer reserves the drawing's geometry, to keep this test
focused on a visible datum interrupting pending thread motion.

The competing `navigateToDatum` call and focus/viewport assertions
remain unchanged. The original focused test reproduced the reported
137px shift on current main; the revised test passes at normal speed and
with Chromium CPU throttled 6×. No watch credit or tolerance changes.

This follows the diff's existing first-paint behavior in
`packages/diff/initial/lf-diff.js` and `packages/diff/styles/theme.css`.
It changes only the fixture, without reverting #3987's bound-value
update gating or changing source delivery behavior.

Closes #4096 — automated triage

Co-authored-by: leaf-agent <[email protected]>
leaf-agent added a commit that referenced this pull request Oct 25, 2026
…te (#4103)

A bound diff could move the paragraph below it by 355px after Leaf
reported its initial presentation complete. Lit leaves `hasUpdated`
false after an update skips drawing while data is unread, so the first
signal-driven retry could start without a presentation ticket. Its
asynchronous `updateComplete` then held no barrier.

`LeafElement` now claims each connected update at its draw gate when it
has no existing ticket. This preserves the asynchronous drawing
guarantee introduced in #3982 while retaining the bound-value gating in
#3929 and #3987. The external resolution behavior and shift tolerances
are unchanged.

The new runtime regression fails before the fix and passes afterward.
The reported browser case reproduces the 355px shift before the fix and
passes afterward, both normally and with 6× CPU throttling. The
data-readiness failure case, all 562 runtime tests, and `pnpm run check`
pass. Rebuilt the committed kernel.

A served `worktree-diffs` comparison against the base loads the same 53
code requests through upgrade and initial server presentation, with 107
additional code bytes (17 JavaScript bytes) and no layout shifts in
either arm. The added claim makes readiness wait for drawing already
underway; it adds no resource dependency.

Closes #4097 — automated triage

Co-authored-by: leaf-agent <[email protected]>
leaf-agent added a commit that referenced this pull request Nov 4, 2026
… updates (#5346)

`lf-diff` lost its whole-patch refusal on updates that changed nothing
it draws. The diff showed the refusal through `LeafElement`'s light-DOM
failure box, which `LeafElement.update()` removes on every update, while
`lf-diff` draws, and fails, asynchronously from `updated()`. #3527 and
#3987 kept the refusal by gating `shouldUpdate` on a changed source, and
#4800 added the Comment opener to that gate, so a thread surface
registering beside a refusal (on load for an inline patch, on return for
a bound one) cleared it again.

The refusal now stands as the diff's shadow stage, as its drawn files
do, so only the next `show` replaces it: a corrected source, or a
rendering a departure cut short. The `shouldUpdate` override and its
opener bookkeeping are gone. `render()` still reads the opener, so a
surface registering or retiring redraws the Comment controls, which
`updated()` reconciles as before.

Page layout can't see into a shadow stage, so the runtime's stage
failure placer (`shadow-stage.js`) marks the host `data-lf-failed` until
the next stage replaces the box. The `layouts.css` rules that give a
failed widget the prose measure and drop its reserved `data-height` read
it beside a light `.lf-error`. That also covers `lf-file-editor`,
`lf-file-tree`, and a bound diff that fails after drawing, whose failure
boxes already stood in the stage unseen by those rules.

Verification:

- `test_a_patch_that_failed_stays_failed_when_its_diff_returns` (inline
and bound) passes; it now reads the refusal from the shadow root.
- `test_a_widget_that_failed_soft_claims_no_room` gains a refused-diff
case, which fails without the `layouts.css` change and passes with it.
- Diff comment-control, preparation-on-return, retry, plain-host and
native-metadata tests pass, as do `pnpm run test:runtime` (777) and
`pnpm run check:browser`.
- `test_a_diff_refresh_keeps_a_selection_in_unchanged_lines` fails
identically on the previous head without this change.

Other tests that read a diff's refusal from light DOM now read the
shadow root, including two in `tests/journeys/test_render_anchors.py`
that weren't run here.

Closes #3986 — 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.

Bound diff reconnect repeats a completed patch refusal

1 participant