From 1048f7eef0e486924cb5ede676b1ff6d392b2a67 Mon Sep 17 00:00:00 2001 From: Softer Date: Sun, 7 Jun 2026 21:31:07 +0300 Subject: [PATCH] Fix WiFi network selection in TUI prompt (#4566) * Fix WiFi network selection in TUI prompt TableSelectionScreen returns the selected network in Result._item, but the check on line 136 only tested Result._data (always None for single-select). This caused every selection to fall through to the "No wifi networks found" error path. Fixes #4564 * Fix empty wifi scan crash and simplify network selection Move wifi scanning out of the TableSelectionScreen callback to avoid MenuItemGroup([]) ValueError when no networks are found. The empty result is now handled before the selection screen, and the Selection branch is simplified to a direct get_value() call. --- archinstall/lib/network/wifi_handler.py | 40 ++++++++++++------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/archinstall/lib/network/wifi_handler.py b/archinstall/lib/network/wifi_handler.py index b5590343..bc068d2a 100644 --- a/archinstall/lib/network/wifi_handler.py +++ b/archinstall/lib/network/wifi_handler.py @@ -1,4 +1,3 @@ -from asyncio import sleep from dataclasses import dataclass from pathlib import Path from typing import assert_never, override @@ -109,36 +108,25 @@ class WifiHandler(InstanceRunnable[bool]): debug(f'Found wifi interface: {wifi_iface}') - async def get_wifi_networks() -> MenuItemGroup: - debug('Scanning Wifi networks') - result = self._wpa_cli('scan', wifi_iface) + wifi_networks = await self._scan_wifi(wifi_iface) - if not result.success: - debug(f'Failed to scan wifi networks: {result.error}') - return MenuItemGroup([]) + if not wifi_networks: + debug('No networks found') + await NotifyScreen(header=tr('No wifi networks found')).run() + tui.exit(Result.false()) + return False - await sleep(5) - wifi_networks = self._get_scan_results(wifi_iface) - - items = [MenuItem(network.ssid, value=network) for network in wifi_networks] - return MenuItemGroup(items) + items = [MenuItem(network.ssid, value=network) for network in wifi_networks] result = await TableSelectionScreen[WifiNetwork]( header=tr('Select wifi network to connect to'), - loading_header=tr('Scanning wifi networks...'), - group_callback=get_wifi_networks, + group=MenuItemGroup(items), allow_skip=True, allow_reset=True, ).run() match result.type_: case ResultType.Selection: - if not result.has_data(): - debug('No networks found') - await NotifyScreen(header=tr('No wifi networks found')).run() - tui.exit(Result.false()) - return False - network = result.get_value() case ResultType.Skip | ResultType.Reset: tui.exit(Result.false()) @@ -184,6 +172,18 @@ class WifiHandler(InstanceRunnable[bool]): return True + async def _scan_wifi(self, wifi_iface: str) -> list[WifiNetwork]: + debug('Scanning Wifi networks') + scan_result = self._wpa_cli('scan', wifi_iface) + + if not scan_result.success: + debug(f'Failed to scan wifi networks: {scan_result.error}') + return [] + + await LoadingScreen(timer=5, header=tr('Scanning wifi networks...')).run() + + return self._get_scan_results(wifi_iface) + async def _notify_failure(self) -> None: await NotifyScreen(header=tr('Failed setting up wifi')).run()