From e93b044f39e2701bb38059bf0d672ab10579a711 Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Wed, 6 Aug 2025 19:41:02 -0500 Subject: [PATCH 1/9] CmdPal: Once again, I am asking you to fix form submits (#41010) Closes #40979 Usually, you're supposed to try to cast the action to a specific type, and use those objects to get the data you need. However, there's something weird with AdaptiveCards and the way it works when we consume it when built in Release, with AOT (and trimming) enabled. Any sort of `action.As()` or similar will throw a System.InvalidCastException. Instead we have this horror show. The `action.ToJson()` blob ACTUALLY CONTAINS THE `type` field, which we can use to determine what kind of action it is. Then we can parse the JSON manually based on the type. --- .../ContentFormViewModel.cs | 116 ++++++++++++++---- .../Pages/SampleContentPage.cs | 5 + 2 files changed, 99 insertions(+), 22 deletions(-) diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ContentFormViewModel.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ContentFormViewModel.cs index d561a0e00f..9728e8339e 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ContentFormViewModel.cs +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ContentFormViewModel.cs @@ -98,35 +98,107 @@ public partial class ContentFormViewModel(IFormContent _form, WeakReference(new(openUrlAction.Url)); - return; - } + // BODGY circa GH #40979 + // Usually, you're supposed to try to cast the action to a specific + // type, and use those objects to get the data you need. + // However, there's something weird with AdaptiveCards and the way it + // works when we consume it when built in Release, with AOT (and + // trimming) enabled. Any sort of `action.As()` + // or similar will throw a System.InvalidCastException. + // + // Instead we have this horror show. + // + // The `action.ToJson()` blob ACTUALLY CONTAINS THE `type` field, which + // we can use to determine what kind of action it is. Then we can parse + // the JSON manually based on the type. + var actionJson = action.ToJson(); - if (action is AdaptiveSubmitAction or AdaptiveExecuteAction) + if (actionJson.TryGetValue("type", out var actionTypeValue)) { - // Get the data and inputs - var dataString = (action as AdaptiveSubmitAction)?.DataJson.Stringify() ?? string.Empty; - var inputString = inputs.Stringify(); + var actionTypeString = actionTypeValue.GetString(); + Logger.LogTrace($"atString={actionTypeString}"); - _ = Task.Run(() => + var actionType = actionTypeString switch { - try - { - var model = _formModel.Unsafe!; - if (model != null) + "Action.Submit" => ActionType.Submit, + "Action.Execute" => ActionType.Execute, + "Action.OpenUrl" => ActionType.OpenUrl, + _ => ActionType.Unsupported, + }; + + Logger.LogDebug($"{actionTypeString}->{actionType}"); + + switch (actionType) + { + case ActionType.OpenUrl: { - var result = model.SubmitForm(inputString, dataString); - WeakReferenceMessenger.Default.Send(new(new(result))); + HandleOpenUrlAction(action, actionJson); } - } - catch (Exception ex) - { - ShowException(ex); - } - }); + + break; + case ActionType.Submit: + case ActionType.Execute: + { + HandleSubmitAction(action, actionJson, inputs); + } + + break; + default: + Logger.LogError($"{actionType} was an unexpected action `type`"); + break; + } } + else + { + Logger.LogError($"actionJson.TryGetValue(type) failed"); + } + } + + private void HandleOpenUrlAction(IAdaptiveActionElement action, JsonObject actionJson) + { + if (actionJson.TryGetValue("url", out var actionUrlValue)) + { + var actionUrl = actionUrlValue.GetString() ?? string.Empty; + if (Uri.TryCreate(actionUrl, default(UriCreationOptions), out var uri)) + { + WeakReferenceMessenger.Default.Send(new(uri)); + } + else + { + Logger.LogError($"Failed to produce URI for {actionUrlValue}"); + } + } + } + + private void HandleSubmitAction( + IAdaptiveActionElement action, + JsonObject actionJson, + JsonObject inputs) + { + var dataString = string.Empty; + if (actionJson.TryGetValue("data", out var actionDataValue)) + { + dataString = actionDataValue.Stringify() ?? string.Empty; + } + + var inputString = inputs.Stringify(); + _ = Task.Run(() => + { + try + { + var model = _formModel.Unsafe!; + if (model != null) + { + var result = model.SubmitForm(inputString, dataString); + Logger.LogDebug($"SubmitForm() returned {result}"); + WeakReferenceMessenger.Default.Send(new(new(result))); + } + } + catch (Exception ex) + { + ShowException(ex); + } + }); } private static readonly string ErrorCardJson = """ diff --git a/src/modules/cmdpal/ext/SamplePagesExtension/Pages/SampleContentPage.cs b/src/modules/cmdpal/ext/SamplePagesExtension/Pages/SampleContentPage.cs index a602f74a00..1e5d3f6c5f 100644 --- a/src/modules/cmdpal/ext/SamplePagesExtension/Pages/SampleContentPage.cs +++ b/src/modules/cmdpal/ext/SamplePagesExtension/Pages/SampleContentPage.cs @@ -225,6 +225,11 @@ internal sealed partial class SampleContentForm : FormContent } ] } + }, + { + "type": "Action.OpenUrl", + "title": "Action.OpenUrl", + "url": "https://adaptivecards.microsoft.com/" } ] } From 0d4f3d851e47fb7bf479feb79d9cb4321bcaa5ef Mon Sep 17 00:00:00 2001 From: Jeremy Sinclair <4016293+snickler@users.noreply.github.com> Date: Thu, 7 Aug 2025 17:28:01 -0700 Subject: [PATCH 2/9] [Deps] Update .NET packages from 9.0.7 to 9.0.8 (#41039) ## Summary of the Pull Request Updates .NET 9 Runtime / Library packages to the latest 9.0.8 servicing release. ## PR Checklist - [ ] Closes: #xxx - [ ] **Communication:** I've discussed this with core contributors already. If the work hasn't been agreed, this work might be rejected - [ ] **Tests:** Added/updated and all pass - [ ] **Localization:** All end-user-facing strings can be localized - [ ] **Dev docs:** Added/updated - [ ] **New binaries:** Added on the required places - [ ] [JSON for signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json) for new binaries - [ ] [WXS for installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs) for new binaries and localization folder - [ ] [YML for CI pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml) for new test projects - [ ] [YML for signed pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml) - [ ] **Documentation updated:** If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys) and link it here: #xxx ## Detailed Description of the Pull Request / Additional comments ## Validation Steps Performed --- Directory.Packages.props | 42 +++++++++---------- NOTICE.md | 42 +++++++++---------- .../Directory.Packages.props | 2 +- 3 files changed, 43 insertions(+), 43 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 3487098f08..71bbda5042 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -34,22 +34,22 @@ - + - + - - - - - + + + + + - + - + - + - - - + + + - + - - + + - + - - - - + + + + diff --git a/NOTICE.md b/NOTICE.md index 4dcc82579d..d75fe99522 100644 --- a/NOTICE.md +++ b/NOTICE.md @@ -1519,23 +1519,23 @@ SOFTWARE. - Mages 3.0.0 - Markdig.Signed 0.34.0 - MessagePack 3.1.3 -- Microsoft.Bcl.AsyncInterfaces 9.0.7 +- Microsoft.Bcl.AsyncInterfaces 9.0.8 - Microsoft.Bot.AdaptiveExpressions.Core 4.23.0 - Microsoft.CodeAnalysis.NetAnalyzers 9.0.0 -- Microsoft.Data.Sqlite 9.0.7 +- Microsoft.Data.Sqlite 9.0.8 - Microsoft.Diagnostics.Tracing.TraceEvent 3.1.16 - Microsoft.DotNet.ILCompiler (A) -- Microsoft.Extensions.DependencyInjection 9.0.7 -- Microsoft.Extensions.Hosting 9.0.7 -- Microsoft.Extensions.Hosting.WindowsServices 9.0.7 -- Microsoft.Extensions.Logging 9.0.7 -- Microsoft.Extensions.Logging.Abstractions 9.0.7 +- Microsoft.Extensions.DependencyInjection 9.0.8 +- Microsoft.Extensions.Hosting 9.0.8 +- Microsoft.Extensions.Hosting.WindowsServices 9.0.8 +- Microsoft.Extensions.Logging 9.0.8 +- Microsoft.Extensions.Logging.Abstractions 9.0.8 - Microsoft.NET.ILLink.Tasks (A) - Microsoft.SemanticKernel 1.15.0 - Microsoft.Toolkit.Uwp.Notifications 7.1.2 - Microsoft.Web.WebView2 1.0.2903.40 -- Microsoft.Win32.SystemEvents 9.0.7 -- Microsoft.Windows.Compatibility 9.0.7 +- Microsoft.Win32.SystemEvents 9.0.8 +- Microsoft.Windows.Compatibility 9.0.8 - Microsoft.Windows.CsWin32 0.3.183 - Microsoft.Windows.CsWinRT 2.2.0 - Microsoft.Windows.SDK.BuildTools 10.0.26100.4188 @@ -1555,25 +1555,25 @@ SOFTWARE. - SkiaSharp.Views.WinUI 2.88.9 - StreamJsonRpc 2.21.69 - StyleCop.Analyzers 1.2.0-beta.556 -- System.CodeDom 9.0.7 +- System.CodeDom 9.0.8 - System.CommandLine 2.0.0-beta4.22272.1 -- System.ComponentModel.Composition 9.0.7 -- System.Configuration.ConfigurationManager 9.0.7 -- System.Data.OleDb 9.0.7 +- System.ComponentModel.Composition 9.0.8 +- System.Configuration.ConfigurationManager 9.0.8 +- System.Data.OleDb 9.0.8 - System.Data.SqlClient 4.9.0 -- System.Diagnostics.EventLog 9.0.7 -- System.Diagnostics.PerformanceCounter 9.0.7 -- System.Drawing.Common 9.0.7 +- System.Diagnostics.EventLog 9.0.8 +- System.Diagnostics.PerformanceCounter 9.0.8 +- System.Drawing.Common 9.0.8 - System.IO.Abstractions 22.0.13 - System.IO.Abstractions.TestingHelpers 22.0.13 -- System.Management 9.0.7 +- System.Management 9.0.8 - System.Net.Http 4.3.4 - System.Private.Uri 4.3.2 - System.Reactive 6.0.1 -- System.Runtime.Caching 9.0.7 -- System.ServiceProcess.ServiceController 9.0.7 -- System.Text.Encoding.CodePages 9.0.7 -- System.Text.Json 9.0.7 +- System.Runtime.Caching 9.0.8 +- System.ServiceProcess.ServiceController 9.0.8 +- System.Text.Encoding.CodePages 9.0.8 +- System.Text.Json 9.0.8 - System.Text.RegularExpressions 4.3.1 - UnicodeInformation 2.6.0 - UnitsNet 5.56.0 diff --git a/src/modules/cmdpal/ExtensionTemplate/TemplateCmdPalExtension/Directory.Packages.props b/src/modules/cmdpal/ExtensionTemplate/TemplateCmdPalExtension/Directory.Packages.props index 664b2d678a..d364f7da8b 100644 --- a/src/modules/cmdpal/ExtensionTemplate/TemplateCmdPalExtension/Directory.Packages.props +++ b/src/modules/cmdpal/ExtensionTemplate/TemplateCmdPalExtension/Directory.Packages.props @@ -12,6 +12,6 @@ - + From 062234c295339f9fc5c3f63cc89421927b8e9463 Mon Sep 17 00:00:00 2001 From: Kai Tao <69313318+vanzue@users.noreply.github.com> Date: Fri, 8 Aug 2025 16:38:46 +0800 Subject: [PATCH 3/9] Settings: Mouse utils setting crash (#41050) ## Summary of the Pull Request Fix a crash in settings page due to not found converter ## AI Summary This pull request makes a small update to the `MouseUtilsPage.xaml` file to use the correct resource for converting boolean values to visibility states in the UI. - Updated the `Visibility` binding on an `InfoBar` to use the `ReverseBoolToVisibilityConverter` instead of the incorrect `BoolToReverseVisibilityConverter` resource. ## PR Checklist - [ ] Closes: #xxx - [ ] **Communication:** I've discussed this with core contributors already. If the work hasn't been agreed, this work might be rejected - [ ] **Tests:** Added/updated and all pass - [ ] **Localization:** All end-user-facing strings can be localized - [ ] **Dev docs:** Added/updated - [ ] **New binaries:** Added on the required places - [ ] [JSON for signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json) for new binaries - [ ] [WXS for installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs) for new binaries and localization folder - [ ] [YML for CI pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml) for new test projects - [ ] [YML for signed pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml) - [ ] **Documentation updated:** If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys) and link it here: #xxx ## Detailed Description of the Pull Request / Additional comments Regression caused by https://github.com/microsoft/PowerToys/pull/40214 ## Validation Steps Performed image --- .../Settings.UI/SettingsXAML/Views/MouseUtilsPage.xaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/settings-ui/Settings.UI/SettingsXAML/Views/MouseUtilsPage.xaml b/src/settings-ui/Settings.UI/SettingsXAML/Views/MouseUtilsPage.xaml index e8ebc76f66..0ba74ca164 100644 --- a/src/settings-ui/Settings.UI/SettingsXAML/Views/MouseUtilsPage.xaml +++ b/src/settings-ui/Settings.UI/SettingsXAML/Views/MouseUtilsPage.xaml @@ -149,7 +149,7 @@ IsClosable="False" IsOpen="True" Severity="Informational" - Visibility="{x:Bind ViewModel.IsAnimationEnabledBySystem, Mode=OneWay, Converter={StaticResource BoolToReverseVisibilityConverter}}"> + Visibility="{x:Bind ViewModel.IsAnimationEnabledBySystem, Mode=OneWay, Converter={StaticResource ReverseBoolToVisibilityConverter}}"> From d72e0ab20d6ca3738b63d087e47525ada66df606 Mon Sep 17 00:00:00 2001 From: Shawn Yuan <128874481+shuaiyuanxx@users.noreply.github.com> Date: Fri, 8 Aug 2025 22:55:00 +0800 Subject: [PATCH 4/9] Fixed toggle switch not working issue. (#41049) ## Summary of the Pull Request Fixed toggle switch not working issue. ## AI Summary This pull request refactors how `DashboardListItem` objects are created and added to collections in the `DashboardViewModel`. The main improvement is to separate the instantiation of each `DashboardListItem` from the assignment of its `EnabledChangedCallback` property, which is now set after the object is added to the relevant collection. This change improves clarity and may help prevent issues related to object initialization order. Refactoring of `DashboardListItem` creation and initialization: * In the `AddDashboardListItem` method, the `DashboardListItem` object is now created and added to `AllModules` before its `EnabledChangedCallback` property is set, instead of setting this property during object initialization. * In the `GetShortcutModules` method, both `ShortcutModules` and `ActionModules` collections now receive `DashboardListItem` objects that are instantiated first, added to the collection, and then have their `EnabledChangedCallback` property set. This replaces the previous pattern of setting the callback during object creation. [[1]](diffhunk://#diff-aea3404667e7a3de2750bf9ab7ee8ff5e717892caa68ee1de86713cf8e21b44cL123-R136) [[2]](diffhunk://#diff-aea3404667e7a3de2750bf9ab7ee8ff5e717892caa68ee1de86713cf8e21b44cL144-R159) * ## PR Checklist - [x] Closes: #41046 - [ ] **Communication:** I've discussed this with core contributors already. If the work hasn't been agreed, this work might be rejected - [ ] **Tests:** Added/updated and all pass - [ ] **Localization:** All end-user-facing strings can be localized - [ ] **Dev docs:** Added/updated - [ ] **New binaries:** Added on the required places - [ ] [JSON for signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json) for new binaries - [ ] [WXS for installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs) for new binaries and localization folder - [ ] [YML for CI pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml) for new test projects - [ ] [YML for signed pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml) - [ ] **Documentation updated:** If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys) and link it here: #xxx ## Detailed Description of the Pull Request / Additional comments It is an regression from https://github.com/microsoft/PowerToys/pull/40214 ## Validation Steps Performed --------- Signed-off-by: Shuai Yuan --- .../ViewModels/DashboardViewModel.cs | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/settings-ui/Settings.UI/ViewModels/DashboardViewModel.cs b/src/settings-ui/Settings.UI/ViewModels/DashboardViewModel.cs index 6e2bb2d432..8dd97c85fa 100644 --- a/src/settings-ui/Settings.UI/ViewModels/DashboardViewModel.cs +++ b/src/settings-ui/Settings.UI/ViewModels/DashboardViewModel.cs @@ -69,16 +69,18 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels private void AddDashboardListItem(ModuleType moduleType) { GpoRuleConfigured gpo = ModuleHelper.GetModuleGpoConfiguration(moduleType); - AllModules.Add(new DashboardListItem() + var newItem = new DashboardListItem() { Tag = moduleType, Label = resourceLoader.GetString(ModuleHelper.GetModuleLabelResourceName(moduleType)), IsEnabled = gpo == GpoRuleConfigured.Enabled || (gpo != GpoRuleConfigured.Disabled && ModuleHelper.GetIsModuleEnabled(generalSettingsConfig, moduleType)), IsLocked = gpo == GpoRuleConfigured.Enabled || gpo == GpoRuleConfigured.Disabled, Icon = ModuleHelper.GetModuleTypeFluentIconName(moduleType), - EnabledChangedCallback = EnabledChangedOnUI, DashboardModuleItems = GetModuleItems(moduleType), - }); + }; + + AllModules.Add(newItem); + newItem.EnabledChangedCallback = EnabledChangedOnUI; } private void EnabledChangedOnUI(DashboardListItem dashboardListItem) @@ -120,16 +122,18 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels if (filteredItems.Count != 0) { - ShortcutModules.Add(new DashboardListItem + var newItem = new DashboardListItem { - EnabledChangedCallback = x.EnabledChangedCallback, Icon = x.Icon, IsLocked = x.IsLocked, Label = x.Label, Tag = x.Tag, IsEnabled = x.IsEnabled, DashboardModuleItems = new ObservableCollection(filteredItems), - }); + }; + + ShortcutModules.Add(newItem); + newItem.EnabledChangedCallback = x.EnabledChangedCallback; } } @@ -141,16 +145,18 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels if (filteredItems.Count != 0) { - ActionModules.Add(new DashboardListItem + var newItem = new DashboardListItem { - EnabledChangedCallback = x.EnabledChangedCallback, Icon = x.Icon, IsLocked = x.IsLocked, Label = x.Label, Tag = x.Tag, IsEnabled = x.IsEnabled, DashboardModuleItems = new ObservableCollection(filteredItems), - }); + }; + + ActionModules.Add(newItem); + newItem.EnabledChangedCallback = x.EnabledChangedCallback; } } } From 04b8234192593d7a0efe2801d657dc85a8db1e79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Pol=C3=A1=C5=A1ek?= Date: Tue, 12 Aug 2025 01:12:05 +0200 Subject: [PATCH 5/9] CmdPal: Fix styles applied to MoreCommandsButton (#41059) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary of the Pull Request - Apply the same padding to the button as used for primary and secondary command buttons. - Use consistent spacing between keycap blocks. - Match keycap border style and inner text brush with other command buttons. - Add min width constraint to shortcut keycap element to make it at least square. image ## PR Checklist - [x] Closes: #41052 - [x] **Communication:** I've discussed this with core contributors already. If the work hasn't been agreed, this work might be rejected - [ ] **Tests:** Added/updated and all pass - [ ] **Localization:** All end-user-facing strings can be localized - [ ] **Dev docs:** Added/updated - [ ] **New binaries:** Added on the required places - [ ] [JSON for signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json) for new binaries - [ ] [WXS for installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs) for new binaries and localization folder - [ ] [YML for CI pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml) for new test projects - [ ] [YML for signed pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml) - [ ] **Documentation updated:** If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys) and link it here: #xxx ## Detailed Description of the Pull Request / Additional comments ## Validation Steps Performed 👀 --- .../Controls/CommandBar.xaml | 68 +++++++------------ 1 file changed, 25 insertions(+), 43 deletions(-) diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/CommandBar.xaml b/src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/CommandBar.xaml index 9fb047641f..107db49939 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/CommandBar.xaml +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/CommandBar.xaml @@ -59,8 +59,24 @@ + + + + + @@ -155,12 +171,7 @@ Style="{StaticResource CaptionTextBlockStyle}" Text="{x:Bind ViewModel.PrimaryCommand.Name, Mode=OneWay}" /> - + @@ -179,19 +190,10 @@ Text="{x:Bind ViewModel.SecondaryCommand.Name, Mode=OneWay}" /> - + - + @@ -199,7 +201,7 @@