Skip to content

refactor(editor): move the Parts overview to src/parts-view.js (R2, step 38) - #190

Merged
byrongamatos merged 2 commits into
mainfrom
refactor/r2-step38-parts-view
Jul 10, 2026
Merged

refactor(editor): move the Parts overview to src/parts-view.js (R2, step 38)#190
byrongamatos merged 2 commits into
mainfrom
refactor/r2-step38-parts-view

Conversation

@byrongamatos

@byrongamatos byrongamatos commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

What

Step 38 of the R2 module-extraction refactor: move the Parts overview (parts-view mode) out of src/main.js into a new native ES module src/parts-view.js.

A stacked read-only silhouette of every part (arrangements + drum tab), armed by lane click and opened by double-click — plus the @pure:parts-view layout pures, the per-part draw + hit handlers, the toggle, and the ☰ Parts toolbar-button injection.

How the seam is drawn

Function-level cut — the draw() reassignment and the drum-button setInterval that share the region stay in main.js:

  • src/parts-view.js: 5 symbols exported back — _editorTogglePartsView, _partsViewDraw, _partsViewOnMouseDown, _partsViewOnDblClick, _refreshPartsViewButton — which the existing setHostHooks wiring, drawNow's call, and the window.editorTogglePartsView re-attach already reference by name; so the seam is just the import + the re-attach. draw / updateStatus / drawWaveform / hideAddNote / finalizeActiveDrag route through host; no new hooks.
  • @pure:parts-view kept export-free for the test slice.
  • Removed 3 dead main.js imports (DRUM_PIECE_META, _stringCountFor, _downbeatTimes).
  • tests/parts_view.test.js retargeted to slice from src/parts-view.js.

main.js drops ~305 lines. 39 modules.

Verification

  • 90/90 JS suites pass; ESLint gate clean (0 errors); strict no-undef clean on parts-view.js.
  • Codex preflight: 0 regressions.
  • New headless harness (verify_parts_view.py) enters parts view (status reports it), captures the part-name silhouette text (proving _partsViewDraw runs through drawNow), confirms the ☰ Parts button is injected + shown, and exits back to note-edit mode — zero page errors. The harness caught a real bug pre-merge: the window.editorTogglePartsView re-attach was missing (the toolbar button / Shift+A would have broken); fixed.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added a dedicated Parts view for browsing musical arrangements and drum sections.
    • Renders lane silhouettes with downbeat markers and a playhead synchronized to the cursor.
    • Enables selecting a part to edit; drum editing is gated with clear status feedback when unavailable.
  • Improvements

    • Parts view UI updates automatically with editor state and refreshes relevant toolbar controls.
    • Entering Parts view now resets conflicting selections and hides related editing UI.
  • Tests

    • Updated Parts view test harness to use the new source location for rendering helpers.

…tep 38)

Extract parts-view mode (a stacked read-only silhouette of every part, armed by
lane click / opened by double-click) out of the src/main.js monolith into a new
native ES module: the @pure:parts-view block, the per-part draw + hit handlers,
the toggle, and the ☰ Parts toolbar-button injection. The draw() reassignment
and the drum-button setInterval that shared the region stay in main.js.

- src/parts-view.js: 5 symbols exported back — _editorTogglePartsView,
  _partsViewDraw, _partsViewOnMouseDown, _partsViewOnDblClick,
  _refreshPartsViewButton — which the existing setHostHooks wiring, drawNow's
  call, and the window.editorTogglePartsView re-attach reference by name; so the
  seam is just the import + the re-attach. draw / updateStatus / drawWaveform /
  hideAddNote / finalizeActiveDrag route through host; no new hooks.
- @pure:parts-view kept export-free for the test slice.
- Removed 3 dead main.js imports (DRUM_PIECE_META, _stringCountFor, _downbeatTimes).
- tests/parts_view.test.js retargeted to slice from src/parts-view.js.

main.js drops ~305 lines. 39 modules.

Verified: 90/90 JS suites pass, ESLint gate clean (0 errors), strict no-undef
clean on parts-view.js, Codex preflight 0 regressions. New headless harness
enters parts view (status reports it), captures the part-name silhouette text
(proving _partsViewDraw runs through drawNow), confirms the ☰ Parts button is
injected + shown, and exits back to note-edit mode — zero page errors. The
harness caught a real bug pre-merge: the window.editorTogglePartsView re-attach
was missing (toolbar button / Shift+A would have broken); fixed.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 10, 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: 40c7d7ae-e322-4993-85b3-edbb880ebeb2

📥 Commits

Reviewing files that changed from the base of the PR and between ae8ad9e and 17850b2.

📒 Files selected for processing (1)
  • src/parts-view.js

📝 Walkthrough

Walkthrough

The Parts view implementation moves from main.js into parts-view.js, which now owns rendering, interaction, mode toggling, and button management. The editor refreshes Parts view UI during drawing, and tests load the pure helper block from its new location.

Changes

Parts view refactor

Layer / File(s) Summary
Module ownership and draw wiring
src/main.js
Imports are reformatted, inline Parts view logic is removed, and button state refresh is integrated into the per-frame draw wrapper.
Parts view derivation and rendering
src/parts-view.js
Lane data, labels, drum and arrangement silhouettes, downbeat markers, and the cursor playhead are implemented in the dedicated Parts view module.
Parts view interaction and validation
src/parts-view.js, tests/parts_view.test.js
Mouse interactions, editing transitions, mode toggling, lazy button creation, button refresh, and pure-block test loading are implemented or updated.

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

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 42.86% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed Clearly summarizes the main refactor by moving Parts overview logic into src/parts-view.js.
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 refactor/r2-step38-parts-view

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/parts-view.js`:
- Around line 232-236: Remove the unused x binding in _partsViewOnDblClick by
destructuring only y from getMousePos(e), since the lane hit-test uses y
exclusively.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 7e710e74-a26d-45b0-bffc-041fce3e67b7

📥 Commits

Reviewing files that changed from the base of the PR and between b31737c and ae8ad9e.

📒 Files selected for processing (3)
  • src/main.js
  • src/parts-view.js
  • tests/parts_view.test.js

Comment thread src/parts-view.js
_partsViewOnDblClick only reads y. Addresses CodeRabbit on #190.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@byrongamatos
byrongamatos merged commit 6f4649a into main Jul 10, 2026
3 of 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.

1 participant