Skip to content
This repository was archived by the owner on Aug 1, 2025. It is now read-only.

Commit 1f04aaa

Browse files
authored
more stable autocomplete (#442)
Makes autocomplete not jitter as much as you type, with a cache and a few other techniques to help increase the (1) cache hit rate and (2) VS Code's ability to reuse and not invalidate existing completion results. Why this change? - Extract the non-VS Code-specific parts of `getInlineCompletions` so we can separately test *it* and the `InlineCompletionItemProvider` logic. - All test cases were ported to the new `getInlineCompletions` (and all pass without modification in substance). - This also helps with extracting completions to the agent. - Make the cache and RequestManager simpler and dumber by exploiting VS Code's existing behavior (of showing w/o jitter a full-line inline completion while it is refreshed in the background). - Remove the existing cache entirely and replace it with a simpler cache that just memoizes calls (inside RequestManager) and does not have any other text logic. - Make the RequestManager not need to support `logId` rewriting or retesting caches for a document (see below). - Separately handle the case of "typing the last suggestion" (e.g., typing as suggested by the ghost text) vs. the general case of cached network requests. This case is the only one where we want to reuse the previous `logId`, and we can do so simply instead of (if the 2 cases are conflated) requiring the cache to support `logId` rewriting. Examples of bugs or undesirable behaviors this fixes: - Absolute minimum jitter when deleting or typing ghost text. - As long as you are still typing ghost text exactly as suggested, it won't replace it underneath you with a new completion. - If you delete through ghost text past the initial trigger point, it will always suggest something new. - When you press delete on an empty but indented line with ghost text, the ghost text remains in place (no jitter) until you type something different. ## Test plan Use completions and watch the logIds. Try typing or deleting over ghost text.
1 parent ba5dcc5 commit 1f04aaa

26 files changed

+2168
-1803
lines changed

lib/shared/src/configuration.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ export interface Configuration {
2424
| 'unstable-azure-openai'
2525
autocompleteAdvancedServerEndpoint: string | null
2626
autocompleteAdvancedAccessToken: string | null
27-
autocompleteAdvancedCache: boolean
2827
autocompleteAdvancedEmbeddings: boolean
2928
autocompleteExperimentalCompleteSuggestWidgetSelection?: boolean
3029
pluginsEnabled?: boolean

vscode/package.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -885,11 +885,6 @@
885885
"type": "string",
886886
"markdownDescription": "Overwrite the access token used for code autocomplete. This is only supported with a provider other than `anthropic`."
887887
},
888-
"cody.autocomplete.advanced.cache": {
889-
"type": "boolean",
890-
"default": true,
891-
"markdownDescription": "Enables caching of code autocomplete."
892-
},
893888
"cody.autocomplete.advanced.embeddings": {
894889
"order": 99,
895890
"type": "boolean",

vscode/src/completions/cache.test.ts

Lines changed: 0 additions & 97 deletions
This file was deleted.

vscode/src/completions/cache.ts

Lines changed: 0 additions & 104 deletions
This file was deleted.

0 commit comments

Comments
 (0)