Skip to content

Commit 364305e

Browse files
authored
Fix perceivedLatency to set it for only 1 trigger per display session (#5118)
for the remaining triggers this value will be 0
1 parent b01283e commit 364305e

File tree

1 file changed

+13
-1
lines changed
  • plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/credentials

1 file changed

+13
-1
lines changed

plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/credentials/CodeWhispererClientAdaptor.kt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,18 @@ open class CodeWhispererClientAdaptorImpl(override val project: Project) : CodeW
304304
val programmingLanguage = fileContext.programmingLanguage
305305
var e2eLatency = sessionContext.latencyContext.getCodeWhispererEndToEndLatency()
306306

307+
// service side will only aggregate perceivedLatency with non-zero value
308+
// For client-side, if the decision is not accept and reject, we will set the value to 0
309+
// If the decision is accept or reject, it's guaranteed that they will need a perceivedLatency
310+
// of non-zero because for accept case it's trivial, for reject case, this trigger must be the
311+
// first seen trigger and this is the only one reject in this display session.
312+
val emittedPerceivedLatency =
313+
if (suggestionState == CodewhispererSuggestionState.Accept || suggestionState == CodewhispererSuggestionState.Reject) {
314+
sessionContext.latencyContext.perceivedLatency
315+
} else {
316+
0.0
317+
}
318+
307319
// When we send a userTriggerDecision of Empty or Discard, we set the time users see the first
308320
// suggestion to be now.
309321
if (e2eLatency < 0) {
@@ -320,7 +332,7 @@ open class CodeWhispererClientAdaptorImpl(override val project: Project) : CodeW
320332
it.sessionId(responseContext.sessionId)
321333
it.recommendationLatencyMilliseconds(e2eLatency)
322334
it.triggerToResponseLatencyMilliseconds(sessionContext.latencyContext.paginationFirstCompletionTime)
323-
it.perceivedLatencyMilliseconds(sessionContext.latencyContext.perceivedLatency)
335+
it.perceivedLatencyMilliseconds(emittedPerceivedLatency)
324336
it.suggestionState(suggestionState.toCodeWhispererSdkType())
325337
it.timestamp(Instant.now())
326338
it.suggestionReferenceCount(suggestionReferenceCount)

0 commit comments

Comments
 (0)