Skip to content

Comments

Integrate pulse metadata in station settings screen#314

Merged
pantelisss merged 9 commits intomainfrom
feature/fe-2006-integrate-pulse-metadata-in-station-settings-screen
Oct 3, 2025
Merged

Integrate pulse metadata in station settings screen#314
pantelisss merged 9 commits intomainfrom
feature/fe-2006-integrate-pulse-metadata-in-station-settings-screen

Conversation

@pantelisss
Copy link
Collaborator

@pantelisss pantelisss commented Oct 2, 2025

Why?

Pulse data in device settings

How?

  • Updated API models
  • Added more fields to show in the device info

Testing

Play with mock json (get_device_info_pulse) and ensure everything is rendered as expected

Additional context

fixes fe-2006

Summary by CodeRabbit

  • New Features

    • Device Info surfaces richer Pulse details: GSM signal, gateway frequency (MHz), external SIM/ICCID, MCC/MNC, gateway battery, gateway↔station signals, next server communication, and station ID.
    • Sections and share text now adapt to device connectivity (Wi‑Fi, Helium, Cellular).
  • Bug Fixes / Improvements

    • Contextual warnings refined, including a gateway low‑battery message and a Pulse troubleshooting link.
    • Backend/device payload parsing extended to return new gateway/station fields.
  • Tests / Mocks

    • Added a Pulse device mock fixture and updated tests to expect the troubleshooting link.
  • Localization

    • Added localized labels for all new fields and a MHz unit.

@coderabbitai
Copy link

coderabbitai bot commented Oct 2, 2025

Walkthrough

Adds a Pulse troubleshooting link and routes Pulse devices to it. Expands Device Info for Pulse (cellular) with new InfoField cases, gateway/station properties, warnings, localizations, mock fixture, and project resource wiring. Updates mock mapping and tests accordingly.

Changes

Cohort / File(s) Summary
Links & DeviceDetails
PresentationLayer/Constants/Strings/DisplayedLinks.swift, PresentationLayer/Extensions/DomainExtensions/DeviceDetails+.swift, WeatherXMTests/PresentationLayer/Extensions/DomainExtensions/DeviceDetailsTests.swift
Adds DisplayedLinks.pulseTroubleshooting and its URL; DeviceDetails.troubleShootingUrl returns that URL for .pulse; updates test expectation to match.
Device Info UI (view + factory + content)
PresentationLayer/UIComponents/Screens/DeviceInfo/DeviceInfoFactory.swift, PresentationLayer/UIComponents/Screens/DeviceInfo/DeviceInfoViewModel+Content.swift, PresentationLayer/UIComponents/Screens/DeviceInfo/DeviceInfoViewModel.swift
Replaces helium-vs-wifi logic with connectivity-based branching (.wifi/.helium/.cellular/nil); adds many InfoField cases (gsmSignal, gwFrequency, externalSim, iccid, mobileCountryCode, gwBatteryState, signalGwStation, nextServerCommunication, stationId, signalStationGw); implements titles/values/warnings, groupings for Pulse (gateway/station), share text, and button handling; updates warning helper signatures.
Domain models & types
wxm-ios/DomainLayer/DomainLayer/Entities/Codables/Devices/NetworkDevicesInfoResponse.swift, wxm-ios/DomainLayer/DomainLayer/Entities/Codables/Devices/NetworkDevicesTypes.swift
Extends Gateway with networkRssi, networkRssiLastActivity, gatewayRssi, gatewayRssiLastActivity, batState, frequency, nextCommunication, sim; adds Sim struct (mcc, mnc, iccid); adds WeatherStation.stationId; updates coding keys and decoding.
Mocks & project resources
wxm-ios/DataLayer/DataLayer/Networking/Mock/Jsons/get_device_info_pulse.json, wxm-ios/DataLayer/DataLayer/Networking/ApiRequestBuilders/MeApiRequestBuilder.swift, wxm-ios/DataLayer/DataLayer.xcodeproj/project.pbxproj
Adds get_device_info_pulse.json fixture, updates mock mapping to use it, and includes the JSON in the Xcode project/resource lists.
Localizations & units
wxm-ios/Resources/Localizable/Localizable.xcstrings, wxm-ios/Resources/Localizable/LocalizableString+DeviceInfo.swift, wxm-ios/Resources/Localizable/LocalizableString+Units.swift, wxm-ios/Resources/Localizable/LocalizableUnits.xcstrings
Adds localized keys/strings for new device info fields and gateway low-battery markdown; adds .mhz unit and units_mhz localization; adds composite MCC/MNC and “is in use” strings.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant View as DeviceInfoViewModel
  participant Factory as DeviceInfoFactory
  participant Device as DeviceDetails
  participant Domain as NetworkDevicesInfoResponse
  participant L10n as LocalizableString

  User->>View: Open Device Info
  View->>Device: read bundle?.connectivity
  alt connectivity = wifi/helium/cellular
    View->>View: select InfoField groups (includes pulse gateway/station groups)
  else nil
    View->>View: empty sections
  end
  loop each InfoField
    View->>Factory: request title/value/warning(field, device, domain)
    Factory->>Domain: read gateway/station props (rssi/sim/frequency/nextCommunication/stationId/batState)
    Factory->>L10n: format strings (units, MCC/MNC, "is in use")
    alt warning needed
      Factory-->>View: CardWarningConfiguration (may reference Device.troubleShootingUrl)
    else value only
      Factory-->>View: formatted value
    end
  end
  View-->>User: render sections, share text, buttons
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested reviewers

  • PavlosTze

Poem

Hop hop, a Pulse link lights the trail,
New fields twitch like whiskers in the gale.
MHz hums, SIMs chatter with glee,
Gateways yodel, stations gossip free.
Troubleshoot stitched — carrots and code for tea. 🥕✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title clearly summarizes the primary change by specifying the integration of pulse metadata into the station settings screen, which matches the pull request’s focus on adding pulse data to device settings. It is concise, descriptive, and avoids extraneous details, allowing a teammate to understand the main update at a glance.
Description Check ✅ Passed The description follows the repository template by including the Why, How, Testing, and Additional context sections, clearly outlining the motivation, implementation steps, and verification process using the mock JSON. It succinctly explains the changes without requiring optional screenshots for non-visual updates. Overall, the content is complete and aligns with the required structure.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/fe-2006-integrate-pulse-metadata-in-station-settings-screen

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ab493e5 and 25f30e5.

📒 Files selected for processing (1)
  • wxm-ios/Resources/Localizable/Localizable.xcstrings (6 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • wxm-ios/Resources/Localizable/Localizable.xcstrings
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: WeatherXM | Unit tests | wxm-ios - iOS

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@pantelisss pantelisss requested a review from PavlosTze October 2, 2025 15:27
Base automatically changed from feature/fe-2004-integrate-pulse-metadata-in-stations-list-and-details to main October 3, 2025 08:34
@pantelisss pantelisss force-pushed the feature/fe-2006-integrate-pulse-metadata-in-station-settings-screen branch from a04317a to 7265239 Compare October 3, 2025 08:37
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 23b4f26 and 7265239.

📒 Files selected for processing (14)
  • PresentationLayer/Constants/Strings/DisplayedLinks.swift (2 hunks)
  • PresentationLayer/Extensions/DomainExtensions/DeviceDetails+.swift (1 hunks)
  • PresentationLayer/UIComponents/Screens/DeviceInfo/DeviceInfoFactory.swift (8 hunks)
  • PresentationLayer/UIComponents/Screens/DeviceInfo/DeviceInfoViewModel+Content.swift (3 hunks)
  • PresentationLayer/UIComponents/Screens/DeviceInfo/DeviceInfoViewModel.swift (2 hunks)
  • wxm-ios/DataLayer/DataLayer.xcodeproj/project.pbxproj (4 hunks)
  • wxm-ios/DataLayer/DataLayer/Networking/ApiRequestBuilders/MeApiRequestBuilder.swift (1 hunks)
  • wxm-ios/DataLayer/DataLayer/Networking/Mock/Jsons/get_device_info_pulse.json (1 hunks)
  • wxm-ios/DomainLayer/DomainLayer/Entities/Codables/Devices/NetworkDevicesInfoResponse.swift (5 hunks)
  • wxm-ios/DomainLayer/DomainLayer/Entities/Codables/Devices/NetworkDevicesTypes.swift (1 hunks)
  • wxm-ios/Resources/Localizable/Localizable.xcstrings (6 hunks)
  • wxm-ios/Resources/Localizable/LocalizableString+DeviceInfo.swift (5 hunks)
  • wxm-ios/Resources/Localizable/LocalizableString+Units.swift (2 hunks)
  • wxm-ios/Resources/Localizable/LocalizableUnits.xcstrings (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
PresentationLayer/UIComponents/Screens/DeviceInfo/DeviceInfoFactory.swift (1)
WeatherXMTests/PresentationLayer/Extensions/DomainExtensions/DeviceDetailsTests.swift (1)
  • troubleShootingUrl (36-49)
🔇 Additional comments (10)
PresentationLayer/Constants/Strings/DisplayedLinks.swift (2)

27-27: LGTM!

The new enum case follows existing naming conventions and aligns with the pattern for other device troubleshooting links.


78-79: LGTM!

The URL follows the established pattern for device troubleshooting documentation and is correctly mapped to the new enum case.

PresentationLayer/Extensions/DomainExtensions/DeviceDetails+.swift (1)

54-55: LGTM!

The change correctly routes Pulse devices to the new troubleshooting URL, maintaining consistency with other device types.

wxm-ios/DataLayer/DataLayer.xcodeproj/project.pbxproj (1)

81-81: LGTM!

The project file changes correctly integrate the new mock JSON resource into the build system.

Also applies to: 187-187, 269-269, 604-604

wxm-ios/Resources/Localizable/LocalizableUnits.xcstrings (1)

268-278: LGTM!

The new MHz unit localization follows the established pattern and supports the new gateway frequency field.

wxm-ios/Resources/Localizable/LocalizableString+Units.swift (1)

43-43: LGTM!

The new MHz enum case and its localization key mapping are correctly implemented and align with the localization resource.

Also applies to: 117-118

wxm-ios/DomainLayer/DomainLayer/Entities/Codables/Devices/NetworkDevicesTypes.swift (1)

112-116: LGTM!

The new Sim struct is cleanly implemented with appropriate optionality for SIM card metadata (MCC, MNC, ICCID).

PresentationLayer/UIComponents/Screens/DeviceInfo/DeviceInfoViewModel.swift (2)

74-89: LGTM!

The switch to a connectivity-based switch statement improves clarity and extensibility. The cellular case correctly routes to pulse-specific field sets.


327-346: LGTM!

The new InfoField cases are appropriately handled with no-op implementations, consistent with other fields that don't require button actions.

wxm-ios/DataLayer/DataLayer/Networking/ApiRequestBuilders/MeApiRequestBuilder.swift (1)

213-214: Verify tests and fixtures for getUserDeviceInfoById
Ensure any tests or mock fixtures expecting M5 device data are updated for the new get_device_info_pulse endpoint and that a corresponding get_device_info_pulse.json (or equivalent) exists.

Comment on lines +17 to +18
"gps_sats_last_activity": "2025-10-01T14:25:44+03:00",
"wifi_rssi_last_activity": "2025-10-01T14:25:44+03:00",
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Fix gateway GPS activity key mismatch. The mock uses gps_sats_last_activity, but the updated models decode gpsRssiLastActivity (JSON key gps_rssi_last_activity). This typo breaks decoding for the GPS activity timestamp when the mock feeds the UI, causing the new Pulse fields to appear empty. Rename the key to gps_rssi_last_activity so it matches the rest of the PR.

🤖 Prompt for AI Agents
In wxm-ios/DataLayer/DataLayer/Networking/Mock/Jsons/get_device_info_pulse.json
around lines 17 to 18, the mock JSON uses the incorrect key
"gps_sats_last_activity"; rename this key to "gps_rssi_last_activity" to match
the model's expected JSON key (gps_rssi_last_activity) so the decoder binds the
GPS RSSI activity timestamp correctly and the Pulse fields are populated in the
UI.

Comment on lines +97 to 104
self.networkRssiLastActivity = try container.decodeIfPresent(Date.self, forKey: .networkRssiLastActivity)
self.gatewayRssi = try container.decodeIfPresent(Int.self, forKey: .gatewayRssi)
self.gatewayRssiLastActivity = try container.decodeIfPresent(Date.self, forKey: .gatewayRssiLastActivity)
self.batState = try container.decodeIfPresent(BatteryState.self, forKey: .batState)
self.frequency = try container.decodeIfPresent(String.self, forKey: .frequency)
self.nextCommunication = try container.decodeIfPresent(Date.self, forKey: .nextCommunication)
self.sim = try container.decodeIfPresent(Sim.self, forKey: .sim)
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Ensure backend delivers numeric RSSI values.

We now decode network_rssi and gateway_rssi as Int, but previous RSSI fields were strings. If the API still emits stringified RSSI (as it did for wifi_rssi), decoding will fail and drop the whole gateway payload. Please double-check the contract or adjust to accept strings. Let me know if you want a quick patch that tolerates both.

🤖 Prompt for AI Agents
In
wxm-ios/DomainLayer/DomainLayer/Entities/Codables/Devices/NetworkDevicesInfoResponse.swift
around lines 97 to 104, decoding of networkRssi and gatewayRssi currently
assumes Int and will fail if the backend emits stringified numeric RSSI; update
the decoder to tolerate both numeric and string RSSI by attempting to decode an
Int first and, if that fails, decode a String and convert it to Int (or nil on
conversion failure), or alternatively decode as String and parse to Int with a
numeric fallback — apply this pattern to both networkRssi and gatewayRssi so
malformed types won't drop the whole payload.

@weatherxmdev
Copy link
Collaborator

Code Coverage Summary

Framework Source Files Coverage
DataLayer.framework 48 65.25%
DomainLayer.framework 66 83.38%
Toolkit.framework 30 53.18%
WeatherXM.app 403 14.06%
station-intent.appex 2 83.04%
station-widgetExtension.appex 45 33.79%

@weatherxmdev
Copy link
Collaborator

Code Coverage Summary

Framework Source Files Coverage
DataLayer.framework 48 65.25%
DomainLayer.framework 66 83.38%
Toolkit.framework 30 53.18%
WeatherXM.app 403 14.06%
station-intent.appex 2 83.04%
station-widgetExtension.appex 45 34.04%

@pantelisss pantelisss merged commit b905494 into main Oct 3, 2025
4 checks passed
@pantelisss pantelisss deleted the feature/fe-2006-integrate-pulse-metadata-in-station-settings-screen branch October 3, 2025 12:25
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.

3 participants