fix(nowplaying): cover leaves with the track, not lingering/expanding on pause#53
Open
gyng wants to merge 1 commit into
Open
fix(nowplaying): cover leaves with the track, not lingering/expanding on pause#53gyng wants to merge 1 commit into
gyng wants to merge 1 commit into
Conversation
… on pause When a session lost its current track (media gone while the session stayed selected — e.g. a player that tears down/recreates its SMTC session on pause), the title cleared instantly (it is prop-derived) while the album cover stayed up on the crossfade's no-art grace (NO_ART_GRACE_MS), growing to fill the box the title/artist had vacated before finally fading — the reported "cover expands for a short while then disappears". Tie the cover's lifecycle to whether there is a current track: drop the layers at once when there is no media (not only when there is no session), and gate the cover stack on `hasMedia` so it leaves in the same commit as the title. The no-art grace now only bridges a genuine art-lag (media present, art not yet arrived); the idle `label` and track-to-track crossfade are unchanged. Adds a failing-first test (a present session with null media) that reproduced the lingering cover (was: 1 layer held; now: 0). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Fixes the now-playing widget where, on pause, the album cover expands to fill the box for a moment before disappearing (reported as "the track text disappears, then the cover").
Root cause
The title/artist are derived straight from props, so they vanish the instant a session loses its media. The cover, however, lives in React state and was held by the crossfade's no-art grace (
NO_ART_GRACE_MS = 1200) whenever the art URL was absent — including when there was no current track at all (a player that tears down / recreates its SMTC session on pause, so the prior track can't be carried forward). With the title/artist rows gone, theflex: 1cover stack grew to fill the freed space and lingered up to ~1.2s before fading.Fix
Tie the cover's lifecycle to whether there's a current track:
!hasSession || !hasMediaRef.current), not only when there's no session. The no-art grace below now only ever bridges a genuine art-lag (a track is present, its cover just hasn't arrived).hasMedia, so the cover leaves in the same commit as the title (no transient expand frame).The idle
label(text with no session) and track-to-track crossfade are unchanged.Test
Adds a failing-first test in
NowPlaying.test.tsxusing a present session withlast_media_update: null. It reproduced the bug (cover held:expected 1 to be 0) and is green after the fix. Existing grace/crossfade tests still pass.Verification
npm run check✓ ·npm run lint✓ (Prettier + ESLint, 0 warnings) · full unit suite 269 files ✓🤖 Generated with Claude Code