Skip to content

Commit 5b06b08

Browse files
committed
Adding Feedback mechanism V2 version
1 parent 25c7caf commit 5b06b08

File tree

6 files changed

+104
-11
lines changed

6 files changed

+104
-11
lines changed

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqCodeTest/CodeWhispererUTGChatManager.kt

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -559,12 +559,23 @@ class CodeWhispererUTGChatManager(val project: Project, private val cs: Coroutin
559559
e is JsonParseException -> message("testgen.error.generic_technical_error_message")
560560
else -> message("testgen.error.generic_error_message")
561561
}
562-
562+
val buttonList = mutableListOf<Button>()
563+
buttonList.add(
564+
Button(
565+
"utg_feedback",
566+
"How can we make /test better?",
567+
keepCardAfterClick = true,
568+
position = "outside",
569+
status = "info",
570+
icon = "comment"
571+
),
572+
)
563573
codeTestChatHelper.addAnswer(
564574
CodeTestChatMessageContent(
565575
message = errorMessage,
566576
type = ChatMessageType.Answer,
567-
canBeVoted = false
577+
canBeVoted = false,
578+
buttons = buttonList
568579
)
569580
)
570581

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqCodeTest/controller/CodeTestChatController.kt

Lines changed: 47 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import com.intellij.diff.DiffManagerEx
99
import com.intellij.diff.requests.SimpleDiffRequest
1010
import com.intellij.ide.BrowserUtil
1111
import com.intellij.openapi.application.ApplicationManager
12+
import com.intellij.openapi.application.runInEdt
1213
import com.intellij.openapi.fileEditor.FileEditorManager
1314
import com.intellij.openapi.project.Project
1415
import com.intellij.openapi.project.guessProjectDir
@@ -92,6 +93,7 @@ import software.aws.toolkits.jetbrains.services.cwc.editor.context.ExtractionTri
9293
import software.aws.toolkits.jetbrains.services.cwc.editor.context.file.FileContext
9394
import software.aws.toolkits.jetbrains.services.cwc.messages.ChatMessageType
9495
import software.aws.toolkits.jetbrains.services.telemetry.TelemetryService
96+
import software.aws.toolkits.jetbrains.ui.feedback.TestGenFeedbackDialog
9597
import software.aws.toolkits.jetbrains.utils.notifyError
9698
import software.aws.toolkits.resources.message
9799
import software.aws.toolkits.telemetry.AmazonqTelemetry
@@ -168,13 +170,14 @@ class CodeTestChatController(
168170
override suspend fun processStartTestGen(message: IncomingCodeTestMessage.StartTestGen) {
169171
codeTestChatHelper.setActiveCodeTestTabId(message.tabId)
170172
val session = codeTestChatHelper.getActiveSession()
173+
if (session.isGeneratingTests) {
174+
return
175+
}
176+
sessionCleanUp(session.tabId)
171177
// check if IDE has active file open, yes return (fileName and filePath) else return null
172178
val project = context.project
173179
val fileInfo = checkActiveFileInIDE(project, message) ?: return
174180
session.programmingLanguage = fileInfo.fileLanguage
175-
if (session.isGeneratingTests === true) {
176-
return
177-
}
178181
session.startTimeOfTestGeneration = Instant.now().toEpochMilli().toDouble()
179182
session.isGeneratingTests = true
180183

@@ -687,14 +690,25 @@ class CodeTestChatController(
687690
requestId = session.startTestGenerationRequestId,
688691
status = Status.ACCEPTED,
689692
)
693+
val buttonList = mutableListOf<Button>()
694+
buttonList.add(
695+
Button(
696+
"utg_feedback",
697+
"How can we make /test better?",
698+
keepCardAfterClick = true,
699+
position = "outside",
700+
status = "info",
701+
icon = "comment"
702+
),
703+
)
690704
codeTestChatHelper.addAnswer(
691705
CodeTestChatMessageContent(
692706
message = message("testgen.message.success"),
693707
type = ChatMessageType.Answer,
694-
canBeVoted = false
708+
canBeVoted = false,
709+
buttons = buttonList
695710
)
696711
)
697-
sessionCleanUp(session.tabId)
698712
codeTestChatHelper.updateUI(
699713
promptInputDisabledState = false,
700714
promptInputPlaceholder = message("testgen.placeholder.enter_slash_quick_actions"),
@@ -836,11 +850,24 @@ class CodeTestChatController(
836850
ApplicationManager.getApplication().invokeLater {
837851
session.openedDiffFile?.let { FileEditorManager.getInstance(context.project).closeFile(it) }
838852
}
853+
val buttonList = mutableListOf<Button>()
854+
buttonList.add(
855+
Button(
856+
"utg_feedback",
857+
"How can we make /test better?",
858+
keepCardAfterClick = true,
859+
position = "outside",
860+
status = "info",
861+
disabled = true,
862+
icon = "comment"
863+
),
864+
)
839865
codeTestChatHelper.addAnswer(
840866
CodeTestChatMessageContent(
841867
message = message("testgen.message.success"),
842868
type = ChatMessageType.Answer,
843-
canBeVoted = false
869+
canBeVoted = false,
870+
buttons = buttonList
844871
)
845872
)
846873
val testGenerationEventResponse = client.sendTestGenerationEvent(
@@ -884,7 +911,10 @@ class CodeTestChatController(
884911
requestId = session.startTestGenerationRequestId,
885912
status = Status.REJECTED,
886913
)
887-
sessionCleanUp(message.tabId)
914+
}
915+
"utg_feedback" -> {
916+
sendFeedback()
917+
UiTelemetry.click(context.project, "unitTestGeneration_provideFeedback")
888918
}
889919
"utg_skip_and_finish" -> {
890920
codeTestChatHelper.addAnswer(
@@ -1373,6 +1403,16 @@ class CodeTestChatController(
13731403
println(message)
13741404
}
13751405

1406+
private fun sendFeedback() {
1407+
runInEdt {
1408+
TestGenFeedbackDialog(
1409+
context.project,
1410+
codeTestChatHelper.getActiveSession().startTestGenerationRequestId,
1411+
codeTestChatHelper.getActiveSession().testGenerationJob
1412+
).show()
1413+
}
1414+
}
1415+
13761416
companion object {
13771417
private val LOG = getLogger<CodeTestChatController>()
13781418

plugins/amazonq/mynah-ui/src/mynah-ui/ui/apps/codeTestChatConnector.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ export class CodeTestChatConnector {
151151
text: '',
152152
options: messageData.followUps,
153153
} : undefined,
154-
canBeVoted: true,
154+
canBeVoted: messageData.canBeVoted ?? false,
155155
fileList: messageData.fileList ? {
156156
rootFolderTitle: messageData.projectRootName,
157157
fileTreeTitle: 'READY FOR REVIEW',
@@ -477,7 +477,20 @@ export class CodeTestChatConnector {
477477
disabled: true
478478
}
479479
]
480-
break;
480+
break
481+
482+
case FormButtonIds.CodeTestProvideFeedback:
483+
answer.buttons = [
484+
{
485+
keepCardAfterClick: true,
486+
text: 'Thanks for providing feedback.',
487+
id: 'utg_provided_feedback',
488+
status: 'success',
489+
position: 'outside',
490+
disabled: true
491+
}
492+
]
493+
break
481494
default:
482495
console.warn(`Unhandled action ID: ${action.id}`);
483496
break;

plugins/amazonq/mynah-ui/src/mynah-ui/ui/forms/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export const enum FormButtonIds {
2727
CodeTestStartGeneration = "code_test_start_generation",
2828
CodeTestViewDiff = "utg_view_diff",
2929
CodeTestAccept = "utg_accept",
30+
CodeTestProvideFeedback = "utg_feedback",
3031
CodeTestRegenerate = "utg_regenerate",
3132
CodeTestReject = "utg_reject",
3233
CodeTestBuildAndExecute = "utg_build_and_execute",
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright 2025 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package software.aws.toolkits.jetbrains.ui.feedback
5+
6+
import com.intellij.openapi.project.Project
7+
import software.aws.toolkits.jetbrains.services.telemetry.TelemetryService
8+
import software.aws.toolkits.resources.message
9+
10+
class TestGenFeedbackDialog(
11+
project: Project,
12+
private val requestId: String? = null,
13+
private val jobId: String? = null,
14+
) : FeedbackDialog(project) {
15+
override fun notificationTitle() = message("aws.notification.title.amazonq.test_generation")
16+
override fun feedbackPrompt() = message("feedback.comment.textbox.title.amazonq.test_generation")
17+
override fun productName() = "Amazon Q Test Generation"
18+
override suspend fun sendFeedback() {
19+
TelemetryService.getInstance().sendFeedback(sentiment, "UserComment: $commentText, RequestId: $requestId, TestGenerationJobId: $jobId")
20+
}
21+
22+
init {
23+
title = message("feedback.title.amazonq.feature_dev")
24+
}
25+
}

plugins/core/resources/resources/software/aws/toolkits/resources/MessagesBundle.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ aws.notification.sam_cli_not_valid=Error: {0}. Click <a href="">here</a> to reco
234234
aws.notification.title=AWS Toolkit
235235
aws.notification.title.amazonq=Amazon Q
236236
aws.notification.title.amazonq.feature_dev=Amazon Q FeatureDev
237+
aws.notification.title.amazonq.test_generation=Amazon Q Test Generation
237238
aws.notification.title.codewhisperer=Amazon Q
238239
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>
239240
aws.onboarding.getstarted.panel.bottom_text_question=Why do these have different authentication requirements?
@@ -1308,6 +1309,7 @@ feedback.comment.textbox.initial.length=2000 characters remaining
13081309
feedback.comment.textbox.title=What do you like about {0}? What can we improve?
13091310
feedback.comment.textbox.title.amazonq=How was your experience with the upgrade of your Java application?
13101311
feedback.comment.textbox.title.amazonq.feature_dev=How has your experience with Amazon Q been? What can we improve?
1312+
feedback.comment.textbox.title.amazonq.test_generation=How has your experience with Amazon Q Test Generation been? What can we improve?
13111313
feedback.connect.with.github.title=Join us on GitHub
13121314
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.
13131315
feedback.description=Submit quick feedback about the AWS Toolkit for JetBrains
@@ -2069,6 +2071,7 @@ testgen.error.generic_technical_error_message=I am experiencing technical diffic
20692071
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>.
20702072
testgen.message.cancelled=Unit test generation cancelled.
20712073
testgen.message.failed=Test generation failed
2074+
testgen.message.feedback=Thanks for providing feedback.
20722075
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.
20732076
testgen.message.success=Unit test generation completed.
20742077
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.

0 commit comments

Comments
 (0)