Add "notify when run" toggle to Details widget (#4037)

## Summary

The Details widget was missing the "notify when run" toggle available in
the Scripts widget, causing unwanted notifications when scripts were
executed from the widget.

Added `showConfirmationNotification` parameter to
`WidgetDetailsAppIntent` following the same pattern as
`WidgetScriptsAppIntent`:

- Added parameter with existing localization strings
(`app_intents.notify_when_run.title/description`)
- Flows through `WidgetDetailsEntry` to `ScriptAppIntent` when widget
button is tapped
- Only visible in configuration when "Run Script" is enabled
- Defaults to `true` for backward compatibility

## Screenshots
<!-- If this is a user-facing change not in the frontend, please include
screenshots in light and dark mode. -->

## Link to pull request in Documentation repository
<!-- Pull requests that add, change or remove functionality must have a
corresponding pull request in the Companion App Documentation repository
(https://github.com/home-assistant/companion.home-assistant). Please add
the number of this pull request after the "#" -->
Documentation: home-assistant/companion.home-assistant#

## Any other notes
<!-- If there is any other information of note, like if this Pull
Request is part of a bigger change, please include it here. -->

<!-- START COPILOT CODING AGENT SUFFIX -->



<details>

<summary>Original prompt</summary>

> 
> ----
> 
> *This section details on the original issue you should resolve*
> 
> <issue_title>Missing "notify when run" toggle for Details
widget</issue_title>
> <issue_description>**iOS device model, version and app version**
> 
> Model Name: iPhone 16 Pro
> Software Version: iOS 26.1
> App version: 2025.11.2 (2025.1537)
> 
> **Home Assistant Core Version**
> 2025.11.3
> 
> A "notify when run" toggle is missing from the "Details" widget
resulting in unwanted notifications when the script is run.
> This toggle exists in the "Scripts" widget.
> </issue_description>
> 
> ## Comments on the Issue (you are @copilot in this section)
> 
> <comments>
> </comments>
> 


</details>

- Fixes home-assistant/iOS#4018

<!-- START COPILOT CODING AGENT TIPS -->
---

💬 We'd love your input! Share your thoughts on Copilot coding agent in
our [2 minute survey](https://gh.io/copilot-coding-agent-survey).

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: bgoncal <5808343+bgoncal@users.noreply.github.com>
This commit is contained in:
Copilot
2025-12-03 10:46:28 +01:00
committed by GitHub
parent dcb85537d7
commit df44bad806
3 changed files with 19 additions and 2 deletions

View File

@@ -70,6 +70,19 @@ struct WidgetDetailsAppIntent: WidgetConfigurationIntent {
)
var script: IntentScriptEntity?
@Parameter(
title: LocalizedStringResource(
"app_intents.notify_when_run.title",
defaultValue: "Notify when run"
),
description: LocalizedStringResource(
"app_intents.notify_when_run.description",
defaultValue: "Shows notification after executed"
),
default: true
)
var showConfirmationNotification: Bool
static var parameterSummary: some ParameterSummary {
When(\WidgetDetailsAppIntent.$runScript, .equalTo, true) {
Summary {
@@ -80,6 +93,7 @@ struct WidgetDetailsAppIntent: WidgetConfigurationIntent {
\.$runScript
\.$script
\.$showConfirmationNotification
}
} otherwise: {
Summary {

View File

@@ -43,7 +43,7 @@ struct WidgetDetailsAppIntentTimelineProvider: AppIntentTimelineProvider {
func placeholder(in context: Context) -> WidgetDetailsEntry {
.init(
upperText: nil, lowerText: nil, detailsText: nil,
runScript: false, script: nil
runScript: false, script: nil, showConfirmationNotification: true
)
}
@@ -105,7 +105,8 @@ struct WidgetDetailsAppIntentTimelineProvider: AppIntentTimelineProvider {
detailsText: detailsText != "?" ? detailsText : nil,
runScript: configuration.runScript,
script: configuration.script
script: configuration.script,
showConfirmationNotification: configuration.showConfirmationNotification
)
}
}
@@ -126,6 +127,7 @@ struct WidgetDetailsEntry: TimelineEntry {
var runScript: Bool
var script: IntentScriptEntity?
var showConfirmationNotification: Bool
}
enum WidgetDetailsDataError: Error {

View File

@@ -32,6 +32,7 @@ struct WidgetDetails: Widget {
if let script = entry.script {
let intent = ScriptAppIntent()
intent.script = script
intent.showConfirmationNotification = entry.showConfirmationNotification
return intent
} else { return nil }
}