8000 fix(timeline): MATCH-snap on cam-track drag by johannboehme · Pull Request #35 · johannboehme/tk-1 · GitHub
[go: up one dir, main page]

Skip to content

fix(timeline): MATCH-snap on cam-track drag - #35

Merged
johannboehme merged 1 commit into
mainfrom
claude/fix-match-snap
May 6, 2026
Merged

johannboehme merged 1 commit into
mainfrom
claude/fix-match-snap

Conversation

@johannboehme
Copy link
Copy Markdown
Owner

Summary

In MATCH snap-mode, dragging a pill body promotes to a "cam-track-move" — the whole cam shifts in lockstep against a candidate-implied anchor. Two bugs combined to make this snap silently do nothing:

  1. The handler never called any candidate-snap. PR Mode-agnostic loop on the composed timeline + reconcile/strip fixes #29 introduced `cam-track-move` but dropped the snap-to-nearest-candidate logic that pre-refactor `clip-move` had (b382cbc). The handler just applied the raw arr-delta to every pill — free movement, regardless of snap mode.
  2. `setSelectedCandidateIdx` had no visible effect. Post the pill-authoritative refactor, pills carry their own `sourceInS` / `sourceOutS`. Changing `clip.syncOffsetMs` doesn't ripple into them, so even if a candidate switch had fired, the rendered output wouldn't move at all.

User-reported: "snappt nicht zu den alternativen Soundmatches".

Fix

  • `store.setSelectedCandidateIdx` now mirrors the `offsetMs` delta into every pill of the cam (live + originals), matching what `setClipSyncOverride` already does for `syncOverrideMs` nudges. Candidate switches now visibly slide the cam-content to the new alignment.
  • Timeline `cam-track-move` handler in MATCH (non-shift): compute the drag-target master-startS from a frozen `origMasterStartS` + arr-delta, find the nearest candidate-implied startS via `buildClipMatchPositions` / `candidateIdxNearestStart`, fire `setSelectedCandidateIdx` if it changed. No threshold — every candidate is a valid lock-target. Free-drag (apply pill arr-delta) only when MATCH is off or shift is held.
  • New `origMasterStartS` on the drag state freezes the cam-anchor at drag-start so candidate positions stay stable across mid-drag switches; without it the math cascades and middle candidates become unreachable.

Test plan

  • `pnpm test --run`: 936 passing (+1 new test for setSelectedCandidateIdx-shifts-pills)
  • `pnpm tsc --noEmit`: clean
  • Existing `setSelectedCandidateIdx switches the active candidate AND mirrors syncOffsetMs` test still passes

🤖 Generated with Claude Code

Introduced in PR #29 alongside `cam-track-move` (the MATCH snap-mode
body-drag), but the candidate-snap step never landed: the handler just
applied the raw arr-delta to all of the cam's pills, which is free
movement in any snap mode. Pre-refactor (b382cbc) `clip-move` had the
proper snap-to-nearest-candidate path; PR #29 dropped it when it
swapped clip-move out for cam-track-move.

Plus a second, deeper bug: pills are authoritative for source-time
post pill-refactor, so changing `clip.syncOffsetMs` (what the
candidate switch does) had no visible effect — pills kept playing the
old candidate's frames at the same arr-positions.

Fix:
- store.setSelectedCandidateIdx mirrors the offsetMs delta into every
  pill of the cam (live + originals), the same way setClipSyncOverride
  mirrors syncOverrideMs nudges. Now a candidate switch actually slides
  the cam-content visually.
- Timeline cam-track-move handler in MATCH mode (non-shift): compute
  the drag-target master-startS from the cam's frozen origMasterStartS
  + arr-delta, find the nearest candidate-implied startS via
  buildClipMatchPositions / candidateIdxNearestStart, fire
  setSelectedCandidateIdx if it changed. No threshold — every candidate
  is a valid lock-target. Free-drag pills only when MATCH is off or
  shift is held.
- New `origMasterStartS` field on the cam-track-move drag state freezes
  the cam-anchor at drag-start so candidate positions stay stable
  across mid-drag switches (otherwise middle candidates become
  unreachable as the math cascades).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@johannboehme
johannboehme merged commit acd78f1 into main May 6, 2026
1 check passed
@johannboehme
johannboehme deleted the claude/fix-match-snap branch May 6, 2026 19:21
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.

1 participant

0