Repository navigation
fix: clear stale section-map bar when the current song has no sections - #12
Conversation
_smUpdate() bailed out on "no sections" (empty array / missing duration) before touching any state, so switching to a song or arrangement with no section data (a GP import, or a core re-stream that bypasses the playSong wrapper's own _smRemove()/reset -- e.g. an in-player arrangement switch) left the previous song's blocks painted and the marker/active-highlight frozen wherever the last real song left them. Now clears _smSections/_smDuration/the bar's innerHTML/cached DOM refs the first time sections disappear, and is a no-op on every later tick once already cleared (clearing is idempotent, so no risk of rebuilding an empty bar every 200ms while genuinely no song is loaded). Bumped plugin.json to 1.2.6 (bug fix affecting real behavior). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HVxQShyx8Mrqe1GKNstjHy
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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 |
There was a problem hiding this comment.
Important
The clear is gated on _smSections.length > 0, but the song:ready listener empties _smSections without clearing the rendered bar — and the host fires song:ready on exactly the arrangement switches / re-streams this fix targets. See the inline comment for the ordering that still leaves the stale bar painted.
Reviewed changes
- plugin.json — version bumped
1.2.5→1.2.6for the user-visible fix. - screen.js —
_smUpdate()now clears_smSections/_smDuration, the bar'sinnerHTML, and the cached_smMarkerEl/_smBlockEls/_smActiveIdxon the first tick where the current song has no section data, then no-ops on subsequent ticks. Side benefit worth keeping: resetting_smDurationto0also makes click/wheel seeking no-ops on a section-less song. - tests/screen.test.js — new test asserting the bar clears and state resets when sections vanish mid-play without going through
_smRemove(), plus a no-op re-tick assertion; suite passes 22/22.
Big Pickle (free) | 𝕏
…path Pullfrog review finding on PR #12: the song:ready handler (installed in _smStartRealtimeHooks) sets _smSections = [] itself and THEN calls _smUpdate() directly. The previous fix's guard, `if (_smSections.length > 0)`, was therefore already false by the time _smUpdate() ran on exactly the transition it was meant to catch -- song:ready fires on essentially every song/arrangement switch, so the clear rarely if ever actually ran. Switched the guard to `_smBar.innerHTML !== ''` -- the bar's actual painted content, which only _smRender() sets and only _smRemove()/this same block ever clears -- so it correctly reflects "is there stale content to clear" regardless of which code path zeroed _smSections first. Also clears _smSectionDifficulty in the same block now, for parity with the other two reset sites (playSong wrapper, song:ready). Added a test that mirrors song:ready's actual ordering (sections already [] before _smUpdate() runs, stale blockEls/markerEl/bar content still live) and confirmed it fails against the previous fix, passes against this one. Full suite: 23 passed. Bumped plugin.json to 1.2.7. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HVxQShyx8Mrqe1GKNstjHy
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- screen.js — re-anchored the stale-bar clear on
_smBar.innerHTML !== ''instead of_smSections.length > 0, so it fires on thesong:readypath where the handler zeroes_smSectionsbefore its own_smUpdate()call (the exact ordering the prior review flagged); also cleared_smSectionDifficultyin the same block for parity with theplaySongwrapper andsong:readyreset sites. - tests/screen.test.js — added a regression test reproducing the song:ready ordering (sections already
[], stale bar DOM/refs still live). Verified it fails against the previous commit's guard and passes on the current code. Suite passes 23/23. - plugin.json — version bumped
1.2.6→1.2.7(net1.2.5→1.2.7from base).
Big Pickle (free) | 𝕏

Summary
_smUpdate()bailed out on "no sections" (empty array / missing duration) before touching any state, so switching to a song or arrangement with no section data (a GP import, or a core re-stream that bypasses theplaySongwrapper's own_smRemove()/reset — e.g. an in-player arrangement switch) left the previous song's blocks painted and the marker/active-highlight frozen wherever the last real song left them.Now clears
_smSections/_smDuration/the bar'sinnerHTML/cached DOM refs the first time sections disappear, and is a no-op on every later tick once already cleared (clearing is idempotent, so no risk of rebuilding an empty bar every 200ms while genuinely no song is loaded).Test plan
node --test tests/screen.test.js— 22 passed (1 new test simulating a song switch to one with no sections, without going through_smRemove()— asserts the bar'sinnerHTMLis cleared and state is reset)🤖 Generated with Claude Code
https://claude.ai/code/session_01HVxQShyx8Mrqe1GKNstjHy
Generated by Claude Code