Add notification history#4880
Merged
Merged
Conversation
Store and list every push notification the device receives (local push, remote push, and Live Activity) in Settings > Notifications > History.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds an in-app Notification History feature under Settings → Notifications → History, persisting received notifications (local push, remote push, and Live Activity-related events) to an app-group-backed store and presenting them via a searchable/filterable SwiftUI UI with a payload detail view.
Changes:
- Introduces
NotificationHistoryEntry+NotificationHistoryStore(JSON file in app group, coordinated viaNSFileCoordinator, capped at 500 entries). - Records entries at delivery chokepoints (Notification Service Extension for remote pushes;
LocalPushManagerfor local push / Live Activities). - Adds SwiftUI screens + localization + snapshot/unit tests for the new history UI and store.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| Tests/Shared/NotificationHistoryStore.test.swift | Unit tests for recording, capping, clearing, and payload redaction behavior. |
| Tests/App/Settings/NotificationHistoryView.test.swift | Snapshot tests for the history list and detail UI. |
| Sources/Shared/Resources/Swiftgen/Strings.swift | SwiftGen updates for new Notification History localized strings. |
| Sources/Shared/Notifications/NotificationHistory.swift | New history model, payload sanitization, and file-backed store implementation. |
| Sources/Shared/Notifications/LocalPush/LocalPushManager.swift | Records received local push / Live Activity events into history at handling time. |
| Sources/Shared/Environment/Environment.swift | Adds notificationHistoryStore dependency to the environment (Current). |
| Sources/Shared/Environment/AppConstants.swift | Adds app-group URL for the notification history JSON file. |
| Sources/Extensions/NotificationService/NotificationService.swift | Records remote pushes into history at extension receive time. |
| Sources/App/Settings/Notifications/NotificationSettingsView.swift | Adds navigation entry to the new Notification History screen. |
| Sources/App/Settings/Notifications/NotificationHistoryView.swift | Implements list/detail UI, filtering, search, clear-all, and copy-payload. |
| Sources/App/Resources/en.lproj/Localizable.strings | Adds English strings for the new UI. |
| HomeAssistant.xcodeproj/project.pbxproj | Wires new sources and tests into the Xcode project. |
Record Live Activities centrally in HandlerStartOrUpdateLiveActivity so remote (APNs) Live Activities, which arrive without mutable-content and bypass the notification service extension, are also stored. The local and remote push chokepoints now record only non–Live-Activity notifications to avoid double-counting.
Live Activities can't be captured consistently across delivery paths (remote ones bypass the notification service extension and native ActivityKit updates never surface as notifications), so showing a partial Live Activity category would be confusing. Drop the liveActivity kind and stop recording Live Activities; the history now covers local and remote push only.
Track local Live Activities as a distinct kind and add a Live Activity (Remote) filter that explains, via an empty state, that remote Live Activities are delivered directly to the system by iOS and cannot be tracked by the app. Filter order is now Local, Remote, Live Activity (Local), Live Activity (Remote).
Apply payload key redaction recursively so nested sensitive values (e.g. homeassistant.webhook_id) are sanitized, not just top-level keys. Remove the unused @Environment(\.dismiss) from the history view.
Add a per-row Copy context menu in the notification payload viewer: leaf rows copy their value, object/array rows copy that subtree as JSON. Store parsed numbers as NSNumber so copied subtrees serialize numbers faithfully.
Replace the per-row Copy context menu with text selection on each payload row, so long-pressing any key or value surfaces the system Copy button. Drop the now-unused copyText/prettyJSON helpers.
The two UI snapshot tests had no committed reference images, so they failed CI by auto-recording on the runner. Drop them (the store/logic tests in Tests/Shared remain) and make NotificationHistoryDetailView private again now that nothing external references it.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4880 +/- ##
=======================================
Coverage ? 47.46%
=======================================
Files ? 278
Lines ? 17566
Branches ? 0
=======================================
Hits ? 8337
Misses ? 9229
Partials ? 0 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a Notification History screen under Settings > Notifications > History that stores and lists the push notifications the device receives.
NotificationHistoryStore(JSON file, cross-process safe viaNSFileCoordinator, capped at 500 entries) records each notification at a single chokepoint per delivery path: the notification service extension for remote pushes, andLocalPushManagerfor local push — so notifications received while the app is backgrounded or killed are captured without double-counting.webhook_idand the local-push confirm id are redacted).Screenshots
Link to pull request in Documentation repository
Documentation: home-assistant/companion.home-assistant#
Any other notes