Reduce ambiguity about the metadata's state#47
Merged
Conversation
…adata with the new ` ServerMetadataStateDelta` struct to reduce ambiguity for metadata's tri-state absent, null, or value.
There was a problem hiding this comment.
Pull request overview
This PR changes how server-sent metadata updates represent “clear” operations by introducing a dedicated wire-level delta type (ServerMetadataStateDelta) with tri-state fields (absent vs explicit null vs value), removing the previous empty-string clearing behavior to reduce ambiguity in merged metadata state.
Changes:
- Introduced
ServerMetadataStateDelta(tri-state per field) and updated server/state parsing to populate it. - Updated metadata delta application logic so explicit JSON
nullclears merged fields (includingprogress). - Updated docs and the TUI example to encourage overwriting mirrored display state each
on_metadata()so clears propagate.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/protocol.cpp | Adds tri-state parsing helpers, parses metadata into ServerMetadataStateDelta, and applies deltas to merged ServerMetadataStateObject with explicit-null clears. |
| src/protocol_messages.h | Introduces ServerMetadataStateDelta, updates ServerStateMessage to carry metadata deltas, and updates delta-merge API signature/docs. |
| src/metadata_role.cpp | Updates metadata role to accept/merge wire deltas in the shadow slot and apply them to the merged metadata state when due. |
| src/metadata_role_impl.h | Updates shadow slot type and method signature to use ServerMetadataStateDelta (and adds needed include). |
| examples/tui_client/main.cpp | Updates metadata listener to always overwrite title/artist/album (so server clears propagate). |
| docs/internals.md | Updates internal shadow-slot documentation to reflect metadata delta type and clear behavior. |
| docs/integration-guide.md | Adds guidance about nullopt representing both “never provided” and “explicitly cleared”, advising overwrite-on-update for UI mirroring. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Replace the metadata role's empty-string approach to clearing old metadata with the new
ServerMetadataStateDeltastruct to reduce ambiguity for metadata's tri-state absent, null, or value.This is a behavioral breaking change. The server clears old metadata states with a
nulloptinstead of an empty string. Updating the state whereprogress: nullnow properly clears the current progress info that before was never actually possible to clear.