Disfavor non-essential widgets in CarPlay widget gallery#4733
Conversation
Mark the Assist, Scripts, Gauge, Details, Sensors and Open Page widgets as disfavored in CarPlay via `disfavoredLocations([.carPlay], for:)`, so they appear in the "Other" section of the CarPlay widget gallery. The Commonly Used Entities, Custom and To-do List widgets stay favored, as they are the ones most useful while driving. A `disfavoredInCarPlayIfAvailable(for:)` helper wraps the iOS 17+ API and guards macOS, where the API and `WidgetLocation.carPlay` are unavailable. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Found 13 unused localization strings in the codebase. Click to see detailsTo clean up these strings, manually remove them from the |
There was a problem hiding this comment.
Pull request overview
Updates the Widgets extension to mark several non-driving-focused widgets as disfavored in the CarPlay widget gallery (moving them into the “Other” section) by applying a shared WidgetConfiguration helper around SwiftUI’s CarPlay widget-location API.
Changes:
- Added a
WidgetConfiguration.disfavoredInCarPlayIfAvailable(for:)helper to conditionally applydisfavoredLocations([.carPlay], for:)on supported platforms/OS versions. - Applied the helper to Assist, Scripts, Gauge, Details, Sensors, and Open Page widgets so they’re deprioritized in the CarPlay widget gallery.
- Kept favored widgets (Commonly Used Entities, Custom, To-do List) unchanged (per PR description).
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| Sources/Extensions/Widgets/Common/WidgetCarPlayLocation.swift | Adds a helper to disfavor widget families specifically for the CarPlay gallery when available. |
| Sources/Extensions/Widgets/Assist/WidgetAssist.swift | Applies the CarPlay disfavoring helper to the Assist widget. |
| Sources/Extensions/Widgets/Script/WidgetScripts.swift | Applies the CarPlay disfavoring helper to the Scripts widget. |
| Sources/Extensions/Widgets/Lockscreen/Gauge/WidgetGauge.swift | Applies the CarPlay disfavoring helper to the Gauge widget. |
| Sources/Extensions/Widgets/Lockscreen/Details/WidgetDetails.swift | Applies the CarPlay disfavoring helper to the Details widget. |
| Sources/Extensions/Widgets/Sensor/WidgetSensors.swift | Applies the CarPlay disfavoring helper to the Sensors widget. |
| Sources/Extensions/Widgets/OpenPage/WidgetOpenPage.swift | Applies the CarPlay disfavoring helper to the Open Page widget. |
`WidgetLocation.carPlay` is `@available(iOS 26.0, *)` (and unavailable on macOS), even though the `disfavoredLocations(_:for:)` modifier itself is iOS 17+. Guarding only on iOS 17 makes the iOS/Mac Catalyst build fail with "'carPlay' is only available in iOS 26.0 or newer". Guard on the stricter iOS 26 requirement instead. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The new helper file was not referenced in project.pbxproj, so it would not be compiled and `.disfavoredInCarPlayIfAvailable(...)` would fail to resolve. Register it (file reference, group entry, and build files) in the same two targets that compile the other Widgets/Common helpers — `App` and `Extensions-Widgets` — mirroring WidgetContentMargin.swift. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
WidgetCarPlayLocation.swift compiles into both the Widgets extension and the non-extension `App` target. `disfavoredLocations(_:for:)` and `WidgetLocation.carPlay` are annotated only in the `iOS` availability domain, so a `#available(iOSApplicationExtension 26.0, *)` check does not refine them when compiled without `-application-extension` (the App target), breaking the build with "only available in iOS 26.0 or newer". Use `#available(iOS 26.0, *)`, which refines correctly in both targets. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4733 +/- ##
=======================================
Coverage ? 44.93%
=======================================
Files ? 277
Lines ? 16782
Branches ? 0
=======================================
Hits ? 7541
Misses ? 9241
Partials ? 0 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Summary
Marks every widget except the most driving-relevant ones as disfavored in the CarPlay widget gallery, using SwiftUI's
disfavoredLocations(_:for:)withWidgetLocation.carPlay. Disfavored widgets are moved to the "Other" section of the CarPlay gallery instead of being suggested up front.Disfavored in CarPlay: Assist, Scripts, Gauge, Details, Sensors, Open Page.
Kept favored (unchanged): Commonly Used Entities, Custom, and To-do List — the widgets most useful at a glance while driving.
Implementation notes:
disfavoredInCarPlayIfAvailable(for:)helper (Sources/Extensions/Widgets/Common/WidgetCarPlayLocation.swift) wraps the API, following the existingcontentMarginsDisabledIfAvailable()pattern. The new file is registered inproject.pbxprojfor both theAppandExtensions-Widgetstargets (the two targets that compile widget code).WidgetLocation.carPlayis@available(iOS 26.0, *)(iOS / iPadOS / Mac Catalyst 26.0+) and unavailable on native macOS. Although thedisfavoredLocations(_:for:)modifier itself is iOS 17+, the.carPlaylocation requires iOS 26, so the helper guards on the stricter requirement (#available(iOS 26.0, *)) and on platform (#if !os(macOS)). TheiOSavailability domain is used rather thaniOSApplicationExtension, because the file also compiles into the non-extensionApptarget where aniOSApplicationExtensioncheck would not refine theseiOS-only symbols. On earlier OS versions the modifier is a no-op, which is correct since the CarPlay widget location doesn't exist there.supportedFamilies.Screenshots
N/A — this only affects the ordering/section of widgets in the CarPlay widget gallery (the "Other" section) on iOS 26+; there is no visual change to the widgets themselves.
Link to pull request in Documentation repository
Documentation: home-assistant/companion.home-assistant#
Any other notes
Family lists are reused verbatim from each widget's existing
supportedFamiliesdeclaration, so disfavoring stays in sync if those lists change.🤖 Generated with Claude Code