Skip to content

Commit 84e2c8c

Browse files
authored
fix: inline UTD empty cases dont differentiate Edit and Completion (aws#2287)
1 parent 60bc68d commit 84e2c8c

File tree

5 files changed

+14
-10
lines changed

5 files changed

+14
-10
lines changed

server/aws-lsp-codewhisperer/src/language-server/inline-completion/codeWhispererServer.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ export const CodewhispererServerFactory =
426426
session.responseContext = suggestionResponse.responseContext
427427
session.codewhispererSessionId = suggestionResponse.responseContext.codewhispererSessionId
428428
session.timeToFirstRecommendation = new Date().getTime() - session.startTime
429-
session.suggestionType = suggestionResponse.suggestionType
429+
session.predictionType = SuggestionType.COMPLETION
430430
} else {
431431
session.suggestions = [...session.suggestions, ...suggestionResponse.suggestions]
432432
}
@@ -454,7 +454,7 @@ export const CodewhispererServerFactory =
454454

455455
// session was closed by user already made decisions consequent completion request before new paginated API response was received
456456
if (
457-
session.suggestionType !== SuggestionType.EDIT && // TODO: this is a shorterm fix to allow Edits tabtabtab experience, however the real solution is to manage such sessions correctly
457+
session.predictionType !== SuggestionType.EDIT && // TODO: this is a shorterm fix to allow Edits tabtabtab experience, however the real solution is to manage such sessions correctly
458458
(session.state === 'CLOSED' || session.state === 'DISCARD')
459459
) {
460460
return EMPTY_RESULT
@@ -640,7 +640,7 @@ export const CodewhispererServerFactory =
640640
let deletedLengthForEdits = 0
641641
if (acceptedSuggestion) {
642642
codePercentageTracker.countSuccess(session.language)
643-
if (session.suggestionType === SuggestionType.EDIT && acceptedSuggestion.content) {
643+
if (session.predictionType === SuggestionType.EDIT && acceptedSuggestion.content) {
644644
// [acceptedSuggestion.insertText] will be undefined for NEP suggestion. Use [acceptedSuggestion.content] instead.
645645
// Since [acceptedSuggestion.content] is in the form of a diff, transform the content into addedCharacters and deletedCharacters.
646646
const { addedLines, deletedLines } = getAddedAndDeletedLines(acceptedSuggestion.content)

server/aws-lsp-codewhisperer/src/language-server/inline-completion/editCompletionHandler.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
GenerateSuggestionsRequest,
1717
GenerateSuggestionsResponse,
1818
getFileContext,
19+
SuggestionType,
1920
} from '../../shared/codeWhispererService'
2021
import { CodeWhispererSession, SessionManager } from './session/sessionManager'
2122
import { CursorTracker } from './tracker/cursorTracker'
@@ -340,7 +341,7 @@ export class EditCompletionHandler {
340341
session.responseContext = suggestionResponse.responseContext
341342
session.codewhispererSessionId = suggestionResponse.responseContext.codewhispererSessionId
342343
session.timeToFirstRecommendation = new Date().getTime() - session.startTime
343-
session.suggestionType = suggestionResponse.suggestionType
344+
session.predictionType = SuggestionType.EDIT
344345
} else {
345346
session.suggestions = [...session.suggestions, ...suggestionResponse.suggestions]
346347
}

server/aws-lsp-codewhisperer/src/language-server/inline-completion/session/sessionManager.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,9 @@ export class CodeWhispererSession {
9191
customizationArn?: string
9292
includeImportsWithSuggestions?: boolean
9393
codewhispererSuggestionImportCount: number = 0
94-
suggestionType?: string
94+
95+
// Suggestion type specified by the clients, could be either "EDIT" or "COMPLETION"
96+
predictionType?: SuggestionType
9597
// Track the most recent itemId for paginated Edit suggestions
9698

9799
constructor(data: SessionData) {
@@ -175,7 +177,7 @@ export class CodeWhispererSession {
175177
if (
176178
this.state === 'CLOSED' ||
177179
this.state === 'DISCARD' ||
178-
(this.completionSessionResult && this.suggestionType === SuggestionType.COMPLETION)
180+
(this.completionSessionResult && this.predictionType === SuggestionType.COMPLETION)
179181
) {
180182
return
181183
}

server/aws-lsp-codewhisperer/src/language-server/inline-completion/telemetry.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ export const emitUserTriggerDecisionTelemetry = async (
156156
// Edits show one suggestion sequentially (with pagination), so use latest itemId state;
157157
// Completions show multiple suggestions together, so aggregate all states
158158
const userTriggerDecision =
159-
session.suggestionType === SuggestionType.EDIT
159+
session.predictionType === SuggestionType.EDIT
160160
? session.getUserTriggerDecision(itemId)
161161
: session.getAggregatedUserTriggerDecision()
162162

server/aws-lsp-codewhisperer/src/shared/telemetry/telemetryService.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import {
2222
ChatAddMessageEvent,
2323
UserIntent,
2424
InlineChatEvent,
25-
AgenticChatEventStatus,
2625
IdeDiagnostic,
2726
UserModificationEvent,
2827
} from '../../client/token/codewhispererbearertokenclient'
@@ -201,6 +200,7 @@ export class TelemetryService {
201200
streakLength?: number
202201
) {
203202
session.decisionMadeTimestamp = performance.now()
203+
// Toolkit telemetry API
204204
if (this.enableTelemetryEventsToDestination) {
205205
const data: CodeWhispererUserTriggerDecisionEvent = {
206206
codewhispererSessionId: session.codewhispererSessionId || '',
@@ -256,8 +256,9 @@ export class TelemetryService {
256256
acceptedSuggestion && acceptedSuggestion.content ? acceptedSuggestion.content.length : 0
257257
const perceivedLatencyMilliseconds =
258258
session.triggerType === 'OnDemand' ? session.timeToFirstRecommendation : timeSinceLastUserModification
259-
const isInlineEdit = session.suggestionType === SuggestionType.EDIT
259+
const isInlineEdit = session.predictionType === SuggestionType.EDIT
260260

261+
// RTS STE API
261262
const event: UserTriggerDecisionEvent = {
262263
sessionId: session.codewhispererSessionId || '',
263264
requestId: session.responseContext?.requestId || '',
@@ -283,7 +284,7 @@ export class TelemetryService {
283284
addedIdeDiagnostics: addedIdeDiagnostics,
284285
removedIdeDiagnostics: removedIdeDiagnostics,
285286
streakLength: streakLength ?? 0,
286-
suggestionType: isInlineEdit ? 'EDITS' : 'COMPLETIONS',
287+
suggestionType: session.predictionType,
287288
}
288289
this.logging.info(`Invoking SendTelemetryEvent:UserTriggerDecisionEvent with:
289290
"requestId": ${event.requestId}

0 commit comments

Comments
 (0)