Skip to content

expose remote state#1704

Open
ralphptorres wants to merge 15 commits intolibrespot-org:devfrom
ralphptorres:expose-remote-state
Open

expose remote state#1704
ralphptorres wants to merge 15 commits intolibrespot-org:devfrom
ralphptorres:expose-remote-state

Conversation

@ralphptorres
Copy link
Copy Markdown

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

  • cluster
    • broadcast when device list (dis/appeared, active device) or info (volume, alias) changes
    • watch current ClusterState with all device info and active device id
    • use case: mpris lifecycle, device picker ui
  • player
    • broadcast when track, play/pause, position, shuffle, repeat or context changes
    • watch current PlayerState snapshot
    • use: remote playback ui, track changes, pause/resume
  • queue
    • broadcast when when prev or next track queue changes
    • watch current QueueList snapshot
    • use: queue ui refresh, skip detection, upcoming track preview

relates to #1448

photovoltex and others added 8 commits April 14, 2026 10:59
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
Copilot AI review requested due to automatic review settings April 18, 2026 10:39
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 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 to Spirc.
  • Implemented emission of player/cluster/queue update events and state snapshots primarily from incoming ClusterUpdates.
  • Extended handle_cluster_update to 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.

Comment thread connect/src/spirc.rs
Comment thread connect/src/spirc.rs
Comment thread connect/src/spirc.rs Outdated
Comment thread connect/src/spirc.rs
let info = DeviceInfo {
device_id: device.device_id.clone(),
device_alias: device.name.clone(),
device_type: format!("{:?}", device.device_type),
Copy link

Copilot AI Apr 18, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
device_type: format!("{:?}", device.device_type),
device_type: device
.device_type
.enum_value_or_default()
.as_str_name()
.to_string(),

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

didn't implement -- doesn't work with the protobuf version. could add a proper mapping later if needed

Comment thread connect/src/spirc.rs
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.

3 participants