From ab0dc2ebc269599dcb75562c45ceea5ee3eba241 Mon Sep 17 00:00:00 2001 From: Edison Jwa Date: Sat, 6 Jun 2026 03:22:47 +0900 Subject: [PATCH] fix(macos): trigger Local Network permission prompt before server connect The Local Network permission prompt (NWBrowser for _ts3._tcp) was never actually triggered anywhere in the app. The service defined triggerLocalNetworkPrompt() but no code called it. Now _onConnect() checks the local network state before connecting. If the state is unknown or notDetermined, it triggers the NWBrowser scan which shows the system Local Network Privacy dialog on macOS 15+. This ensures the prompt appears before the connection attempt so the user can grant permission and the connection succeeds in one flow. Non-macOS platforms are unaffected (short-circuited by the service). --- apps/chanora_flutter/lib/main.dart | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/apps/chanora_flutter/lib/main.dart b/apps/chanora_flutter/lib/main.dart index 438a732..6732a7b 100644 --- a/apps/chanora_flutter/lib/main.dart +++ b/apps/chanora_flutter/lib/main.dart @@ -1067,6 +1067,18 @@ class _BetaHomeState extends State<_BetaHome> with WidgetsBindingObserver { String? password, }) async { final connectEpoch = ++_connectionEpoch; + + // Trigger macOS Local Network permission prompt before connecting. + // On macOS 15+ the first network connection triggers the system + // dialog; triggering it via NWBrowser here ensures the prompt + // appears *before* the actual connect attempt so the user can grant + // permission and the connection succeeds in one flow. + final lnState = _macOSPermissions.localNetworkState.value; + if (lnState == MacOSLocalNetworkState.unknown || + lnState == MacOSLocalNetworkState.notDetermined) { + await _macOSPermissions.triggerLocalNetworkPrompt(); + } + setState(() { _phase = ConnectionPhase.connecting; _snapshot = null;