From 7fb2ff5119abf5b9fbf8a08e2e28331de5920842 Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Tue, 2 Sep 2025 06:20:56 -0500 Subject: [PATCH] CmdPal: init Details in a slow pass; add more winget logs (#41425) Related to #41384 We should load the `IDetails` from a `IListItem` in the slow pass, instead of immediately when we load the list of items. see also #39215 Also adds a lot of logging on our side, which helped ID that it isn't our fault that the winget APIs are returning slowly. That's tracked upstream (somewhere) --- .../CommandItemViewModel.cs | 2 +- .../ListItemViewModel.cs | 18 +++++++++++++++--- .../Pages/WinGetExtensionPage.cs | 12 ++++++++++++ 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/CommandItemViewModel.cs b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/CommandItemViewModel.cs index ea7b8fb516..5e2fcea295 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/CommandItemViewModel.cs +++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/CommandItemViewModel.cs @@ -160,7 +160,7 @@ public partial class CommandItemViewModel : ExtensionObjectViewModel, ICommandBa Initialized |= InitializedState.Initialized; } - public void SlowInitializeProperties() + public virtual void SlowInitializeProperties() { if (IsSelectedInitialized) { diff --git a/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/ListItemViewModel.cs b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/ListItemViewModel.cs index ad1aebe2d1..43dc24f72f 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/ListItemViewModel.cs +++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/ListItemViewModel.cs @@ -47,9 +47,21 @@ public partial class ListItemViewModel(IListItem model, WeakReference catalog.FindPackages(opts), ct); var searchResults = await internalSearchTask; + findPackages_stopwatch.Stop(); + Logger.LogDebug($"FindPackages for \"{searchDebugText}\" took {findPackages_stopwatch.ElapsedMilliseconds}ms", memberName: nameof(DoSearchAsync)); + // TODO more error handling like this: if (searchResults.Status != FindPackagesResultStatus.Ok) { @@ -261,6 +271,8 @@ internal sealed partial class WinGetExtensionPage : DynamicListPage, IDisposable return []; } + ct.ThrowIfCancellationRequested(); + Logger.LogDebug($" got results for ({query})", memberName: nameof(DoSearchAsync)); // FYI Using .ToArray or any other kind of enumerable loop