fix(ui): show Wi-Fi unavailable banner only during active network scan#5892
Conversation
📄 Docs staleness check — advisoryThis PR modifies user-facing UI source files but does not update any page under
Changed source files: What to check:
New page checklist (if adding a new doc page):
If this PR does not require a doc update (e.g., internal refactor, bug fix, test change), add the
|
🖼️ Preview staleness check — advisoryThis PR modifies UI composables but does not update any
Changed UI files: What to check:
Adding previews checklist:
If this PR does not require preview updates (e.g., logic-only change, non-visual refactor), add the |
cce6db6 to
42dbe8e
Compare
The banner predicate previously OR'd `showNetworkTransport` (a default-on user preference for the Network chip) with `isNetworkScanning`, so it fired whenever the chip was enabled — even with no scan running. Drop the chip term so the banner only renders while a scan is actively running. The auto-scan case (chip off but auto-scan pref on) is still covered because `isNetworkScanning` is true during auto-scan regardless of chip state. The unused `showNetworkTransport` parameter is removed from the predicate signature and its single call site. Tests: the prior scenario asserting "section visible plus scan idle yields banner shown" is flipped to assert the banner is hidden, pinning the reported bug. A new positive case (scan_active_permission_granted_wifi_unavailable_then_banner_shows) locks in the desired behavior. The remaining existing scenarios retain their semantics under the narrower predicate.
The WiFi-unavailable recovery banner in ConnectionsScreen is a hint for the case where the user has started a network scan but the device is on a transport that cannot carry NSD/mDNS traffic to a Meshtastic node (cellular-only, no Wi-Fi/Ethernet/VPN). It points the user at Wi-Fi settings as the recovery path. Once the live scan has actually surfaced discovered TCP nodes, the user has already found what the hint was trying to help them reach. Keeping the banner visible past that point is noise — it pulls attention away from the freshly populated device list and implies recovery is still needed when, from the user's intent, it is not. Extend the `shouldShowWifiUnavailableBanner` predicate with a fourth AND-term, `discoveredTcpDevicesEmpty`, sourced from the already-collected `discoveredTcpDevices` state. The banner now requires all four conditions: scan active, local-network permission granted, WiFi unavailable, and the discovered-TCP list still empty. Naming mirrors the negative phrasing of `wifiUnavailable` so the predicate reads symmetrically. The predicate stays a pure boolean function with no coupling to feature-specific types, so existing commonTest coverage extends cleanly: the six prior WifiUnavailableBannerTest cases gain the new argument pinned to `true` (preserving the empty-list banner-shows behavior), and one new case pins the results-found suppression path.
42dbe8e to
0d9c080
Compare
Overview
This PR fixes Connections screen Wi-Fi recovery banner behavior so the banner appears only when it is useful: during an active network scan, after local-network permission has been granted, when no Wi-Fi/VPN/Ethernet scan transport is available, and before any TCP devices have been discovered. This prevents the banner from appearing just because the Network section is visible, and hides it once discovery has produced usable results.
This PR is related to the scan lifecycle coordination PR (#5887) and should land after it. That PR makes
isNetworkScanninga more reliable runtime signal; this PR then uses that signal as the banner’s user-intent gate. Because both PRs touch nearbyConnectionsScreen.ktcode, this branch may need a small rebase after the scan lifecycle PR lands.Key Changes
Fixes
isNetworkScanning, not the Network section visibility chip.Refactors
shouldShowWifiUnavailableBanner()to use scan/result state instead of transport chip visibility:showNetworkTransport.isNetworkScanning.discoveredTcpDevicesEmpty.localNetworkPermissionGrantedandwifiUnavailable.ConnectionsScreencall site to pass active scan state, permission state, transport availability, and whether the discovered TCP list is empty.Testing
showNetworkTransportpredicate argument is removed from touched files.Breaking Changes
The internal
shouldShowWifiUnavailableBanner()helper signature changed.Removed:
showNetworkTransport: BooleanAdded:
isNetworkScanning: BooleandiscoveredTcpDevicesEmpty: BooleanRetained:
localNetworkPermissionGranted: BooleanwifiUnavailable: BooleanNo user-facing migration is required.