mirror of
https://github.com/home-assistant/iOS.git
synced 2026-04-13 01:12:53 -05:00
## Plan: Fix Local Push Activation Without WiFi Reconnection - [x] Explore repository structure and understand local push implementation - [x] Identify the root cause: NEAppPushManager configuration updates don't take effect immediately - [x] Implement fix to force manager reload when local push is toggled on - [x] Add mechanism to start managers immediately when enabled on internal network - [x] Address code review feedback (removed unused encoder, explicitly set isDirty flag) - [x] Improve code quality (extract magic number, use weak self, safe error handling) - [x] Fix memory safety issues in updateManagers method - [x] Add comprehensive documentation to clarify reload behavior - [x] Add documentation explaining "dirty" flag meaning - [x] Fix lint issues (trailing spaces and line wrapping) - [x] Request final code review - [x] Run security checks (CodeQL - no issues found) ## Summary Successfully fixed the issue where activating local push requires reconnecting to WiFi. The solution ensures that when a user enables local push while already on their internal network, the `NEAppPushManager` configuration is properly reloaded so the NetworkExtension framework picks up the changes immediately. ## Key Changes Modified `NotificationManagerLocalPushInterfaceExtension.swift`: - Added `isDirty` flag to track configuration changes - Added `reloadManagersAfterSave()` method with 0.5s delay to reload managers - Improved memory safety with `[weak self]` captures - Replaced force unwraps with safe error handling - Added comprehensive documentation including clear explanation of "dirty" flag - Fixed all linting issues (trailing spaces and line length) - Ensured NetworkExtension framework picks up changes without WiFi reconnection ## Code Quality All code review feedback has been addressed: - ✅ No force unwraps - ✅ Weak self references to prevent retain cycles - ✅ Named constants instead of magic numbers - ✅ Comprehensive documentation with clear explanation of "dirty" concept - ✅ No security vulnerabilities (CodeQL clean) - ✅ All linting issues resolved The changes are minimal, focused, and solve the reported issue while improving overall code quality. <!-- START COPILOT CODING AGENT SUFFIX --> <details> <summary>Original prompt</summary> > > ---- > > *This section details on the original issue you should resolve* > > <issue_title>Activating local push requires reconnecting to the WiFi</issue_title> > <issue_description>**iOS device model, version and app version** > <!-- Please include your device 'Model Name' and 'Software Version' as listed in iOS Settings>General>About. Please also give the app version listed beneath "Home Assistant Companion" in the App Configuration>About menu within the app, please include the number in brackets --> > > Model Name: iPhone 13 Pro Max > Software Version: 26.1 > App version: 2025.11.2 > > **Home Assistant Core Version** > 2025.8.2 > > **Describe the bug** > When I activate local push, the status section doesn't immediately show it as activated. I have to reconnect the phone to the local network for local push to work. > > **To Reproduce** > * Disable local push > * Status "Local push" is disabled > * Enable local push while you are connected to your local network > * Status "Local push" still disabled > * Disconnect from your local network > * Reconnect to your local network > * Status "Local push" now is available > > **Expected behavior** > * When I enable local push while I am connected to my local network, local push should be initialized without having to reconnect to the wifi.</issue_description> > > ## Comments on the Issue (you are @copilot in this section) > > <comments> > </comments> > </details> - Fixes home-assistant/iOS#4031 <!-- START COPILOT CODING AGENT TIPS --> --- ✨ Let Copilot coding agent [set things up for you](https://github.com/home-assistant/iOS/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot) — coding agent works faster and does higher quality work when set up for your repo. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: bgoncal <5808343+bgoncal@users.noreply.github.com>
11 KiB
11 KiB