Skip to content

Commit ae31791

Browse files
authored
Fix install source and final progress (microsoft#5764)
Fixes microsoft#5715 ## Change Use the correct property when filtering for the source. Send a final progress message when successful to ensure that clients that display the progress don't get stuck with "finishing up".
1 parent 329b197 commit ae31791

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/WinGetMCPServer/WingetPackageTools.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@ public async Task<CallToolResult> InstallPackage(
148148

149149
if (installResult.Status == InstallResultStatus.Ok)
150150
{
151+
// Send a completed progress entry in the event that async progress forwarding didn't
152+
progress.Report(CreateInstallProgressNotification(PackageInstallProgressState.Finished, 1.0, 1.0));
151153
findResult = ReFindForPackage(catalogPackage.DefaultInstallVersion);
152154
}
153155

@@ -167,7 +169,7 @@ private ConnectResult ConnectCatalogWithResult(string? catalog = null)
167169
for (int i = 0; i < catalogs.Count; ++i)
168170
{
169171
var catalogRef = catalogs[i];
170-
if (string.IsNullOrEmpty(catalog) || catalogRef?.Info.Id == catalog)
172+
if (string.IsNullOrEmpty(catalog) || catalogRef?.Info.Name == catalog)
171173
{
172174
createCompositePackageCatalogOptions.Catalogs.Add(catalogs[i]);
173175
}
@@ -232,10 +234,15 @@ private FindPackagesResult FindForIdentifier(PackageCatalog catalog, string quer
232234
}
233235

234236
private static ProgressNotificationValue CreateInstallProgressNotification(ref InstallProgress installProgress)
237+
{
238+
return CreateInstallProgressNotification(installProgress.State, installProgress.DownloadProgress, installProgress.InstallationProgress);
239+
}
240+
241+
private static ProgressNotificationValue CreateInstallProgressNotification(PackageInstallProgressState state, double downloadProgress, double installProgress)
235242
{
236243
string? message = null;
237244

238-
switch (installProgress.State)
245+
switch (state)
239246
{
240247
case PackageInstallProgressState.Queued:
241248
message = "The install operation is queued";
@@ -261,7 +268,7 @@ private static ProgressNotificationValue CreateInstallProgressNotification(ref I
261268

262269
ProgressNotificationValue result = new ProgressNotificationValue()
263270
{
264-
Progress = (float)((installProgress.DownloadProgress * downloadPercentage) + (installProgress.InstallationProgress * (1.0f - downloadPercentage))),
271+
Progress = (float)((downloadProgress * downloadPercentage) + (installProgress * (1.0f - downloadPercentage))),
265272
Message = message,
266273
};
267274

0 commit comments

Comments
 (0)