Skip to content

Commit

Permalink
Fix perceivedLatency to set it for only 1 trigger per display session (
Browse files Browse the repository at this point in the history
…#5118)

for the remaining triggers this value will be 0
  • Loading branch information
andrewyuq authored Nov 22, 2024
1 parent b01283e commit 364305e
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,18 @@ open class CodeWhispererClientAdaptorImpl(override val project: Project) : CodeW
val programmingLanguage = fileContext.programmingLanguage
var e2eLatency = sessionContext.latencyContext.getCodeWhispererEndToEndLatency()

// service side will only aggregate perceivedLatency with non-zero value
// For client-side, if the decision is not accept and reject, we will set the value to 0
// If the decision is accept or reject, it's guaranteed that they will need a perceivedLatency
// of non-zero because for accept case it's trivial, for reject case, this trigger must be the
// first seen trigger and this is the only one reject in this display session.
val emittedPerceivedLatency =
if (suggestionState == CodewhispererSuggestionState.Accept || suggestionState == CodewhispererSuggestionState.Reject) {
sessionContext.latencyContext.perceivedLatency
} else {
0.0
}

// When we send a userTriggerDecision of Empty or Discard, we set the time users see the first
// suggestion to be now.
if (e2eLatency < 0) {
Expand All @@ -320,7 +332,7 @@ open class CodeWhispererClientAdaptorImpl(override val project: Project) : CodeW
it.sessionId(responseContext.sessionId)
it.recommendationLatencyMilliseconds(e2eLatency)
it.triggerToResponseLatencyMilliseconds(sessionContext.latencyContext.paginationFirstCompletionTime)
it.perceivedLatencyMilliseconds(sessionContext.latencyContext.perceivedLatency)
it.perceivedLatencyMilliseconds(emittedPerceivedLatency)
it.suggestionState(suggestionState.toCodeWhispererSdkType())
it.timestamp(Instant.now())
it.suggestionReferenceCount(suggestionReferenceCount)
Expand Down

0 comments on commit 364305e

Please sign in to comment.