refactor(editor): move the Parts overview to src/parts-view.js (R2, step 38) - #190
Conversation
…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>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe Parts view implementation moves from ChangesParts view refactor
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (3)
src/main.jssrc/parts-view.jstests/parts_view.test.js
_partsViewOnDblClick only reads y. Addresses CodeRabbit on #190. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
What
Step 38 of the R2 module-extraction refactor: move the Parts overview (parts-view mode) out of
src/main.jsinto a new native ES modulesrc/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-viewlayout 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-buttonsetIntervalthat share the region stay in main.js:src/parts-view.js: 5 symbols exported back —_editorTogglePartsView,_partsViewDraw,_partsViewOnMouseDown,_partsViewOnDblClick,_refreshPartsViewButton— which the existingsetHostHookswiring,drawNow's call, and thewindow.editorTogglePartsViewre-attach already reference by name; so the seam is just the import + the re-attach.draw/updateStatus/drawWaveform/hideAddNote/finalizeActiveDragroute throughhost; no new hooks.@pure:parts-viewkept export-free for the test slice.DRUM_PIECE_META,_stringCountFor,_downbeatTimes).tests/parts_view.test.jsretargeted to slice fromsrc/parts-view.js.main.js drops ~305 lines. 39 modules.
Verification
no-undefclean onparts-view.js.verify_parts_view.py) enters parts view (status reports it), captures the part-name silhouette text (proving_partsViewDrawruns throughdrawNow), 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: thewindow.editorTogglePartsViewre-attach was missing (the toolbar button / Shift+A would have broken); fixed.🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Improvements
Tests