Repository navigation
Conversation
A player that accepts the control connection and never answers used to block exchange_control_request forever: the TUI stopped polling, its progress bar froze, and quitting hung on the worker's join. Every send and receive on the client socket now gives up after 3 s with "the player did not answer within 3 s", and the TUI's 250 ms tick runs on a thread that does no socket I/O.
The library keeps the pairing window open until the attempt concludes, so an attempt let past it showed its code behind "Y to allow, N to refuse", and after y the prompt stayed up, where a following n cancelled the attempt just allowed. A code now outranks the window, and once y has gone out the takeover says "Allowed -- waiting for the server..." and ignores y and n until that attempt ends.
The 3 s bound was set only after connect(), and on Linux a blocking AF_UNIX connect() to a wedged player's full accept backlog waits for room for ever, so the TUI's worker, and q with it, could hang for good. The bound is now set before connect(), and a connect that runs it out fails as "the player did not answer within 3 s". Windows refuses a full backlog at once and takes no bound for connect() from these options. The worker also sent every queued request, the token and a poll without looking at the stop flag in between, so a quit could wait out several bounds. It now checks before each exchange.
A poll that timed out, broke off or did not parse detached the TUI, and the next good poll rebaselined, so a pairing attempt that ended in between was never shown: the code flashed to "No sendspin-cli player is running here" and then to the main screen without a word. Such a poll now keeps the last screen and the baseline and leaves the notice "The player did not answer -- retrying"; only a socket that is gone or refused detaches. After a real detach, a reattach to the same player (same client id, its counter not gone backwards) treats an attempt that ended meanwhile as news rather than history.
The dispatcher's new branches had no end-to-end check. Both smoke scripts now set this player's volume and mute with no server and read them back from status, check that status-kv leads with version=1, and check that player-vol under --fixed-volume exits 2.
A local volume or mute change left no line in the log, unlike a local
delay. Both now log at INFO ("Player volume set to 30 locally", "Player
muted locally"), and the smoke scripts check for the lines.
A pairing with a server that has no name read "Paired with " and nothing after it; it now falls back to the id, with "..." only when the id was actually cut. The name seen while the attempt was under way is kept for the outcome, since right after success the re-handshake can leave the connected server unknown for a poll. p toggled the token on the takeovers, where the footer that shows it is hidden, and on the no-player screens, where its fetch could only fail and left "unavailable" showing after the attach. It now does nothing off the main screen.
Controlling-the-Player gains a tui row in its subcommand table and lists status-kv among the commands answered locally with exit 0, and the prose this branch lengthened is wrapped again. Using-the-TUI no longer calls the system service's socket root-only: it belongs to the service account at mode 0600, and root gets in because root ignores the mode.
On Windows a recv() already blocked on an AF_UNIX socket can miss the player's close and wait forever (or until the 3 s bound), although the reply has arrived. select() reports that end of stream at once, so the client now waits for readability, against one overall deadline, before each read. This also affected main, where a status could hang. The full-backlog connect test is Linux-only: macOS, like Windows, refuses such a connect at once.
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved timeout and TUI state-handling defects can exceed exchange bounds, prevent repeated key presses from accumulating, and disable consent controls after failed confirmations.
6 open issues
What changed in this PR
Adds sendspin-cli tui as a terminal remote for the existing player, using the control socket without starting another player or creating a separate identity.
Changes:
- Adds playback controls, responsive status panels, pairing screens and attachment recovery.
- Extends player controls with local volume/mute, machine-readable status, pairing outcomes and socket timeouts.
- Adds unit and smoke coverage, optional FTXUI build integration, and user documentation.
| File | Description |
|---|---|
tests/tui_model_test.cpp |
Tests screens, keys, pairing state and token handling. |
tests/status_kv_test.cpp |
Tests status serialization and parsing. |
tests/player_listener_test.cpp |
Tests local volume/mute and fixed-volume refusal. |
tests/pairing_tracker_test.cpp |
Tests pairing callback sequences and outcomes. |
tests/control_test.cpp |
Covers new commands and status fields. |
tests/control_exchange_test.cpp |
Tests socket replies and timeout scenarios. |
src/tui.h |
Declares the terminal UI entry point. |
src/tui.cpp |
Implements rendering, keyboard input and background exchanges. |
src/tui_model.h |
Defines UI state and model interfaces. |
src/tui_model.cpp |
Implements screen selection and control behavior. |
src/status_kv.h |
Defines the parsed status view and format interfaces. |
src/status_kv.cpp |
Implements versioned key-value status. |
src/socket_compat.h |
Adds portable timeout and readiness helpers. |
src/player_listener.h |
Exposes local volume/mute setters. |
src/player_listener.cpp |
Applies, publishes and persists local changes. |
src/pairing_tracker.h |
Defines pairing attempt tracking. |
src/pairing_tracker.cpp |
Records pairing lifecycle and outcomes. |
src/main.cpp |
Integrates TUI dispatch and expanded player status. |
src/control.h |
Adds commands, snapshot fields and exchange results. |
src/control_common.cpp |
Registers commands and formats new status fields. |
src/control_client.cpp |
Separates structured exchanges from printing and adds timeouts. |
src/audio_sink.h |
Adds the local volume-source category. |
scripts/smoke_test.sh |
Checks new controls and status on Linux. |
scripts/smoke_test_windows.ps1 |
Adds equivalent Windows smoke checks. |
README.md |
Introduces commands and links TUI documentation. |
docs/wiki/Using-the-TUI.md |
Documents screens, keys and connection handling. |
docs/wiki/Pairing-a-Player.md |
Explains pairing outcomes and TUI usage. |
docs/wiki/Controlling-the-Player.md |
Documents new commands and status format. |
docs/wiki/_Sidebar.md |
Adds the TUI navigation link. |
docs/superpowers/specs/2026-11-10-tui-design.md |
Records the TUI design and constraints. |
docs/superpowers/plans/2026-11-10-tui.md |
Records implementation and validation steps. |
docs/ROADMAP.md |
Marks the TUI delivered and lists deferred features. |
CMakeLists.txt |
Adds optional FTXUI integration, sources and tests. |
Review effort: Balanced
Fold pairing results into main's PairingListener and port status to the v0.10.0 accessors.
Also rebaseline pairing outcomes on a restart seen while attached, and move the position at the reported speed.
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.

Adds
sendspin-cli tui, a terminal remote for the player that is already running. It attaches over the control socket, the same waysendspin-cli statusdoes, and never plays audio or gets an identity of its own. When a server starts pairing, the code takes over the screen. The rest of the time it shows what is playing and drives playback with the Python TUI's keys. This is roadmap item 9. Design:docs/superpowers/specs/2026-11-10-tui-design.md; plan:docs/superpowers/plans/2026-11-10-tui.md.The TUI
sendspin-cli tuifinds the player through the same--port,--control-socketand config-file rules as every other subcommand.pair confirmasks Y/N. Aftery, it says it is waiting for the server.[/](group),m/M,r,x,g,,/.andq.pshows or hides the pairing token, on the main screen only.sudo ... --control-socket /run/sendspin-cli/control.sockcommand.sendspin-cli-tuilibrary. It is behindSENDSPIN_CLI_WITH_TUI, on by default. Core never includes FTXUI.What the player gained for it
statusgains new lines. Every existing line is unchanged.last pairing:shows paired, failed with the reason, or abandoned. Without it, a wrong code fails faster than anything polling could see.album:,group:andcodec:show when they are known.player-vol <0-100>andplayer-mute on|offset this endpoint's own level. They are answered locally, published to the server, and remembered. Under--fixed-volumethey are refused with exit 2.volandmutestill address the group.status-kvis status askey=valuelines for scripts and the TUI. The first line isversion=1, and the keys are documented and never renamed.Testing
-Werror, static CRT): 596/596 tests andsmoke_test_windows.ps1pass. The format check is clean.-Werror, every backend):StateStorepermission tests that also fail onmainin the same root container.smoke_test.shpasses, as a non-root user.status-kvround trip, newline injection, and unknown and missing keys;player-vol,player-mute,status-kvand--fixed-volume.tuiwithout a TTY exits 1.Binary size: Windows +476 KB (2.27 MB to 2.74 MB); Linux +861 KB (2.84 MB to 3.70 MB).
Still to check by hand
y.Known, not addressed here
main, and it affectsstatustoo. It needs its own look at how the player closes the socket on Windows.sudounder the system service (asendspin-cligroup with a0660socket);Compatibility
Nothing breaks for CLI users. Everything here is additive: new
tui,status-kv,player-volandplayer-mutesubcommands, and newlast pairing,codec,albumandgrouplines instatus. Existing lines, flags and defaults are unchanged. A control exchange is now bounded by a single 3 s deadline across connect, write and read; before, each step had its own bound.