Skip to content

refactor(editor): move the context menu to src/context-menu.js (R2, step 25) - #177

Merged
byrongamatos merged 1 commit into
mainfrom
refactor/r2-step25-context-menu
Jul 10, 2026
Merged

refactor(editor): move the context menu to src/context-menu.js (R2, step 25)#177
byrongamatos merged 1 commit into
mainfrom
refactor/r2-step25-context-menu

Conversation

@byrongamatos

@byrongamatos byrongamatos commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

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

That is the reason this one is cheap. 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 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 confirmed host.promptBend still lands on a real function and the inspector’s “Edit curve…” still works.

main.js keeps the canvas contextmenu event that decides when to open the menu, and imports showContextMenu and the prompt* dialogs directly.

Harness

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 returns on undo.

check wired showContextMenu() call commented out
right-click opens the menu PASS FAIL
menu has a Delete entry PASS FAIL
Delete removes the note and repaints PASS FAIL
undo brings it back PASS FAIL

Verification

node --test 90/90 · pytest 248/248 · npm run lint 0 errors (6 warnings) · Codex clean (no this/arguments reliance, no inspector → context-menu cycle) · all 19 headless harnesses pass.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added a canvas context menu for editing notes, including moving, deleting, accepting suggested positions, and toggling techniques.
    • Added dialogs for editing fret positions, bends, and slides.
    • Added an interactive bend curve editor with presets, curve controls, and undo support.
    • Added safeguards for read-only rolls and validation for fret, bend, and slide values.

…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>
Copilot AI review requested due to automatic review settings July 10, 2026 00:44
@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: f90c140c-f047-4777-a48b-82746df4445e

📥 Commits

Reviewing files that changed from the base of the PR and between bc79b24 and d9ed65b.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • src/context-menu.js
  • src/main.js

📝 Walkthrough

Walkthrough

The canvas context menu and note-editing prompts were moved from main.js into context-menu.js. The new module handles menu actions, fret, bend, and slide prompts, while main.js retains event integration and imports the extracted functions.

Changes

Context menu refactor

Layer / File(s) Summary
Context menu module and editor wiring
src/context-menu.js, src/main.js, CHANGELOG.md
Context-menu rendering, actions, visibility, and fret prompting are implemented in context-menu.js; main.js imports these functions and removes the duplicated inline implementation.
Bend prompt and curve editor
src/context-menu.js
Bend editing derives existing note state, provides an interactive curve modal, applies SetBendShapeCmd, and refreshes the editor.
Slide prompt handling
src/context-menu.js
Slide and unpitched-slide prompts validate input, enforce read-only protection, update note techniques, and refresh the display.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

🚥 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 accurately describes the main change: moving the editor context menu into src/context-menu.js.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/r2-step25-context-menu

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

Copilot AI 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.

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 / promptSlideUnpitch into src/context-menu.js.
  • Updated src/main.js to import and wire the extracted context-menu functions (including keeping the contextmenu event handler in main.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.

@byrongamatos
byrongamatos merged commit c251ae8 into main Jul 10, 2026
4 of 5 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.

2 participants