Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 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 @@ -29,6 +29,7 @@
import software.aws.toolkits.core.utils.error
import software.aws.toolkits.core.utils.getLogger
import software.aws.toolkits.core.utils.info
import software.aws.toolkits.jetbrains.core.credentials.sono.isInternalUser
import software.aws.toolkits.jetbrains.services.amazonq.clients.AmazonQStreamingClient
import software.aws.toolkits.jetbrains.services.amazonqCodeTest.controller.CodeTestChatHelper
import software.aws.toolkits.jetbrains.services.amazonqCodeTest.messages.Button
Expand Down Expand Up @@ -556,15 +557,28 @@
message("testgen.error.maximum_generations_reach")

e is CodeTestException -> e.uiMessage
e is JsonParseException -> message("testgen.error.generic_technical_error_message")

Check warning on line 560 in plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqCodeTest/CodeWhispererUTGChatManager.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
else -> message("testgen.error.generic_error_message")
}

val buttonList = mutableListOf<Button>()
if (isInternalUser(getStartUrl(project))) {
Copy link
Contributor

Choose a reason for hiding this comment

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

i think we need a discussion on why this is proliferating

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This PR is aimed for only internal users to get feedback about quality of UTG. So, I used this, but LMK if there is a better way todo this!
Thank you.

buttonList.add(
Button(
"utg_feedback",
message("testgen.button.feedback"),
keepCardAfterClick = true,
position = "outside",
status = "info",
icon = "comment"
),
)
}
codeTestChatHelper.addAnswer(
CodeTestChatMessageContent(
message = errorMessage,
type = ChatMessageType.Answer,
canBeVoted = false
canBeVoted = false,
buttons = buttonList
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.intellij.diff.requests.SimpleDiffRequest
import com.intellij.ide.BrowserUtil
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.application.runInEdt
import com.intellij.openapi.fileEditor.FileEditorManager
import com.intellij.openapi.project.Project
import com.intellij.openapi.project.guessProjectDir
Expand Down Expand Up @@ -53,6 +54,7 @@
import software.aws.toolkits.jetbrains.core.coroutines.EDT
import software.aws.toolkits.jetbrains.core.credentials.ToolkitConnectionManager
import software.aws.toolkits.jetbrains.core.credentials.pinning.QConnection
import software.aws.toolkits.jetbrains.core.credentials.sono.isInternalUser
import software.aws.toolkits.jetbrains.services.amazonq.apps.AmazonQAppInitContext
import software.aws.toolkits.jetbrains.services.amazonq.auth.AuthController
import software.aws.toolkits.jetbrains.services.amazonq.project.RelevantDocument
Expand Down Expand Up @@ -92,6 +94,7 @@
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.ui.feedback.TestGenFeedbackDialog
import software.aws.toolkits.jetbrains.utils.notifyError
import software.aws.toolkits.resources.message
import software.aws.toolkits.telemetry.AmazonqTelemetry
Expand Down Expand Up @@ -168,13 +171,14 @@
override suspend fun processStartTestGen(message: IncomingCodeTestMessage.StartTestGen) {
codeTestChatHelper.setActiveCodeTestTabId(message.tabId)
val session = codeTestChatHelper.getActiveSession()
if (session.isGeneratingTests) {
return
}
sessionCleanUp(session.tabId)
// check if IDE has active file open, yes return (fileName and filePath) else return null
val project = context.project
val fileInfo = checkActiveFileInIDE(project, message) ?: return
session.programmingLanguage = fileInfo.fileLanguage
if (session.isGeneratingTests === true) {
return
}
session.startTimeOfTestGeneration = Instant.now().toEpochMilli().toDouble()
session.isGeneratingTests = true

Expand Down Expand Up @@ -565,7 +569,7 @@
session.linesOfCodeGenerated = lineDifference.coerceAtLeast(0)
session.charsOfCodeGenerated = charDifference.coerceAtLeast(0)
session.latencyOfTestGeneration = (Instant.now().toEpochMilli() - session.startTimeOfTestGeneration)
UiTelemetry.click(null as Project?, "unitTestGeneration_viewDiff")
UiTelemetry.click(context.project, "unitTestGeneration_viewDiff")

val buttonList = mutableListOf<Button>()
buttonList.add(
Expand Down Expand Up @@ -662,7 +666,7 @@
testGenerationEventResponse.responseMetadata().requestId()}"
}

UiTelemetry.click(null as Project?, "unitTestGeneration_acceptDiff")
UiTelemetry.click(context.project, "unitTestGeneration_acceptDiff")

AmazonqTelemetry.utgGenerateTests(
cwsprChatProgrammingLanguage = session.programmingLanguage.languageId,
Expand Down Expand Up @@ -691,10 +695,10 @@
CodeTestChatMessageContent(
message = message("testgen.message.success"),
type = ChatMessageType.Answer,
canBeVoted = false
canBeVoted = false,
buttons = this.showFeedbackButton()
)
)
sessionCleanUp(session.tabId)
codeTestChatHelper.updateUI(
promptInputDisabledState = false,
promptInputPlaceholder = message("testgen.placeholder.enter_slash_quick_actions"),
Expand Down Expand Up @@ -840,7 +844,8 @@
CodeTestChatMessageContent(
message = message("testgen.message.success"),
type = ChatMessageType.Answer,
canBeVoted = false
canBeVoted = false,
buttons = this.showFeedbackButton()
)
)
val testGenerationEventResponse = client.sendTestGenerationEvent(
Expand Down Expand Up @@ -884,7 +889,10 @@
requestId = session.startTestGenerationRequestId,
status = Status.REJECTED,
)
sessionCleanUp(message.tabId)
}
"utg_feedback" -> {
sendFeedback()
UiTelemetry.click(context.project, "unitTestGeneration_provideFeedback")
}
"utg_skip_and_finish" -> {
codeTestChatHelper.addAnswer(
Expand Down Expand Up @@ -1373,6 +1381,33 @@
println(message)
}

private fun sendFeedback() {
runInEdt {
TestGenFeedbackDialog(
context.project,
codeTestChatHelper.getActiveSession().startTestGenerationRequestId,
codeTestChatHelper.getActiveSession().testGenerationJob
).show()
}
}

private fun showFeedbackButton(): MutableList<Button> {
val buttonList = mutableListOf<Button>()
if (isInternalUser(getStartUrl(context.project))) {
buttonList.add(
Button(
"utg_feedback",
message("testgen.button.feedback"),
keepCardAfterClick = true,
position = "outside",
status = "info",
icon = "comment"
),
)
}
return buttonList
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export class CodeTestChatConnector {
text: '',
options: messageData.followUps,
} : undefined,
canBeVoted: true,
canBeVoted: messageData.canBeVoted ?? false,
fileList: messageData.fileList ? {
rootFolderTitle: messageData.projectRootName,
fileTreeTitle: 'READY FOR REVIEW',
Expand Down Expand Up @@ -477,7 +477,20 @@ export class CodeTestChatConnector {
disabled: true
}
]
break;
break

case FormButtonIds.CodeTestProvideFeedback:
answer.buttons = [
{
keepCardAfterClick: true,
text: 'Thanks for providing feedback.',
id: 'utg_provided_feedback',
status: 'success',
position: 'outside',
disabled: true
}
]
break
default:
console.warn(`Unhandled action ID: ${action.id}`);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const enum FormButtonIds {
CodeTestStartGeneration = "code_test_start_generation",
CodeTestViewDiff = "utg_view_diff",
CodeTestAccept = "utg_accept",
CodeTestProvideFeedback = "utg_feedback",
CodeTestRegenerate = "utg_regenerate",
CodeTestReject = "utg_reject",
CodeTestBuildAndExecute = "utg_build_and_execute",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
}

init {
title = message("feedback.title.amazonq.feature_dev")
title = message("feedback.title.amazonq.send_feedback")

Check warning on line 19 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/ui/feedback/FeatureDevFeedbackDialog.kt

View workflow job for this annotation

GitHub Actions / qodana

Incorrect string capitalization

String 'Send feedback for Amazon Q' is not properly capitalized. It should have title capitalization
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Generalizing string name to reuse this for both /test and /dev.

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright 2025 Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

package software.aws.toolkits.jetbrains.ui.feedback

import com.intellij.openapi.project.Project
import software.aws.toolkits.jetbrains.services.telemetry.TelemetryService
import software.aws.toolkits.resources.message

Check warning on line 8 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/ui/feedback/TestGenFeedbackDialog.kt

View workflow job for this annotation

GitHub Actions / qodana

Usage of redundant or deprecated syntax or deprecated symbols

Remove deprecated symbol import

class TestGenFeedbackDialog(
project: Project,
private val requestId: String? = null,
private val jobId: String? = null,
) : FeedbackDialog(project) {
override fun notificationTitle() = message("aws.notification.title.amazonq.test_generation")

Check warning on line 15 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/ui/feedback/TestGenFeedbackDialog.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
override fun feedbackPrompt() = message("feedback.comment.textbox.title.amazonq.test_generation")

Check warning on line 16 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/ui/feedback/TestGenFeedbackDialog.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
override fun productName() = "Amazon Q Test Generation"
override suspend fun sendFeedback() {
TelemetryService.getInstance().sendFeedback(sentiment, "UserComment: $commentText, RequestId: $requestId, TestGenerationJobId: $jobId")
}

init {
title = message("feedback.title.amazonq.send_feedback")

Check warning on line 23 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/ui/feedback/TestGenFeedbackDialog.kt

View workflow job for this annotation

GitHub Actions / qodana

Incorrect string capitalization

String 'Send feedback for Amazon Q' is not properly capitalized. It should have title capitalization

Check warning on line 23 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/ui/feedback/TestGenFeedbackDialog.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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ aws.notification.sam_cli_not_valid=Error: {0}. Click <a href="">here</a> to reco
aws.notification.title=AWS Toolkit
aws.notification.title.amazonq=Amazon Q
aws.notification.title.amazonq.feature_dev=Amazon Q FeatureDev
aws.notification.title.amazonq.test_generation=Amazon Q Test Generation
aws.notification.title.codewhisperer=Amazon Q
aws.onboarding.getstarted.panel.bottom_text=<a href="https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/auth-access.html">Learn more about authenticating with the Toolkit</a>
aws.onboarding.getstarted.panel.bottom_text_question=Why do these have different authentication requirements?
Expand Down Expand Up @@ -1308,6 +1309,7 @@ feedback.comment.textbox.initial.length=2000 characters remaining
feedback.comment.textbox.title=What do you like about {0}? What can we improve?
feedback.comment.textbox.title.amazonq=How was your experience with the upgrade of your Java application?
feedback.comment.textbox.title.amazonq.feature_dev=How has your experience with Amazon Q been? What can we improve?
feedback.comment.textbox.title.amazonq.test_generation=How has your experience with Amazon Q Test Generation been? What can we improve?
feedback.connect.with.github.title=Join us on GitHub
feedback.customer.alert.info=Please don't add personally identifiable information (PII), confidential or sensitive information in your feedback.<br>Remove any PII when sharing file paths, error messages, etc.
feedback.description=Submit quick feedback about the AWS Toolkit for JetBrains
Expand All @@ -1327,7 +1329,7 @@ feedback.submit_success=Thanks for the feedback!
feedback.submitting=Sharing...
feedback.title=Share Feedback for {0}...
feedback.title.amazonq=Send feedback for Code Transformation by Amazon Q
feedback.title.amazonq.feature_dev=Send feedback for Amazon Q
feedback.title.amazonq.send_feedback=Send feedback for Amazon Q
feedback.validation.comment_too_long=Comment is too long.
feedback.validation.empty_comment=Please provide a comment.
feedback.validation.no_sentiment=Please select how you're feeling.
Expand Down Expand Up @@ -2064,6 +2066,7 @@ sqs.subscribe.sns.validation.empty_topic=Topic must be specified.
sqs.toolwindow=SQS
sqs.url.parse_error=Error parsing SQS queue URL
tags.title=Tags
testgen.button.feedback=How can we make /test better?
testgen.error.generic_error_message=Amazon Q encountered an error while generating tests. Try again later.
testgen.error.generic_technical_error_message=I am experiencing technical difficulties at the moment. Please try again in a few minutes.
testgen.error.maximum_generations_reach=You've reached the monthly quota for Amazon Q Developer's agent capabilities. You can try again next month. For more information on usage limits, see the <a href=\"https://aws.amazon.com/q/developer/pricing/\" target=\"_blank\">Amazon Q Developer pricing page</a>.
Expand Down
Loading