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

PowerToys Run Plugin interface cannot enforce result order #36519

Open
Heck-R opened this issue Dec 22, 2024 · 0 comments
Open

PowerToys Run Plugin interface cannot enforce result order #36519

Heck-R opened this issue Dec 22, 2024 · 0 comments
Labels
Issue-Bug Something isn't working Needs-Triage For issues raised to be triaged and prioritized by internal Microsoft teams

Comments

@Heck-R
Copy link

Heck-R commented Dec 22, 2024

Microsoft PowerToys version

0.87.0

Installation method

Microsoft Store

Running as admin

Yes

Area(s) with issue?

PowerToys Run

Steps to reproduce

I'm not sure whether it is a bug or something weird that is either not documented or I could not find the documentation for, but here we go:

When making a plugin, it is not possible to fix the order of the results from the plugin side for specific sets of searches.
Let's take a specific example, which is a barebone plugin (not global, no result tuning [although] that does not matter because it is a user setting which should be possible to ignore on purpose), and the following Query function:

        public List<Result> Query(Query query) {
            List<Result> results = [];
            string[] items = query.Search.Split(";");
            for (int index = 0; index < items.Length; index++) {
                results.Add(new Result {
                    Title = items[index],
                    Score = items.Length - index,
                    SelectedCount = 0,
                    Action = actionContext => {
                        this.Context.API.ChangeQuery(query.RawQuery, true);
                        return false;
                    },
                });
                results.Last().SubTitle = $"{Context.CurrentPluginMetadata.WeightBoost} - {results.Last().Score} - {results.Last().SelectedCount}";
            }

            return results;
        }

The interface for ordering, as far as I know, is the Score, and it does work until something is selected, which in general makes sense because of the order tuning, but the issue is that the order tuning cannot be avoided from the plugin side properly when a set of results are meant to have a strict order (I want to have it most of the time, but sometimes I to provide a strict order)

As it can be seen above, I tried to also set the SelectedCount based on a snippet I found in the PowerToys source code (PowerLauncher > ResultsViewModel > Sort), and while I did not spend much time on it, I assume that is more or less what is happening (please correct me if I'm wrong)
Image

The issue is that while I have no weight boost and have a good score the SelectedCount seems to have no effect because as I select something, it jumps to the top regardless, and that persists, even though the results are recreated with 0 SelectedCount, so I don't get what the SelectedCount does at all (which is mostly why I marked this as a bug, but it's the smaller issue)

Technically I could multiply the scores, but that's just a weird workaround, which works until it doesn't as the user selects enough stuff, and making the user change the tuning is not a good solution, especially when in some cases the tuning is preferred within the same plugin.

In case it is not a bug, and the method to do fixed ordering exists, I'd appreciate a link to the docs, and if there are no docs, then I'd appreciate help with this, and some docs to be made on the plugin and result interface because I can't find docs when it comes to doing anything meaningful

✔️ Expected Behavior

The code above does this regardless of selecting items
Image

❌ Actual Behavior

The code above does this after selecting items
Image

Other Software

No response

@Heck-R Heck-R added Issue-Bug Something isn't working Needs-Triage For issues raised to be triaged and prioritized by internal Microsoft teams labels Dec 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Bug Something isn't working Needs-Triage For issues raised to be triaged and prioritized by internal Microsoft teams
Projects
None yet
Development

No branches or pull requests

1 participant