Skip to content

feat(network): NetworkManager refactor and NetworkControlWindow rewrite#182

Open
gmmcosta15 wants to merge 2 commits intodevfrom
ref/network_window
Open

feat(network): NetworkManager refactor and NetworkControlWindow rewrite#182
gmmcosta15 wants to merge 2 commits intodevfrom
ref/network_window

Conversation

@gmmcosta15
Copy link
Collaborator

@gmmcosta15 gmmcosta15 commented Feb 27, 2026

Description

Select the type:

  • Feature
  • Bug fix
  • Code refactor
  • Documentation

This PR delivers a complete refactor of the NetworkManager subsystem and the
NetworkControlWindow, replacing the monolithic lib/network.py with a clean
manager/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.pyNetworkManager(QObject): main-thread-safe
    interface. Submits coroutines to the worker's asyncio loop; emits pyqtSignal
    for 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.pyNetworkManagerWorker: daemon thread owning the
    asyncio 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.pyNetworkControlWindow rewritten against the
    manager API: hidden network page, VLAN/DHCP flow, network priority management,
    hotspot QR code, update page.
  • lib/panels/mainWindow.py — wired to the new NetworkManager.
  • lib/qrcode_gen.py — updated to accept hotspot SSID/password/security.
  • configfile.py — added edit_option / get_option helpers for
    BlocksScreen.cfg (used by hotspot persistence).
  • SVG icons reorganised from btn_icons/ into btn_icons/network/; added
    ethernet_connected.svg and static_ip.svg; removed internet_cable.svg
    from the top-bar resources.
  • lib/ui/wifiConnectivityWindow.ui and wifiConnectivityWindow_ui.py — deleted
    (replaced by the new window implementation).
  • list_model.py refactored 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 — updated
    dependencies.
  • 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 for list_model and qrcode_gen.

Motivation

The original lib/network.py (≈1 550 lines) mixed D-Bus I/O, Qt signal
emission, threading concerns, and business logic in a single file, making it
hard to test, maintain, and extend. The new architecture separates concerns
strictly:

  • Testability: the manager and worker can be tested in isolation with mock
    D-Bus proxies — no real NetworkManager required for unit tests.
  • Thread safety: all D-Bus work runs on the asyncio thread; all Qt widget
    updates run on the main thread via queued pyqtSignal delivery.
  • Reliability: signal-reactive model (no polling) with debounce; keepalive
    timer guards against missed D-Bus signals; connection timeout increased to 20 s
    to handle WPA3/Nokia routers.
  • Hotspot persistence (from PR Feat/hotspot qrcode #168 and PR Feature hotspot config file #178): SSID and password survive
    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-missingmanager.py at 100 %.
  • Integration tests (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

@gmmcosta15 gmmcosta15 added enhancement New feature or request. MajorUpdate An update that introduces major changes overall codeto the labels Feb 27, 2026
@gmmcosta15 gmmcosta15 self-assigned this Feb 27, 2026
@gmmcosta15 gmmcosta15 added enhancement New feature or request. MajorUpdate An update that introduces major changes overall codeto the Refactor Enhancing code's readability, maintainability, and extensibility while addressing technical debt. labels Feb 27, 2026
@gmmcosta15 gmmcosta15 requested a review from HugoCLSC February 27, 2026 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request. MajorUpdate An update that introduces major changes overall codeto the Refactor Enhancing code's readability, maintainability, and extensibility while addressing technical debt.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant