Skip to content

refactor(editor): move the add-note dialog to src/add-note.js (R2, step 40) - #192

Merged
byrongamatos merged 1 commit into
mainfrom
refactor/r2-step40-add-note
Jul 10, 2026
Merged

refactor(editor): move the add-note dialog to src/add-note.js (R2, step 40)#192
byrongamatos merged 1 commit into
mainfrom
refactor/r2-step40-add-note

Conversation

@byrongamatos

@byrongamatos byrongamatos commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

What

Step 40 of the R2 refactor: move the add-note dialog (addNoteData state, showAddNote / hideAddNote, and the editorConfirmAddNote handler that commits an undoable AddNoteCmd) out of src/main.js into a new native ES module src/add-note.js. The boot-teardown machinery that shared the "Add note dialog" banner stays.

How the seam is drawn

  • showAddNote / hideAddNote are host hooks — main.js imports them (the existing thunk/shorthand host wiring resolves by name) — plus 2 re-attached window handlers.
  • addNoteData is exported as a live binding read by main.js's boot Enter-key handler across the module boundary.
  • draw/updateStatus route through host. Removed 2 dead main.js imports (AddNoteCmd, noteToMidi).

main.js drops ~53 lines. 41 modules.

Verification

  • 90/90 JS suites pass; ESLint gate clean (0 errors); strict no-undef clean on add-note.js.
  • Codex preflight: 0 regressions.
  • New headless harness (verify_add_note.py) double-clicks empty grid to open the dialog (proving showAddNote via the mouse host hook), confirms the default note (note count 3→4, proving editorConfirmAddNote + AddNoteCmd + host.draw), and undoes it (4→3) — zero page errors. Negative-checked by dropping a re-attach.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added an Add Note dialog for entering notes in fret or pitch mode.
    • Automatically positions the dialog and focuses the relevant input.
    • Supports note timing, string, fret, and sustain values with input validation.
    • Refreshes the editor and status display after adding a note.
  • Bug Fixes
    • Improved dialog cleanup when closing the Add Note editor.

…ep 40)

Extract the add-note dialog (addNoteData state, showAddNote / hideAddNote, and
the editorConfirmAddNote handler that commits an undoable AddNoteCmd) out of the
src/main.js monolith into a new native ES module. The boot-teardown machinery
that shared the "Add note dialog" banner stays in main.js.

- src/add-note.js: showAddNote / hideAddNote are host hooks (main.js imports them;
  the existing thunk/shorthand host wiring resolves by name), plus 2 re-attached
  window handlers. addNoteData is exported as a live binding read by main.js's
  boot Enter-key handler across the module boundary. draw/updateStatus via host.
- Removed 2 dead main.js imports (AddNoteCmd, noteToMidi).

main.js drops ~53 lines. 41 modules.

Verified: 90/90 JS suites pass, ESLint gate clean (0 errors), strict no-undef
clean on add-note.js, Codex preflight 0 regressions. New headless harness
double-clicks empty grid to open the dialog (proving showAddNote via the mouse
host hook), confirms the default note (note count 3->4, proving editorConfirmAddNote
+ AddNoteCmd + host.draw), and undoes it (4->3) — zero page errors. Negative-checked.

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

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: e8db36c8-854d-4689-be64-7b99b1ba5edb

📥 Commits

Reviewing files that changed from the base of the PR and between 59e7e27 and d6e8251.

📒 Files selected for processing (2)
  • src/add-note.js
  • src/main.js

📝 Walkthrough

Walkthrough

The Add Note dialog implementation moves from src/main.js into a new src/add-note.js module. The module owns dialog state, input handling, note creation, command execution, and editor refreshes. Global editor handlers in main.js now delegate to the extracted functions.

Changes

Add Note extraction

Layer / File(s) Summary
Add Note dialog module
src/add-note.js
Adds shared dialog state and functions for showing, hiding, validating, and committing notes in fret-entry and pitch-entry modes.
Main editor integration
src/main.js
Removes the inlined Add Note implementation and obsolete imports, then wires global editor handlers to the extracted module functions.

Estimated code review effort: 3 (Moderate) | ~20 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 Clearly describes the main change: extracting the add-note dialog into src/add-note.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-step40-add-note

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

@byrongamatos
byrongamatos merged commit df77288 into main Jul 10, 2026
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