From 114c3972be78ba6f0ac1c995b1c8d32631be6d51 Mon Sep 17 00:00:00 2001 From: Michael Jolley Date: Mon, 28 Jul 2025 08:45:08 -0500 Subject: [PATCH] CmdPal: Filtering out pinned apps on search (#40785) Closes #40781 Filters out TopLevelCommands whose Id matches an app coming from the `AllAppsCommandProvider.Page.GetItems()`. Hate adding processing there, but without adding some type of `bool HideMeOnSearch` to something low enough (like ICommandItem), I don't see another way to distinguish these. --- .../Microsoft.CmdPal.UI.ViewModels/Commands/MainListPage.cs | 5 +++++ .../cmdpal/ext/Microsoft.CmdPal.Ext.Apps/AppCommand.cs | 6 ++---- src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/AppItem.cs | 4 +--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Commands/MainListPage.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Commands/MainListPage.cs index b0d0346f51..2817ab9824 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Commands/MainListPage.cs +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Commands/MainListPage.cs @@ -164,6 +164,11 @@ public partial class MainListPage : DynamicListPage, if (_includeApps) { IEnumerable apps = AllAppsCommandProvider.Page.GetItems(); + var appIds = apps.Select(app => app.Command.Id).ToArray(); + + // Remove any top level pinned apps and use the apps from AllAppsCommandProvider.Page.GetItems() + // since they contain details. + _filteredItems = _filteredItems.Where(item => item.Command is not AppCommand); _filteredItems = _filteredItems.Concat(apps); } } diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/AppCommand.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/AppCommand.cs index d2fe194830..4f26d45839 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/AppCommand.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/AppCommand.cs @@ -6,11 +6,9 @@ using System; using System.Diagnostics; using System.Threading.Tasks; using ManagedCommon; -using Microsoft.CmdPal.Ext.Apps.Programs; using Microsoft.CmdPal.Ext.Apps.Properties; using Microsoft.CmdPal.Ext.Apps.Utils; using Microsoft.CommandPalette.Extensions.Toolkit; -using Windows.Services.Maps; using Windows.Win32; using Windows.Win32.System.Com; using Windows.Win32.UI.Shell; @@ -18,11 +16,11 @@ using WyHash; namespace Microsoft.CmdPal.Ext.Apps; -internal sealed partial class AppCommand : InvokableCommand +public sealed partial class AppCommand : InvokableCommand { private readonly AppItem _app; - internal AppCommand(AppItem app) + public AppCommand(AppItem app) { _app = app; diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/AppItem.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/AppItem.cs index 2e5ba78b1f..b7d01593cb 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/AppItem.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/AppItem.cs @@ -3,13 +3,11 @@ // See the LICENSE file in the project root for more information. using System.Collections.Generic; -using Microsoft.CmdPal.Ext.Apps.Programs; using Microsoft.CommandPalette.Extensions; -using Microsoft.CommandPalette.Extensions.Toolkit; namespace Microsoft.CmdPal.Ext.Apps; -internal sealed class AppItem +public sealed class AppItem { public string Name { get; set; } = string.Empty;