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).
This commit is contained in:
Edison Jwa
2026-06-07 23:12:07 +09:00
parent 5e8b7915db
commit ab0dc2ebc2
+12
View File
@@ -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;