From edcd30f6bc95e31a19f9eebef5d19f41b830288a Mon Sep 17 00:00:00 2001 From: ddidderr Date: Fri, 22 May 2026 07:26:55 +0200 Subject: [PATCH] feat(client): show gateway peer in startup status The relay welcome now carries the gateway peer id, but the first Windows client startup line still only showed whether a gateway was connected. Surface the peer id there when it is known so manual MVP testers can record it even before or without relying on a later lifecycle catch-up line. Keep the older yes/no text when a gateway is connected but the peer id is not available, which preserves useful output for older welcome payloads. Test Plan: - cargo fmt --check - cargo test -p lanparty-client-win gateway_status - cargo clippy -p lanparty-client-win --all-targets -- -D warnings - git diff --check - git diff --cached --check Refs: MVP manual validation --- TESTING.md | 2 +- crates/lanparty-client-win/src/main.rs | 20 +++++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/TESTING.md b/TESTING.md index 4e2cf25..613e89d 100644 --- a/TESTING.md +++ b/TESTING.md @@ -171,7 +171,7 @@ Expected client output: ```text prepared TAP adapter ... MAC ... configured and media disconnected before relay connect -lanparty-client-win connected as peer ... +lanparty-client-win connected as peer ...; LAN gateway connected yes (peer ...) relay event: LAN gateway connected as peer ... relay route pinned before TAP ... relay route verified after TAP activation ... diff --git a/crates/lanparty-client-win/src/main.rs b/crates/lanparty-client-win/src/main.rs index 9edd02a..f7da10e 100644 --- a/crates/lanparty-client-win/src/main.rs +++ b/crates/lanparty-client-win/src/main.rs @@ -193,7 +193,10 @@ async fn main() -> Result<()> { session.welcome().room_id(), session.welcome().effective_tap_mtu(), session.welcome().mode(), - yes_no(session.welcome().gateway_connected()) + gateway_status_label( + session.welcome().gateway_connected(), + session.welcome().gateway_peer_id() + ) ); #[cfg(windows)] let relay_route_pin = match pin_relay_route_before_tap(session.config().relay_addr().ip()) { @@ -755,6 +758,14 @@ const fn yes_no(value: bool) -> &'static str { if value { "yes" } else { "no" } } +fn gateway_status_label(gateway_connected: bool, gateway_peer_id: Option) -> String { + match (gateway_connected, gateway_peer_id) { + (true, Some(peer_id)) => format!("yes (peer {peer_id})"), + (true, None) => "yes".to_owned(), + (false, _) => "no".to_owned(), + } +} + fn optional_label(value: Option) -> String { value.map_or_else(|| "unknown".to_string(), |value| value.to_string()) } @@ -1243,6 +1254,13 @@ mod tests { ); } + #[test] + fn formats_gateway_status_with_welcome_peer_id() { + assert_eq!(gateway_status_label(true, Some(7)), "yes (peer 7)"); + assert_eq!(gateway_status_label(true, None), "yes"); + assert_eq!(gateway_status_label(false, Some(7)), "no"); + } + #[test] fn formats_missing_client_diagnostics_as_unknown() { let diagnostics = ClientDiagnostics::new(