Skip to content

feat(editor): drum grid row density — Full / Compact family rows - #120

Merged
byrongamatos merged 2 commits into
mainfrom
feat/editor-drum-density
Jul 7, 2026
Merged

feat(editor): drum grid row density — Full / Compact family rows#120
byrongamatos merged 2 commits into
mainfrom
feat/editor-drum-density

Conversation

@ChrisBeWithYou

@ChrisBeWithYou ChrisBeWithYou commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

P2 of the view-modality train (EDITOR-VIEW-MODALITY-DESIGN.md VD.1, decision V6: one evolving drum grid with density presets — never a parallel "game-style" editor, which could only lose information). Independent of the P1 stack; branched off current main.

What

  • Drum lane geometry routes through a density lane table: Full = one row per piece (today''s grid, byte-for-byte), Compact = the community 7-row family shape — crash / hi-hat / ride / toms / floor toms / snare / kick, mirroring core lib/drums.py PRESET_RB4 family boundaries — so the backbeat reads at a glance.
  • Strictly render/selection grouping — the V6 guarantee: hits keep their real piece-ids and per-piece colors (a compact row shows members distinctly), every piece lives on exactly one row (collapsing can never hide data), and hit lookup matches any row member.
  • Authoring semantics in Compact, documented in the button title: adding writes the family''s canonical piece (crash→crash_l, hi-hat→hh_closed, ride→ride…); a time-only drag keeps the hit''s original piece (hh_open never silently becomes hh_closed); crossing rows assigns the target family''s canonical. In Full, both rules reduce to exactly today''s behavior.
  • "Rows: Full/Compact" button next to Edit Drums (visible in drum mode only, per-draw memoized), registry command toggleDrumDensity, localStorage pref — never pack data.

Tests

tests/drum_density.test.js (7): full-mode identity with the physical-kit order, total coverage + uniqueness of the compact mapping (no piece falls off the grid), canonical row-membership, junk-pref fallback to Full, table purity (no config mutation leaks), and the same-row/cross-row drag semantics. Full suite green except the pre-existing CRLF section_coverage failure (#116 fixes it).

Fresh region vs the open queue — drum lane geometry + one toolbar button. (Registry/draw-wrapper insertion points may keep-both against sibling PRs, the usual resolution.)

🤖 Generated with Claude Code

https://claude.ai/code/session_01JEoFeTPSnz4NpwwCG52hnu

Summary by CodeRabbit

  • New Features

    • Added a drum grid density toggle with Full and Compact views.
    • Compact mode groups drum pieces into shared family rows while keeping piece selection and colors consistent.
    • Dragging between rows now moves hits to the destination row’s mapped piece, and the density button updates to show the current mode.
  • Bug Fixes

    • Switching grid density now clears the current selection and keeps drum lane interactions aligned with the displayed rows.

EDITOR-VIEW-MODALITY-DESIGN P2 (VD.1, decision V6): one grid, density
presets, never a second data path or a parallel "game-style" editor.

- Lane geometry now routes through a density lane table: Full = one row
  per piece (today's grid unchanged), Compact = the community 7-row
  family shape (crash/hi-hat/ride/toms/floor-toms/snare/kick, mirroring
  core lib/drums.py PRESET_RB4 family boundaries).
- Render/selection grouping ONLY: hits keep real piece-ids + per-piece
  colors; every piece maps to exactly one row (collapse never hides
  data); hit lookup matches any row member.
- Add in a compact row writes the family's CANONICAL piece; a time-only
  drag keeps the hit's original piece (hh_open never silently becomes
  hh_closed); crossing rows assigns the target family's canonical — in
  Full both rules reduce to today's behavior exactly.
- "Rows: Full/Compact" button next to Edit Drums (drum mode only),
  registry command toggleDrumDensity; localStorage pref, never pack.

Tests: tests/drum_density.test.js (7) — full-mode identity, total
coverage/uniqueness of the compact mapping, canonical membership, junk
pref fallback, purity, and the same-row/cross-row drag semantics. Full
suite green except the pre-existing CRLF section_coverage failure (#116).

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

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

No new commits to review since the last review.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 29170aeb-3439-4474-a0cc-5afde7d2a357

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Introduces a drum grid row density toggle (Full/Compact) with a family-lane mapping table, pure helper functions, localStorage persistence, updated rendering/hit-testing/drag logic keyed off lane index, a new UI toggle button, a Node test suite, and a changelog entry.

Changes

Drum row density feature

Layer / File(s) Summary
Density mode and lane table core
screen.js
Adds DRUM_COMPACT_LANES, pure lane-table/lane-index helpers, localStorage-backed density preference caching, _editorToggleDrumDensity(), and wires the toggleDrumDensity command into the shortcut list and command router.
Rendering and hit-testing via lane table
screen.js
Reworks _drumPieceCount, _drumPieceAtY, _drumHitAtPoint, lane-grid drawing, lane label rendering, and dot/hit positioning to use the density lane table instead of DRUM_PIECE_ORDER indexing.
Drag remapping and density toggle button
screen.js
Updates drag lane-move remap logic to clamp and remap pieces via lane canonicals, updates per-hit lane placement, and adds/refreshes the editor-drum-density-btn UI control in the draw() lifecycle.
Tests and changelog
tests/drum_density.test.js, CHANGELOG.md
Adds a test suite validating full/compact lane shapes, family canonicals, unknown-density fallback, lane lookups, projection purity, and drag remap semantics, plus a changelog entry describing the feature.

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

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant UIButton as editor-drum-density-btn
  participant Toggle as _editorToggleDrumDensity
  participant LaneTable as _drumLanes / lane helpers
  participant Renderer as Drum grid renderer

  User->>UIButton: click toggle
  UIButton->>Toggle: onclick()
  Toggle->>Toggle: flip density, persist preference
  Toggle->>Toggle: clear drum selection
  Toggle->>Renderer: redraw()
  Renderer->>LaneTable: _drumLanes() / _drumLaneIdxForPiece()
  LaneTable-->>Renderer: lane rows, canonical pieces
  Renderer-->>User: updated grid + status text
Loading

Related Issues: None referenced.

Related PRs: None referenced.

Suggested labels: enhancement, editor, drum-grid

Suggested reviewers: None identified from the provided context.

🐰 A drummer's rows once stood alone,
now families gather, each finds a home,
compact or full, the beat stays true,
seven lanes wide, or one-for-you,
a button clicks—the grid renews.

🚥 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 and concisely summarizes the main editor change: adding full/compact drum grid row density modes.
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 unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/editor-drum-density

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

@byrongamatos

Copy link
Copy Markdown
Collaborator

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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