Skip to content

Enable loading of Feedback providers via config #25115

Closed

Description

@SteveL-MSFT

Summary of the new feature / enhancement

Some native commands may want to participate by providing a Feedback provider, but not want to craft a whole module just for it. Tools today modify the user's $profile during app install and can be tricky to remove correctly during uninstall.

Proposed technical implementation details (optional)

Extend powershell.config.json to have a section for Feedback providers. Essentially containing this section:

(actual implementation will be in JSON, using YAML for readability)

FeedbackProviders:
  - Name: WinGet CommandNotFound
     Path: $env:programfiles\foo\bar.dll
     Enabled: true

The system config.json would be the default and users can override with their own config.json (setting Enabled: false).

Feedback providers loaded on startup via this method would need to have some message shown to inform the user.

One problem is that new installs of PS7 have a default system config.json which would clobber the old one. Perhaps instead we should have the system one under ProgramData (on Windows) which would be the one apps can modify for install/uninstall.

Activity

  1. SteveL-MSFT commented on Mar 2, 2025

    @SteveL-MSFT
    MemberAuthor
  2. rhubarb-geek-nz commented on Mar 3, 2025

    @rhubarb-geek-nz

    which would be the one apps can modify for install/uninstall.

    This is a generally problematic approach of having multiple different installers modifying files that other tools have changed. When does a tools add to the file, when does it remove from the file, how does it know what it has to remove.

    In the UNIX world this problem has been addressed by having directories with the ".d" suffix so installers add and remove atomic files without interfering with others. ( eg /etc/rsyslog.d, /etc/apt/apt.conf.d etc)

    find /etc -name "*.d" -type d
    

    PowerShell already has a mechanism to do this, scoped by user or system; PowerShell modules.

    There is no problem with a native command's MSI also installing files in %ProgramFiles%\PowerShell\7\Modules\... or an RPM adding files to /opt/microsoft/powershell/7/Modules/....

    An MSIX or snap can't do this because they are self-contained directories, but then neither could they install other configuration files.

  3. daxian-dbw commented on Mar 3, 2025

    @daxian-dbw
    Member

    Asking each tool to update a config.json file -- would that be the same as asking tools to update the profile? All tools still need to change a file to add/remove a section, and they will need to get permission from user first before doing it because no one wants the PowerShell startup suddenly slows down without knowing why (I installed miniconda on my personal computer recently which adds a allUsers profile that slows down PowerShell startup. It took me sometime to figure out why PS suddenly slows down).

    Ideally, the loading of a feedback provider should be lazy, which only happens when the native command run fails. I like the directory mechanism used on Linux better but need to think about how to use that for feedback provider loading.

  4. iSazonov commented on Mar 3, 2025

    @iSazonov
    Collaborator

    Why really invent something if there is already a module mechanism? All you need is a contract on how to find them (by specific name format or a flag in manifest) and download them automatically at the right time.

  5. SteveL-MSFT commented on Mar 3, 2025

    @SteveL-MSFT
    MemberAuthor

    Updating a json file (which is structured) isn't the same as adding/removing lines from $profile which is a script.

    Ilya (@iSazonov) , rhubarb-geek-nz the intent is to enable apps/tools that DON'T have a PowerShell module, they are native commands that want PowerShell integration. We have some partners asking for this, so this isn't a hypothetical situation.

    The directory mechanism means you would still need some config for the user to indicate they DON'T want auto-loading of some extensions.

  6. rhubarb-geek-nz commented on Mar 3, 2025

    @rhubarb-geek-nz

    the intent is to enable apps/tools that DON'T have a PowerShell module, they are native commands that want PowerShell integration.

    How is the native tool packaged?

    If it is an MSI it can provide a psd1 file and a psm1 file in %ProgramFiles%\PowerShell\7\Modules\Contoso.SuperDooperApp.

    That would be less work than adding additional scripting within an MSI that changes a json file and abides by all the MSI roll-back rules.

    In what other manner are you expecting the json file to be updated?

  7. iSazonov commented on Mar 4, 2025

    @iSazonov
    Collaborator

    @iSazonov , @rhubarb-geek-nz the intent is to enable apps/tools that DON'T have a PowerShell module, they are native commands that want PowerShell integration. We have some partners asking for this, so this isn't a hypothetical situation.

    Thanks for clarify! Although there is still little information to understand their request. When I think of a native app, I imagine that it uses the SDK. Then why bother with the config at all - rather, you need a public API to discover and manage the providers. In this case, if the config is needed, then the application itself, but not for pwsh.

  8. rhubarb-geek-nz commented on Mar 4, 2025

    @rhubarb-geek-nz

    Can you give some examples of what you mean by native app? It can mean anything.

    Do you mean C/C++/Rust apps? Console or GUI? Installed from AppStore or MSI?

    Are you wanting a solution that works on all platforms, or only Windows?

    Is it supposed to be completely seamless or should the user do anything additional?

    What happens when PowerShell 7 is not installed, and then it is installed after the native app?

    What installation methods of PowerShell should be supported, eg from zip, msi, appstore, msix, homebrew, snap etc?

    Given the installation base, does the mechanism have to work with PowerShell Desktop?

    Why not have a public github project and PSGallery module containing feedback providers for common command line apps, then simply ask the app developers to contribute to that rather than providing the additional resources in their app that won't be used by 99% of their installed base?

  9. daxian-dbw commented on Mar 6, 2025

    @daxian-dbw
    Member

    the intent is to enable apps/tools that DON'T have a PowerShell module, they are native commands that want PowerShell integration. We have some partners asking for this, so this isn't a hypothetical situation.

    The directory mechanism doesn't necessarily require a module to be present. The configuration in the directory of a specific tool just need to indicate where to find the provider -- it could be from a module, or from an assembly (which may just be deployed in that directory).

    The directory mechanism means you would still need some config for the user to indicate they DON'T want auto-loading of some extensions.

    No matter it's the PowerShell config file or the directory mechanism, the installation always needs to get permission from user before making the change. For the directory approach, we can define a key in the configuration of each directory to control whether it's disabled. The benefits of the directory mechanism are:

    1. Lazy loading
    2. Take effect right after the installation of the tool thanks to the lazy loading.
    3. Safer update and cleanup -- different tools operating on different directories/files.
  10. daxian-dbw commented on Mar 19, 2025

    @daxian-dbw
    Member

    Steve Lee (@SteveL-MSFT) I submitted a draft spec for auto-discovering feedback providers and tab-completers: PowerShell/PowerShell-RFC#386

  11. added
    WG-ReviewedA Working Group has reviewed this and made a recommendation
    and removed
    Needs-TriageThe issue is new and needs to be triaged by a work group.
    WG-NeedsReviewNeeds a review by the labeled Working Group
    on May 14, 2025
  12. theJasonHelmick commented on May 14, 2025

    @theJasonHelmick
    Collaborator

    Thank you Steve Lee (@SteveL-MSFT) for this issue. The WG interactive has reviewed this and prefers the alternative mini-spec from Dongbo Wang (@daxian-dbw) and would like to see that move forward. spec: PowerShell/PowerShell-RFC#386

  13. microsoft-github-policy-service commented on May 16, 2025

    @microsoft-github-policy-service
    Contributor

    This issue has been marked as declined and has not had any activity for 1 day. It has been closed for housekeeping purposes.

  14. microsoft-github-policy-service commented on May 16, 2025

    @microsoft-github-policy-service
    Contributor

    📣 Hey @Steve Lee (@SteveL-MSFT), how did we do? We would love to hear your feedback with the link below! 🗣️

    🔗 https://aka.ms/PSRepoFeedback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Enhancementthe issue is more of a feature request than a bugResolution-DeclinedThe proposed feature is declined.WG-Interactive-Consolethe console experienceWG-ReviewedA Working Group has reviewed this and made a recommendation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions