feat(network): NetworkManager refactor and NetworkControlWindow rewrite#182
Open
gmmcosta15 wants to merge 2 commits intodevfrom
Open
feat(network): NetworkManager refactor and NetworkControlWindow
rewrite#182gmmcosta15 wants to merge 2 commits intodevfrom
gmmcosta15 wants to merge 2 commits intodevfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Select the type:
This PR delivers a complete refactor of the NetworkManager subsystem and the
NetworkControlWindow, replacing the monolithiclib/network.pywith a cleanmanager/worker architecture. It also incorporates all changes from PR #168
(hotspot QR code) and PR #178 (hotspot config file persistence), which were
never merged to
dev.lib/network/manager.py—NetworkManager(QObject): main-thread-safeinterface. Submits coroutines to the worker's asyncio loop; emits
pyqtSignalfor state, scan results, connection outcome, connectivity, hotspot config, and
errors. Includes a 5-minute keepalive timer as a safety net for missed D-Bus
signals.
lib/network/worker.py—NetworkManagerWorker: daemon thread owning theasyncio loop and D-Bus connection. Signal-reactive (no polling); 0.8 s debounce
for rapid NM signal bursts.
lib/network/models.py— frozen dataclasses and enums:NetworkInfo,SavedNetwork,NetworkState,ConnectivityState,SecurityType,HotspotConfig,VlanInfo,ConnectionPriority, etc.lib/panels/networkWindow.py—NetworkControlWindowrewritten against themanager API: hidden network page, VLAN/DHCP flow, network priority management,
hotspot QR code, update page.
lib/panels/mainWindow.py— wired to the newNetworkManager.lib/qrcode_gen.py— updated to accept hotspot SSID/password/security.configfile.py— addededit_option/get_optionhelpers forBlocksScreen.cfg(used by hotspot persistence).btn_icons/intobtn_icons/network/; addedethernet_connected.svgandstatic_ip.svg; removedinternet_cable.svgfrom the top-bar resources.
lib/ui/wifiConnectivityWindow.uiandwifiConnectivityWindow_ui.py— deleted(replaced by the new window implementation).
list_model.pyrefactored for the new network list view.pytest.ini— added project-wide pytest configuration (qt_api=pyqt6,asyncio_mode=auto, integration marker gating).scripts/requirements.txt/scripts/requirements-dev.txt— updateddependencies.
tests/network/— unit tests for manager (72 tests, 100 % coverage), worker,models, and a gated sdbus integration test suite; UI tests for
NetworkControlWindow.tests/util/— unit tests forlist_modelandqrcode_gen.Motivation
The original
lib/network.py(≈1 550 lines) mixed D-Bus I/O, Qt signalemission, threading concerns, and business logic in a single file, making it
hard to test, maintain, and extend. The new architecture separates concerns
strictly:
D-Bus proxies — no real NetworkManager required for unit tests.
updates run on the main thread via queued
pyqtSignaldelivery.timer guards against missed D-Bus signals; connection timeout increased to 20 s
to handle WPA3/Nokia routers.
reboots via
BlocksScreen.cfg; QR code displayed on the hotspot panel.Tests
pytest tests/network/— unit + UI tests, all pass.python -m pytest tests/network/test_manager_unit.py --cov=BlocksScreen.lib.network.manager --cov-report=term-missing—manager.pyat 100 %.NM_INTEGRATION_TESTS=1 pytest -m integration tests/network/)require a real NetworkManager and are excluded from CI by default.
Test configuration:
pytest.ini,qt_api=pyqt6,asyncio_mode=auto,QT_QPA_PLATFORM=offscreen.Co-Authors
Co-author: @Robert0Mart