[CmdPal] Fix details pane not hiding when item initialization fails (#44757)

Fixes #44487

## Summary
Fixed issue where the details pane would display stale information when
navigating from an item with details to an item without details or where
details failed to load.

## Changes
1. **ListViewModel.cs**: Added HideDetailsMessage when SafeSlowInit()
fails to ensure previous details are cleared
2. **InstallPackageListItem.cs**: Added exception handling for WinRT
marshaling errors when accessing metadata.Documentations and
metadata.Tags collections

The fix ensures graceful degradation - if certain metadata collections
fail to load due to WinRT issues, the details pane still displays
available information rather than failing completely.
This commit is contained in:
Michael Jolley
2026-01-20 19:16:43 -06:00
committed by GitHub
parent 8e2123cfea
commit b5e9f346da
2 changed files with 31 additions and 11 deletions

View File

@@ -132,12 +132,20 @@ public partial class InstallPackageListItem : ListItem
// These can be l o n g
{ Properties.Resources.winget_release_notes, (metadata.ReleaseNotes, string.Empty) },
};
var docs = metadata.Documentations;
var count = docs.Count;
for (var i = 0; i < count; i++)
try
{
var item = docs[i];
simpleData.Add(item.DocumentLabel, (string.Empty, item.DocumentUrl));
var docs = metadata.Documentations;
var count = docs.Count;
for (var i = 0; i < count; i++)
{
var item = docs[i];
simpleData.Add(item.DocumentLabel, (string.Empty, item.DocumentUrl));
}
}
catch (Exception ex)
{
Logger.LogWarning($"Failed to retrieve documentations from metadata: {ex.Message}");
}
UriCreationOptions options = default;
@@ -159,14 +167,21 @@ public partial class InstallPackageListItem : ListItem
}
}
if (metadata.Tags.Count > 0)
try
{
DetailsElement pair = new()
if (metadata.Tags.Count > 0)
{
Key = "Tags",
Data = new DetailsTags() { Tags = metadata.Tags.Select(t => new Tag(t)).ToArray() },
};
detailsElements.Add(pair);
DetailsElement pair = new()
{
Key = "Tags",
Data = new DetailsTags() { Tags = metadata.Tags.Select(t => new Tag(t)).ToArray() },
};
detailsElements.Add(pair);
}
}
catch (Exception ex)
{
Logger.LogWarning($"Failed to retrieve tags from metadata: {ex.Message}");
}
return detailsElements;