docs(editor): document remaining load-bearing invariants in README - #212
Conversation
The architecture section covered five of the invariants contributors trip over; this adds the other four that so far lived only in code comments and session notes: the screen-teardown registry (host re-injection leaks), kind inference ordering with the start-anchored KEYS_PATTERN, the capo pair (_soundingPitchPure vs _absolutePitch), and WeakSet-not-note-field transient UI marks. Also names _NOTE_TECH_FIELDS as the single source of truth in the backend paragraph and refreshes the module count (~50). Docs-only; no CHANGELOG entry (not user-visible). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EBQCHCNA81E9tHmSDHSe2Q
📝 WalkthroughWalkthroughThe README architecture guide updates frontend module and orchestration details, adds frontend invariants, and expands backend responsibilities and precedence rules. ChangesArchitecture Documentation
Estimated code review effort: 1 (Trivial) | ~3 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 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 `@README.md`:
- Around line 90-93: Update the README guidance around host.addGlobalListener
and window.__editorScreenTeardown to distinguish global event listeners from
timers: state that timers such as _bootPollInterval are explicitly stopped or
cleared during teardown, rather than registered through the listener registry.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
| - **Global listeners and timers must register with the teardown registry** | ||
| (`host.addGlobalListener`, tracked via `window.__editorScreenTeardown`): | ||
| the host re-injects the screen, so anything unregistered leaks across | ||
| re-injection. New chrome rides the rAF draw-coalesce — no per-frame work. |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
Clarify that timers are explicitly stopped, not registered through host.addGlobalListener.
src/main.js tracks _bootPollInterval separately and clears it from window.__editorScreenTeardown; the supplied implementation only places global event listeners in the registry. Please avoid implying that timers use the listener registry.
Proposed wording
-- Global listeners and timers must register with the teardown registry
- (`host.addGlobalListener`, tracked via `window.__editorScreenTeardown`):
+- Global listeners must use the teardown registry (`host.addGlobalListener`);
+ timers and observers must also be explicitly stopped by
+ `window.__editorScreenTeardown`:📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| - **Global listeners and timers must register with the teardown registry** | |
| (`host.addGlobalListener`, tracked via `window.__editorScreenTeardown`): | |
| the host re-injects the screen, so anything unregistered leaks across | |
| re-injection. New chrome rides the rAF draw-coalesce — no per-frame work. | |
| - **Global listeners must use the teardown registry** | |
| (`host.addGlobalListener`); | |
| timers and observers must also be explicitly stopped by | |
| `window.__editorScreenTeardown`: | |
| the host re-injects the screen, so anything unregistered leaks across | |
| re-injection. New chrome rides the rAF draw-coalesce — no per-frame work. |
🤖 Prompt for 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.
In `@README.md` around lines 90 - 93, Update the README guidance around
host.addGlobalListener and window.__editorScreenTeardown to distinguish global
event listeners from timers: state that timers such as _bootPollInterval are
explicitly stopped or cleared during teardown, rather than registered through
the listener registry.
What
Docs-only refresh of the README's "Architecture in five minutes" section, bringing the tracked contributor docs up to date with the invariants that have accumulated over the recent PR waves but so far lived only in code comments:
host.addGlobalListener(tracked viawindow.__editorScreenTeardown) or they leak across host screen re-injection; new chrome rides the rAF draw-coalesce.KEYS_PATTERNis start-anchored ("Electric Piano" is not a keys name)._soundingPitchPureadds the capo once (matching core'spitch_from_base);_absolutePitchdeliberately omits it. Never compose them blindly.WeakSets, never underscore note fields (which leak into the save body on solo notes and vanish on chord notes viareconstructChords)._NOTE_TECH_FIELDSas the single source of truth for authorable techniques.ls src/*.js | wc -lon main).Why
The README tells newcomers to "read this top-to-bottom once" — these are exactly the invariants reviewers keep re-explaining on PRs, so they belong in the tracked doc.
Testing
Docs-only diff.
npm test(all suites pass) andnpm run lint(0 errors; 3 pre-existing warnings) run clean on the branch. No CHANGELOG entry since nothing is user-visible.🤖 Generated with Claude Code
https://claude.ai/code/session_01EBQCHCNA81E9tHmSDHSe2Q
Summary by CodeRabbit