Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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 @@ -559,12 +559,23 @@ class CodeWhispererUTGChatManager(val project: Project, private val cs: Coroutin
e is JsonParseException -> message("testgen.error.generic_technical_error_message")
else -> message("testgen.error.generic_error_message")
}

val buttonList = mutableListOf<Button>()
buttonList.add(
Button(
"utg_feedback",
"How can we make /test better?",
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 @@ -92,6 +93,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 +170,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 +568,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")

Check warning on line 571 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

'UiTelemetry' is deprecated. Use type-safe metric builders

val buttonList = mutableListOf<Button>()
buttonList.add(
Expand Down Expand Up @@ -687,14 +690,25 @@
requestId = session.startTestGenerationRequestId,
status = Status.ACCEPTED,
)
val buttonList = mutableListOf<Button>()
buttonList.add(
Button(
"utg_feedback",
"How can we make /test better?",
keepCardAfterClick = true,
position = "outside",
status = "info",
icon = "comment"
),
)
codeTestChatHelper.addAnswer(
CodeTestChatMessageContent(
message = message("testgen.message.success"),
type = ChatMessageType.Answer,
canBeVoted = false
canBeVoted = false,
buttons = buttonList
)
)
sessionCleanUp(session.tabId)
codeTestChatHelper.updateUI(
promptInputDisabledState = false,
promptInputPlaceholder = message("testgen.placeholder.enter_slash_quick_actions"),
Expand Down Expand Up @@ -836,11 +850,24 @@
ApplicationManager.getApplication().invokeLater {
session.openedDiffFile?.let { FileEditorManager.getInstance(context.project).closeFile(it) }
}
val buttonList = mutableListOf<Button>()
buttonList.add(
Button(
"utg_feedback",
"How can we make /test better?",
keepCardAfterClick = true,
position = "outside",
status = "info",
disabled = true,
icon = "comment"
),
)
codeTestChatHelper.addAnswer(
CodeTestChatMessageContent(
message = message("testgen.message.success"),
type = ChatMessageType.Answer,
canBeVoted = false
canBeVoted = false,
buttons = buttonList
)
)
val testGenerationEventResponse = client.sendTestGenerationEvent(
Expand Down Expand Up @@ -884,7 +911,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 +1403,16 @@
println(message)
}

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

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
@@ -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.feature_dev")

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 Down Expand Up @@ -2069,6 +2071,7 @@ testgen.error.generic_technical_error_message=I am experiencing technical diffic
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>.
testgen.message.cancelled=Unit test generation cancelled.
testgen.message.failed=Test generation failed
testgen.message.feedback=Thanks for providing feedback.
testgen.message.regenerate_input=Sure thing. Please provide new instructions for me to generate the tests, and select the function(s) you would like to test.
testgen.message.success=Unit test generation completed.
testgen.no_file_found=Sorry, there isn't a source file open right now that I can generate a test for. Make sure you open a source file so I can generate tests.
Expand Down
Loading