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

Add capability to disable Flow Launcher result auto rank system (i.e. Score) for plugins where result order matters #2998

Open
Or1g3n opened this issue Sep 26, 2024 Discussed in #2993 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@Or1g3n
Copy link

Or1g3n commented Sep 26, 2024

Discussed in #2993

Originally posted by Or1g3n September 24, 2024
Plugin developer question - is there a way to disable flow launchers auto rank system when result order matters

I maintain a plugin where order matters (e.g., help feature shows available commands that should be ordered alphabetically, there is a sort feature where user can specify sort order, etc.). The issue I have found is that flow launcher appears to keep a ranking of results in a UserSelectedRecord.json file and that this ranking takes precedence over all; I tried hard coding a sort order in the c# list object but the ranking by Flow still took precedence; clearing the data stored in the UserSelectedRecord.json resulted in expected sort order.

I can see why this auto ranking system can be very useful in most use cases given it avoids the user having to manually search multiple matches to select the most common result record, however, in for my use case where sort order matters, this is not the desired behavior.

Is there a way to turn this off using the plugin api?

Suggestion

Either via Flow.Launcher.Plugin API or other mechanism, enable way for auto rank process to ignore plugins based on a flag property. So if theoretical property is set, Flow Launcher will ignore that plugin and not add result to UserSelectedRecord.json file. If we want to allow for more flexibility then this property could be part of the Result class so that the plugin developer can specify for a given List to enable auto rank or disable auto when user interacts with result set. I am new to Flow Launcher plugin dev so tried my best to find the mechanism for this.

It appears to be here:

private List<ResultViewModel> NewResults(IEnumerable<ResultsForUpdate> resultsForUpdates)
{
if (!resultsForUpdates.Any())
return Results;
return Results.Where(r => r != null && !resultsForUpdates.Any(u => u.ID == r.Result.PluginID))
.Concat(resultsForUpdates.SelectMany(u => u.Results, (u, r) => new ResultViewModel(r, _settings)))
.OrderByDescending(rv => rv.Result.Score)
.ToList();
}

@jjw24 jjw24 added the bug Something isn't working label Sep 26, 2024
@jjw24
Copy link
Member

jjw24 commented Sep 26, 2024

Yes, add the flag to Result class, default to allow ranking, and plugin can optionally disable when they create the results. In the code where it does the rank sorting, check for this flag.

@taooceros taooceros self-assigned this Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants