Skip to content

feat(editor): standard notation in the score view (View ▸ Score staff) - #288

Merged
byrongamatos merged 2 commits into
mainfrom
feat/editor-notation-staff
Jul 15, 2026
Merged

feat(editor): standard notation in the score view (View ▸ Score staff)#288
byrongamatos merged 2 commits into
mainfrom
feat/editor-notation-staff

Conversation

@byrongamatos

@byrongamatos byrongamatos commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

Supersedes #274 (auto-closed when its stacked base branch feat/editor-tab-view-live was deleted on merge of #273). Rebased cleanly onto main; content unchanged — notation staff + the review listener-leak fix. Reviewed green (161 pass); CodeRabbit clean.

Summary by CodeRabbit

  • New Features

    • Added a Score staff option to the View menu.
    • Choose tablature only, standard notation only, or both staves.
    • Staff selections apply across beat selections and are remembered in your browser.
    • Selecting a staff automatically opens score view when it is inactive.
  • Bug Fixes

    • Improved score-view switching to prevent duplicate selection handlers.

ChrisBeWithYou and others added 2 commits July 15, 2026 22:27
The live score view grows a staff preference: tablature only (default,
per the v1 call), standard notation only, or both staves together —
same generated alphaTex either way, alphaTab derives pitch from
tuning + fret, so notation comes free of new generation code.

- tab-view-live.js: _scoreStaffProfilePure maps the preference to
  alphaTab's StaveProfile key (unknown/legacy stored values degrade to
  tab, never throw into the renderer); the api tracks the staff it was
  built with and rebuilds on change (staveProfile is construction-time);
  editorSetTabViewStaff validates + persists (localStorage, a reading
  preference like loop-snap) and ENTERS the view when it's off.
- menu-bar.js: a Score-staff radio trio in the View menu, same ctx/
  dispatch pattern as the loop-snap trio; checkmarks resolve at open.
- state.js: S.tabViewStaff ('tab' default).

Live-verified on :8001 (AC/DC pak): all three staves engrave (tab
frets / treble-clef pitches with accidentals / braced grand system),
click-to-select works under 'both' (3 notes), the real View-menu radio
renders + dispatches + enters the view, preference persists. 148/148,
lint baseline, new tab_view_staff suite + menu-model radio pin.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EBQCHCNA81E9tHmSDHSe2Q
…build

The Score-staff switch made _ensureApi rebuild the alphaTab api on the
SAME mount node (staveProfile is a construction-time setting). But
_destroyApi only tore down alphaTab's own api — it never removed our
capture-phase mousedown fallback, which is our own closure. So every
staff toggle stacked another live listener on the surviving mount, and
each subsequent beat click fired select() / editorSeekToTime() / status
updates once per accumulated listener.

Root cause: the manual mount.addEventListener('mousedown', ..., true) in
_ensureApi had no matching removeEventListener. Name the handler, drop it
in _destroyApi before nulling _apiMount. In PR #273 this path never fired
on a surviving node (rebuild happened only on a NEW mount, GC'd the old
listener), so the leak is specific to the staff-switch guard this PR adds.

Regression test (tests/tab_view_staff.test.mjs): three staff switches on
one mount keep exactly one mousedown listener; fails pre-fix (2 !== 1).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@byrongamatos
byrongamatos merged commit fd57fb2 into main Jul 15, 2026
3 of 4 checks passed
@byrongamatos
byrongamatos deleted the feat/editor-notation-staff branch July 15, 2026 20:28
@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 8f69794c-ee08-427c-a40c-cb7b7b0af5e7

📥 Commits

Reviewing files that changed from the base of the PR and between f1eda8c and d14f565.

📒 Files selected for processing (6)
  • CHANGELOG.md
  • src/menu-bar.js
  • src/state.js
  • src/tab-view-live.js
  • tests/menu_model.test.mjs
  • tests/tab_view_staff.test.mjs

📝 Walkthrough

Walkthrough

Adds a persisted score-staff preference with tablature, notation, and combined modes. The View menu controls the preference, alphaTab rebuilds when it changes, score view activation is supported, and listener cleanup plus menu behavior are tested.

Changes

Score staff preference

Layer / File(s) Summary
Staff preference and live-view engine
src/state.js, src/tab-view-live.js, tests/tab_view_staff.test.mjs
Adds the staff state, local preference restoration and persistence, alphaTab stave-profile mapping, view activation, rebuild behavior, and capture-listener cleanup tests.
View menu integration
src/menu-bar.js, tests/menu_model.test.mjs, CHANGELOG.md
Adds three Score staff radio options, connects menu state and dispatch, and documents the available score-view modes.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ViewMenu
  participant editorSetTabViewStaff
  participant localStorage
  participant alphaTabAPI
  ViewMenu->>editorSetTabViewStaff: select staff mode
  editorSetTabViewStaff->>localStorage: persist editorTabViewStaff
  editorSetTabViewStaff->>alphaTabAPI: rebuild with staveProfile
  alphaTabAPI-->>editorSetTabViewStaff: attach one mousedown handler
Loading

Possibly related PRs

Suggested reviewers: chrisbewithyou

✨ 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 feat/editor-notation-staff

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

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