Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(amazonq): refactor, remove shortAnswer to suit the API changes, display the plan summary to the customer #5453

Open
wants to merge 21 commits into
base: main
Choose a base branch
from

Conversation

Randall-Jiang
Copy link
Contributor

@Randall-Jiang Randall-Jiang commented Mar 7, 2025

Problem

Before re:Invent, we used shortAnswer to pass data such as the test file path. However, this approach is unreliable in a long term. To improve stability, we decided to refactor the backend API by replacing shortAnswer with packageInfo and targetFileInfo. These new fields will now carry the values previously stored in shortAnswer, ensuring a more structured and reliable data transfer mechanism.

Solution

Remove the shortAnswer and replace it with packageInfo and targetFileInfo.

To-Do

  1. Handle the situation when status == stopped.

Checklist

  • My code follows the code style of this project
  • I have added tests to cover my changes
  • A short description of the change has been added to the CHANGELOG if the change is customer-facing in the IDE.
  • I have added metrics for my changes (if required)

License

I confirm that my contribution is made under the terms of the Apache 2.0 license.

@Randall-Jiang Randall-Jiang changed the title (feat) API refactor refactor(amazonQ): refactor, remove shortAnswer to suit the API changes Mar 8, 2025
@Randall-Jiang Randall-Jiang changed the title refactor(amazonQ): refactor, remove shortAnswer to suit the API changes refactor(amazonq): refactor, remove shortAnswer to suit the API changes Mar 8, 2025
@Randall-Jiang Randall-Jiang marked this pull request as ready for review March 8, 2025 01:59
@Randall-Jiang Randall-Jiang requested review from a team as code owners March 8, 2025 01:59
@Randall-Jiang Randall-Jiang marked this pull request as draft March 10, 2025 17:44
@Randall-Jiang Randall-Jiang reopened this Mar 10, 2025
@Randall-Jiang Randall-Jiang marked this pull request as ready for review March 10, 2025 17:45
}

// TO DO
// add TestGenerationJobStatus.STOPPED status

// If job status is Failed and has no ShortAnswer then there might be some issue in the backend.
Copy link
Contributor

Choose a reason for hiding this comment

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

is this still true?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no, i think that is no in to-do any more

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah we can remove this comment

@@ -0,0 +1,4 @@
{
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't need change log for this IMO.

Copy link
Contributor

Choose a reason for hiding this comment

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

Better to add change log for Plan summary

footer = listOf(testFileName)
),
messageIdOverride = codeTestResponseContext.testSummaryMessageId
var packageInfoList = testGenerationResponse.testGenerationJob().packageInfoList()
Copy link
Contributor

Choose a reason for hiding this comment

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

packageInfoList is declared at L176

throw CodeTestException("TestGenFailedError: ${shortAnswer.planSummary}", "TestGenFailedError", shortAnswer.planSummary)
}

val packageInfoList = testGenerationResponse.testGenerationJob().packageInfoList()
Copy link
Contributor

@laileni-aws laileni-aws Mar 11, 2025

Choose a reason for hiding this comment

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

Why we are declaring this again? Any specific reason.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

previously the L176 declaration is not the correct one, will remove this in the new commit

}

// TO DO
Copy link
Contributor

Choose a reason for hiding this comment

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

QQ: Do we have TestGenerationJobStatus.STOPPED field from backend?

if (shortAnswer.stopIteration == "true") {
throw CodeTestException("TestGenFailedError: ${shortAnswer.planSummary}", "TestGenFailedError", shortAnswer.planSummary)
if (previousIterationContext == null) {
val packageInfoList = testGenerationResponse.testGenerationJob().packageInfoList()
Copy link
Contributor

@laileni-aws laileni-aws Mar 11, 2025

Choose a reason for hiding this comment

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

Can we declare these variables globally to the function?

)
}
} catch (e: Exception) {
LOG.debug("failed to process package info: ${e.message}")
Copy link
Contributor

Choose a reason for hiding this comment

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

This Log does not give good insight to the user and developer to debug.

@@ -37,14 +37,18 @@ data class Session(val tabId: String) {
// First iteration will have a value of 1
var iteration: Int = 0
var projectRoot: String = "/"
var shortAnswer: ShortAnswer = ShortAnswer()

// var shortAnswer: ShortAnswer = ShortAnswer()
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove commented code

@Randall-Jiang Randall-Jiang changed the title refactor(amazonq): refactor, remove shortAnswer to suit the API changes refactor(amazonq): refactor, remove shortAnswer to suit the API changes, display the plan summary to the customer Mar 11, 2025
}

// polling every 2 seconds to reduce # of API calls
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you include this comment

var selectedFile: VirtualFile? = null
var testFileRelativePathToProjectRoot: String = ""
var testFileName: String = ""
var viewDiffMessageId: String? = null
var openedDiffFile: VirtualFile? = null
val generatedTestDiffs = mutableMapOf<String, String>()
var codeReferences: List<ShortAnswerReference>? = null

Copy link
Contributor

Choose a reason for hiding this comment

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

unnecessary line

.replace(Regex("\\s*```$"), "") // Remove trailing triple backticks
.trim()

val fullMessage = """
Copy link
Contributor

Choose a reason for hiding this comment

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

Rename fullMessage to summary or something relevant.

Copy link
Contributor

Choose a reason for hiding this comment

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

can we figure out why this keeps happening?

@@ -0,0 +1,4 @@
{
"type" : "feature",
"description" : "display plan summary to customer"
Copy link
Contributor

Choose a reason for hiding this comment

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

changelogs do not meet bar for what will be shown to customer

@@ -0,0 +1,4 @@
{
"type" : "feature",
"description" : "Amazonq /test now display the plan summary to customer"
Copy link
Contributor

Choose a reason for hiding this comment

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

AmazonQ /test now displays a concise test plan summary to users.

@laileni-aws laileni-aws requested a review from rli March 12, 2025 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants