Skip to content

fix(editor): snap dragged barlines to chart-time onsets (fixes #254) - #255

Merged
byrongamatos merged 1 commit into
mainfrom
fix/editor-tempo-snap-timebase
Jul 14, 2026
Merged

fix(editor): snap dragged barlines to chart-time onsets (fixes #254)#255
byrongamatos merged 1 commit into
mainfrom
fix/editor-tempo-snap-timebase

Conversation

@ChrisBeWithYou

@ChrisBeWithYou ChrisBeWithYou commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Fixes #254 (Byron's review catch on #249).

_tempoMapOnDragMove snapped a dragged barline to the nearest detected onset using _ensureOnsets() (buffer time) against rawT (chart time). When the recording is shifted (S.audioShift != 0) the two time bases diverge, so the barline snapped to the un-shifted attack instead of the heard one.

Fix: use _ensureOnsetsShifted() — the chart-time onsets the Suggest-fit path already uses (tempo.js ~L691). Pre-existing since the onset-snap-on-drag change (#235); low impact (only bites with shifted audio), undoable, but a wrong snap target.

  • Drops the now-unused _ensureOnsets import from tempo.js.
  • tempo_onset_snap.test.mjs's source-text assertion updated to _ensureOnsetsShifted.
  • 146 JS green, ESLint 0 errors, routes.py untouched.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved barline dragging with Snap = Onset so snapping stays correct when audio and chart timing are offset.
    • Onset snapping now uses shift-corrected chart-time onset positions, avoiding snaps to misaligned attacks.
  • Tests
    • Updated the tempo-map onset-snap drag test to verify snapping behavior against chart-time onset references.

@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 86985678-2426-4e66-b5de-2c4b2d5e7569

📥 Commits

Reviewing files that changed from the base of the PR and between c2116da and 2be6164.

📒 Files selected for processing (2)
  • src/tempo.js
  • tests/tempo_onset_snap.test.mjs
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/tempo_onset_snap.test.mjs

📝 Walkthrough

Walkthrough

Tempo-map barline dragging with onset snapping now compares chart-time positions against shift-corrected onsets. The unused unshifted onset import is removed, and the related guard test is updated.

Changes

Tempo onset snapping

Layer / File(s) Summary
Use shifted onsets for drag snapping
src/tempo.js, tests/tempo_onset_snap.test.mjs
The drag handler now calls _ensureOnsetsShifted() for onset snapping, removes the unused _ensureOnsets import, and updates the source-inspection assertion.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately summarizes the main change: snapping dragged barlines to chart-time onsets.
Linked Issues check ✅ Passed The change replaces buffer-time onsets with _ensureOnsetsShifted() in _tempoMapOnDragMove, matching issue #254's fix.
Out of Scope Changes check ✅ Passed The PR stays focused on the onset-snap bug fix and the corresponding test update, with no unrelated changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/editor-tempo-snap-timebase

Comment @coderabbitai help to get the list of available commands.

_tempoMapOnDragMove snapped a dragged barline to the nearest onset using
_ensureOnsets() (BUFFER time) against rawT (CHART time). When the recording is
shifted (S.audioShift != 0) the two diverge, so the barline snapped to the
un-shifted attack. Use _ensureOnsetsShifted() — the chart-time onsets Suggest-fit
already uses. Pre-existing since #235; low impact (only with a shifted audio),
undoable, but a wrong snap target.

Also drops the now-unused _ensureOnsets import. tempo_onset_snap.test.mjs's
source-text assertion updated to _ensureOnsetsShifted. 146 JS green, lint 0-err.

Fixes #254.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EBQCHCNA81E9tHmSDHSe2Q
@byrongamatos
byrongamatos force-pushed the fix/editor-tempo-snap-timebase branch from c2116da to 2be6164 Compare July 14, 2026 17:40
@byrongamatos
byrongamatos merged commit 1f0be1d into main Jul 14, 2026
4 checks passed
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.

Tempo-map drag-snap uses buffer-time onsets against a chart-time value (mis-snaps when audio is shifted)

2 participants