Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,6 @@ export const CodewhispererServerFactory =
partialResultToken: suggestionResponse.responseContext.nextToken,
}
} else {
session.hasEditsPending = suggestionResponse.responseContext.nextToken ? true : false
return {
items: suggestionResponse.suggestions
.map(suggestion => {
Expand Down Expand Up @@ -691,13 +690,7 @@ export const CodewhispererServerFactory =
if (firstCompletionDisplayLatency) emitPerceivedLatencyTelemetry(telemetry, session)

// Always emit user trigger decision at session close
// Close session unless Edit suggestion was accepted with more pending
const shouldKeepSessionOpen =
session.suggestionType === SuggestionType.EDIT && isAccepted && session.hasEditsPending

if (!shouldKeepSessionOpen) {
sessionManager.closeSession(session)
}
sessionManager.closeSession(session)
const streakLength = editsEnabled ? sessionManager.getAndUpdateStreakLength(isAccepted) : 0
await emitUserTriggerDecisionTelemetry(
telemetry,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,16 +120,35 @@ export class EditCompletionHandler {
}

if (params.partialResultToken && currentSession) {
// Close ACTIVE session. We shouldn't record Discard trigger decision for trigger with nextToken.
if (currentSession && currentSession.state === 'ACTIVE') {
this.sessionManager.discardSession(currentSession)
}

const newSession = this.sessionManager.createSession({
document: textDocument,
startPosition: params.position,
triggerType: 'AutoTrigger',
language: currentSession.language,
requestContext: currentSession.requestContext,
autoTriggerType: undefined,
triggerCharacter: '',
classifierResult: undefined,
classifierThreshold: undefined,
credentialStartUrl: currentSession.credentialStartUrl,
supplementalMetadata: currentSession.supplementalMetadata,
customizationArn: currentSession.customizationArn,
})
// subsequent paginated requests for current session
try {
const suggestionResponse = await this.codeWhispererService.generateSuggestions({
...currentSession.requestContext,
...newSession.requestContext,
nextToken: `${params.partialResultToken}`,
})
return await this.processSuggestionResponse(
suggestionResponse,
currentSession,
false,
newSession,
true,
params.context.selectedCompletionInfo?.range
)
} catch (error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ export class CodeWhispererSession {
includeImportsWithSuggestions?: boolean
codewhispererSuggestionImportCount: number = 0
suggestionType?: string
hasEditsPending?: boolean = false
// Track the most recent itemId for paginated Edit suggestions

constructor(data: SessionData) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,7 @@ export const emitUserTriggerDecisionTelemetry = async (
streakLength
)

// Mark telemetry as complete unless Edit suggestion was accepted with more pending
const hasPendingEditTelemetry =
session.suggestionType === SuggestionType.EDIT && session.acceptedSuggestionId && session.hasEditsPending

if (!hasPendingEditTelemetry) {
session.reportedUserDecision = true
}
session.reportedUserDecision = true
}

export const emitAggregatedUserTriggerDecisionTelemetry = (
Expand Down
Loading