major bug fixes

This commit is contained in:
Forrest 2026-08-04 19:29:58 -04:00
parent 9728906556
commit d6144c4483
39 changed files with 483 additions and 53 deletions

View file

@ -209,10 +209,12 @@ class RemoteControlController extends StateNotifier<RemoteControlState> {
_statusSub = session.status.listen((st) {
_update((s) => s.copyWith(status: st));
// Any terminal status drops us back to local playback.
if (st == RemoteConnStatus.disconnected ||
st == RemoteConnStatus.error ||
st == RemoteConnStatus.denied) {
// Only a terminal status drops us back to local playback. Transient
// drops (phone locked, Wi-Fi blip) are healed inside the session, which
// retries and re-emits `connecting` — we stay attached (bug-fixes #5).
// `denied` is a hard rejection; `error` here only means a device that
// never answered the initial dial.
if (st == RemoteConnStatus.denied || st == RemoteConnStatus.error) {
// Defer so we're not tearing the session down inside its own callback.
scheduleMicrotask(detach);
}
@ -225,6 +227,13 @@ class RemoteControlController extends StateNotifier<RemoteControlState> {
await session.connect();
}
/// Re-establish a dropped remote session immediately when the app returns to
/// the foreground. A controller is suspended while the phone is locked, so
/// its socket to the host is usually dead on resume; without this nudge the
/// user would wait out the reconnect backoff before control is restored
/// (bug-fixes #5). No-op when playing locally.
void onResume() => _session?.reconnectNow();
Future<void> detach() async {
await _snapSub?.cancel();
_snapSub = null;