Conversation
semantically diff for player changes. also emit cluster and queue updates to their broadcast channels
use server cluster update reasons for cluster changes. also emit cluster topology snapshots with all devices and active device
diff prev and next tracks for queue changes. also emit queue list
There was a problem hiding this comment.
Pull request overview
This PR exposes remote Spotify Connect state updates from Spirc via three broadcast/watch channel pairs (cluster, player, queue) so clients can observe playback/device changes even when this device isn’t the active Connect device (relates to #1448).
Changes:
- Added new public state/event types (
ClusterState,QueueList,*UpdateEvent,*UpdateReason,DeviceInfo) and associated tokio broadcast/watch channels toSpirc. - Implemented emission of player/cluster/queue update events and state snapshots primarily from incoming
ClusterUpdates. - Extended
handle_cluster_updateto maintain and publish cluster/player/queue state, with diff-based semantic “reason” classification.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| let info = DeviceInfo { | ||
| device_id: device.device_id.clone(), | ||
| device_alias: device.name.clone(), | ||
| device_type: format!("{:?}", device.device_type), |
There was a problem hiding this comment.
DeviceInfo.device_type is documented as a human-readable value (e.g. "Speaker", "Phone"), but it’s currently built via format!("{:?}", device.device_type). Since this field is a protobuf enum wrapper, the Debug output is typically not user-friendly/stable. Consider using the enum’s string name (e.g. enum_value_or_default().as_str_name()) or mapping to your own display strings to match the docs.
| device_type: format!("{:?}", device.device_type), | |
| device_type: device | |
| .device_type | |
| .enum_value_or_default() | |
| .as_str_name() | |
| .to_string(), |
There was a problem hiding this comment.
didn't implement -- doesn't work with the protobuf version. could add a proper mapping later if needed
account for elapsed time and play/pause state. also rename to SeekChanged
expose 3 broadcast/watch channel pairs to observe remote playback and other states. pattern-wise, broadcast channels (lightweight) emit only update (or state change) events with semantic reasons. watch channels (stateful) emit complete state snapshots
relates to #1448