Add persistence to command palette history (#26948)

Closes #20391

### Summary
This adds a persistence layer to the command palette so that usages can
persist after Zed is closed and re-opened.

The current "usage" algorithm is unchanged, e.g.:
- Sorts by number of usages descending (no recency preference)
- Once a user's query is active, removes these suggestions in favor of
fuzzy matching

There are some additional considerations in order to keep the DB from
growing uncontrollably (and to make long-term use ergonomic):
- The "invocations" count handles max values (though at u16, it seems
unlikely a user will deal with this)
- If a command is un-invoked for more than a month, it stops being
considered a recent usage, and its next update will update its usages
back to 1

### Future Considerations
- Could make the "command expiry" configurable in settings, so the user
can decide how long to hold onto recent usages
- Could make a more sophisticated algorithm which balances recency and
total invocations - e.g. if I've used COMMAND_A 100 times in the last
month, but COMMAND_B 10 times today, should COMMAND_B actually be
preferred?
- Could do preferential fuzzy-matching against these matches once the
user starts a query.

Release Notes:

- Added persistent history of command palette usages.

---------

Co-authored-by: Peter Finn <mastion11@gmail.com>
Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
This commit is contained in:
KyleBarton 2025-04-01 14:46:35 -07:00 committed by GitHub
parent 9bc4697a33
commit 16f625bd07
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 251 additions and 17 deletions

View file

@ -13,9 +13,11 @@ path = "src/command_palette.rs"
doctest = false
[dependencies]
anyhow.workspace = true
client.workspace = true
collections.workspace = true
command_palette_hooks.workspace = true
db.workspace = true
fuzzy.workspace = true
gpui.workspace = true
picker.workspace = true
@ -23,6 +25,7 @@ postage.workspace = true
serde.workspace = true
settings.workspace = true
theme.workspace = true
time.workspace = true
ui.workspace = true
util.workspace = true
telemetry.workspace = true
@ -31,6 +34,7 @@ zed_actions.workspace = true
[dev-dependencies]
ctor.workspace = true
db = { workspace = true, features = ["test-support"] }
editor = { workspace = true, features = ["test-support"] }
env_logger.workspace = true
go_to_line.workspace = true