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 · 2 comments
Open

PowerToys Run Plugin interface cannot enforce result order #36519

Heck-R opened this issue Dec 22, 2024 · 2 comments
Labels
Issue-Bug Something isn't working Needs-Team-Response An issue author responded so the team needs to follow up 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
@htcfreek
Copy link
Collaborator

@Heck-R
I don't know the use case of your plugin enough. But PowerToys Run definitely works as designed and expected: The common used results are at the top of the list.

So what is the rarely usevcase of your plugin that you need the same results order every time?

/needinfo

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something and removed Needs-Triage For issues raised to be triaged and prioritized by internal Microsoft teams labels Dec 26, 2024
@Heck-R
Copy link
Author

Heck-R commented Dec 26, 2024

@htcfreek
Regarding the "expected" part, what is unexpected, or unknown to me is the SelectedCount field of the Result type seemingly not doing anything (that's the less important part, although if it worked as expected, it would kinda be a solution to the main point, although still debatable as it ties back to some separate undocumented implementation, at least if it is what I assume it to be)

In my specific use case:

  • I'm making a random picker, which can also create a list, where the order is part of the feature (think of a series of coin tosses)
  • Also, I have a history feature for it, which is a history of the "pickable list" if that makes sense (e.g.: heads;tails would give you one of those at random, and also put heads;tails into the history), and a good history is chronological in my opinion
  • I also have a favorites feature, where I'm not yet sure what I'd prefer, a purposefully ordered list, or the usage frequency order (current normal PT behavior), but the point is that I'd say it's a valid feature I may want to put in
  • I also have mini menus that can be navigated with the arrow keys if the user wants, and in my opinion, it's weird if a menu of a few items changes order

Some other examples outside my current use case:
Any search with results that have some inherent ordering or grouping gets chaotic when fixed ordering is not allowed

  • for example, a list of files is better ordered if they are grouped in chronological order (or at least the folders are grouped) in my opinion, effectively forced usage frequency ordering can result in chaos after a while when there are many results (e.g.: the Everything plugin can have such results or even the inbuilt plugin that uses Windows indexing)

I get that for global results the dynamic scoring system is a good idea, but for non-global results, it is sometimes (and in my experience not that rarely) a restriction to be worked around (and can only kinda be worked around)
Even, frequency aside, I do think that it's a valid thing to want to make (I'd kinda say it would be the obvious default what I'd normally expect, but of course changing the default would be bad for existing stuff, so I'd just like to have a way to do it properly, which is not some heuristic messing with the score)
It is hard to work around especially when considering that the scoring system is not well documented, although it could be just me who can't find it (if so, then please correct me, I always appreciate docs, but unless it can be disabled on the plugin side based on the given non-global query, my base issue / request still stands)

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs-Triage For issues raised to be triaged and prioritized by internal Microsoft teams Needs-Team-Response An issue author responded so the team needs to follow up and removed Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something labels Dec 26, 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-Team-Response An issue author responded so the team needs to follow up Needs-Triage For issues raised to be triaged and prioritized by internal Microsoft teams
Projects
Status: No status
Development

No branches or pull requests

2 participants