microsoft / PowerToys

Windows system utilities to maximize productivity
MIT License
111.25k stars 6.54k forks source link

PowerToys Run: search sorting is tricky #24870

Open roozbehid opened 1 year ago

roozbehid commented 1 year ago

Description of the new feature / enhancement

typing "rem" or "remo" or "remot" should bring me "Remote Desktop" first, then Windows Settings then Command line based on my settings, but it seems it is always Windows Settings.

Scenario when this would be used?

I expect results are aggregated then sorted. I still dont understand what is the current behavior

Supporting information

"rem" image

"remo" image

"remot" image

and here are my settings image

Program (which should be the "Remote application" program in this case) has the highest rank image

Shell which is also second result in my case should have had middle rank image

Windows Settings has the lowest rank but showed first image

stefansjfw commented 1 year ago

Hi, thanks for reaching out. This looks like order score is not giving a result we expect.

Could you try Results order tuning option:

image

This should prioritize the results you've selected the most. /needinfo

overpeaks commented 1 year ago

I'm having the same issue where Global sort order modifier does not seem to be affecting the order. I have the Windows walker set to 100 but whenever I search for a program it'll always show the App (which opens a new app) before showing the running app version.

Toggling the above mentioned "Results order tuning" does not seem to make a difference on my end.

FauconSpartiate commented 1 year ago

Same here, Windows settings seem to be prioritized all the time and are not influenced by any ranking. @stefansjfw any idea what this could be?

thurstonian commented 1 year ago

Also reporting in that I'm experiencing this. Global search weights being applied per plugin seems to be doing little to nothing at all, though the tuning seems to manually put recently used tasks at the top.

Even though I have Window Walker priority at 30, recents at 10, and Programs at -20, searching "outlook" or "firefox", it prioritizes the applications as opposed to the actively running windows.

dgva commented 1 year ago

Having the same issue here. When searching for "Fire", it should show "Firefox" first, but it shows "Windows Defender Firewall with Advanced Security".

The only way to force "Firefox" is to pump all the values to 1000 or -1000 (1000 for the fine tunning and the "Programs" plugin, and -1000 for the "Windows Settings" plugin) and even then, it mixes the results in a weird way:

image (This is the behaviour with the values pumped to 1000 or -1000)

FauconSpartiate commented 1 year ago

I'm going to be digging in the code a bit to see if I can find something obvisously wrong, wish me luck

Update: I lost myself in the codebase

igorzhilin commented 1 year ago

I confirm that the sort order modifier does not guarantee that the result from the category with a higher modifier will pop at the top of the list.

My case:

I want Programs to appear at the top. However, Windows settings hijack this and appear at the top instead, despite the sort order modifiers.

I use v0.73.0.

My configuration is:

I try to launch Telegram.

Expected: when I type "tele", Program "Telegram" pops at the top of the list. Actual: when I type "tele", Windows settings "Phone and modem" pops at the top. Only after I type "teleg" does Telegram pop at the top.

PowerToys PowerLauncher_oR0VBFPE7U

Either I don't understand the concept of sort order modifier or there is something wrong with it.

boryun commented 1 year ago

I dig a little bit, and if I didn't make any mistakes, ResultsViewModel.Sort is what sort the result list:

public void Sort(MainViewModel.QueryTuningOptions options)
{
    List<ResultViewModel> sorted = null;

    if (options.SearchQueryTuningEnabled)
    {
        sorted = Results.OrderByDescending(x => (x.Result.Metadata.WeightBoost + x.Result.Score + (x.Result.SelectedCount * options.SearchClickedItemWeight))).ToList();
    }
    else
    {
        sorted = Results.OrderByDescending(x => (x.Result.Metadata.WeightBoost + x.Result.Score + (x.Result.SelectedCount * 5))).ToList();
    }

    // remove history items in they are in the list as non-history items
    foreach (var nonHistoryResult in sorted.Where(x => x.Result.Metadata.Name != "History").ToList())
    {
        var historyToRemove = sorted.FirstOrDefault(x => x.Result.Metadata.Name == "History" && x.Result.Title == nonHistoryResult.Result.Title && x.Result.SubTitle == nonHistoryResult.Result.SubTitle);
        if (historyToRemove != null)
        {
            sorted.Remove(historyToRemove);
        }
    }

    Clear();
    Results.AddRange(sorted);
}

The sorting score equals to "WeightBoost + Score + SelectedCountScore", and by my understanding, WeightBoost and SelectedCountScore is controled by PowerToysRun itself, while Score can be modified by plugin, for example Calculator Plugin set the result score as 300:

public static Result CreateResult(decimal? roundedResult, string iconPath, CultureInfo culture)
{
    // Return null when the expression is not a valid calculator query.
    if (roundedResult == null)
    {
        return null;
    }

    return new Result
    {
        // Using CurrentCulture since this is user facing
        Title = roundedResult?.ToString(culture),
        IcoPath = iconPath,
        Score = 300,
        SubTitle = Properties.Resources.wox_plugin_calculator_copy_number_to_clipboard,
        Action = c => Action(roundedResult, culture),
    };
}

So, if I didn't make any mistake, the problem is the WeightBoost i.e. "global sort order score modifier" which we can control is limited to 1000 maximum, while the Score controled by plugin can be arbitrary large, I think a effective solution is to set a UpperBound for score returned by plugin and make the final score something like "ScoreModifier * UpperBound + PluginScore + SelectedCountScore"?

deanmongel commented 12 months ago

same to me,it not fix yet

R4ygen commented 11 months ago

Same here.. found a couple of similar issues too in the github, linked them to here.

Hi, thanks for reaching out. This looks like order score is not giving a result we expect.

Could you try Results order tuning option:

This should prioritize the results you've selected the most. /needinfo

Enabling "Results order tuning", ticking "wait for slower plugins", and bumping the weight up to 30, did not fix the issue.

ianelletson commented 10 months ago

I had been experiencing the same issue, principally that WindowWalker does not show above Programs regardless of settings. This is why I had switched to Flowy launcher for some time.

Setting WindowWalker priority to 1000 and Programs to -10 does seem to make PowerToys Run respect the ordering, although I won't be surprised if it returns to the old behavior of ignoring my configuration. image