Skip to content

Added basic support for Windows App Actions. #39927

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

Merged
merged 15 commits into from
Jun 18, 2025

Conversation

azchohfi
Copy link
Contributor

@azchohfi azchohfi commented Jun 6, 2025

Summary of the Pull Request

Adds basic support for finding, listing, and executing Windows App Actions on files found by the Microsoft.CmdPal.Ext.Indexer extension.

PR Checklist

Detailed Description of the Pull Request / Additional comments

We also update cswin32 to stable version.

Validation Steps Performed

Validated that it doesn't show on older versions of Windows (<26100 insiders) and that it does work on newer version that have the App Actions runtime.

@azchohfi azchohfi requested a review from a team as a code owner June 6, 2025 00:58
moooyo
moooyo previously requested changes Jun 6, 2025
Copy link
Contributor

@moooyo moooyo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not add new PInvoke call in cmdpal. We are trying to make it become native aot.

@moooyo
Copy link
Contributor

moooyo commented Jun 6, 2025

I'm not sure if it's suitable for indexer extension. I guess we need to create a new ext for it?

At least, I think we need to add a new setting to control this behaviour.

@zadjii-msft @cinnamon-msft

any idea?

This comment has been minimized.

@yeelam-gordon yeelam-gordon requested a review from Copilot June 10, 2025 04:40
@yeelam-gordon yeelam-gordon added the Product-Command Palette Refers to the Command Palette utility label Jun 10, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds basic support for Windows App Actions by updating Windows SDK and related package versions while introducing new actions handling commands into the Command Palette.

  • Update package versions and Windows SDK target versions
  • Introduce ActionsListContextItem along with supporting commands and runtime for handling app actions
  • Update project configuration files and resource definitions to support new actions

Reviewed Changes

Copilot reviewed 20 out of 21 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages.config Updated Microsoft.Windows.SDK.BuildTools version to 10.0.26100.4188
Microsoft.CommandPalette.Extensions.vcxproj Updated WindowsTargetPlatformVersion to 10.0.26100.0
Utilities.cs Removed redundant cast from flag parameter
DefaultBrowserInfo.cs Updated SHLoadIndirectString call to use new syntax and pointer handling
Resources.resx Added new localized string for actions
Icons.cs Added new icon for actions support
ActionsListContextItem.cs Introduced new context item for listing available actions based on file type
NativeMethods.json, NativeHelpers.cs Updated COM related constants and settings
IndexerListItem.cs Modified MoreCommands to conditionally include the new actions context item
ExecuteActionCommand.cs Added new command for executing a selected Windows App Action
ActionRuntimeFactory.cs Added factory for creating an ActionRuntime instance
UWPApplication.cs Updated resource loading with updated SHLoadIndirectString usage
Common.Dotnet.CsWinRT.props, Directory.Packages.props, Cpp.Build.props, .vsconfig Revised SDK/package versions to align with new Windows SDK support
Files not reviewed (1)
  • src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/Properties/Resources.Designer.cs: Language not supported

== 0)
{
return new string(buffer);
default) == 0)
Copy link
Preview

Copilot AI Jun 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It appears there is an extra closing parenthesis when passing 'default' as the fourth argument to SHLoadIndirectString; please review and adjust the parameter parentheses so that the method call compiles correctly.

Copilot uses AI. Check for mistakes.

internal sealed partial class ActionsListContextItem : CommandContextItem
{
private readonly string fullPath;
private readonly List<CommandContextItem> actions = [];
Copy link
Preview

Copilot AI Jun 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The empty list initializer using '[]' is not a standard way to initialize a List in C#; consider using 'new List()' instead.

Suggested change
private readonly List<CommandContextItem> actions = [];
private readonly List<CommandContextItem> actions = new List<CommandContextItem>();

Copilot uses AI. Check for mistakes.

Copy link
Contributor

@yeelam-gordon yeelam-gordon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@azchohfi, can you show some screenshot as well as part of the PR description?
Looks like we support 3 experiences now:
a. Photos (hardcode extension list)
b. Docs (hardcode extension list)
c. Normal Files (any others)

@cinnamon-msft and @niels9001, please review the experience.

@@ -4,8 +4,8 @@
<Import Project=".\Common.Dotnet.PrepareGeneratedFolder.targets" />

<PropertyGroup>
<WindowsSdkPackageVersion>10.0.22621.57</WindowsSdkPackageVersion>
<TargetFramework>net9.0-windows10.0.22621.0</TargetFramework>
<WindowsSdkPackageVersion>10.0.26100.68-preview</WindowsSdkPackageVersion>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thus, it is not only Win11, but even need more advanced version?
Given Powertoys support from Win10 to Win11, asking this to see what experience it can be.

Copy link
Contributor

@yeelam-gordon yeelam-gordon Jun 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like since we specified SupportedOSPlatformVersion, during build time will tell us as warning if we access any API only support in higher version of OS.

I don't see warning about API usage like CA1416;CS8776, we should be good.

@yeelam-gordon yeelam-gordon added the Needs-Triage For issues raised to be triaged and prioritized by internal Microsoft teams label Jun 10, 2025
@zadjii-msft
Copy link
Member

Here's a small GIF
actions-in-indexer-000

(admittedly, I had to make a small change to support this - I had to change

-this.Name = actionInstance.DisplayInfo.Description
+this.Name = actionInstance.Definition.Description

in ExecuteActionCommand.cs. Presumably I'm on the wrong OS build for that API. But I also don't hate this?

We have other Big Ideas here with Actions and Command Palette (which I'll probably start working on more again in July when I'm back)

Copy link
Member

@zadjii-msft zadjii-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm like mostly okay with this. Couple nits - I didn't read the code too carefully. But it's cool, that's for sure.

Updating the SDK version is always scary (Terminal's hit some breaking changes in the past with SDK updates 🙃) but What Could Go Wrong?

Hopefully we'll see more than just a couple actions showing up in here soon 😉

@@ -9,6 +9,7 @@
"Microsoft.VisualStudio.Component.Windows10SDK.19041",
"Microsoft.VisualStudio.Component.Windows10SDK.20348",
"Microsoft.VisualStudio.Component.Windows10SDK.22621",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't specific to this PR:
@crutkas have we been just adding new SDK versions to our .vsconfig this whole time? Presumably we don't need all of them - only the latest, right? We can probably prune this down, yea?

if (actionRuntime == null)
{
actionRuntime = ActionRuntimeFactory.CreateActionRuntime();
Task.Delay(500).Wait();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks sus - why wait 500ms here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bug we uncovered on the runtime last minute... It will be fixed, but its not yet, so if we don't add this, all instant calls to the runtime hung...

}

actionRuntime.ActionCatalog.Changed -= ActionCatalog_Changed;
actionRuntime.ActionCatalog.Changed += ActionCatalog_Changed;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to remove this event handler in our dtor?

(this is just me being mid at C# - I forget if these event handlers are smart and will get cleaned up for us or not)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good question, but I had no easy solution here. The actionRuntime is static, so we don't recreate it all the time, so this event subscription will keep a hold of the instance of ActionsListContextItem that holds the ActionCatalog_Changed instance method. There is no dctor here to be called, or any pattern actually that would suffice without adding something into the toolkit, since the object won't be disposed by the garbage collector. This object is passed down to the MoreItems property of the ListItem, and, AFAIK, there is no such concept of being dismissed or anything like that.

The reason we have this event handler to begin with is to handle the case where the user typed something, it returned a list of actions, but then something happens and the available actions change (multiple different things could have happened, like a user signed out of the account and they decided to make the action not available, or there is a quota and that quota is over, so it should not be available, or the user uninstalled, or installed, an app).

this.Icon = new IconInfo(actionInstance.Definition.IconFullPath);
}

public override CommandResult Invoke()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note to self: this is the canonical example of #38326

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, please.

This comment has been minimized.

This comment has been minimized.

@cinnamon-msft
Copy link
Collaborator

From a PM stance I'm cool with this, looks like a nice toe-dip into Actions and I'm eager to see community feedback on it :)

@moooyo moooyo dismissed their stale review June 11, 2025 01:50

Solved

@moooyo moooyo self-requested a review June 11, 2025 01:51
@yeelam-gordon yeelam-gordon requested a review from lei9444 June 11, 2025 10:08
@yeelam-gordon yeelam-gordon added Needs-Review This Pull Request awaits the review of a maintainer. and removed Needs-Triage For issues raised to be triaged and prioritized by internal Microsoft teams labels Jun 11, 2025
@yeelam-gordon yeelam-gordon force-pushed the alzollin/actionsInvoke branch from af87ba3 to d168ae5 Compare June 12, 2025 02:31

This comment has been minimized.

@lei9444
Copy link
Contributor

lei9444 commented Jun 16, 2025

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@lei9444
Copy link
Contributor

lei9444 commented Jun 16, 2025

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@lei9444
Copy link
Contributor

lei9444 commented Jun 16, 2025

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@lei9444
Copy link
Contributor

lei9444 commented Jun 16, 2025

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@lei9444
Copy link
Contributor

lei9444 commented Jun 16, 2025

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@lei9444
Copy link
Contributor

lei9444 commented Jun 17, 2025

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@@ -4,8 +4,8 @@
<Import Project=".\Common.Dotnet.PrepareGeneratedFolder.targets" />

<PropertyGroup>
<WindowsSdkPackageVersion>10.0.22621.57</WindowsSdkPackageVersion>
<TargetFramework>net9.0-windows10.0.22621.0</TargetFramework>
<WindowsSdkPackageVersion>10.0.26100.68-preview</WindowsSdkPackageVersion>
Copy link
Contributor

@yeelam-gordon yeelam-gordon Jun 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like since we specified SupportedOSPlatformVersion, during build time will tell us as warning if we access any API only support in higher version of OS.

I don't see warning about API usage like CA1416;CS8776, we should be good.

@lei9444
Copy link
Contributor

lei9444 commented Jun 18, 2025

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@lei9444 lei9444 merged commit 4737ec9 into microsoft:main Jun 18, 2025
9 checks passed
@zadjii-msft zadjii-msft linked an issue Jun 18, 2025 that may be closed by this pull request
yeelam-gordon added a commit that referenced this pull request Jun 20, 2025
## Summary of the Pull Request
Adds basic support for finding, listing, and executing Windows App
Actions on files found by the Microsoft.CmdPal.Ext.Indexer extension.

## PR Checklist

- [X] **Closes:** #39926
- [X] **Communication:** I've discussed this with core contributors
already. If work hasn't been agreed, this work might be rejected
- [ ] **Tests:** Added/updated and all pass
- [X] **Localization:** All end user facing strings can be localized
- [ ] **Dev docs:** Added/updated
- [ ] **New binaries:** Added on the required places
- [ ] [JSON for
signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
for new binaries
- [ ] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs)
for new binaries and localization folder
- [ ] [YML for CI
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml)
for new test projects
- [ ] [YML for signed
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml)
- [ ] **Documentation updated:** If checked, please file a pull request
on [our docs
repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys)
and link it here: #xxx

## Detailed Description of the Pull Request / Additional comments
We also update cswin32 to stable version.

<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
Validated that it doesn't show on older versions of Windows (<26100
insiders) and that it does work on newer version that have the App
Actions runtime.

---------

Co-authored-by: Gordon Lam (SH) <yeelam@microsoft.com>
Co-authored-by: Mike Griese <migrie@microsoft.com>
Co-authored-by: Leilei Zhang <leilzh@microsoft.com>
@yeelam-gordon yeelam-gordon added this to the PowerToys 0.92 milestone Jun 24, 2025
@yeelam-gordon yeelam-gordon removed the Needs-Review This Pull Request awaits the review of a maintainer. label Jun 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Product-Command Palette Refers to the Command Palette utility
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Windows App Actions support.
7 participants