Skip to content

Add notification history#4880

Merged
bgoncal merged 10 commits into
mainfrom
notification-history
Jun 30, 2026
Merged

Add notification history#4880
bgoncal merged 10 commits into
mainfrom
notification-history

Conversation

@bgoncal

@bgoncal bgoncal commented Jun 29, 2026

Copy link
Copy Markdown
Member

Summary

Adds a Notification History screen under Settings > Notifications > History that stores and lists the push notifications the device receives.

  • A new app-group–backed NotificationHistoryStore (JSON file, cross-process safe via NSFileCoordinator, capped at 500 entries) records each notification at a single chokepoint per delivery path: the notification service extension for remote pushes, and LocalPushManager for local push — so notifications received while the app is backgrounded or killed are captured without double-counting.
  • Each entry stores its kind, date, title/subtitle/body, and a sanitized payload (sensitive values such as webhook_id and the local-push confirm id are redacted).
  • The list can be filtered by kind — Local, Remote, Live Activity (Local), and Live Activity (Remote) — and supports full-text search and clearing all history. Tapping a row presents the payload as a structured, nested key/value tree with a Copy Payload button.
  • Local Live Activities are tracked. Remote Live Activities are delivered straight to the system by iOS and never reach the app, so the Live Activity (Remote) filter shows an explanatory empty state rather than implying it can list them.

Note: remote silent/data-only pushes (no mutable-content) bypass the app/extension and are not recorded.

Screenshots

Link to pull request in Documentation repository

Documentation: home-assistant/companion.home-assistant#

Any other notes

Store and list every push notification the device receives (local push,
remote push, and Live Activity) in Settings > Notifications > History.
Copilot AI review requested due to automatic review settings June 29, 2026 21:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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 via NSFileCoordinator, capped at 500 entries).
  • Records entries at delivery chokepoints (Notification Service Extension for remote pushes; LocalPushManager for 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.

Comment thread Sources/App/Settings/Notifications/NotificationHistoryView.swift
Comment thread Sources/App/Settings/Notifications/NotificationHistoryView.swift
Comment thread Sources/Shared/Notifications/NotificationHistory.swift
bgoncal added 7 commits June 29, 2026 23:26
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.
@bgoncal bgoncal enabled auto-merge (squash) June 29, 2026 22:09
bgoncal added 2 commits June 30, 2026 00:45
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

codecov Bot commented Jun 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 76.51515% with 31 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@ad64f94). Learn more about missing BASE report.

Files with missing lines Patch % Lines
...ces/Shared/Notifications/NotificationHistory.swift 76.92% 27 Missing ⚠️
Sources/Shared/Environment/AppConstants.swift 60.00% 4 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@bgoncal bgoncal merged commit 27367a4 into main Jun 30, 2026
15 checks passed
@bgoncal bgoncal deleted the notification-history branch June 30, 2026 00:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants