Run Focus filter when the app is in the background - #5656
Conversation
A plain SetFocusFilterIntent is only reliably performed while the app is in the foreground, so a Focus that starts with the app closed never reports its name. Conforming the intent to LiveActivityIntent opts it into running in the app's process in the background. That protocol is iOS 17+, so the filter is now gated to iOS 17.
There was a problem hiding this comment.
🟡 Changes recommended
The current iOS 17 availability gate on the entire intent likely removes the Focus Filter feature on iOS 16.x deployments rather than only enhancing behavior on iOS 17+.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR addresses Focus filter execution reliability by opting the SetFocusFilterIntent into background execution so the app can report the active Focus name even when the Focus starts while the app is closed (related to #5467).
Changes:
- Added
LiveActivityIntentconformance to the Focus filter App Intent to allow it to run in the app process while in the background. - Gated the Focus filter intent to iOS 17+ due to
LiveActivityIntentavailability. - Expanded inline documentation explaining why
LiveActivityIntentis used here.
File summaries
| File | Description |
|---|---|
| Sources/App/Settings/Focus/FocusNameFocusFilterAppIntent.swift | Adds LiveActivityIntent conformance (iOS 17+) and documents the background-execution rationale for Focus filter reporting. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| @available(iOS 17.0, *) | ||
| struct FocusNameFocusFilterAppIntent: SetFocusFilterIntent, LiveActivityIntent { |
Declare the LiveActivityIntent conformance in an availability-gated extension instead of on the type, so the filter itself is not removed from the iOS versions that predate the protocol.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5656 +/- ##
==========================================
+ Coverage 35.29% 35.43% +0.14%
==========================================
Files 1013 1033 +20
Lines 73124 73801 +677
==========================================
+ Hits 25812 26155 +343
- Misses 47312 47646 +334
☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
AI Policy
Select exactly one option that describes AI usage in this contribution:
Summary
A plain
SetFocusFilterIntentis only reliably performed while the app is in the foreground, and is skipped when iOS would have to launch the app to run it. That means a Focus starting with the app closed never reports its name, andfocus_nameblanks instead. Conforming the intent toLiveActivityIntentopts it into running in the app's process in the background, which is the known workaround for this (see FB14715113).That protocol is iOS 17+, so the conformance sits in an availability-gated extension and the filter itself stays available below iOS 17.
Related to #5467.
Screenshots
Not a UI change.
Link to pull request in Documentation repository
Documentation: home-assistant/companion.home-assistant# N/A
Any other notes
The other option Apple documents for this is hosting the filter in an App Intents extension so no app launch is needed. That needs a new extension target, a new App ID and a provisioning profile, so it is not in this PR.