From 5800b816386a7bad40b9ffe9c7327f88b4a5ab73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Pol=C3=A1=C5=A1ek?= Date: Tue, 15 Jul 2025 03:03:52 +0200 Subject: [PATCH] Fix loading top-level commands (#40602) ## Summary of the Pull Request Updates LoadTopLevelCommandsFromProvider so it returns list of top-level commands for further instead of modifying TopLevelCommands collection directly. Reverts unintended change from cfa5f75 where LoadTopLevelCommandsFromProvider updates the shared TopLevelCommands collection directly from in a task, causing thread-safety issues and bypassing synchronization lock on the collection. ## PR Checklist - [ ] **Closes:** -- - [ ] **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 --- .../Microsoft.CmdPal.UI.ViewModels/TopLevelCommandManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/TopLevelCommandManager.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/TopLevelCommandManager.cs index 752ca0e38e..d9beb0995d 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/TopLevelCommandManager.cs +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/TopLevelCommandManager.cs @@ -104,14 +104,14 @@ public partial class TopLevelCommandManager : ObservableObject, List commands = []; foreach (var item in commandProvider.TopLevelItems) { - TopLevelCommands.Add(item); + commands.Add(item); } foreach (var item in commandProvider.FallbackItems) { if (item.IsEnabled) { - TopLevelCommands.Add(item); + commands.Add(item); } }