Add seek command support and refactor controller command API#94
Merged
Conversation
Wire up the player seek commands that were previously recognized but unsendable: SEEK now carries position_ms and SEEK_RELATIVE carries offset_ms, and the controller state parses the server's seek_max_ms. Refactor send_command onto a flat ClientCommandControllerObject struct built with designated initializers, replacing the positional optional<volume>/optional<mute> parameters (which would have grown a 4th and 5th positional arg for seek). The old positional overload is kept, marked deprecated for removal in v0.8.0, so existing ESPHome/dev-branch callers keep working until the v0.7.0 migration. The vestigial internal ClientCommandControllerObject/ClientCommandMessage structs are removed in favor of the public struct. Migrate the TUI example to the struct API and add a Shift+Left/Shift+Right relative-seek keybinding.
Migrate the Sending Commands examples and the accessor snippet to the ClientCommandControllerObject designated-initializer API, add SEEK and SEEK_RELATIVE examples, and note the deprecated positional overload. Add SEEK/SEEK_RELATIVE to the SendspinControllerCommand reference table, fix the VOLUME/MUTE field descriptions, and list seek_max_ms among the controller state fields.
Contributor
There was a problem hiding this comment.
Pull request overview
Adds full seek support to the controller role by (1) parsing the server-provided seek_max_ms upper bound and (2) making client seek commands sendable with explicit parameters. It also refactors the controller command-sending API to a single struct-based interface to avoid growing positional optional parameters.
Changes:
- Parse
seek_max_msfromserver/statecontroller payloads and expose it viaServerStateControllerObject. - Refactor
format_client_command_messageand controllersend_commandto useClientCommandControllerObject, addingposition_ms/offset_msserialization forSEEK/SEEK_RELATIVE. - Update tests, docs, and the TUI example (including Shift+Left/Right relative-seek keybindings) to use the struct API.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_protocol.cpp | Adds coverage for seek_max_ms parsing and seek/struct-based command serialization behavior. |
| src/protocol.cpp | Implements seek_max_ms parsing and struct-based client/command JSON formatting (including seek fields). |
| src/protocol_messages.h | Removes internal vestigial command message structs; updates client/command formatter declaration to struct-based API. |
| src/controller_role.cpp | Adds struct-based send_command overload and forwards deprecated positional overload into the struct form. |
| src/controller_role_impl.h | Updates Impl API to accept ClientCommandControllerObject. |
| include/sendspin/controller_role.h | Exposes seek_max_ms and defines the public ClientCommandControllerObject (volume/mute/seek params) plus the new send_command overload. |
| examples/tui_client/tui.cpp | Migrates TUI to struct-based commands and adds Shift+Arrow relative-seek handling. |
| docs/integration-guide.md | Updates integration documentation to the struct-based command API and documents seek usage + deprecation notice. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
kahrendt
enabled auto-merge (squash)
July 14, 2026 14:38
4 tasks
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.
Wires up the player seek commands that were previously recognized but unsendable:
SEEKnow carriesposition_msandSEEK_RELATIVEcarriesoffset_ms, and the controller state parses the server'sseek_max_ms.Refactors
send_commandonto a flatClientCommandControllerObjectstruct built with designated initializers, replacing the positionaloptional<volume>/optional<mute>parameters (which would have grown a 4th and 5th positional arg for seek). The old positional overload is kept, marked deprecated for removal in v0.8.0, so existing ESPHome/dev-branch callers keep working until the v0.7.0 migration. The vestigial internalClientCommandControllerObject/ClientCommandMessagestructs are removed in favor of the public struct.Migrates the TUI example to the struct API and add a Shift+Left/Shift+Right relative-seek keybinding.