[CmdPal] Time-decayed frecency signal for main-page ranking#49190
Draft
michaeljolley wants to merge 1 commit into
Draft
[CmdPal] Time-decayed frecency signal for main-page ranking#49190michaeljolley wants to merge 1 commit into
michaeljolley wants to merge 1 commit into
Conversation
Replace the list-position frecency heuristic in RecentCommandsManager with a real time-decayed signal: exponential recency decay (3-day half-life) combined with log2(uses) for frequency, clamped to the previous ~0..70 range so the ranker's within-tier math is unchanged and the tier still dominates ordering. - HistoryItem gains a persisted LastUsed timestamp. - Store cap grows from 50 to 500 entries. - Legacy persisted items (no LastUsed) are treated as used one day ago so day-one ordering degrades to Uses-ordering instead of going all-equal. - Add internal WithHistoryItem/GetCommandHistoryWeight overloads that take an explicit 'now' so tests can inject strictly-increasing timestamps. - Mark the internal History property [JsonInclude] so history (and LastUsed) actually round-trips through the source-generated serializer; old empty state still deserializes cleanly. - Rewrite the position-bucket tests as explicit time-decay tests; keep the tier-invariant tests unchanged in spirit. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 2 of the CmdPal search overhaul (stacked)
Base branch is
dev/mjolley/cmdpal-search-overhaul(phase 1), NOTmain. Phase 3 (provider weighting) will stack on this branch.What changed
Replaces the list-position frecency heuristic in
RecentCommandsManagerwith a real time-decayed signal so recently- and frequently-used commands reorder correctly within their ranker tier. The tier always dominates; frecency only reorders within a tier, so overall ordering behavior is preserved.recency = 2^(-ageDays / halfLife)combined withlog2(uses + 1)for frequency, clamped to the previous ~0..70 range so the ranker's within-tier math andFrecencyScale = 1.0are unaffected.HistoryItem.LastUsed: new persistedDateTimeOffsetdriving the decay.LastUseddeserialize asMinValueand are treated as used one day ago, so day-one behavior degrades to Uses-ordering rather than all-equal.Historyproperty was never emitted by the source-generated serializer, so recent-command history was silently not persisted across restarts. Marked it[JsonInclude]so history (and the newLastUsed) actually round-trips. Old empty persisted state still deserializes cleanly.WithHistoryItem(commandId, now)/GetCommandHistoryWeight(commandId, now)overloads let tests inject strictly-increasing timestamps. Public overloads passDateTimeOffset.UtcNow; the publicIRecentCommandsManagercontract is unchanged, soMainListPageneeded no changes.Design constants
Tests
Microsoft.CmdPal.UI.ViewModels.UnitTests: 150/150 pass (RecentCommandsTests 14/14).No emdashes. Change is atomic to this phase and confined to
CommandPalette.slnf.