Skip to content

Keep roles active during pairing and clean up removed roles - #204

Merged
maximmaxim345 merged 4 commits into
mainfrom
fix/role-removal-pairing-activations
Oct 27, 2026
Merged

maximmaxim345 merged 4 commits into
mainfrom
fix/role-removal-pairing-activations

Conversation

@maximmaxim345

Copy link
Copy Markdown
Member

What does this implement/fix?

Starting a pairing attempt while the player was active stopped clock sync, client/state updates and controller commands until pairing ended, and could leave the client with no active roles. A server/activate that adds pairing now keeps the active roles, as the spec requires.

Removing a role in server/activate now also cleans up after it. Removing player@v1 stops output and clears the buffers, and removing metadata@v1 or controller@v1 discards its cached server/state and any pending metadata update.

aiosendspin still stops playback before pairing for this client, since our client/hello still looks like an older client to it.

Related issue or spec PR (if applicable):

Types of changes

  • Bugfix (non-breaking change which fixes an issue): bugfix
  • New feature (non-breaking change which adds functionality): new-feature
  • Enhancement to an existing feature: enhancement
  • Breaking change (changes the public API or the protocol in a way that is not backwards compatible): breaking-change
  • Refactor (no behavior change): refactor
  • Documentation only: documentation
  • Maintenance / chore: maintenance
  • CI / workflow change: ci
  • Dependencies bump: dependencies

A server/activate that added pairing dropped its active_roles, stopped
time sync and client/state, and blocked controller commands, including
ones queued during a re-handshake.

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

Static review identified no blocking issues in the focused activation and cleanup changes, which include regression coverage; tests were not run.

No open issues 🎉

What changed in this PR

This PR fixes activation handling in the Sendspin SDK so pairing can coexist with active roles, while removed roles release their playback resources and cached state.

Changes:

  • Preserve clock sync, state updates, and controller commands during pairing when their roles remain active.
  • Stop playback when the player role is removed and discard cached state and pending metadata for removed roles.
  • Add regression coverage and adjust pairing and encryption tests for shared activation handling.
File Description
tests/​unit/​transport-rehandshake.test.ts Verify queued commands survive pairing when the controller role remains active.
tests/​unit/​protocol-handler.test.ts Cover player shutdown and removed-role state cleanup.
tests/​unit/​pairing.test.ts Adapt tests to the activation handler’s void return type.
tests/​unit/​core.test.ts Verify state updates and controller commands remain available during pairing.
tests/​unit/​core-encryption.test.ts Consume all activation replies to keep encryption nonces aligned.
src/​core/​transport.ts Retain queued commands based on the active controller role.
src/​core/​state-manager.ts Discard removed-role state and cancel pending metadata updates.
src/​core/​protocol-handler.ts Remove pairing suspension and clean up deactivated roles.
src/​core/​pairing.ts Stop treating pairing activation as an exclusively consumed message.
src/​core/​core.ts Route activation messages to both protocol and pairing handlers.

Review effort: Balanced

@maximmaxim345
maximmaxim345 merged commit dda2f69 into main Oct 27, 2026
4 checks passed
@maximmaxim345
maximmaxim345 deleted the fix/role-removal-pairing-activations branch October 27, 2026 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants