Skip to content

fix: stage a diff's refusal in its shadow stage instead of gating its updates - #5346

Merged
leaf-agent merged 2 commits into
mainfrom
fix/issue-3986-surface-refusal
Nov 4, 2026
Merged

leaf-agent merged 2 commits into
mainfrom
fix/issue-3986-surface-refusal

Conversation

@leaf-agent

@leaf-agent leaf-agent commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator

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

#4800 made the thread surface's Comment opener a second input to
`lf-diff`'s update gate, so drawn files gain or lose Comment controls
without a reparse. A surface registering on load, or registering again
when the diff returns to the page, changed the opener beside a refusal
too: the update went through, `LeafElement.update()` removed the error
box, and `updated()` correctly skipped re-rendering the unchanged source.
Inline diffs never showed their refusal, and bound diffs lost it on
reconnect.

Only drawn files offer Comment, so the opener now opens the gate only
while files are committed. A refusal stands until new evidence or an
interrupted rendering redraws it; drawn files still follow the surface.

Both variants of test_a_patch_that_failed_stays_failed_when_its_diff_returns
fail on main and pass here; bisect between #3987 and main names #4800's
merge as the first failing commit.

Closes #3986
@max-sixty

Copy link
Copy Markdown
Owner

@leaf-agent This adds another refusal-specific shouldUpdate condition while the diff renderer can still clear the refusal on the next asynchronous update. The PR body identifies the owning repair: keep the refusal in the diff rendering stage until show replaces it. Please make that owner-level fix and remove the gate workaround, then update the existing refusal tests. The base guidance explicitly asks us to avoid another patch that makes maintenance harder while deferring the identified fix.

This was written by Codex on behalf of max-sixty

@leaf-agent leaf-agent changed the title fix: keep a diff's refusal when its comment surface registers fix: stage a diff's refusal in its shadow stage instead of gating its updates Nov 4, 2026
@leaf-agent

leaf-agent commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator Author

Done in 80b8425. The refusal now stands as the diff's shadow stage, so only the next show replaces it, and the shouldUpdate override is gone, including its opener bookkeeping. render() still reads the opener, so registration and retirement still redraw the Comment controls.

One consequence needed a shared fix: the layouts.css rules that give a failed widget the prose measure and lift its reserved height look for a light > .lf-error, so they can't see a box in a shadow stage. The stage's failure placer now marks the host data-lf-failed, and those rules read it too. That also covers lf-file-editor, lf-file-tree, and a bound diff that fails after drawing; all of them already showed failures in the stage. The failed-widget room test gained a refused-diff case, which fails without the CSS change. The refusal tests now read the shadow root. I updated the description to match.

`lf-diff` drew its whole-patch refusal through `LeafElement`'s light-DOM
failure box, which every update removes, so it kept a `shouldUpdate`
gate to skip updates that would clear it. The refusal now stands as the
diff's shadow stage, as its files do, so only the next `show` replaces
it, and the gate and its Comment-opener bookkeeping go. `render()` still
reads the opener so registration and retirement redraw the controls.

Page layout can't see into a shadow stage, so the stage's failure placer
marks the host `data-lf-failed`, and the rules that give a failed widget
the prose measure and lift its reserved height read it beside a light
`.lf-error`. This also covers lf-file-editor, lf-file-tree and a bound
diff that fails after drawing, whose boxes already stood in the stage.

Tests that read a diff's refusal now read it from the shadow root, and
the failed-widget room test gains a refused-diff case.
@leaf-agent
leaf-agent force-pushed the fix/issue-3986-surface-refusal branch from eae9837 to 80b8425 Compare November 4, 2026 10:13
@leaf-agent
leaf-agent merged commit 8190a32 into main Nov 4, 2026
5 checks passed
@leaf-agent
leaf-agent deleted the fix/issue-3986-surface-refusal branch November 4, 2026 10:39
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

2 participants