Repository navigation
Command line: AutoComplete learns the commands used most - #24
Merged
Merged
Conversation
Commands run from the command line (typed, picked with the arrows, or clicked in the list) feed a frecency score per command: +1 per use, halved every 300 later command runs. Suggestions are ranked by it; ties keep the old order. A full command name typed exactly always stays first; an exact alias counts as 3 uses, so LI lists LINE above LIST once LINE is used more. - Up/Down move through the AutoComplete list; Enter and Tab take the highlighted row. - Scores persist in the interface prefs (cmdlineUsage), also on the web; loaded data is validated and capped (200 commands, score 1000). - Reset Suggestion Order in the command line's shortcut menu forgets it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.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.
Implements the community request "Alias/Command Suggestion biasing" (from Treasure, using the web demo): typing
LIlists LIST first, though LINE is used far more. The command line now learns which commands its user runs, as AutoCAD's adaptive suggestions and the fish shell do, with no alias editing.How it ranks
l,li→LINE andlineall count for LINE).cmd_usage::decayed,cmd_usage::rank) with unit tests.EXACT_ALIAS_BONUS), so a couple of stray uses don't take its place. After about 4 uses LINE moves above LIST forLI, and Enter onLIthen runs LINE. LIST stays one Down away, and choosing it counts for it.cmdline.inputare not affected. Only the interactive Enter/Tab/click in the UI uses the learned order.Keyboard
Treasure described "type li, key down to LINE, Enter". The list had no keyboard navigation, so it does now:
Storage and bounds
prefs_json→cmdlineUsage), which the desktop app and the web build (localStorage via eframe storage) already persist. Nothing is written while nothing has been learned.unwrap,expectorpanicin non-test code.Reset
ui.cmdline.resetsuggestions(Reset Suggestion Order) forgets everything learned. It is in the command line's right-click menu, next to Clear Command History, and greyed out while nothing is learned. It has no ribbon button: AutoCAD keeps its AutoComplete settings in the command line's shortcut menu too, andui.cmdline.clearsets the precedent. Translations are in it/zh and the 12 other languages that already translate that menu (de/fr/ru don't have it yet).Tests
cmd_usage::tests: decay, ranking ties and NaN, recency over frequency, caps, clock rebase, round trip, corrupt stored values ignored.cmdline::autocomplete_tests:li_lists_line_above_list_once_line_is_used_moreuses_typed_in_any_form_count_and_fadelearning_moves_a_command_into_the_shortened_listarrows_move_the_highlight_and_typing_resets_itlearned_order_is_kept_with_the_preferences_and_can_be_reset(corrupt prefs included)cargo xtask ci: fmt, clippy, i18n, assets, layers and wasm pass. All tests pass except the three known macOS-only failures (read_file_refuses_a_name_that_is_not_unicode,usage::non_unicode_output_names,thai_marks_stack_in_an_installed_font).lilistsLI (LIST)first;li+ Enter starts LINE.🤖 Generated with Claude Code