Repository navigation
fix: restore controlled inputs after deferred replay drains - #1968
Conversation
Benchmark report
Compares js-framework: 1k/10k row operationsAll 20 timed operations (20 without a verdict)
All 64 work counters are unchanged. Application bundle size (bytes)
9 other measured values are unchanged. Public-import reachability bundles (bytes)
36 other measured values are unchanged. |
|
Needs one small change. The fix is in the right place: restores queued during a flush now wait for the ambient flush instead of writing a stale controlled value partway through. The layout-adoption rows of the new test would fail on main. One part of the new guard is broader than the fix needs, though, and it changes documented timing.
Verified:
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Bugbot Autofix is ON, but it could not run because the branch was deleted or merged before autofix could start.
Reviewed by Cursor Bugbot for commit c76654a. Configure here.
|
The restore-timing concern is resolved. Good to go once it's green on current main.
Non-blocking questions:
Verified:
|

Summary
Preserve accepted controlled-input drafts during deferred replay, and restore rejected edits at the completion boundary that owns the edit.
An event replayed inside a flush can schedule an accepted update before the outer flush finishes. Restoring immediately erases its draft. Conversely, a native edit outside that flush must not wait for unrelated parked transition work.
Changes
The news benchmark fixture change has been removed. The fix uses the existing controlled driver and queue; it adds no scheduler task, Block/Scope field, public export or parallel restoration system.
Validation
20f0ab92b, integrated with main64c33de2f: 54/54 owning development/production cases and 310/310 nearby checks pass across controlled restoration, form diagnostics, native signal cleanup, scalar DOM bindings and context promotion.pnpm syncpass with no generated changes.c76654a0e: the six added mode-specific cases have four passing controls and two expected failures when transition cleanup creates a foreign root. The fix passes those cases after integration. The active initial-root accepted-edit case is neighboring compatibility coverage.perf-review: the narrow review fix has zero candidates. The full PR has one candidate: the existingqueueMicrotask(flush)is unchanged scheduling moved through cleanup nesting, not a new task.concise-code: runtime +341 −204 against main; the existing queue and driver are extended, with no new public export or Block/Scope field.Risk / follow-ups
This changes restoration ordering across flush, event and deferred-layout boundaries. Delivery ownership adds scalar event/host bookkeeping when controlled restoration is installed. The public failures justify this correctness fix; no production-latency improvement or Ripple parity is claimed.
Six matched Vite/OXC production builds against exact main
64c33de2fpass source-map reachability checks: restoration functions and the driver remain absent from no-control and event-only fixtures, with the existing queue retained equally. The controlled positive retains the restoration owners and passes accepted/rejected-input, identity and unmount gates.These are complete fixture bundles, not latency measurements. The bundle fixtures' public behavior ran in JSDOM; the separate Chromium checks above establish their stated browser scope.
Provenance
agent-authored)Codex task · implementation host
com-79386.Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
Medium Risk
Changes restoration ordering across flush, event dispatch, and deferred-layout boundaries in core runtime; behavior is heavily tested but touches form-control correctness paths.
Overview
Fixes controlled form control behavior when edits are replayed or triggered during hydration, layout effects,
flushSync, deferred layout completion, or view transitions.The runtime now defers DOM restoration until the owning flush or commit boundary finishes: pending restores record whether each edit happened during a flush, so accepted drafts are not wiped early while unrelated parked work drains. Input/change deliveries get ownership tokens (
beginControlledDelivery/$$restoreDelivery) so stopped events, nested dispatch, shadow roots, and reusedEventobjects cannot restore over a newer edit.restoreControlledStatesruns after successfulflushWork,flushSync, andcompleteDeferredLayouts, andrethrowAfterControlledRestoreruns restoration on render/commit failures without masking the original error.Adds hydration regression tests for text inputs, checkbox/radio/select, focus/selection, Send, animations, and error paths.
Reviewed by Cursor Bugbot for commit 20f0ab9. Bugbot is set up for automated code reviews on this repo. Configure here.