refactor(editor): move the context menu to src/context-menu.js (R2, step 25) - #177
Conversation
…tep 25) src/main.js 9,146 -> 8,786. Twenty-seventh module; the graph stays acyclic. 362 lines: the canvas right-click menu (change fret, bend, slide, delete, position moves — each entry runs a command from src/commands.js) and the prompt dialogs it opens (promptFret / promptBend / promptSlide / promptSlideUnpitch). ZERO new host hooks, which is the point. Its three main.js dependencies — draw, updateStatus, _editBlipAt — were already on host. And it OWNS promptBend and hideContextMenu, both of which were already host hooks that the inspector and several modes call. They resolve to this module's exports now instead of definitions in main.js; the wiring did not change, only where it points. main.js keeps the canvas `contextmenu` event that decides WHEN to open the menu and imports showContextMenu / the prompt* dialogs directly. verify_context_menu.py right-clicks a note, asserts the menu opens with a Delete entry, clicks it, and checks the note is gone from the CANVAS (not just the model) and comes back on undo. Commenting out main.js's showContextMenu() call fails it — the menu never opens. node --test 90/90, pytest 248/248, npm run lint 0 errors (6 warnings), Codex clean, all 19 headless harnesses pass. 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 canvas context menu and note-editing prompts were moved from ChangesContext menu refactor
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Pull request overview
Refactors the editor by extracting the canvas right-click context menu and its associated prompt dialogs from src/main.js into a dedicated src/context-menu.js module, reducing main.js size while keeping module dependencies acyclic and preserving existing host-hook wiring.
Changes:
- Moved the canvas context menu renderer/dispatcher plus
promptFret/promptBend/promptSlide/promptSlideUnpitchintosrc/context-menu.js. - Updated
src/main.jsto import and wire the extracted context-menu functions (including keeping thecontextmenuevent handler inmain.js). - Documented the refactor in
CHANGELOG.md.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/main.js | Removes inlined context-menu + prompt dialog implementations and imports the new module exports while retaining the contextmenu event entry point. |
| src/context-menu.js | New module containing the extracted context menu UI logic and prompt dialogs, using host callbacks for main.js-bound operations. |
| CHANGELOG.md | Adds a changelog entry describing the refactor and its scope (no new host hooks). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/main.js9,146 → 8,786. Twenty-seventh module; the graph stays acyclic.362 lines: the canvas right-click menu (change fret, bend, slide, delete, position moves — each entry runs a command from
src/commands.js) and the prompt dialogs it opens (promptFret/promptBend/promptSlide/promptSlideUnpitch).Zero new host hooks
That is the reason this one is cheap. Its three
main.jsdependencies —draw,updateStatus,_editBlipAt— were already onhost. And it ownspromptBendandhideContextMenu, both of which were already host hooks the inspector and several modes call.They resolve to this module’s exports now instead of definitions in
main.js— the wiring did not change, only where it points. Codex confirmedhost.promptBendstill lands on a real function and the inspector’s “Edit curve…” still works.main.jskeeps the canvascontextmenuevent that decides when to open the menu, and importsshowContextMenuand theprompt*dialogs directly.Harness
verify_context_menu.pyright-clicks a note, asserts the menu opens with aDeleteentry, clicks it, and checks the note is gone from the canvas (not just the model) and returns on undo.showContextMenu()call commented outVerification
node --test90/90 ·pytest248/248 ·npm run lint0 errors (6 warnings) · Codex clean (nothis/argumentsreliance, noinspector → context-menucycle) · all 19 headless harnesses pass.🤖 Generated with Claude Code
Summary by CodeRabbit