feat: sort backend selection by MRU order with history persistence#411
feat: sort backend selection by MRU order with history persistence#411tninja wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5e15926f87
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| (unless (string-empty-p content) | ||
| (read content)))) |
There was a problem hiding this comment.
Validate history shape before returning it
If ai-code-backends-history.el contains valid Lisp that is not a proper list of backend symbols, such as a truncated atom or dotted list, this read returns it as-is instead of treating it as corrupted. The next C-c a s or backend switch then iterates/removes over that malformed value and can signal wrong-type-argument, leaving the selector broken until the user manually deletes the history file; the loader should reject and delete malformed-but-readable history too.
Useful? React with 👍 / 👎.
This pull request implements backend selection ordering based on the user's most recently used (MRU) history, resolving the issue where the candidate order in
C-c a sremained static.Approach
ai-code-backends-history.elunder theuser-emacs-directoryto serialize the list of recently selected AI backends.ai-code-select-backendsuch that the active effective backend remains first, followed by valid historical backend keys in MRU order, and lastly any remaining available backends. This ensures all backends stay accessible even if the history is partial or contains outdated keys.Verification
test_ai-code-backends.elto verify MRU list sorting, corrupted file automatic deletion, and partial history handling.