Skip to content

fix(studio): debounce flat slider drag commits to prevent rapid-fire writes#2190

Open
vanceingalls wants to merge 2 commits into
studio-flat-13-slider-dragfrom
07-10-fix_studio_debounce_flat_slider_drag_commits_to_prevent_rapid-fire_writes
Open

fix(studio): debounce flat slider drag commits to prevent rapid-fire writes#2190
vanceingalls wants to merge 2 commits into
studio-flat-13-slider-dragfrom
07-10-fix_studio_debounce_flat_slider_drag_commits_to_prevent_rapid-fire_writes

Conversation

@vanceingalls

@vanceingalls vanceingalls commented Jul 11, 2026

Copy link
Copy Markdown
Collaborator

Summary

FlatSlider's drag support (added in the prior stacked PR) called onCommit synchronously on every pointermove/pointerdown, with no debouncing — unlike the legacy SliderControl, which coalesces rapid drag input into a single debounced commit. This stack rewires FlatSlider to match that established pattern:

  • Local draft state drives instant knob position / aria-valuenow feedback on every pointer event (no lag).
  • Actual onCommit calls are debounced 40ms during drag and flushed immediately on pointerup/release, deduped against the current committed value (skips a no-op commit).
  • Fixed a real bug found while wiring this up: onPointerUp previously read the draft closure, which can be stale if pointerdown+pointerup land in the same React batch (e.g. a very fast click) — it now recomputes the release value fresh from the event's own clientX.

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 FlatSlider in 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 --check on all touched files — clean
  • Please re-verify the original repro (Layer Blur slider drag on an image/video clip) live — this fix is well-reasoned but not confirmed against your exact repro

vanceingalls commented Jul 11, 2026

Copy link
Copy Markdown
Collaborator Author

@miga-heygen miga-heygen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 miguel-heygen left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@vanceingalls vanceingalls force-pushed the studio-flat-13-slider-drag branch from ad36891 to 102c503 Compare July 11, 2026 01:34
@vanceingalls vanceingalls force-pushed the 07-10-fix_studio_debounce_flat_slider_drag_commits_to_prevent_rapid-fire_writes branch from d10ce38 to 0e39019 Compare July 11, 2026 01:34

@miguel-heygen miguel-heygen left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

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.

3 participants