Skip to content

fix(cursor): advance on bass-only beats; make final beat reachable - #21

Merged
byrongamatos merged 1 commit into
mainfrom
fix/cursor-both-hands
Jul 17, 2026
Merged

fix(cursor): advance on bass-only beats; make final beat reachable#21
byrongamatos merged 1 commit into
mainfrom
fix/cursor-both-hands

Conversation

@gionnibgud

@gionnibgud gionnibgud commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Problem

The playback cursor only advanced on right-hand (treble) beats, and never reached the last beat of a song.

Two independent bugs in the tick index:

  • _svBuildBeatTimeline walked only the first staff of the first track (break trackLoop right after staff 0). Beats that exist only on the bass staff were absent from the index used for cursor sync, so the cursor stalled or skipped through left-hand-only passages.
  • _svSyncCursor's binary search bounded hi at beats.length - 2, making the final beat unreachable.

Fix

  • _svBuildBeatTimeline now collects beats from all staves of the first track, sorts, then dedupes by tick — the stable sort keeps the first (treble) entry where both staves share a position, preserving the existing preference.
  • Binary search bound corrected to beats.length - 1.
  • Stale comment above _svBuildBeatTimeline updated to match.

Testing

  • npm test — 104/104 pass (unchanged from baseline; pure bugfix over already-covered helpers).
  • Verified in the running app against a two-hand piano chart: cursor advances on left-hand-only beats and reaches the final beat.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Fixed cursor synchronization for songs containing bass-only beats.
    • Improved beat timeline handling across treble and bass staves.
    • Fixed playback markers so they can correctly reach the song’s final beat.

_svBuildBeatTimeline walked only the first staff of the first track
(breaking out of the loop right after staff 0), so any beat that only
existed on the bass staff was absent from the tick index used for
cursor sync — the cursor would stall or skip during left-hand-only
passages. It now collects beats from all staves of the first track,
sorts, and dedupes by tick, keeping the first (treble) entry when both
staves share a position.

_svSyncCursor's binary search bounded hi at beats.length - 2, which
made the very last beat of a song unreachable by the search. Bound is
now beats.length - 1.

Co-Authored-By: Claude Sonnet <noreply@anthropic.com>
Signed-off-by: gionnibgud <gionnibgud@gmail.com>
@coderabbitai

coderabbitai Bot commented Jul 17, 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: 58776d24-7562-4788-8aa0-3200884d30bc

📥 Commits

Reviewing files that changed from the base of the PR and between 58ca2ae and 3d7640c.

📒 Files selected for processing (2)
  • CHANGELOG.md
  • screen.js

📝 Walkthrough

Walkthrough

Staffview cursor synchronization now includes beats from all staves, deduplicates shared ticks with treble precedence, and searches through the final beat. The changelog documents both fixes.

Changes

Staffview cursor fixes

Layer / File(s) Summary
Timeline construction and cursor synchronization
screen.js, CHANGELOG.md
_svBuildBeatTimeline collects beats across the first track’s staves and deduplicates shared ticks; _svSyncCursor includes the final beat in its binary search range. The changelog records both corrections.

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

Possibly related PRs

Suggested reviewers: byrongamatos

🚥 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 clearly summarizes the two main cursor-sync fixes: bass-only beat advancement and reaching the final beat.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ 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/cursor-both-hands

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

@byrongamatos
byrongamatos merged commit dc85c67 into main Jul 17, 2026
3 checks passed
@byrongamatos
byrongamatos deleted the fix/cursor-both-hands branch July 17, 2026 09:14
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.

2 participants