TT-7625 fix: keep PBT segment boundaries flush when dragged after playback - #524
Open
nabalone wants to merge 1 commit into
Open
TT-7625 fix: keep PBT segment boundaries flush when dragged after playback#524nabalone wants to merge 1 commit into
nabalone wants to merge 1 commit into
Conversation
…yback The shared-boundary clamp in useWaveSurferRegions is gated on updatingRef, a latch meant to mark "we are moving region bounds programmatically". wsPlayRegion set that latch but only released it on its early-return path, so any successful region play left it stuck true for the rest of the session. Phrase Back Translate (and Careful Speech) pass forceRegionOnly, which routes every play through wsPlayRegion, so once the first segment auto-played the clamp stopped running: dragging a boundary moved only the dragged segment and left its neighbor behind, so the two overlapped or disconnected. Release the latch in a finally so it covers just the synchronous body. Also extract the clamp math into utils/sharedSegmentBoundary.ts with unit tests, so the "end of one segment is the start of the next" rule the other waveforms already follow is verifiable on its own. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
nabalone
force-pushed
the
TT-7625_pbt-segment-boundaries
branch
from
August 21, 2026 21:04
61040e4 to
0afb870
Compare
nabalone
marked this pull request as ready for review
August 21, 2026 23:26
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes TT-7625 — PBT segments can overlap and disconnect.
Problem
On the Phrase Back Translate step: with multiple segments, click Start Recording, let the first segment auto-play, then drag the boundary between two segments. The adjoining segment's boundary does not follow — the segments overlap or leave a gap.
Root cause
useWaveSurferRegionsalready keeps segment maps contiguous: onregion-update/region-updatedit clamps the dragged boundary and shifts the single adjacent neighbor's shared boundary to follow (constrainResizedRegion). Both handlers gate that on!updatingRef.current— a latch that means "we are moving region bounds programmatically, ignore this event".wsPlayRegionset that latch and released it only on its early-return path (region not found). Every successful region play left it stucktruefor the rest of the session.PBT (like Careful Speech) passes
forceRegionOnly, soWSAudioPlayer.handlePlayStatusroutes every play throughwsPlayRegion. Once the first segment auto-played, the clamp never ran again — which is exactly why the other waveforms (which play the whole file) still behave correctly.Change
wsPlayRegionnow releasesupdatingRefin afinally, so the latch covers only its synchronous body. The shared-boundary behavior PBT gets is the same code path Mark Verses already uses — no new special case.utils/sharedSegmentBoundary.ts(clampSharedBoundary) with unit tests, so the "end of one segment is the start of the next" rule is verifiable on its own.constrainResizedRegionis now just the wavesurfer plumbing around it.Note: the regions plugin emits
region-update/region-updatedonly from drag/resize (_onUpdate), never fromsetOptions, so releasing the latch cannot let programmatic bound/color changes be mistaken for a user drag.Test plan
npx jestinsrc/renderer— 164 suites, 1317 tests pass, including the newsharedSegmentBoundarysuite (9 tests) and the fullPassageDetailMarkVersessuite (18 tests, re-run in isolation before and after the change).npx tsc --noEmitclean; eslint + prettier clean on the touched files.🤖 Generated with Claude Code