Repository navigation
Rank results by usage (frecency) - #87
Merged
Merged
Conversation
# Conflicts: # src/SearchViewController.swift
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.
Items you open often and recently now rank higher.
Behaviour
0.04 * log2(1 + uses), at most 0.15), so a much better match still wins and usage settles near-ties like Calculator vs Calendar forcal.data == nil). Typed free-text commands aren't recorded either.Implementation
src/UsageStore.swift:UsageStore(takes the UserDefaults instance, half-life and clock, so it can be injected) and aUsageIdentifiableprotocol (URL, Command, and the composite provider's tagged wrapper).SearchServicetakes an optionalusage:store (defaults to nil, so existing callers and tests behave as before) and hasrecordSelection(_:).SearchViewController: a two-line change, which passesUsageStore.sharedand records the selected item insubmit.Testing
UsageStoreTests(13 tests) use a throwaway UserDefaults suite and a fake clock. They cover accumulation, decay, persistence, pruning, the pipe/no-identity skip, composite/command identity, empty-query ordering, tie-breaking, the boost cap, and recording throughsubmit.xcodebuild ... test: 225 tests pass.swiftlint --strict: 0 violations.🤖 Generated with Claude Code