Skip to content

Commit 3167b31

Browse files
authored
Merge pull request #3399 from Kilo-Org/bmc/hide-spinner-on-error
Hide autocomplete indicator when LLM call throws
2 parents 769a684 + 7dbe073 commit 3167b31

File tree

1 file changed

+31
-25
lines changed

1 file changed

+31
-25
lines changed

src/services/ghost/classic-auto-complete/GhostInlineCompletionProvider.ts

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -270,33 +270,39 @@ export class GhostInlineCompletionProvider implements vscode.InlineCompletionIte
270270
}
271271

272272
const fullContext = await this.ghostContext.generate(context)
273-
const result = await this.getFromLLM(fullContext, this.model)
274-
275-
// Hide cursor animation after generation
276-
this.cursorAnimation.hide()
277-
278-
// Track costs
279-
if (this.costTrackingCallback) {
280-
this.costTrackingCallback(
281-
result.cost,
282-
result.inputTokens,
283-
result.outputTokens,
284-
result.cacheWriteTokens,
285-
result.cacheReadTokens,
286-
)
287-
}
288-
289-
// Update suggestions history
290-
this.updateSuggestions(result.suggestions)
273+
try {
274+
const result = await this.getFromLLM(fullContext, this.model)
275+
276+
// Hide cursor animation after generation
277+
this.cursorAnimation.hide()
278+
279+
// Track costs
280+
if (this.costTrackingCallback) {
281+
this.costTrackingCallback(
282+
result.cost,
283+
result.inputTokens,
284+
result.outputTokens,
285+
result.cacheWriteTokens,
286+
result.cacheReadTokens,
287+
)
288+
}
291289

292-
// Return the new suggestion if available
293-
const fillInAtCursor = result.suggestions.getFillInAtCursor()
294-
if (fillInAtCursor) {
295-
const item: vscode.InlineCompletionItem = {
296-
insertText: fillInAtCursor.text,
297-
range: new vscode.Range(position, position),
290+
// Update suggestions history
291+
this.updateSuggestions(result.suggestions)
292+
293+
// Return the new suggestion if available
294+
const fillInAtCursor = result.suggestions.getFillInAtCursor()
295+
if (fillInAtCursor) {
296+
const item: vscode.InlineCompletionItem = {
297+
insertText: fillInAtCursor.text,
298+
range: new vscode.Range(position, position),
299+
}
300+
return [item]
298301
}
299-
return [item]
302+
} catch (error) {
303+
this.cursorAnimation.hide()
304+
console.error("Error getting inline completion from LLM:", error)
305+
return []
300306
}
301307
}
302308

0 commit comments

Comments
 (0)