Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/fast-carrots-remember.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"kilo-code": patch
---

Add id field to autocomplete cache for better visibility tracking

Added an `id` property to `FillInAtCursorSuggestion` type and updated visibility tracking to use the id instead of the prefix/suffix/suggestion triplet for more reliable telemetry.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export type { AutocompleteContext, CacheMatchType, FillInAtCursorSuggestion }
* This key is used to track whether the same suggestion is still being displayed.
*/
export function getSuggestionKey(suggestion: FillInAtCursorSuggestion): string {
return `${suggestion.prefix}|${suggestion.suffix}|${suggestion.text}`
return suggestion.id
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,13 @@ export class GhostInlineCompletionProvider implements vscode.InlineCompletionIte
return
}

// Ensure the suggestion has an id for telemetry tracking
const suggestionWithId = fillInAtCursor.id
? fillInAtCursor
: { ...fillInAtCursor, id: crypto.randomUUID() }

// Add to the end of the array (most recent)
this.suggestionsHistory.push(fillInAtCursor)
this.suggestionsHistory.push(suggestionWithId)

// Remove oldest if we exceed the limit
if (this.suggestionsHistory.length > MAX_SUGGESTIONS_HISTORY) {
Expand Down Expand Up @@ -368,7 +373,7 @@ export class GhostInlineCompletionProvider implements vscode.InlineCompletionIte
): FillInAtCursorSuggestion {
if (!suggestionText) {
this.telemetry?.captureSuggestionFiltered("empty_response", telemetryContext)
return { text: "", prefix, suffix }
return { text: "", prefix, suffix, id: crypto.randomUUID() }
}

const processedText = postprocessGhostSuggestion({
Expand All @@ -379,11 +384,11 @@ export class GhostInlineCompletionProvider implements vscode.InlineCompletionIte
})

if (processedText) {
return { text: processedText, prefix, suffix }
return { text: processedText, prefix, suffix, id: crypto.randomUUID() }
}

this.telemetry?.captureSuggestionFiltered("filtered_by_postprocessing", telemetryContext)
return { text: "", prefix, suffix }
return { text: "", prefix, suffix, id: crypto.randomUUID() }
}

private async disposeIgnoreController(): Promise<void> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ describe("AutocompleteTelemetry", () => {
text: `text-${index}`,
prefix: `prefix-${index}`,
suffix: `suffix-${index}`,
id: `suggestion-${index}`,
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/services/ghost/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ export interface FillInAtCursorSuggestion {
text: string
prefix: string
suffix: string
/** Unique identifier for this suggestion, used for telemetry tracking */
id: string
}

export interface MatchingSuggestionResult {
Expand Down
Loading