Repository navigation
feat: consume server/state as full state, discard removed-role state - #292
Merged
chrisuthe merged 1 commit intoSep 17, 2026
Merged
Conversation
Implement the inbound side of spec PRs #175 and #275 (issue #288). #175 (full state): each server/state role object is the role's complete state, so a leaf the object omits is unset. The client now builds each TrackMetadata / ColorPalette / seek_max_ms from the incoming object alone rather than merging an absent leaf against the previous value: an absent metadata `progress` clears the exposed Position, and an omitted colour or `seek_max_ms` is unset. The payload level is unchanged (absent role = no change, null role = clear the whole role, present role = full state). Optional<> is neutralised, not removed: the wire leaf types keep it and the apply paths read absent-or-null as null via GetValueOrDefault(). Removing it from the ColorState leaves would cascade into OptionalRgbColorJsonConverter's malformed-colour tolerance (one bad colour must not abort the whole message and drop co-resident updates), so the wire types and their serialization tests are left untouched. #275 (discard on activate): when server/activate drops metadata/color/ controller from active_roles, the client discards that role's current state and any future-scheduled pending update (new MediaDisplayScheduler.FlushStateUpdate), raising the same cleared events a null role object raises. Roles still active are untouched. Tests: inverted the old absent-leaf-keeps merge tests to full state and added coverage for deactivation discard (current cleared, pending update never fires, siblings untouched). Suite per framework: net8.0 1166 (was 1163), net10.0 1168 (was 1165), 0 failed. Also corrects the now-false colour delta wording in the SDK README.
There was a problem hiding this comment.
🟢 Approval recommended
The changes consistently implement the specified full-state semantics and deactivated-role discard behavior, with corresponding doc updates and expanded/inverted test coverage validating the new expectations.
Pull request overview
This PR updates the .NET client’s server/state consumption to match the spec’s “full-state object” semantics and ensures state for roles removed by server/activate is immediately discarded (including pending scheduled updates).
Changes:
- Treat
server/staterole objects as full state: omitted leaves are now read as unset (includingprogress, color channels, and controllerseek_max_ms). - Discard state (and pending scheduled metadata/color updates) for role families removed from
active_rolesonserver/activate, raising the same clear events as before. - Update SDK docs and invert/add tests to match the new conformance behavior.
File summaries
| File | Description |
|---|---|
| tests/Sendspin.SDK.Tests/Client/SendspinClientServiceServerStateTests.cs | Inverts metadata merge expectations; adds coverage for discard-on-activate behavior and progress clearing when omitted. |
| tests/Sendspin.SDK.Tests/Client/SendspinClientServiceControllerTests.cs | Updates controller seek bound behavior: omitted seek_max_ms now unsets. |
| tests/Sendspin.SDK.Tests/Client/SendspinClientServiceColorTests.cs | Updates color behavior to full-state semantics; verifies omitted channels/timestamp unset and malformed colors don’t drop sibling updates. |
| tests/Sendspin.SDK.Tests/Client/MediaDisplaySchedulingTests.cs | Adds coverage ensuring pending scheduled metadata updates are discarded when metadata is dropped on activate (while color remains scheduled). |
| src/Sendspin.SDK/README.md | Corrects color role documentation to describe full-state palette semantics. |
| src/Sendspin.SDK/Protocol/Messages/ServerStateMessage.cs | Updates protocol docs/remarks to describe full-state semantics and how Optional leaves are interpreted by the client. |
| src/Sendspin.SDK/Protocol/Messages/ColorState.cs | Updates remarks to reflect full-state palette semantics and rationale for keeping Optional<> for malformed-color tolerance. |
| src/Sendspin.SDK/Models/TrackMetadata.cs | Updates Progress remarks: omitted progress now unsets/clears position rather than carrying forward by reference. |
| src/Sendspin.SDK/Models/GroupState.cs | Updates SeekMaxMs documentation to match full-state semantics for omission. |
| src/Sendspin.SDK/Client/SendSpinClient.cs | Implements full-state application for metadata/color, unsets controller seek_max_ms on omission, and discards state for deactivated role families on server/activate. |
| src/Sendspin.SDK/Client/MediaDisplayScheduler.cs | Adds targeted flushing of a single pending scheduled state update slot (metadata or color). |
Review details
- Files reviewed: 11/11 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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 changed
The client now consumes
server/stateas the spec defines it.Full state, absent leaf = unset (Sendspin/spec#175;
messaging.md,roles/metadata/v1.md,roles/color/v1.md,roles/controller/v1.md).ApplyMetadataandApplyColorbuild the new state from the message alone instead of merging against the previous value; an absentprogressclears the position; an absent controllerseek_max_msis unset rather than "keep the last bound". TheOptional<>wrappers on the leaf fields are neutralised (absent reads as null) rather than removed, because removing the type cascaded beyond the metadata/colour/controller types and their tests. Anullrole object is still tolerated and treated as removal, since the reference server still sends it on clear.Discard a removed role's state on
server/activate(Sendspin/spec#275).DiscardDeactivatedRoleStateclears the current metadata, colour and controller state for each role family that left the active set, raises the same cleared events anullobject raised before, and flushes that family's pending scheduled updates inMediaDisplayScheduler(reusing the flush pathstream/endalready uses). The first activation is a no-op. Active roles are untouched.Docs. Two README lines that described the old colour-delta behaviour were corrected; they document exactly the behaviour this PR inverts.
Tests
Seven tests that asserted the old merge behaviour are inverted (four metadata, two colour, one controller seek). Three added: metadata dropped on activation is cleared and announced while colour and controller are left alone; controller dropped on activation is cleared; a pending scheduled metadata update is discarded on removal while the colour one stays scheduled.
net8.0 1166/1166, net10.0 1168/1168 (baseline 1163/1165, +3).
Closes #288