Skip to content

Conversation

@hassoncs
Copy link
Contributor

@hassoncs hassoncs commented Jun 3, 2025

This improves the behavior of autocomplete in cases where the text in the document may already contain a prefix or suffix from the completion.

Now, with this change, we add more complex prefix and suffix checking, and we only insert the completion preview with matching text removed, greatly improving the issue where we duplicate closing braces.

image
2025-06-03 11 11 12
2025-06-02 07 43 59

@changeset-bot
Copy link

changeset-bot bot commented Jun 3, 2025

⚠️ No Changeset found

Latest commit: 366c3f3

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@hassoncs hassoncs force-pushed the autocomplete-follow-ups branch 6 times, most recently from 372d323 to f1e7c8f Compare June 3, 2025 20:49
@hassoncs hassoncs marked this pull request as ready for review June 3, 2025 20:50
@hassoncs hassoncs force-pushed the autocomplete-follow-ups branch from be87c60 to 614b2c3 Compare June 3, 2025 21:29
Kilo Code added 11 commits June 4, 2025 08:23
- eliminate static instance to simplify class design
- adjust animation manager initialization to use new operator
- integrate processTextInsertion to handle overlapping text
- enhance createInlineCompletionItem to use insertRange

✅ test(autocomplete): add tests for CompletionTextProcessor

- add unit tests for processTextInsertion function
- include MockTextEditor and MockTextDocument for testing
- test various completion and overlap scenarios
…er for better request management

Use AbortController instead of requestId tracking

- modify error handling to exclude expected AbortErrors
- ensure smoother user experience by avoiding unnecessary error logs
- Introduce `AutocompleteStatusBar` class to manage status bar display.
- Display current state with cost information and token validation.

♻️ refactor(autocomplete): centralize state management

- Consolidate autocomplete state into a single `AutocompleteState` object.
- Simplify state updates and improve readability.

✅ test(autocomplete): add tests for AutocompleteStatusBar

- Implement unit tests for `AutocompleteStatusBar` behavior.
- Verify correct display text and tooltip for different states.

✨ feat(utils): add cost formatting utility

- Create `formatCost` utility for consistent cost display.
- Handle small amount formatting with precision.

✅ test(utils): add tests for cost formatting utility

- Test `formatCost` function for various input scenarios.
- Ensure correct formatting for zero, small, and large amounts.
- replace LRUCache with AutocompleteCache for better modularity
- remove generateCacheKey function from AutocompleteProvider
- implement cache key generation within AutocompleteCache
- streamline cache operations with new findMatchingCompletion and addCompletion methods

✨ feat(cache): introduce AutocompleteCache class

- create AutocompleteCache class to handle completion caching
- include methods for adding and retrieving completions
- ensure cache size and TTL are configurable
- provide cache clearing functionality
…eContext

Often we need to pass all three at the same time, so let's just put the document and position into the context.

Also:
- remove unnecessary parameters from function calls
- streamline cache operations
- remove text insertion options for prefix and suffix trimming
- default trimming behavior to always active
- introduce `Autocompletion` type to encapsulate completion data
- update cache to store structured `Autocompletion` objects
- modify completion generation to return structured results

♻️ refactor(autocomplete): improve completion processing logic

- adjust completion processing to use structured data
- streamline cache interactions with new `Autocompletion` type
- revise log outputs to reflect structured completion data

🐛 fix(autocomplete): correct cache entry duplication detection

- ensure completions are checked against structured data for uniqueness
- prevent duplicate cache entries by comparing full structured objects
- introduce lastCompletionTime to track completion duration
- display completion time in status bar if available

✅ test(autocomplete): ensure completion time is tested

- add tests for status bar display with completion time
- verify correct formatting in tooltip and text display

♻️ refactor(templating): simplify AutocompleteTemplate formatting

- remove redundant example queries from template
- streamline user prompt generation logic
- extract duplicated API handler creation logic into a helper function
- improve maintainability and readability by centralizing logic

✅ test(autocomplete): add tests for API handler creation logic

- verify the refactored API handler creation logic in dedicated test file
- ensure correct behavior for various token configurations

✅ test(autocomplete): add tests for token validation logic

- verify token validation is correctly derived from API handler state
- ensure accurate token status updates across different scenarios

💄 style(autocomplete): enhance status bar display

- add completion time to status bar text for improved user feedback
@hassoncs hassoncs force-pushed the autocomplete-follow-ups branch from 614b2c3 to bc03f2b Compare June 4, 2025 21:21
- replace timer-based animation with abortable delay for better control
- introduce runAnimation method to handle animation lifecycle
- use AbortController to manage animation cancellation

✅ test(autocomplete): add tests for abortableDelay utility

- ensure delay resolves after specified time
- verify delay rejects when aborted before completion
- test immediate rejection if signal is already aborted

✨ feat(utils): add abortableDelay utility function

- create a promise-based delay that can be aborted
- support cancellation through AbortSignal for flexible use
@hassoncs hassoncs force-pushed the autocomplete-follow-ups branch from bc03f2b to 366c3f3 Compare June 5, 2025 07:34
@hassoncs
Copy link
Contributor Author

hassoncs commented Jul 7, 2025

Closing this PR as most of tit was included in #1130

@hassoncs hassoncs closed this Jul 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants