Skip to content

feat(editor): drums become a type:"drums" arrangement (model foundation) - #336

Merged
byrongamatos merged 1 commit into
mainfrom
mt-drums-p1
Jul 21, 2026
Merged

byrongamatos merged 1 commit into
mainfrom
mt-drums-p1

Conversation

@ChrisBeWithYou

Copy link
Copy Markdown
Contributor

Stacked on #335 (needs arrKind / _arrTypeKind / the type round-trip). Review/merge #335 first; I'll retarget this to main after.

What & why

The foundation for multiple drum charts (the drums-as-arrangements arc). The single drum tab has always lived entirely outside S.arrangements[] as a lone off-array singleton edited through a global mode — the one instrument that isn't an ordinary arrangement. This gives it a home in the list as a derived type:"drums" arrangement (via the #335 instrument-type-as-data seam), the substrate multiple drum charts grow from.

Byte-identical: no pack change, no UI change, drum-editor undo untouched. routes.py untouched.

How

New leaf src/drum-arrangement.js:

  • syncDrumArrangement(S) materializes / updates / removes the drums arrangement so its .drumTab payload is S.drumTab — the same object reference, so every existing S.drumTab reader/mutator and every drum undo command (which hold references into S.drumTab.hits) keep working unchanged. Appends (never inserts), so existing arr indices / arr:<idx> keys are stable. Called at every S.drumTab (re)assignment: load migration, GP/MIDI import + empty-add, delete + its undo-restore.
  • isDrumArrangement keys on the authored type alone (normalized), not arrKindarrKind would name-infer and wrongly catch a pitched part a user literally named "Drums", then hide/drop it.
  • pitchedArrangementCount / clampAwayFromDrums / pitchedIndexOf keep index math correct now that S.arrangements[] can hold a drums entry: the remove-last-arrangement guard counts pitched parts, S.currentArr never lands on drums, and the /remove-arrangement backend index maps to its pitched-only position (the backend manifest has no drums arrangement).

Byte-identical surfaces (drums bridged to the legacy paths; promoting them to arr:<idx> + drum-edit-via-selection is the follow-up):

  • Save (_buildSaveBody, editorBuild): the drums arrangement is excluded from body.arrangements — drums still persist as the song-level drum_tab, so the built pack is byte-identical (and no drums entry reaches arrangements[], where an old core would fretted-grade it as garbage).
  • Tracks targets / Parts view / band roster / pitched switcher: each skips the drums arrangement so it isn't listed twice — drums stay the legacy 'drums' target/key.

Tests

tests/drum_arrangement.test.mjs (+15): the sync state machine (materialize/update/remove/idempotent/append/same-ref/degrade), the remove→restore undo round-trip, byte-identical load→save, the "Drums"-named-but-untyped safety case (survives save, keeps its arr target), no duplicate tracks/band rows, and the index helpers incl. the interspersed-drums backend index.

Gates: JS 297/0 · lint 0 err / 3 baseline · routes.py untouched (no pytest).

Next in the arc

Promote the tracks/mixer/switcher off the legacy 'drums' singleton → arr:<idx> + open the drum grid via arrangement selection; then N drums; then the per-arrangement drum_tab build format (with the spec/core FEP); then the region R3b import driver.

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@byrongamatos, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 40 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: a292021d-a233-4d80-a4f9-5fa594717cb2

📥 Commits

Reviewing files that changed from the base of the PR and between 736077f and 555d3e1.

📒 Files selected for processing (16)
  • CHANGELOG.md
  • src/arrangement.js
  • src/audio.js
  • src/create.js
  • src/drum-arrangement.js
  • src/file-ops.js
  • src/main.js
  • src/mixer-panel.js
  • src/parts-view.js
  • src/stem-tracks.js
  • src/track-session.js
  • tests/create_drum_materialize.test.js
  • tests/drum_arrangement.test.mjs
  • tests/mixer_panel.test.mjs
  • tests/reorder_part.test.js
  • tests/stem_tracks.test.mjs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch mt-drums-p1

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

…on) (#336)

Includes review fixes: audit S.arrangements consumers after materializing drums.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@byrongamatos
byrongamatos merged commit 96de8e7 into main Jul 21, 2026
1 of 2 checks passed
@byrongamatos
byrongamatos deleted the mt-drums-p1 branch July 21, 2026 11:38
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