Skip to content

Fix WiFi network selection in TUI prompt#4566

Open
Softer wants to merge 3 commits into
archlinux:masterfrom
Softer:fix-wifi-prompt
Open

Fix WiFi network selection in TUI prompt#4566
Softer wants to merge 3 commits into
archlinux:masterfrom
Softer:fix-wifi-prompt

Conversation

@Softer
Copy link
Copy Markdown
Contributor

@Softer Softer commented Jun 3, 2026

TableSelectionScreen returns selected item in Result._item, but wifi_handler.py checked only Result._data (via has_data()), which is always None for single-select mode.
Every WiFi network selection fell through to the "No wifi networks found" error path, making WiFi setup completely broken.

Fix: check both has_value() and has_data() before treating the result as empty

Fixes #4564

Softer added 2 commits June 3, 2026 16:19
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 archlinux#4564
@Softer Softer requested a review from Torxed as a code owner June 3, 2026 16:31
Comment thread archinstall/lib/network/wifi_handler.py Outdated
match result.type_:
case ResultType.Selection:
if not result.has_data():
if not result.has_value() and not result.has_data():
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no reason to check this at all here as on a selection there should always be a value present, so it can altogether be simplified to

			case ResultType.Selection:
				network = result.get_value()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point - for the normal flow where a user picks a row, _item is always set. However, _put_data_to_table dismisses with a bare Result(ResultType.Selection) (no _item, no _data) when the item list is empty. In that case get_value() would hit the assertion.

Or am I wrong?..

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's actually another bug in the function

		async def get_wifi_networks() -> MenuItemGroup:
			debug('Scanning Wifi networks')
			result = self._wpa_cli('scan', wifi_iface)

			if not result.success:
				debug(f'Failed to scan wifi networks: {result.error}')
				return MenuItemGroup([])

			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)

If that returns no results with MenuItemGroup([]) then the whole TUI blows up, which I think is the case you described?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm.. Maybe you're right, let me think...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@svartkanin
You're right, I moved the scan logic out of the callback into a separate _scan_wifi() method. Now the empty result is handled before TableSelectionScreen, so MenuItemGroup([]) never happens. The Selection branch is simplified to just get_value(). See 93092a7 - what do you think?

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Prompt to connect to a WiFi network if not already does not work

2 participants