Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Quick Fix] WinGet suggestions not shown for elevated sessions #17677

Open
carlos-zamora opened this issue Aug 6, 2024 · 0 comments
Open

[Quick Fix] WinGet suggestions not shown for elevated sessions #17677

carlos-zamora opened this issue Aug 6, 2024 · 0 comments
Labels
Area-Suggestions Anything related to tasks or the suggestions UI (sxnui) Issue-Task It's a feature request, but it doesn't really need a major design. Needs-Tag-Fix Doesn't match tag requirements Product-Terminal The new Windows Terminal.

Comments

@carlos-zamora
Copy link
Member

Internal request tracked here: https://microsoft.visualstudio.com/OS/_workitems/edit/50066117

@carlos-zamora carlos-zamora added Product-Terminal The new Windows Terminal. Issue-Task It's a feature request, but it doesn't really need a major design. Area-Suggestions Anything related to tasks or the suggestions UI (sxnui) labels Aug 6, 2024
@carlos-zamora carlos-zamora added this to the Terminal v1.23 milestone Aug 6, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added Needs-Tag-Fix Doesn't match tag requirements Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels Aug 6, 2024
@carlos-zamora carlos-zamora removed Needs-Tag-Fix Doesn't match tag requirements Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels Aug 7, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs-Tag-Fix Doesn't match tag requirements label Aug 7, 2024
DHowett pushed a commit that referenced this issue Aug 23, 2024
## Summary of the Pull Request
Improves Quick Fix's suggestions to use WinGet API and actually query
winget for packages based on the missing command.

To interact with the WinGet API, we need the
`Microsoft.WindowsPackageManager.ComInterop` NuGet package.
`Microsoft.WindowsPackageManager.ComInterop.Additional.targets` is used
to copy over the winmd into CascadiaPackage. The build variable
`TerminalWinGetInterop` is used to import the package properly.

`WindowsPackageManagerFactory` is used as a centralized way to generate
the winget objects. Long-term, we may need to do manual activation for
elevated sessions, which this class can easily be extended to support.
In the meantime, we'll just use the normal `winrt::create_instance` on
all sessions.

In `TerminalPage`, we conduct the search asynchronously when a missing
command was found. Search results are limited to 20 packages. We try to
retrieve packages with the following filters set, then fallback into the
next step:
1. `PackageMatchField::Command`,
`PackageFieldMatchOption::StartsWithCaseInsensitive`
2. `PackageMatchField::Name`,
`PackageFieldMatchOption::ContainsCaseInsensitive`
3. `PackageMatchField::Moniker`,
`PackageFieldMatchOption::ContainsCaseInsensitive`

This aligns with the Microsoft.WinGet.CommandNotFound PowerShell module
([link to relevant
code](https://github.com/microsoft/winget-command-not-found/blob/9bc83617b94f6dc88e1fc9599e1c859bc3adf96f/src/WinGetCommandNotFoundFeedbackPredictor.cs#L165-L202)).

Closes #17378
Closes #17631
Support for elevated sessions tracked in #17677

## References
-
https://github.com/microsoft/winget-cli/blob/master/src/Microsoft.Management.Deployment/PackageManager.idl:
winget object documentation

## Validation Steps Performed
- [X] unelevated sessions --> winget query performed and presented
- [X] elevated sessions --> nothing happens (got rid of `winget install
{}` suggestion)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Suggestions Anything related to tasks or the suggestions UI (sxnui) Issue-Task It's a feature request, but it doesn't really need a major design. Needs-Tag-Fix Doesn't match tag requirements Product-Terminal The new Windows Terminal.
Projects
None yet
Development

No branches or pull requests

1 participant