fix: stop blocking on balance check for autocomplete provider selection#62
Open
kilo-code-bot[bot] wants to merge 1 commit into
Open
fix: stop blocking on balance check for autocomplete provider selection#62kilo-code-bot[bot] wants to merge 1 commit into
kilo-code-bot[bot] wants to merge 1 commit into
Conversation
Remove the synchronous balance check from AutocompleteModel.reload() that was hitting /api/profile/balance on every model reload. The kilocode provider is now selected immediately when a token is present, and the balance check runs in the background with a 5-minute TTL cache for the status bar UI flag. This eliminates thousands of unnecessary API calls per day per user, since reload() is called on startup, settings changes, snooze/unsnooze, etc.
🦋 Changeset detectedLatest commit: 0cb60f5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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.
Summary
/api/profile/balancecall fromAutocompleteModel.reload()that was blocking provider selection on every model reload (startup, settings changes, snooze/unsnooze, etc.)fetchAndCacheSuggestion.hasKilocodeProfileWithNoBalanceflag for the status bar UI.Impact
For an authenticated user with autocomplete enabled, this eliminates a blocking HTTP request on every model reload. Previously this could generate thousands of
/api/profile/balancecalls per day tied to keystroke frequency. Now the balance endpoint is hit at most once every 5 minutes, purely for UI status.Changes
src/services/autocomplete/utils/kilocode-utils.tscheckKilocodeBalanceCached()with 5-minute TTL,resetBalanceCache()for testing, exportedBALANCE_CACHE_TTL_MSsrc/services/autocomplete/AutocompleteModel.tscheckKilocodeBalance()with non-blockingvoid checkKilocodeBalanceCached().then(...)src/services/autocomplete/utils/kilocode-utils.test.tscheckKilocodeBalanceCached(TTL, cache invalidation, credential changes)src/services/autocomplete/__tests__/AutocompleteModel.spec.tsTesting
All 36 tests pass (15 in
kilocode-utils.test.ts+ 21 inAutocompleteModel.spec.ts).