Skip to content

Port the network page to the rewritten NetworkMgr API - #13

Merged
ericbsd merged 4 commits into
masterfrom
port-networkmgr-api
Oct 17, 2026
Merged

ericbsd merged 4 commits into
masterfrom
port-networkmgr-api

Conversation

@ericbsd

@ericbsd ericbsd commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

NetworkMgr renamed its net_api functions and moved the scan results out of network_dictionary() into scan_networks(), which returns dicts instead of index-based lists. setup-station failed to import at startup with the new NetworkMgr.

Changes

  • Use the new API names and read access points from scan_networks().
  • Save networks through wpa_supplicant's control socket instead of appending to /etc/wpa_supplicant.conf. The config is written only after a connection succeeds, so a wrong password never reaches disk.
  • Re-enable the other saved networks before saving the config. select_network disables them, and saving first stored them as disabled=1.
  • A failed attempt reopens the password dialog titled "Could not connect to {ssid}". A failed save of the config is reported on the status line.
  • Scan once in the background when the page opens, since the scan table can be empty or stale.
  • Connecting to a saved or open network no longer runs on the GTK thread, which froze the window for up to 30 seconds.
  • Translations updated for the two new strings.

Same changes as ghostbsd/install-station#21.

Summary by Sourcery

Modernize the network setup page for the rewritten NetworkMgr API and improve Wi-Fi scanning, authentication, persistence, and responsiveness.

New Features:

  • Add WPA-Enterprise Wi-Fi configuration with EAP method, certificate, identity, and phase-two authentication support.
  • Add background Wi-Fi scanning with rescan controls and refreshed access-point status.

Bug Fixes:

  • Port network setup to the renamed NetworkMgr API and its dictionary-based scan results, restoring startup compatibility.
  • Persist Wi-Fi networks through wpa_supplicant while avoiding disk writes for unsuccessful credentials and preserving other saved networks.
  • Prevent Wi-Fi connection attempts from blocking the GTK interface and provide clearer failure and configuration-save feedback.

Enhancements:

  • Update Wi-Fi authentication and connection handling for open, PSK, WEP, and enterprise networks using the NetworkMgr control interface.

Build:

  • Bump the application version from 0.5 to 0.6.

Chores:

  • Update translations and message catalogs for the revised network setup interface.

NetworkMgr renamed its net_api functions and moved scan results out of
network_dictionary() into scan_networks(), which returns dicts instead
of index-based lists, so setup-station failed to import at startup.

Networks are now saved through wpa_supplicant's control socket rather
than appended to wpa_supplicant.conf. The config is written only after
a connection succeeds, with the other saved networks re-enabled first
so they are not stored as disabled. A failed attempt reopens the dialog
titled "Could not connect to {ssid}", and a failed save of the config
is reported on the status line.

The page scans once in the background when it opens, and connecting
to a saved or open network no longer blocks the GTK thread.
Extract the two new network page strings into the template and merge them into every language file.
@ericbsd
ericbsd requested review from a team as code owners October 16, 2026 21:21
@sourcery-ai

sourcery-ai Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Updates the network setup page for the rewritten NetworkMgr API, adds asynchronous scanning and connection attempts, and delegates network persistence to wpa_supplicant while improving failure feedback and translations.

Sequence diagram for asynchronous Wi-Fi scan refresh

sequenceDiagram
    participant Page as NetworkSetup
    participant Worker as Scan worker
    participant API as NetworkMgr
    participant GTK as GTK main loop

    Page->>API: scan_networks(wifi_card)
    Page->>Worker: scan_and_refresh(wifi_card)
    Worker->>API: wait_for_daemon(wifi_card)
    Worker->>API: request_scan(wifi_card)
    Worker->>Worker: sleep(SCAN_WAIT)
    Worker->>API: scan_networks(wifi_card)
    Worker->>GTK: GLib.idle_add(refresh_networks, networks)
    GTK->>Page: refresh_networks(networks)
Loading

Sequence diagram for background Wi-Fi connection and persistence

sequenceDiagram
    participant User
    participant Page as NetworkSetup
    participant Worker as Connection worker
    participant API as NetworkMgr
    participant GTK as GTK main loop

    User->>Page: Select network
    Page->>API: save_psk_network(ssid, security, password, card)
    Page->>Worker: connect_in_background(network, card)
    Worker->>API: connect_to_ssid(ssid, card)
    Worker->>API: wait_for_connection(card, ssid)
    Worker->>API: enable_all_networks(card)
    alt Connected
        Worker->>API: wpa_save_config(card)
        Worker->>GTK: GLib.idle_add(connection_finished, ...)
        GTK->>Page: connection_finished(network_info, ssid, saved)
    else Failed
        Worker->>API: wpa_reconfigure(card)
        Worker->>GTK: GLib.idle_add(restart_authentication, network, card)
        GTK->>Page: restart_authentication(network, card)
    end
Loading

File-Level Changes

Change Details Files
Port Wi-Fi discovery and connection flows to the rewritten NetworkMgr API and dictionary-based scan results.
  • Replace renamed NetworkMgr imports and calls.
  • Consume scan_networks() records for signal, security, and SSID data.
  • Populate the list immediately and refresh it after a background scan.
  • Run saved and open-network connection attempts off the GTK thread.
setup_station/network_setup.py
Move network persistence and credential handling into wpa_supplicant’s control API.
  • Save or update networks through the control socket rather than editing the config file directly.
  • Persist configuration only after a successful connection.
  • Re-enable all networks before saving to avoid retaining disabled entries.
  • Report configuration-save failures without treating the connection itself as failed.
setup_station/network_setup.py
Improve authentication failure handling and localized user feedback.
  • Reopen the password dialog with the failed SSID in its title.
  • Show connection and save errors through the status UI.
  • Update translation catalogs and the POT template for the new messages.
setup_station/network_setup.py
po/ar_SA.po
po/bg_BG.po
po/ca_ES.po
po/cs_CZ.po
po/da_DK.po
po/de_DE.po
po/el_GR.po
po/en_GB.po
po/en_US.po
po/es_ES.po
po/et_EE.po
po/fi_FI.po
po/fr_CA.po
po/fr_FR.po
po/hr_HR.po
po/hu_HU.po
po/it_IT.po
po/ja_JP.po
po/ko_KR.po
po/lt_LT.po
po/lv_LV.po
po/nl_NL.po
po/no_NO.po
po/pl_PL.po
po/pt_BR.po
po/pt_PT.po
po/ro_RO.po
po/ru_RU.po
po/setup-station.pot
po/sk_SK.po
po/sl_SI.po
po/sv_SE.po
po/th_TH.po
po/tr_TR.po
po/vi_VN.po
po/zh_CN.po
po/zh_TW.po

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey - I've found 6 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="setup_station/network_setup.py" line_range="330" />
<code_context>
+            network: Access point record from scan_networks()
+            card: Name of the wireless network interface
+        """
+        threading.Thread(
             target=cls.try_to_connect_to_ssid,
-            args=(ssid_info[0], ssid_info, card),
</code_context>
<issue_to_address>
**Connection attempts interfere**

When the user selects another network before a connection worker finishes, `connect_in_background` starts another worker, and both workers change, reconfigure, or save the same supplicant state; an earlier attempt can disrupt the later one or publish or save a stale result, so the connection and saved configuration can disagree.

Serialize connection attempts or prevent further selections until the active worker finishes.

Also at `setup_station/network_setup.py:349-368`.
</issue_to_address>

### Comment 2
<location path="setup_station/network_setup.py" line_range="349" />
<code_context>
+        connected = connect_to_ssid(ssid, card) and wait_for_connection(card, ssid)
+        # select_network disabled every other saved network. Re-enable them
+        # before saving, or the file keeps them disabled for good.
+        enable_all_networks(card)
+        if connected:
+            saved = wpa_save_config(card)
</code_context>
<issue_to_address>
**Disabled networks become enabled**

When the wpa_supplicant configuration contains a network intentionally marked disabled and this connection succeeds, `enable_all_networks(card)` also enables profiles that were already disabled before this attempt, and the subsequent `wpa_save_config(card)` persists that change. Those networks can then auto-connect despite having been intentionally disabled.

Preserve each profile’s prior disabled state and re-enable only profiles disabled by this connection attempt before saving.
</issue_to_address>

### Comment 3
<location path="setup_station/network_setup.py" line_range="349-351" />
<code_context>
+        connected = connect_to_ssid(ssid, card) and wait_for_connection(card, ssid)
+        # select_network disabled every other saved network. Re-enable them
+        # before saving, or the file keeps them disabled for good.
+        enable_all_networks(card)
+        if connected:
+            saved = wpa_save_config(card)
+            GLib.idle_add(cls.connection_finished, network_dictionary(), ssid, saved)
         else:
</code_context>
<issue_to_address>
**Disabled profiles remain saved**

When re-enabling networks fails while the selected connection succeeds, `try_to_connect_to_ssid` ignores the result of `enable_all_networks` and still calls `wpa_save_config`, saving other networks as disabled and preventing them from reconnecting automatically after a restart.

Check whether `enable_all_networks` succeeded and avoid saving the configuration as successful when it did not.
</issue_to_address>

### Comment 4
<location path="setup_station/network_setup.py" line_range="315" />
<code_context>
+        if ssid_is_saved(ssid, card):
+            stored = update_psk_network(ssid, pwd, card)
+        else:
+            stored = save_psk_network(ssid, network['security'], pwd, card) is not None
+        if stored:
+            cls.connect_in_background(network, card)
</code_context>
<issue_to_address>
**WEP networks cannot connect**

When the selected access point uses WEP security, `wifi_setup` sends every non-open network through `save_psk_network`, which is the PSK credential path. WEP access points therefore cannot be saved or connected through this flow, even though the removed `setup_wpa_supplicant` code wrote WEP keys for networks that were neither RSN nor WPA.

Handle WEP with a supported WEP credential API, or clearly reject it rather than routing it through the PSK path.
</issue_to_address>

### Comment 5
<location path="setup_station/network_setup.py" line_range="255-257" />
<code_context>
+        Args:
+            wifi_card: Name of the wireless network interface
+        """
+        if wait_for_daemon(wifi_card) and request_scan(wifi_card):
+            sleep(SCAN_WAIT)
+        GLib.idle_add(cls.refresh_networks, scan_networks(wifi_card))
+
+    @classmethod
</code_context>
<issue_to_address>
**Access point list stays stale**

When the daemon is unavailable or scan results take longer than four seconds, `scan_and_refresh` can skip `request_scan` or read the table before it is updated, then publish that result without retrying; access points remain stale or absent until another page initialization.

Wait for the daemon and scan completion, or retry until fresh results are available before refreshing the list.
</issue_to_address>

### Comment 6
<location path="setup_station/network_setup.py" line_range="355" />
<code_context>
-                GLib.idle_add(cls.restart_authentication, ssid_info, card)
-        return
+            wpa_reconfigure(card)
+            GLib.idle_add(cls.restart_authentication, network, card)
+
+    @classmethod
</code_context>
<issue_to_address>
**Open-network failures go unnoticed**

When an open-network connection attempt fails, `try_to_connect_to_ssid` schedules `restart_authentication`, but that handler skips OPEN networks and no other failure handler updates the status; the user sees no failure indication and the page retains stale connection status.

Handle failed OPEN attempts by refreshing the status and showing a failure indication instead of relying on `restart_authentication`.

Also at `setup_station/network_setup.py:384-385`.
</issue_to_address>

Sourcery assessment

Needs a human reviewer. 6 findings to address first, and before saving a successful connection, the code enables every saved network and persists the supplicant configuration, including profiles a user may have deliberately disabled. Those networks could reconnect and expose traffic; reverting the code will not restore the prior saved settings or undo any exposure.

Blocking findings: setup_station/network_setup.py:330, setup_station/network_setup.py:349, setup_station/network_setup.py:351, setup_station/network_setup.py:315, setup_station/network_setup.py:257, and 1 more


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread setup_station/network_setup.py Resolved
Comment thread setup_station/network_setup.py Resolved
Comment thread setup_station/network_setup.py Resolved
Comment thread setup_station/network_setup.py Resolved
Comment thread setup_station/network_setup.py Resolved
Comment thread setup_station/network_setup.py Resolved
Both pages had the same connect code with diverging fixes. Copy
install-station's page, adjusted for setup-station's package and CSS
path, so setup-station gains the Rescan button, the WPA-Enterprise
dialog, the connection spinner and the locked list during an attempt.

This also addresses the review findings on overlapping connection
attempts, a stale access point list with no way to refresh it, and a
failed open network giving no feedback.
Add the strings from the new network page, fill every untranslated
string in all language files and replace the fuzzy guesses msgmerge
made, which are ignored at runtime and were often wrong. Existing
translations are kept. The files are now UTF-8, since their headers
declared ASCII.
@ericbsd
ericbsd merged commit c277882 into master Oct 17, 2026
1 check passed
@ericbsd
ericbsd deleted the port-networkmgr-api branch October 17, 2026 00:27
@github-project-automation github-project-automation Bot moved this from In Review to Done in Development Tracker Oct 17, 2026
@ericbsd ericbsd self-assigned this Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant