Persist learned role-pitch maps; add singleton guard for re-launches#2
Persist learned role-pitch maps; add singleton guard for re-launches#2wretcher207 wants to merge 1 commit into
Conversation
Two lifecycle fixes from internal review: - Learn from Selection now sticks. Pitches added to ROLE_MAP were stored in-memory only, so any new mapping was lost on Reaper restart. ROLE_MAP is now persisted alongside the other settings, restored on load (side effect of load_settings), and auto-saved the moment Learn from Selection adds a new pitch — the user doesn't have to remember Save Settings. - Singleton guard against duplicate launches. Each run() created a fresh ReaImGui context. Re-firing the toolbar action while the previous instance was still running opened a second window with its own context. A heartbeat ExtState is stamped each frame; a new launch only proceeds if the previous stamp is older than 2 seconds (i.e. the previous run died). atexit clears the flag on normal exit. Also added a cached _ctx with ValidatePtr so a stale ref is replaced rather than appended to. Mirrored to Scripts/dehumanizer-pro.lua (ReaPack install target). Syntax verified with luac. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
Warning Review limit reached
More reviews will be available in 26 minutes and 21 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
- MEMORY.md: repo conventions (dual-path ReaPack mirroring) + 2026-06-16 session summary covering the three open fix PRs (#1 velocity parity, #2 lifecycle persistence, #3 per-note tempo). - HANDOFF.md: next-chat resume point with verification checklist for the three PRs and gotchas (script mirrored at /dehumanizer-pro.lua and /Scripts/dehumanizer-pro.lua per ReaPack packaging). No code changes. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Summary
Two lifecycle fixes from internal review. Independent of #1 — both branch from
mainand can land in either order.C3 — Learn from Selection now persists
Old code did
table.insert(ROLE_MAP[active_role], pitch)in memory and never wrote it anywhere. Restart Reaper → the learned mapping is gone.Fix:
save_settingsnow writesrolemap_<role>ExtState entries (comma-separated pitch list).load_settingsreads them and mutates the module-levelROLE_MAPas a documented side effect. Roles with no stored entry keep their built-in defaults, so future versions adding new roles aren't broken by old persisted state.C9 — Singleton guard against duplicate launches
run()calledreaper.ImGui_CreateContextunconditionally. Re-firing the toolbar action while a previous instance was still running opened a second window with its own context.Fix:
SetExtState(SCRIPT_ID, "instance_heartbeat", time_precise)at the top of every frame.singleton_can_start()— if the last stamp is < 2s old, show a message and bail. If the previous run died (no heartbeat for 2s+), proceed.reaper.atexit(singleton_release)clears the flag on normal script exit._ctxwithValidatePtrso a stale ref is replaced rather than appended to. Useful when the Lua state persists across script reloads; harmless when it doesn't.Test plan
rolemap_Kicksentry, launch the script. Kicks should be{35, 36}again.luac -palready verified on both file copies.🤖 Generated with Claude Code