Skip to content

Set PlayerQueue.is_dynamic when radio_source changes#3886

Draft
dmoo500 wants to merge 1 commit into
music-assistant:devfrom
dmoo500:feature/player-queue-is-dynamic
Draft

Set PlayerQueue.is_dynamic when radio_source changes#3886
dmoo500 wants to merge 1 commit into
music-assistant:devfrom
dmoo500:feature/player-queue-is-dynamic

Conversation

@dmoo500
Copy link
Copy Markdown
Contributor

@dmoo500 dmoo500 commented May 13, 2026

Summary

Sets the new is_dynamic field on PlayerQueue (added in music-assistant/models#224) whenever radio_source is updated, so clients can read it directly.

Changes

  • PlayerQueuesController._calc_is_dynamic(): static helper that checks if radio_source is a single dynamic playlist
  • Sets queue.is_dynamic at all 5 radio_source assignment points in player_queues.py
  • signal_update is called after all field mutations so clients receive a consistent state in one event

Why is_dynamic lives on the model (not computed client-side)

PlayerQueue uses mashumaro's DataClassDictMixin. A @property is silently skipped by to_dict() / to_cache() — only dataclass fields are serialized. Clients and the restore path would always see the default value. A plain bool = False field is the correct approach: it is serialized like any other field and kept in sync by the server.

Dependencies

Requires music-assistant/models#224 to be merged and released first. PR is in draft until then.

Related

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the server to keep the new PlayerQueue.is_dynamic field in sync with queue.radio_source, allowing clients to read whether the queue is driven by a single dynamic playlist directly from the queue state.

Changes:

  • Add PlayerQueuesController._calc_is_dynamic() to detect when radio_source is exactly one dynamic Playlist.
  • Set/clear queue.is_dynamic alongside queue.radio_source updates throughout player_queues.py.
  • Ensure the Yandex Music provider sets queue.is_dynamic = False when it assigns a track as radio_source.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
music_assistant/controllers/player_queues.py Adds _calc_is_dynamic and updates radio_source mutation points to maintain queue.is_dynamic.
music_assistant/providers/yandex_music/provider.py Explicitly sets queue.is_dynamic = False when assigning a Track as the queue’s radio_source.

Comment thread music_assistant/controllers/player_queues.py
Comment thread music_assistant/controllers/player_queues.py
Comment thread music_assistant/controllers/player_queues.py
@dmoo500 dmoo500 force-pushed the feature/player-queue-is-dynamic branch from dfe9540 to e02acb8 Compare May 13, 2026 18:23
@dmoo500 dmoo500 force-pushed the feature/player-queue-is-dynamic branch from e02acb8 to 7be55f9 Compare May 13, 2026 18:26
Copilot AI review requested due to automatic review settings May 13, 2026 18:26
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comment thread music_assistant/controllers/player_queues.py
@dmoo500 dmoo500 marked this pull request as draft May 13, 2026 18:35
@dmoo500
Copy link
Copy Markdown
Contributor Author

dmoo500 commented May 13, 2026

Converting to draft — the mypy lint failure is expected: this PR depends on music-assistant/models#224 which adds PlayerQueue.is_dynamic. Once that is merged and a new models release is published, this PR will be updated to bump the music-assistant-models version and marked ready for review.

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