fix(studio): debounce flat slider drag commits to prevent rapid-fire writes#2190
Conversation
miga-heygen
left a comment
There was a problem hiding this comment.
Reviewed as part of the 15-PR edit-panel redesign stack. Full stack review posted on #2120. No blockers on this PR. — Miga
A pure debounce resets its timer on every pointermove, so a real drag (events faster than 40ms apart) never commits until the pointer pauses or lifts — killing live preview updates mid-drag. Throttle with a leading-edge commit + trailing flush instead.
miguel-heygen
left a comment
There was a problem hiding this comment.
Final current-head pass: d10ce38. Reviewed the stack boundaries and current diff against the flat-inspector contracts; required checks have no failures/pending checks and no unresolved review threads remain. No new drift found; residual notes are non-blocking.
ad36891 to
102c503
Compare
d10ce38 to
0e39019
Compare
miguel-heygen
left a comment
There was a problem hiding this comment.
Superseding earlier approval: the latest max-review pass found confirmed correctness issues in this flat-inspector stack (identity/selector-index state, hide-all write races, timing inference, slider pointer/keyboard/reset semantics, and duplicate React keys). Hold merge and require fixes plus re-review on the current stack head.

Summary
FlatSlider's drag support (added in the prior stacked PR) calledonCommitsynchronously on everypointermove/pointerdown, with no debouncing — unlike the legacySliderControl, which coalesces rapid drag input into a single debounced commit. This stack rewiresFlatSliderto match that established pattern:draftstate drives instant knob position /aria-valuenowfeedback on every pointer event (no lag).onCommitcalls are debounced 40ms during drag and flushed immediately onpointerup/release, deduped against the current committed value (skips a no-op commit).onPointerUppreviously read thedraftclosure, which can be stale ifpointerdown+pointerupland in the same React batch (e.g. a very fast click) — it now recomputes the release value fresh from the event's ownclientX.This is a defensive fix for a reported issue ("live preview shows the wrong value while dragging; the correct value only appears after deselecting," reproduced by the reporter on Layer Blur). I was not able to reproduce the exact symptom myself despite extensive scripted browser testing, but the un-debounced commit-per-pointermove is a plausible root cause and this brings
FlatSliderin line with the codebase's existing debounce pattern for exactly this class of bug.Test plan
bunx vitest run— full studio suite passes (1585 passed)bunx oxlint/bunx oxfmt --checkon all touched files — clean