Skip to content

feat: consume server/state as full state, discard removed-role state - #292

Merged
chrisuthe merged 1 commit into
mainfrom
chrisuthe/task/server-state-full-state-absent-leaf-is-unset
Sep 17, 2026
Merged

chrisuthe merged 1 commit into
mainfrom
chrisuthe/task/server-state-full-state-absent-leaf-is-unset

Conversation

@chrisuthe

@chrisuthe chrisuthe commented Sep 17, 2026 •

Copy link
Copy Markdown
Member

What changed

The client now consumes server/state as 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). ApplyMetadata and ApplyColor build the new state from the message alone instead of merging against the previous value; an absent progress clears the position; an absent controller seek_max_ms is unset rather than "keep the last bound". The Optional<> 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. A null role 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). DiscardDeactivatedRoleState clears the current metadata, colour and controller state for each role family that left the active set, raises the same cleared events a null object raised before, and flushes that family's pending scheduled updates in MediaDisplayScheduler (reusing the flush path stream/end already 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

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.
@chrisuthe chrisuthe added the upstream Tracks spec or aiosendspin changes label Sep 17, 2026
@chrisuthe
chrisuthe requested a lite review from Copilot September 17, 2026 00:47

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 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/state role objects as full state: omitted leaves are now read as unset (including progress, color channels, and controller seek_max_ms).
  • Discard state (and pending scheduled metadata/color updates) for role families removed from active_roles on server/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.

@chrisuthe
chrisuthe marked this pull request as ready for review September 17, 2026 00:50
@chrisuthe
chrisuthe merged commit 3022882 into main Sep 17, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

upstream Tracks spec or aiosendspin changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

server/state is full state: stop merging metadata, colour and controller leaves; discard a removed role's state on server/activate

2 participants