Files
qbz/src-tauri
vicrodh 532ec89095 refactor(qconnect): extract QconnectServiceState to service.rs
The final extraction of Alcance A. Move the public service facade
(QconnectServiceState struct + impl + Default impl, plus the spawned
event-loop task, the renderer/queue snapshot queries, the controller-
handoff helpers, send_command/send_renderer_report, the deferred
renderer-join plumbing, and the bootstrap_remote_presence pending-
action machinery) from mod.rs into a dedicated service submodule.

Items moved:
- struct QconnectRuntime, QconnectServiceInner
- pub struct QconnectServiceState (re-exported via `pub use`)
- impl QconnectServiceState (~50 methods) and impl Default
- bootstrap_remote_presence, deferred_renderer_join,
  clear_pending_if_matches
- queue_payload_track_preview, update_lifecycle_state_if_running,
  emit_qconnect_diagnostic (private helpers used only by the service)
- Constants: JOIN_SESSION_REASON_CONTROLLER_REQUEST,
  QCONNECT_PLAY_TRACK_HANDOFF_WAIT_MS,
  QCONNECT_PLAY_TRACK_HANDOFF_POLL_MS

All methods on QconnectServiceState are pub(super) so the commands
submodule (which was already extracted) can dispatch through them.
The Default impl uses plain `fn default()` (visibility qualifiers are
not permitted in trait impls).

mod.rs now contains only the cross-submodule glue (~140 lines):
shared constants (PLAYING_STATE_*, AUDIO_QUALITY_*, BUFFER_STATE_OK,
DEFAULT_QCONNECT_CHANNEL_COUNT, QCONNECT_REMOTE_QUEUE_SOURCE), the
QconnectRemoteSyncState accumulator, qconnect_now_ms,
qconnect_repeat_mode_from_loop_mode, normalize_volume_to_fraction,
model_track_to_core_queue_track, and the module declarations.

session.rs and commands.rs imports re-pathed to point at submodules
directly (super::transport::*, super::queue_resolution::*,
super::session::*, super::service::*) instead of going through
re-exports in mod.rs.

mod.rs: 1820 → 142 lines (-92%). service.rs: 1689 lines.

Final layout:

  src-tauri/src/qconnect/
  ├── mod.rs              ( 142)  module glue
  ├── types.rs            ( 273)  wire types, payloads
  ├── session.rs          ( 374)  topology, renderer snapshots
  ├── queue_resolution.rs ( 481)  cursors, shuffle order
  ├── corebridge.rs       ( 566)  apply_renderer_command, materialize
  ├── track_loading.rs    ( 337)  streaming, FLAC probe, dedup
  ├── event_sink.rs       ( 461)  QconnectEventSink + dispatch
  ├── transport.rs        ( 386)  credentials, device identity
  ├── service.rs          (1689)  QconnectServiceState facade
  ├── commands.rs         ( 849)  Tauri invoke handlers
  └── tests.rs            (1044)  37 unit tests

From 6371 lines in 1 monolith → 6602 lines across 11 focused files,
each with a single clear responsibility. mod.rs went 6371 → 142 lines
(-98%). All 37 tests pass. Alcance A complete; the codebase is ready
for unified-binary Phase 0 to resume.

cc
2026-04-27 18:00:43 -06:00
..