Skip to content

fix: clear stale section-map bar when the current song has no sections - #12

Merged
cchacs merged 2 commits into
mainfrom
claude/bug-search-mfyoq0
Sep 9, 2026
Merged

cchacs merged 2 commits into
mainfrom
claude/bug-search-mfyoq0

Conversation

@cchacs

@cchacs cchacs commented Sep 8, 2026

Copy link
Copy Markdown

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 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).

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's innerHTML is cleared and state is reset)

🤖 Generated with Claude Code

https://claude.ai/code/session_01HVxQShyx8Mrqe1GKNstjHy


Generated by Claude Code

_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
@coderabbitai

coderabbitai Bot commented Sep 8, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 176f365e-7e88-4ea8-9158-17f7da473468

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

❤️ Share

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

@pullfrog pullfrog Bot 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.

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.6 for the user-visible fix.
  • screen.js — _smUpdate() now clears _smSections/_smDuration, the bar's innerHTML, and the cached _smMarkerEl/_smBlockEls/_smActiveIdx on the first tick where the current song has no section data, then no-ops on subsequent ticks. Side benefit worth keeping: resetting _smDuration to 0 also 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.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using Big Pickle (free) | 𝕏

Comment thread screen.js Resolved
…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

@pullfrog pullfrog Bot 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.

✅ 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 the song:ready path where the handler zeroes _smSections before its own _smUpdate() call (the exact ordering the prior review flagged); also cleared _smSectionDifficulty in the same block for parity with the playSong wrapper and song:ready reset 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 (net 1.2.5 → 1.2.7 from base).

Pullfrog  | View workflow run | Using Big Pickle (free) | 𝕏

@cchacs
cchacs merged commit 0ca6946 into main Sep 9, 2026
9 checks passed
@cchacs
cchacs deleted the claude/bug-search-mfyoq0 branch September 9, 2026 03:33
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