Skip to content

refactor(runtime): extract native-streaming startup - #486

Merged
LargeModGames merged 1 commit into
mainfrom
refactor/runtime-streaming-module
Aug 26, 2026
Merged

LargeModGames merged 1 commit into
mainfrom
refactor/runtime-streaming-module

Conversation

@LargeModGames

@LargeModGames LargeModGames commented Aug 26, 2026 •

Copy link
Copy Markdown
Owner

Summary

Move the native-streaming startup out of the tui-gated runtime/startup.rs into a new runtime/streaming/ module, gated on streaming:

  • streaming/mod.rs holds the pure saved-device decision (startup_device_decision) and its tests.
  • streaming/launch.rs holds the credential gate (cache_streaming_credentials), the deferred librespot bring-up (deferred_streaming_startup), and DeferredStreamingContext.
  • startup.rs keeps only the UI-launch half and calls the module.

The code is moved, not changed. There are two differences beyond the move: the inline credential gate became a function with early returns, and the recovery supervisor spawn moved (see Additional notes). The Boot dead-code attributes in bootstrap.rs now match the new gates.

Add a headless-streaming CI leg (telemetry,streaming, check + clippy) so the streaming startup and the player-event wiring build with no terminal frontend in scope. This is the combination a second frontend or a daemon consumes, and nothing covered it before. The three doc copies describe the seven-leg matrix and the new runtime/streaming/ unit.

Testing

  • cargo fmt --all -- --check: clean
  • cargo clippy --no-default-features --features telemetry,tui -- -D warnings: clean
  • cargo test --no-default-features --features telemetry,tui: 867 passed, 0 failed
  • cargo clippy --no-default-features --features telemetry,streaming -- -D warnings (the new leg): clean
  • cargo clippy --no-default-features --features telemetry -- -D warnings: clean
  • cargo test (default features): 1167 passed, 0 failed

Additional notes

  • The two entry points in launch.rs carry allow(dead_code) without tui, so the new leg proves they compile with no terminal frontend, not that they are live there. The leg has no test job.
  • This unblocks a spotatui daemon subcommand (Daemon mode: persistent headless Connect device for CLI playback #466), which needs the streaming startup without tui.
  • deferred_streaming_startup now takes recovery_rx and spawns player::spawn_streaming_recovery_handler itself, so the recovery supervisor starts only when streaming is attempted. Before, it started whenever the streaming feature was on. Every recovery-request sender needs a live player, and the App sender handles a dropped receiver, so nothing observable changes. startup.rs installs the sender on the same condition. This keeps the recovery chain live on the new leg.

💬 Questions or want to chat with other contributors? Join the spotatui Discord.

Summary by CodeRabbit

  • New Features

    • Improved native streaming startup with faster background initialization.
    • Restored saved playback devices and resumed pending playback actions more reliably.
    • Added smarter device selection and fallback behavior when saved devices are unavailable.
  • Bug Fixes

    • Improved handling of authentication, unsupported accounts, and streaming recovery.
    • Reduced startup delays by caching credentials without blocking the application.
  • Documentation

    • Updated build and runtime documentation to clarify streaming support and configuration coverage.

Move the credential gate, the deferred librespot bring-up, and the
saved-device decision out of the tui-gated startup.rs into
runtime/streaming/, gated on streaming. The pure decision lives in
mod.rs, the bring-up in launch.rs.

Add a headless-streaming CI leg (telemetry,streaming; check + clippy)
so the startup builds with no terminal frontend.
@coderabbitai

coderabbitai Bot commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 3dfba6b9-01f9-4f0b-afbc-19bc96dc079d

📥 Commits

Reviewing files that changed from the base of the PR and between 15f254e and c92cb79.

📒 Files selected for processing (9)
  • .github/copilot-instructions.md
  • .github/workflows/ci.yml
  • AGENTS.md
  • CLAUDE.md
  • src/runtime/bootstrap.rs
  • src/runtime/mod.rs
  • src/runtime/startup.rs
  • src/runtime/streaming/launch.rs
  • src/runtime/streaming/mod.rs

Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

The PR moves native streaming startup into runtime/streaming/, adds account and player initialization handling, centralizes startup device decisions, and adds a dedicated headless-streaming CI leg.

Changes

Native streaming startup

Layer / File(s) Summary
CI matrix and runtime architecture
.github/workflows/ci.yml, .github/copilot-instructions.md, AGENTS.md, CLAUDE.md
The CI matrix now has seven legs, including headless-streaming with telemetry,streaming. Documentation describes the shared runtime/streaming/ startup path.
Runtime module gating and bootstrap contracts
src/runtime/mod.rs, src/runtime/bootstrap.rs
The streaming module is compiled for the streaming feature and tests. Bootstrap documentation and dead-code conditions reflect TUI and streaming startup.
Credential caching and deferred streaming startup
src/runtime/startup.rs, src/runtime/streaming/launch.rs
Streaming startup now handles account validation, credential caching, recovery setup, player initialization, event wiring, playlist refresh, and pending playback replay.
Startup device decisions and validation
src/runtime/streaming/mod.rs, src/runtime/streaming/launch.rs
Startup selects saved, native, or fallback devices. Tests cover Play, Continue, unavailable devices, persistence, and status messages.

Estimated code review effort: 4 (Complex) | ~60 minutes

Merge Risk: ⚪ Minimal · up to c92cb

The PR reorganizes streaming startup behind its feature gate and adds headless build coverage; no actionable merge-blocking risk remains after normal checks and review.

Sequence Diagram(s)

sequenceDiagram
  participant launch_ui
  participant cache_streaming_credentials
  participant deferred_streaming_startup
  participant Spotify
  participant librespot
  participant App
  launch_ui->>cache_streaming_credentials: Cache streaming credentials
  cache_streaming_credentials->>Spotify: Probe account and refresh /me
  launch_ui->>deferred_streaming_startup: Pass deferred startup context
  deferred_streaming_startup->>Spotify: Validate account and fetch devices
  deferred_streaming_startup->>librespot: Initialize streaming player
  librespot->>App: Wire player and recovery events
  deferred_streaming_startup->>App: Refresh playlists and replay playback
Loading
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title uses the approved conventional-commit prefix refactor, includes a relevant scope, and concisely states the main change with the imperative verb extract.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/runtime-streaming-module
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch refactor/runtime-streaming-module

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Aug 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 44.00978% with 229 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/runtime/streaming/launch.rs 0.0% 216 Missing ⚠️
src/runtime/startup.rs 0.0% 13 Missing ⚠️

📢 Thoughts on this report? Let us know!

@LargeModGames
LargeModGames merged commit 0b7d8bd into main Aug 26, 2026
29 checks passed
@LargeModGames
LargeModGames deleted the refactor/runtime-streaming-module branch August 26, 2026 10:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant