From 0115d54ab84fccacaa4e0f282529e74fd8c91f30 Mon Sep 17 00:00:00 2001 From: foxyz Date: Fri, 9 Oct 2026 23:36:30 +0300 Subject: [PATCH] Strip shows the joined server's name (its --name via /health), the address until known Co-Authored-By: Claude Opus 5.5 --- apps/desktop/lib/src/shell/party_strip.dart | 8 +++++--- apps/desktop/lib/src/state/session_state.dart | 10 ++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/apps/desktop/lib/src/shell/party_strip.dart b/apps/desktop/lib/src/shell/party_strip.dart index 527d2e6..ce96b33 100644 --- a/apps/desktop/lib/src/shell/party_strip.dart +++ b/apps/desktop/lib/src/shell/party_strip.dart @@ -309,12 +309,14 @@ class _ServerLabel extends StatelessWidget { ); } -/// "Solo" alone, "Your server" when hosting, else the address joined. +/// "Solo" alone, "Your server" when hosting, else the joined server's +/// name (its `--name`), or its address while unknown. String serverName() { final session = SessionState.instance; - if (session.solo.peek()) return 'Solo'; + if (session.solo.value) return 'Solo'; if (session.coordinator.hostFile != null) return 'Your server'; - return session.lastForm.host; + final label = session.serverLabel.value; + return label.isNotEmpty ? label : session.lastForm.host; } /// Solo: just you, on your own; a spinner while it becomes a server. diff --git a/apps/desktop/lib/src/state/session_state.dart b/apps/desktop/lib/src/state/session_state.dart index f0040a7..08ce8eb 100644 --- a/apps/desktop/lib/src/state/session_state.dart +++ b/apps/desktop/lib/src/state/session_state.dart @@ -8,6 +8,7 @@ import 'package:sync_relay_core/core.dart'; import '../jellyfin/accounts.dart'; import '../jellyfin/session_media.dart'; +import '../screens/home/health_probe.dart'; import '../screens/home/picked_media.dart'; import '../playback/yt_dlp_app.dart'; import '../sfx/sfx.dart'; @@ -173,6 +174,9 @@ class SessionState { /// In a solo session: this app's own server on 127.0.0.1, only you in /// it. Hosting from it ([host]) keeps what plays and where. final solo = signal(false); + /// The joined server's own name (`/health`), '' until known or when it + /// only has the default name. + final serverLabel = signal(''); /// A solo session is becoming a hosted one: the player has nothing open /// until the media is up again on the new server. final switching = signal(false); @@ -418,6 +422,11 @@ class SessionState { await coordinator.connect(params); if (op != _op) throw const ConnectCancelled(); route.value = AppRoute.session; + serverLabel.value = ''; + unawaited(probeHealth(params.host, '${params.port}', defaultHealthGet).then((h) { + // 'server' is the dedicated server's default --name: not a name. + if (op == _op && h.online && h.name.isNotEmpty && h.name != 'server') serverLabel.value = h.name; + }).catchError((Object _) {})); } finally { await _saveFormQuietly(); } @@ -469,6 +478,7 @@ class SessionState { await coordinator.leave(); await stopServer(); solo.value = false; + serverLabel.value = ''; status.value = const HealthStatus(HealthSeverity.info, 'idle'); route.value = AppRoute.home; }