Devices and Dashboard related service extraction - #537
Conversation
- Create DeviceManagerService at lib/core/jnap/services/device_manager_service.dart - Move transformPollingData (formerly createState) with all helper methods - Move updateDeviceNameAndIcon, deleteDevices, deauthClient operations - Add ServiceError mapping for JNAP errors - Improve type safety with explicit JNAPSuccess checks - Refactor DeviceManagerNotifier to delegate to service - Remove all JNAP model/result/action imports (architecture compliance) - build() now delegates to service.transformPollingData() - All write operations delegate to service methods - Keep state query methods (getSsidConnectedBy, getBandConnectedBy, findParent) - Add comprehensive test coverage - Service tests: transformPollingData, updateDeviceNameAndIcon, deleteDevices, deauthClient - Provider tests: verify delegation to service - State tests: LinksysDevice, DeviceManagerState, WifiConnectionType - Test data builder: DeviceManagerTestData with JNAP response factories - Update implementation checklist and tasks.md
…hboardManagerNotifier - Create DashboardManagerService to handle all JNAP communication - transformPollingData(): transforms CoreTransactionData to DashboardManagerState - checkRouterIsBack(): verifies router connectivity and serial number matching - checkDeviceInfo(): fetches device info with cache-first strategy - Refactor DashboardManagerProvider to delegate to service - Remove direct JNAP imports (actions, result, models) - Simplify build() to call service.transformPollingData() - Update checkRouterIsBack() and checkDeviceInfo() to use service - Add new ServiceError types for router operations - SerialNumberMismatchError: router SN doesn't match expected - ConnectivityError: router is unreachable - Add comprehensive test coverage (41 tests) - DashboardManagerService tests (15): transformPollingData, checkRouterIsBack, checkDeviceInfo - DashboardManagerProvider tests (9): delegation verification - DashboardManagerState tests (17): default values, equality, serialization - Add DashboardManagerTestData builder for test data generation - Add feature spec documentation - Service contract with method signatures - Data model flow diagrams - Implementation plan and tasks
…HomeNotifier - Extract transformation logic to DashboardHomeService for three-layer architecture compliance - Remove JNAP model imports from provider and state files (RadioInfo, GuestRadioSettings) - Rename UI model classes per Constitution Article III Section 3.3.4: - DashboardSpeedItem → DashboardSpeedUIModel - DashboardWiFiItem → DashboardWiFiUIModel - Move factory methods from DashboardWiFiUIModel to service layer - Add comprehensive unit tests (72 tests total): - dashboard_home_service_test.dart (15 tests) - dashboard_home_state_test.dart (49 tests) - dashboard_home_provider_test.dart (8 tests) - Create test data builder: DashboardHomeTestData - Add specs documentation for feature 006
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
|||||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
||||||||||||||||||||||||
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
User description
PR Type
Enhancement, Tests
Description
Service Layer Extraction for Dashboard and Device Management
Extracted transformation logic to three new service classes (
DashboardHomeService,DashboardManagerService,DeviceManagerService) for three-layer architecture complianceRemoved JNAP model imports from provider and state files, isolating JNAP communication to service layer only
Renamed UI model classes per Constitution Article III Section 3.3.4:
DashboardSpeedItem→DashboardSpeedUIModelDashboardWiFiItem→DashboardWiFiUIModelMoved factory methods from UI models to service layer for proper separation of concerns
Created
DashboardManagerServicewith polling data transformation, router connectivity checks (checkRouterIsBack()), and device info retrieval with cache-first strategyCreated
DeviceManagerServicewith JNAP communication isolation for device operations (update, delete, deauthenticate)Created
DashboardHomeServiceorchestrating WiFi list building, node status detection, and UI state compositionAdded new
ServiceErrortypes:SerialNumberMismatchErrorandConnectivityErrorfor router operationsRefactored three providers (
DashboardHomeNotifier,DashboardManagerNotifier,DeviceManagerNotifier) to delegate to service layerAdded comprehensive test coverage: 72 tests total across service, provider, and state layers
Created test data builders (
DashboardHomeTestData,DashboardManagerTestData,DeviceManagerTestData) with JNAP response factoriesCreated detailed feature specifications, task breakdowns, service contracts, and implementation guides for all three service extractions
Diagram Walkthrough
File Walkthrough
12 files
dashboard_home_state_test.dart
Dashboard home state model comprehensive unit teststest/page/dashboard/providers/dashboard_home_state_test.dart
DashboardSpeedUIModelcoveringconstruction, copyWith, equality, and serialization
(toMap/fromMap/toJson/fromJson)
DashboardWiFiUIModelwith all fieldvariations and state transitions
DashboardHomeStateincluding defaults,copyWith operations, and round-trip serialization
DashboardHomeStateExtcoveringmainSSIDandisBridgeModecomputed propertiesdevice_manager_test_data.dart
Device manager test data builder with JNAP factoriestest/mocks/test_data/device_manager_test_data.dart
(
createGetDevicesSuccess,createGetNetworkConnectionsSuccess, etc.)createCompletePollingData()withcustomizable parameters
createMasterDevice(),createSlaveDevice(),createExternalDevice()errors)
createJnapError()device_manager_state_test.dart
Device manager state model comprehensive unit teststest/core/jnap/providers/device_manager_state_test.dart
LinksysDevicefromMap/toMap conversion, copyWith, andcomputed properties (
isMaster)DeviceManagerStateconstruction, copyWith, and computedproperties (
nodeDevices,externalDevices,mainWifiDevices,guestWifiDevices,masterDevice,slaveDevices)devices
WifiConnectionTypeenum valuesdashboard_home_test_data.dart
Dashboard home test data builder with state factoriestest/mocks/test_data/dashboard_home_test_data.dart
DashboardManagerStatewith default andcustom values
DeviceManagerStatewith variousconfigurations
RouterRadiobuilder supporting customizable radio parameters (band,SSID, passphrase)
GuestRadioInfobuilder for guest network testingcreateMasterDevice(),createSlaveDevice(),createMainWifiDevice(),createGuestWifiDevice()NodeDeviceInfo,RouterWANStatus, and bandcallback functions
dashboard_home_service_test.dart
Dashboard home service transformation logic unit teststest/page/dashboard/services/dashboard_home_service_test.dart
DashboardHomeService.buildDashboardHomeState()methodoffline detection, and first polling state
layout determination, and master icon selection
dashboard_manager_state_test.dart
Dashboard manager state model unit teststest/core/jnap/providers/dashboard_manager_state_test.dart
DashboardManagerStatecovering default values,equality, copyWith, and serialization
round-trip serialization
dashboard_manager_service_test.dart
Dashboard manager service JNAP communication teststest/core/jnap/services/dashboard_manager_service_test.dart
DashboardManagerServicecovering datatransformation and router connectivity checks
transformPollingData()handles complete/partial/nullpolling data correctly
checkRouterIsBack()serial number matching and errorhandling
checkDeviceInfo()cache-first strategy and API fallbackbehavior
dashboard_home_provider_test.dart
Dashboard home provider delegation teststest/page/dashboard/providers/dashboard_home_provider_test.dart
DashboardHomeNotifierverifying delegation toservice layer
dashboardManagerProvideranddeviceManagerProviderto servicecorrect state propagation
dashboard_manager_provider_test.dart
Dashboard manager provider service delegation teststest/core/jnap/providers/dashboard_manager_provider_test.dart
DashboardManagerNotifierverifying servicedelegation pattern
transformPollingData()delegation,checkRouterIsBack()error propagation, and
checkDeviceInfo()cachingSerialNumberMismatchErrorandConnectivityErrordashboard_manager_test_data.dart
Dashboard manager test data factory builderstest/mocks/test_data/dashboard_manager_test_data.dart
mock responses
createDeviceInfoSuccess(),createRadioInfoSuccess(), etc.)data scenarios
device_manager_provider_test.dart
Device manager provider service delegation teststest/core/jnap/providers/device_manager_provider_test.dart
DeviceManagerNotifierverifying delegation toDeviceManagerServicetransformPollingData(),updateDeviceNameAndIcon(),deleteDevices(), anddeauthClient()delegationlayer
device_manager_service_test.dart
Device manager service data transformation teststest/core/jnap/services/device_manager_service_test.dart
DeviceManagerService.transformPollingData()method
wireless connection mapping
9 files
device_manager_provider.dart
Device manager provider refactored to service delegationlib/core/jnap/providers/device_manager_provider.dart
architecture compliance
build()method to delegate toDeviceManagerService.transformPollingData()updateDeviceNameAndIcon()to call service and update localstate
deleteDevices()anddeauthClient()to delegate to servicelayer
createState()and all helper methods (_getWirelessConnections,_getDeviceListAndLocations, etc.)getSsidConnectedBy,getBandConnectedBy,findParent)device_manager_service.dart
Device manager service layer with JNAP isolationlib/core/jnap/services/device_manager_service.dart
transformation logic
transformPollingData()method convertsCoreTransactionDatatoDeviceManagerStatewith safe result extractionstatus, and backhaul info processing
updateDeviceNameAndIcon()operation with property updates and devicelist refresh
deleteDevices()anddeauthClient()write operations with error mappingServiceErrortypes for consistent error handlingdashboard_manager_service.dart
Dashboard manager service layer with router connectivity checkslib/core/jnap/services/dashboard_manager_service.dart
isolation
transformPollingData()method extracts and transforms device info,radio settings, system stats, and ethernet port connections
_getMainRadioList()and_getGuestRadioList()for radiodata extraction
checkRouterIsBack()method verifying router connectivity and serialnumber matching with
SerialNumberMismatchErrorandConnectivityErrorhandling
checkDeviceInfo()method with cache-first strategy for deviceinformation retrieval
ServiceErrortypes for consistent error handlingdashboard_manager_provider.dart
Dashboard manager provider service extraction refactorlib/core/jnap/providers/dashboard_manager_provider.dart
DashboardManagerNotifier.build()to delegate toDashboardManagerService.transformPollingData()createState()methodand helpers)
checkRouterIsBack()andcheckDeviceInfo()to delegate toservice methods
dashboard_home_state.dart
UI model class renaming per constitution compliancelib/page/dashboard/providers/dashboard_home_state.dart
DashboardSpeedItemtoDashboardSpeedUIModelper ConstitutionArticle III Section 3.3.4
DashboardWiFiItemtoDashboardWiFiUIModelper ConstitutionArticle III Section 3.3.4
fromMainRadios()andfromGuestRadios()fromDashboardWiFiUIModel(moved to service)names
dashboard_home_service.dart
Dashboard home service extraction with transformation logiclib/page/dashboard/services/dashboard_home_service.dart
DashboardHomeServiceclass encapsulating dashboard statetransformation logic
buildDashboardHomeState()orchestrating WiFi listbuilding, node status detection, and icon/layout determination
DashboardWiFiUIModelto private servicemethods
_createWiFiItemFromMainRadios()and_createWiFiItemFromGuestRadios()dashboardHomeServiceProviderfor dependencyinjection
dashboard_home_provider.dart
Dashboard home provider service extraction refactorlib/page/dashboard/providers/dashboard_home_provider.dart
DashboardHomeNotifier.build()to delegate toDashboardHomeService.buildDashboardHomeState()createState()methodstate
deviceManagerState, getBandForDevice callback) to service
service_error.dart
New service error types for router operationslib/core/errors/service_error.dart
SerialNumberMismatchErrorfor router serial number validationfailures
ConnectivityErrorfor router unreachability scenariosServiceErrorbase class for consistent errorhandling
wifi_grid.dart
WiFi grid component type reference updatelib/page/dashboard/views/components/wifi_grid.dart
WiFiCardwidget to use renamedDashboardWiFiUIModeltypeinstead of
DashboardWiFiItem17 files
spec.md
Device manager service extraction feature specificationspecs/001-device-manager-service-extraction/spec.md
extraction
and edge cases
updates, deletion, and deauthentication
documentation
tasks.md
Dashboard Manager Service Extraction Task Breakdownspecs/005-dashboard-service-extraction/tasks.md
extraction with 80 tasks organized into 7 phases
for polling data transformation, router connectivity, device info
retrieval, and provider refactoring
MVP-first implementation strategy
coverage requirements (≥90% service, ≥85% provider)
tasks.md
Device Manager Service Extraction Task Completion Recordspecs/001-device-manager-service-extraction/tasks.md
Service extraction
opportunities identified
order
tasks.md
DashboardHome Service Extraction Task Breakdownspecs/006-dashboard-home-service-extraction/tasks.md
tasks across 5 phases
Service Layer Testability (P2)
tasks with exact file paths
dashboard_manager_service_contract.md
Dashboard Manager Service Contract Definitionspecs/005-dashboard-service-extraction/contracts/dashboard_manager_service_contract.md
DashboardManagerServicewith three publicmethods:
transformPollingData(),checkRouterIsBack(),checkDeviceInfo()handling with
ServiceErrortypesspec.md
Dashboard Manager Service Feature Specificationspecs/005-dashboard-service-extraction/spec.md
data transformation, router connectivity, device info retrieval, and
provider architecture compliance
criteria (SC-001 through SC-005)
state management
coverage
device_manager_service_contract.md
Device Manager Service Contract Definitionspecs/001-device-manager-service-extraction/contracts/device_manager_service_contract.md
DeviceManagerServicewith four publicmethods for data transformation and write operations
patterns
transformPollingData(),updateDeviceNameAndIcon(),deleteDevices(), anddeauthClient()compliance
research.md
Device Manager Service Extraction Research Findingsspecs/001-device-manager-service-extraction/research.md
with rationale and alternatives considered
lib/core/jnap/services/), state classlocation, JNAP model handling, and helper method placement
constitution requirements
ref.read()pattern
dashboard_home_service_contract.md
Dashboard Home Service Contract Definitionspecs/006-dashboard-home-service-extraction/contracts/dashboard_home_service_contract.md
DashboardHomeServicewith single publicmethod
buildDashboardHomeState()checking, and icon/layout determination
edge case handling
specifications
data-model.md
Dashboard Home Service Data Model Documentationspecs/006-dashboard-home-service-extraction/data-model.md
DashboardHomeState,DashboardWiFiUIModel,DashboardSpeedUIModel) with no structuralchanges
DashboardManagerState,DeviceManagerState) consumed by servicethrough service to UI layer
quickstart.md
Dashboard Manager Service Extraction Quickstart Guidespecs/005-dashboard-service-extraction/quickstart.md
Service extraction
through architecture compliance verification
error type additions
data-model.md
Dashboard Manager Service Data Model Documentationspecs/005-dashboard-service-extraction/data-model.md
DashboardManagerStateentity with no structuralchanges required
NodeDeviceInfo,RouterRadio,GuestRadioInfo,SoftSKUSettingsinsertion between polling and provider
fields
spec.md
Dashboard Home Service Feature Specificationspecs/006-dashboard-home-service-extraction/spec.md
Compliance Refactoring (P1) and Service Layer Testability (P2)
creation and provider/state refactoring
layer and ≥90% test coverage
quickstart.md
Dashboard Home Service Extraction Quickstart Guidespecs/006-dashboard-home-service-extraction/quickstart.md
extraction
through state file refactoring
test data builder setup
quickstart.md
Device Manager Service Extraction Quickstart Guidespecs/001-device-manager-service-extraction/quickstart.md
extraction
requirements
and import removal
service-contract.md
Dashboard Home Service Contract Quality Checklistspecs/006-dashboard-home-service-extraction/checklists/service-contract.md
items across 7 categories
changes prevention, clarity, and consistency
validation
plan.md
Dashboard Home Service Extraction Implementation Planspecs/006-dashboard-home-service-extraction/plan.md
compliance check, and project structure
code and tests
VIII, IX, XI) with pass status
moved)
9 files