-
Notifications
You must be signed in to change notification settings - Fork 405
Improve local push reliability and reconnection #4113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR enhances the local push notification reliability by implementing automatic reconnection logic with exponential backoff and extensive diagnostic logging. The changes aim to handle network disruptions more gracefully by detecting when local push becomes unavailable and automatically attempting to re-establish the connection.
Key changes:
- Adds automatic reconnection mechanism with backoff delays (5s, 10s, 30s) when local push connections fail
- Introduces comprehensive verbose logging throughout the local push infrastructure for better debugging
- Refactors manager configuration code into smaller, well-documented helper methods
Sources/App/Notifications/NotificationManagerLocalPushInterfaceExtension.swift
Show resolved
Hide resolved
Sources/App/Notifications/NotificationManagerLocalPushInterfaceExtension.swift
Outdated
Show resolved
Hide resolved
Sources/App/Notifications/NotificationManagerLocalPushInterfaceExtension.swift
Show resolved
Hide resolved
Sources/App/Notifications/NotificationManagerLocalPushInterfaceExtension.swift
Outdated
Show resolved
Hide resolved
Sources/App/Notifications/NotificationManagerLocalPushInterfaceExtension.swift
Show resolved
Hide resolved
…eExtension.swift Co-authored-by: Copilot <[email protected]>
|
Found 1 unused localization strings in the codebase. Click to see detailsTo clean up these strings, manually remove them from the |
## Summary Adds comprehensive unit tests for the reconnection logic introduced in PR #4113, covering backoff delays, timer cancellation, state transitions, and edge cases with rapid disconnect/reconnect events. ## Screenshots N/A - Test coverage only ## Link to pull request in Documentation repository Documentation: home-assistant/companion.home-assistant# ## Any other notes This PR addresses feedback from the code review on #4113 requesting test coverage for the `scheduleReconnection()`, `attemptReconnection()`, and `cancelReconnection()` methods. **Implementation approach:** - Added DEBUG-only test accessors to `NotificationManagerLocalPushInterfaceExtension` to expose internal state for verification without compromising production code - Created 13 focused test cases that directly verify private state and behavior through test helpers **Test coverage includes:** - Exponential backoff delay calculation (5s, 10s, 30s capped) - Timer cancellation when all servers reconnect - State tracking of disconnected servers across multiple events - Rapid disconnection/reconnection event handling - Attempt counter increment and reset behavior - Edge cases: reconnection during active timer, multiple servers disconnecting simultaneously, inactive managers **Note:** Due to NetworkExtension framework constraints (NEAppPushManager requires provisioning/entitlements), full integration testing requires Xcode environment. The unit tests verify all testable logic through internal accessors. <!-- START COPILOT CODING AGENT TIPS --> --- 💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more [Copilot coding agent tips](https://gh.io/copilot-coding-agent-tips) in the docs. --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: bgoncal <[email protected]> Co-authored-by: Copilot <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4113 +/- ##
=======================================
Coverage ? 45.17%
=======================================
Files ? 249
Lines ? 14286
Branches ? 0
=======================================
Hits ? 6453
Misses ? 7833
Partials ? 0 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary
Screenshots
Link to pull request in Documentation repository
Documentation: home-assistant/companion.home-assistant#
Any other notes