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 15:46:35 -06:00
committed by GitHub
co-authored by Peter Finn Conrad Irwin
parent 9bc4697a33
commit 16f625bd07
4 changed files with 251 additions and 17 deletions
Generated
+3
View File
@@ -3113,10 +3113,12 @@ dependencies = [
name = "command_palette"
version = "0.1.0"
dependencies = [
"anyhow",
"client",
"collections",
"command_palette_hooks",
"ctor",
"db",
"editor",
"env_logger 0.11.7",
"fuzzy",
@@ -3132,6 +3134,7 @@ dependencies = [
"settings",
"telemetry",
"theme",
"time",
"ui",
"util",
"workspace",