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
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ mockitoKotlin = "5.4.0"
mockk = "1.13.10"
nimbus-jose-jwt = "9.40"
node-gradle = "7.0.2"
telemetryGenerator = "1.0.295"
telemetryGenerator = "1.0.297"
testLogger = "4.0.0"
testRetry = "1.5.10"
# test-only; platform provides slf4j transitively at runtime
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ class CodeTestChatApp(private val scope: CoroutineScope) : AmazonQApp {
"start-test-gen" to IncomingCodeTestMessage.StartTestGen::class,
"response-body-link-click" to IncomingCodeTestMessage.ClickedLink::class,
"button-click" to IncomingCodeTestMessage.ButtonClicked::class,
"chat-item-voted" to IncomingCodeTestMessage.ChatItemVoted::class,
"chat-item-feedback" to IncomingCodeTestMessage.ChatItemFeedback::class,
"button-click" to IncomingCodeTestMessage.ButtonClicked::class,
"auth-follow-up-was-clicked" to IncomingCodeTestMessage.AuthFollowUpWasClicked::class
)

Expand Down Expand Up @@ -80,6 +83,8 @@ class CodeTestChatApp(private val scope: CoroutineScope) : AmazonQApp {
is IncomingCodeTestMessage.StartTestGen -> inboundAppMessagesHandler.processStartTestGen(message)
is IncomingCodeTestMessage.ClickedLink -> inboundAppMessagesHandler.processLinkClick(message)
is IncomingCodeTestMessage.ButtonClicked -> inboundAppMessagesHandler.processButtonClickedMessage(message)
is IncomingCodeTestMessage.ChatItemVoted -> inboundAppMessagesHandler.processChatItemVoted(message)
is IncomingCodeTestMessage.ChatItemFeedback -> inboundAppMessagesHandler.processChatItemFeedBack(message)
is IncomingCodeTestMessage.AuthFollowUpWasClicked -> inboundAppMessagesHandler.processAuthFollowUpClick(message)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,9 @@ interface InboundAppMessagesHandler {

suspend fun processButtonClickedMessage(message: IncomingCodeTestMessage.ButtonClicked)

suspend fun processChatItemVoted(message: IncomingCodeTestMessage.ChatItemVoted)

suspend fun processChatItemFeedBack(message: IncomingCodeTestMessage.ChatItemFeedback)

suspend fun processAuthFollowUpClick(message: IncomingCodeTestMessage.AuthFollowUpWasClicked)
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

package software.aws.toolkits.jetbrains.services.amazonqCodeTest.controller

import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import com.intellij.diff.DiffContentFactory
import com.intellij.diff.DiffManager
import com.intellij.diff.DiffManagerEx
Expand Down Expand Up @@ -44,8 +44,11 @@
import software.amazon.awssdk.services.codewhispererstreaming.model.UserInputMessage
import software.amazon.awssdk.services.codewhispererstreaming.model.UserInputMessageContext
import software.amazon.awssdk.services.codewhispererstreaming.model.UserIntent
import software.amazon.awssdk.services.toolkittelemetry.model.Sentiment
import software.aws.toolkits.core.utils.debug
import software.aws.toolkits.core.utils.getLogger
import software.aws.toolkits.core.utils.info
import software.aws.toolkits.core.utils.warn
import software.aws.toolkits.jetbrains.core.AwsClientManager
import software.aws.toolkits.jetbrains.core.coroutines.EDT
import software.aws.toolkits.jetbrains.core.credentials.ToolkitConnectionManager
Expand Down Expand Up @@ -81,14 +84,19 @@
import software.aws.toolkits.jetbrains.services.cwc.clients.chat.v1.ChatSessionV1.Companion.validLanguages
import software.aws.toolkits.jetbrains.services.cwc.controller.chat.StaticPrompt
import software.aws.toolkits.jetbrains.services.cwc.controller.chat.StaticTextResponse
import software.aws.toolkits.jetbrains.services.cwc.controller.chat.telemetry.FeedbackComment
import software.aws.toolkits.jetbrains.services.cwc.controller.chat.telemetry.getStartUrl
import software.aws.toolkits.jetbrains.services.cwc.editor.context.ActiveFileContext
import software.aws.toolkits.jetbrains.services.cwc.editor.context.ActiveFileContextExtractor
import software.aws.toolkits.jetbrains.services.cwc.editor.context.ExtractionTriggerType
import software.aws.toolkits.jetbrains.services.cwc.editor.context.file.FileContext
import software.aws.toolkits.jetbrains.services.cwc.messages.ChatMessageType
import software.aws.toolkits.jetbrains.services.telemetry.TelemetryService
import software.aws.toolkits.jetbrains.utils.notifyError
import software.aws.toolkits.resources.message
import software.aws.toolkits.telemetry.AmazonqTelemetry

Check warning on line 97 in plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqCodeTest/controller/CodeTestChatController.kt

View workflow job for this annotation

GitHub Actions / qodana

Usage of redundant or deprecated syntax or deprecated symbols

'AmazonqTelemetry' is deprecated. Use type-safe metric builders
import software.aws.toolkits.telemetry.FeatureId
import software.aws.toolkits.telemetry.InteractionType
import software.aws.toolkits.telemetry.MetricResult
import software.aws.toolkits.telemetry.UiTelemetry
import java.io.File
Expand Down Expand Up @@ -403,6 +411,57 @@
.build()
}

override suspend fun processChatItemFeedBack(message: IncomingCodeTestMessage.ChatItemFeedback) {
LOG.debug { "$FEATURE_NAME: Processing ChatItemFeedBackMessage: ${message.comment}" }

val session = codeTestChatHelper.getActiveSession()

val comment = FeedbackComment(
conversationId = session.startTestGenerationRequestId,
userComment = message.comment.orEmpty(),
reason = message.selectedOption,
type = "testgen-chat-answer-feedback",
messageId = "",
)

try {
TelemetryService.getInstance().sendFeedback(
sentiment = Sentiment.NEGATIVE,
comment = objectMapper.writeValueAsString(comment),
)
LOG.info { "$FEATURE_NAME answer feedback sent: \"Negative\"" }
} catch (e: Throwable) {
e.notifyError(message("feedback.submit_failed", e))
LOG.warn(e) { "Failed to submit feedback" }
return
}
}

override suspend fun processChatItemVoted(message: IncomingCodeTestMessage.ChatItemVoted) {
LOG.debug { "$FEATURE_NAME: Processing ChatItemVotedMessage: $message" }

val session = codeTestChatHelper.getActiveSession()
when (message.vote) {
"upvote" -> {
AmazonqTelemetry.feedback(
featureId = FeatureId.AmazonQTest,
interactionType = InteractionType.Upvote,
credentialStartUrl = getStartUrl(project = context.project),
amazonqConversationId = session.startTestGenerationRequestId

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: extra line

)
}
"downvote" -> {
AmazonqTelemetry.feedback(
featureId = FeatureId.AmazonQTest,
interactionType = InteractionType.Downvote,
credentialStartUrl = getStartUrl(project = context.project),
amazonqConversationId = session.startTestGenerationRequestId
)
}
}
}

override suspend fun processNewTabCreatedMessage(message: IncomingCodeTestMessage.NewTabCreated) {
newTabOpened(message.tabId)
LOG.debug { "$FEATURE_NAME: New tab created: $message" }
Expand Down Expand Up @@ -799,7 +858,7 @@
}

UiTelemetry.click(null as Project?, "unitTestGeneration_rejectDiff")
AmazonqTelemetry.utgGenerateTests(

Check warning on line 861 in plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqCodeTest/controller/CodeTestChatController.kt

View workflow job for this annotation

GitHub Actions / qodana

Usage of redundant or deprecated syntax or deprecated symbols

'AmazonqTelemetry' is deprecated. Use type-safe metric builders
cwsprChatProgrammingLanguage = session.programmingLanguage.languageId,
hasUserPromptSupplied = session.hasUserPromptSupplied,
isFileInWorkspace = true,
Expand All @@ -826,7 +885,7 @@
"utg_skip_and_finish" -> {
codeTestChatHelper.addAnswer(
CodeTestChatMessageContent(
message = message("testgen.message.success"),

Check warning on line 888 in plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqCodeTest/controller/CodeTestChatController.kt

View workflow job for this annotation

GitHub Actions / qodana

Usage of redundant or deprecated syntax or deprecated symbols

'message(String, vararg Any): String' is deprecated. Use extension-specific localization bundle instead
type = ChatMessageType.Answer,
canBeVoted = false
)
Expand Down Expand Up @@ -1312,5 +1371,7 @@

companion object {
private val LOG = getLogger<CodeTestChatController>()

private val objectMapper = jacksonObjectMapper()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,17 @@ sealed interface IncomingCodeTestMessage : CodeTestBaseMessage {
@JsonProperty("actionID") val actionID: String,
) : IncomingCodeTestMessage

data class ChatItemVoted(
@JsonProperty("tabID") val tabId: String,
val vote: String,
) : IncomingCodeTestMessage

data class ChatItemFeedback(
@JsonProperty("tabID") val tabId: String,
val selectedOption: String,
val comment: String?,
) : IncomingCodeTestMessage

data class AuthFollowUpWasClicked(
@JsonProperty("tabID") val tabId: String,
val authType: AuthFollowUpType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ class TelemetryHelper(private val project: Project, private val sessionStorage:

data class FeedbackComment(
val conversationId: String,
val messageId: String,
val messageId: String?,
val reason: String,
val userComment: String,
val type: String = "codewhisperer-chat-answer-feedback",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import {ExtensionMessage} from "../commands";
import {ChatPayload, ConnectorProps} from "../connector";
import {FormButtonIds} from "../forms/constants";
import {ChatItem, ChatItemAction, ChatItemType, MynahIcons, MynahUIDataModel} from '@aws/mynah-ui-chat'
import {ChatItem, ChatItemAction, ChatItemType, FeedbackPayload, MynahIcons, MynahUIDataModel} from '@aws/mynah-ui-chat'
import {CodeReference} from "./amazonqCommonsConnector";
import {Status} from "@aws/mynah-ui-chat/dist/static";
import {EmptyMynahUIDataModel} from "@aws/mynah-ui-chat/dist/helper/store";
Expand All @@ -13,6 +13,7 @@ import {doesNotMatch} from "node:assert";
export interface ICodeTestChatConnectorProps {
sendMessageToExtension: (message: ExtensionMessage) => void
onChatAnswerReceived?: (tabID: string, message: ChatItem) => void
sendFeedback?: (tabId: string, feedbackPayload: FeedbackPayload) => void | undefined
onUpdateAuthentication: (
featureDevEnabled: boolean,
codeTransformEnabled: boolean,
Expand Down Expand Up @@ -571,6 +572,24 @@ export class CodeTestChatConnector {
})
}

onChatItemVoted = (tabId: string, messageId: string, vote: string): void | undefined => {
this.sendMessageToExtension({
tabID: tabId,
vote: vote,
command: 'chat-item-voted',
tabType: 'codetest',
})
}

sendFeedback = (tabId: string, feedbackPayload: FeedbackPayload): void | undefined => {
this.sendMessageToExtension({
command: 'chat-item-feedback',
...feedbackPayload,
tabType: 'codetest',
tabID: tabId,
})
}

onResponseBodyLinkClick = (tabID: string, messageId: string, link: string): void => {
this.sendMessageToExtension({
command: 'response-body-link-click',
Expand Down
6 changes: 6 additions & 0 deletions plugins/amazonq/mynah-ui/src/mynah-ui/ui/connector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,9 @@ export class Connector {
case 'cwc':
this.cwChatConnector.onSendFeedback(tabId, feedbackPayload)
break
case 'codetest':
this.codeTestChatConnector.sendFeedback(tabId,feedbackPayload)
break
}
}

Expand All @@ -604,6 +607,9 @@ export class Connector {
case 'featuredev':
this.featureDevChatConnector.onChatItemVoted(tabId, messageId, vote)
break
case 'codetest' :
this.codeTestChatConnector.onChatItemVoted(tabId,messageId,vote)
break
}
}
}
Loading