refactor(editor): move the key & view controls to src/key-view.js (R2, step 41) - #193
Merged
Merged
Conversation
…, step 41)
Extract the in-key highlight controls (tonic/scale selectors + auto-detect) and
the per-part view switcher (String / Piano roll / Parts) out of the src/main.js
Drawing section into a new native ES module.
- src/key-view.js: 4 symbols exported back (_editorCycleViewMode /
_editorToggleKeyHighlight — existing host hooks; _refreshKeyControls /
_refreshViewSwitch — called by drawNow + the toolbar), 5 re-attached window
handlers. draw / updateStatus route through host.
- One new host hook, resizeCanvas (a view-mode reflow recomputes lane metrics);
dropped the now-moot typeof guard on the bare resizeCanvas reference.
- Removed 10 now-dead main.js imports.
main.js drops ~175 lines to under 2,000. 42 modules.
Verified: 90/90 JS suites pass, ESLint gate clean (0 errors), strict no-undef
clean on key-view.js, Codex preflight 0 regressions. New headless harness:
editorToggleKeyHighlight reports on/off, editorSetViewMode('piano') paints the
piano-roll keyboard gutter (24 fills) and ('string') drops it to 0 — proving the
view switch repaints through host.draw + the new resizeCanvas hook. Negative-checked.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe PR extracts editor key and view controls from ChangesKey and view controls
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant Editor
participant editorSetViewMode
participant host.resizeCanvas
participant resizeCanvas
Editor->>editorSetViewMode: select string or piano mode
editorSetViewMode->>host.resizeCanvas: schedule canvas resize
host.resizeCanvas->>resizeCanvas: recompute canvas and lane metrics
editorSetViewMode->>Editor: redraw and show mode status
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
This was referenced Jul 11, 2026
This was referenced Jul 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Step 41 of the R2 refactor: move the key & view controls (in-key highlight — tonic/scale selectors + auto-detect — and the per-part view switcher: String / Piano roll / Parts) out of
src/main.js's Drawing section into a new native ES modulesrc/key-view.js.How the seam is drawn
src/key-view.js: 4 symbols exported back —_editorCycleViewMode/_editorToggleKeyHighlight(existing host hooks),_refreshKeyControls/_refreshViewSwitch(called bydrawNow+ the toolbar) — plus 5 re-attached window handlers.draw/updateStatusroute throughhost.resizeCanvas(a view-mode reflow recomputes lane metrics); dropped the now-moottypeofguard on the bareresizeCanvasreference.main.js drops ~175 lines to under 2,000. 42 modules.
Verification
no-undefclean onkey-view.js.verify_key_view.py):editorToggleKeyHighlightreports on/off,editorSetViewMode('piano')paints the piano-roll keyboard gutter (24 fills) and('string')drops it to 0 — proving the view switch repaints throughhost.draw+ the newresizeCanvashook. Negative-checked by dropping a re-attach.🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Improvements