CmdPal: adjust frecency weighting (#42242)

In #41959 we changed the string matcher's weighting. It ended up giving
us lower scores than before.

That meant that the weighting from recent commands was far too heavy,
and it was polluting the results. Basically any command that you'd run
would be like, 30 characters of weight heavier than anything you
haven't.


This increases the weight of all string matches by 10x. That means
something like
`Command Prompt` will get a string matched weight of `100` instead of
`10`. This balances better with the weighting from frecency (where the
MRU command gets +35, then `+min(5*uses,35)`, for up to 70 points of
weight)

It also adds a bunch of tests here, to try and catch this again in the
future.

Closes #42158
This commit is contained in:
Mike Griese
2025-10-09 14:35:22 -05:00
committed by GitHub
parent b06cd9f896
commit f55c49e15b
6 changed files with 507 additions and 11 deletions

View File

@@ -7,7 +7,7 @@ using CommunityToolkit.Mvvm.ComponentModel;
namespace Microsoft.CmdPal.UI.ViewModels;
public partial class RecentCommandsManager : ObservableObject
public partial class RecentCommandsManager : ObservableObject, IRecentCommandsManager
{
[JsonInclude]
internal List<HistoryItem> History { get; set; } = [];
@@ -80,3 +80,10 @@ public partial class RecentCommandsManager : ObservableObject
}
}
}
public interface IRecentCommandsManager
{
int GetCommandHistoryWeight(string commandId);
void AddHistoryItem(string commandId);
}