Repository navigation
Fix the next track's title showing early after connecting - #238
Merged
Merged
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Replayed updates can continue after an onStateChange callback disconnects, allowing stale metadata from the disconnected session to reappear because cleanup does not invalidate the local replay batch.
1 open issue
What changed in this PR
This PR fixes premature next-track titles when joining an active stream by holding metadata until clock synchronization completes.
Changes:
- Hold unsynchronized metadata and replay it in arrival order once the clock syncs.
- Calculate playback-aligned delays for replayed metadata.
- Add a regression test for current-to-next title timing and reuse a time-sync test helper.
| File | Description |
|---|---|
| tests/unit/protocol-handler.test.ts | Tests deferred metadata replay and scheduled title changes. |
| src/core/state-manager.ts | Queues held metadata, replays it, and clears it during cleanup. |
| src/core/protocol-handler.ts | Defers metadata until synchronization and triggers replay afterward. |
Review effort: Balanced
33 tasks done
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 does this implement/fix?
When a client connected while the server already had the next track's metadata scheduled, the next title showed right away instead of at the track change, up to 20 seconds early. The server sends that scheduled update on join, before the first time sync reply, and metadata without a clock estimate applied at once.
Metadata that arrives before the first time sync is now held and replayed in arrival order once the clock syncs, so the current track shows first and the next one switches in on time. If time sync never completes, metadata now stays hidden instead of showing unsynced.
Related issue or spec PR (if applicable):
Types of changes
bugfixnew-featureenhancementbreaking-changerefactordocumentationmaintenancecidependencies