Skip to content

Commit 853b40c

Browse files
committed
adding new UI messaging for patch descriptions and removing redundant view diff buttons
1 parent 6ef2c1a commit 853b40c

File tree

7 files changed

+43
-13
lines changed

7 files changed

+43
-13
lines changed

plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/ArtifactHandler.kt

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,13 @@ import software.aws.toolkits.jetbrains.services.codemodernizer.constants.buildSt
7575
const val DOWNLOAD_PROXY_WILDCARD_ERROR: String = "Dangling meta character '*' near index 0"
7676
const val DOWNLOAD_SSL_HANDSHAKE_ERROR: String = "Unable to execute HTTP request: javax.net.ssl.SSLHandshakeException"
7777
const val INVALID_ARTIFACT_ERROR: String = "Invalid artifact"
78+
val patchDescriptions: Map<String, String> = mapOf(
79+
"Minimal Compatible Library Upgrade to Java 17" to "This diff patch covers the set of upgrades for Springboot, JUnit, and PowerMockito frameworks.",
80+
"Popular Enterprise Specifications and Application Frameworks" to "This diff patch covers the set of upgrades for Jakarta EE 10, Hibernate 6.2, and Micronaut 3.",
81+
"HTTP Client Utilities, Apache Commons Utilities, and Web Frameworks" to "This diff patch covers the set of upgrades for Apache HTTP Client 5, Apache Commons utilities (Collections, IO, Lang, Math), Struts 6.0.",
82+
"Testing Tools and Frameworks" to "This diff patch covers the set of upgrades for ArchUnit, Mockito, TestContainers, Cucumber, and additionally, Jenkins plugins and the Maven Wrapper.",
83+
"Miscellaneous Processing Documentation" to "This diff patch covers a diverse set of upgrades spanning ORMs, XML processing, API documentation, and more."
84+
)
7885

7986
class ArtifactHandler(private val project: Project, private val clientAdaptor: GumbyClient, private val codeTransformChatHelper: CodeTransformChatHelper? = null) {
8087
private val telemetry = CodeTransformTelemetryManager.getInstance(project)
@@ -212,7 +219,7 @@ class ArtifactHandler(private val project: Project, private val clientAdaptor: G
212219
// path = result.first
213220
// totalDownloadBytes = result.second
214221
// zipPath = path.toAbsolutePath().toString()
215-
zipPath = "/Users/ntarakad/Desktop/SampleArtifact.zip"
222+
zipPath = "/Users/ntarakad/Desktop/SampleArtifactOneDiffNoJson.zip"
216223
LOG.info { "Successfully converted the download to a zip at $zipPath." }
217224
} catch (e: Exception) {
218225
LOG.error { e.message.toString() }
@@ -277,7 +284,11 @@ class ArtifactHandler(private val project: Project, private val clientAdaptor: G
277284
null,
278285
ChangeListManager.getInstance(project)
279286
.addChangeList(
280-
diffDescription?.name ?: patchFile.name,
287+
if (diffDescription != null) {
288+
"${diffDescription.name} (${if (diffDescription.isSuccessful) "Success" else "Failure"})"
289+
} else {
290+
patchFile.name
291+
},
281292
""),
282293
null,
283294
null,
@@ -292,9 +303,14 @@ class ArtifactHandler(private val project: Project, private val clientAdaptor: G
292303
telemetry.viewArtifact(CodeTransformArtifactType.ClientInstructions, jobId, "Submit", source)
293304
setCurrentPatchIndex(getCurrentPatchIndex() + 1)
294305
if (getCurrentPatchIndex() < totalPatchFiles){
306+
val message = if (diffDescription != null) {
307+
"I applied the changes in diff patch ${getCurrentPatchIndex()} of $totalPatchFiles. ${patchDescriptions[diffDescription.name]} You can make a commit if the diff shows success. If the diff shows partial success, apply and fix the errors, and start a new transformation."
308+
} else {
309+
"I applied the changes to your project."
310+
}
295311
val resultContent = CodeTransformChatMessageContent(
296312
type = CodeTransformChatMessageType.PendingAnswer,
297-
message = message("codemodernizer.chat.message.result.success"),
313+
message = message,
298314
buttons = listOf(createViewDiffButton("View diff ${getCurrentPatchIndex() + 1}/${totalPatchFiles}"), viewSummaryButton),
299315
)
300316
codeTransformChatHelper?.updateLastPendingMessage(resultContent)

plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/CodeModernizerManager.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -560,11 +560,11 @@ class CodeModernizerManager(private val project: Project) : PersistentStateCompo
560560
resumeJob(session, lastJobId, currentJobResult)
561561
}
562562

563-
private fun displayDiffNotificationAction(jobId: JobId): NotificationAction = NotificationAction.createSimple(
564-
message("codemodernizer.notification.info.modernize_complete.view_diff")
565-
) {
566-
artifactHandler.displayDiffAction(jobId, CodeTransformVCSViewerSrcComponents.ToastNotification)
567-
}
563+
// private fun displayDiffNotificationAction(jobId: JobId): NotificationAction = NotificationAction.createSimple(
564+
// message("codemodernizer.notification.info.modernize_complete.view_diff")
565+
// ) {
566+
// artifactHandler.displayDiffAction(jobId, CodeTransformVCSViewerSrcComponents.ToastNotification)
567+
// }
568568

569569
private fun displaySummaryNotificationAction(jobId: JobId) =
570570
NotificationAction.createSimple(message("codemodernizer.notification.info.modernize_complete.view_summary")) {
@@ -622,7 +622,7 @@ class CodeModernizerManager(private val project: Project) : PersistentStateCompo
622622
message("codemodernizer.notification.info.modernize_partial_complete.title"),
623623
message("codemodernizer.notification.info.modernize_partial_complete.content", result.targetJavaVersion.description),
624624
project,
625-
listOf(displayDiffNotificationAction(result.jobId), displaySummaryNotificationAction(result.jobId), displayFeedbackNotificationAction()),
625+
listOf(displaySummaryNotificationAction(result.jobId), displayFeedbackNotificationAction()),
626626
)
627627
jobId = result.jobId
628628
}
@@ -632,7 +632,7 @@ class CodeModernizerManager(private val project: Project) : PersistentStateCompo
632632
message("codemodernizer.notification.info.modernize_complete.title"),
633633
message("codemodernizer.notification.info.modernize_complete.content"),
634634
project,
635-
listOf(displayDiffNotificationAction(result.jobId), displaySummaryNotificationAction(result.jobId)),
635+
listOf(displaySummaryNotificationAction(result.jobId)),
636636
)
637637
jobId = result.jobId
638638
}

plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/constants/CodeTransformChatItems.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,11 @@ fun buildTransformBeginChatContent() = CodeTransformChatMessageContent(
361361
message = message("codemodernizer.chat.message.transform_begin"),
362362
)
363363

364+
fun buildMultipleDiffsChatContent() = CodeTransformChatMessageContent(
365+
type = CodeTransformChatMessageType.PendingAnswer,
366+
message = message("codemodernizer.chat.message.multiple_patch_descriptions")
367+
)
368+
364369
fun buildTransformInProgressChatContent() = CodeTransformChatMessageContent(
365370
type = CodeTransformChatMessageType.PendingAnswer,
366371
message = message("codemodernizer.chat.message.transform_in_progress"),

plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/controller/CodeTransformChatController.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import software.aws.toolkits.jetbrains.services.codemodernizer.constants.buildHi
4242
import software.aws.toolkits.jetbrains.services.codemodernizer.constants.buildHilRejectContent
4343
import software.aws.toolkits.jetbrains.services.codemodernizer.constants.buildHilResumeWithErrorContent
4444
import software.aws.toolkits.jetbrains.services.codemodernizer.constants.buildHilResumedContent
45+
import software.aws.toolkits.jetbrains.services.codemodernizer.constants.buildMultipleDiffsChatContent
4546
import software.aws.toolkits.jetbrains.services.codemodernizer.constants.buildProjectInvalidChatContent
4647
import software.aws.toolkits.jetbrains.services.codemodernizer.constants.buildProjectValidChatContent
4748
import software.aws.toolkits.jetbrains.services.codemodernizer.constants.buildStartNewTransformFollowup
@@ -173,6 +174,7 @@ class CodeTransformChatController(
173174
codeTransformChatHelper.addNewMessage(buildTransformInProgressChatContent())
174175
} else {
175176
codeTransformChatHelper.addNewMessage(buildTransformBeginChatContent())
177+
codeTransformChatHelper.addNewMessage(buildMultipleDiffsChatContent())
176178
codeTransformChatHelper.addNewMessage(buildTransformInProgressChatContent())
177179
}
178180
return true
@@ -503,6 +505,7 @@ class CodeTransformChatController(
503505

504506
private suspend fun handleCodeTransformUploadCompleted() {
505507
codeTransformChatHelper.addNewMessage(buildTransformBeginChatContent())
508+
codeTransformChatHelper.addNewMessage(buildMultipleDiffsChatContent())
506509
codeTransformChatHelper.addNewMessage(buildTransformInProgressChatContent())
507510
}
508511

plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/model/CodeModernizerArtifact.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ open class CodeModernizerArtifact(
6161
}
6262
// notifyStickyInfo("Zip", path.name)
6363
// notifyStickyInfo("Zip", tempDir.path)
64-
tempDir = tempDir.resolve("SampleArtifact")
64+
tempDir = tempDir.resolve("SampleArtifactOneDiffNoJson")
6565
val manifest = loadManifest()
6666
if (manifest.version > maxSupportedVersion) {
6767
// If not supported we can still try to use it, i.e. the versions should largely be backwards compatible

plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/panels/managers/CodeModernizerBottomWindowPanelManager.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ class CodeModernizerBottomWindowPanelManager(private val project: Project) : JPa
209209
private fun setJobCompletedSuccessfullyUI() {
210210
add(BorderLayout.CENTER, buildProgressSplitterPanelManager)
211211
buildProgressSplitterPanelManager.apply {
212-
addViewDiffToBanner()
212+
// addViewDiffToBanner()
213213
addViewSummaryToBanner()
214214
banner.updateContent(message("codemodernizer.toolwindow.banner.run_scan_complete"), AllIcons.Actions.Commit)
215215
setSplitPanelStopView()

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,13 @@ codemodernizer.chat.message.skip_tests_form.response=Okay, I will {0} when build
618618
codemodernizer.chat.message.skip_tests_form.run_tests=Run unit tests
619619
codemodernizer.chat.message.skip_tests_form.skip=Skip unit tests
620620
codemodernizer.chat.message.transform_begin=I'm starting to transform your code. It can take 10 to 30 minutes to upgrade your code, depending on the size of your module. To monitor progress, go to the Transformation Hub.
621+
codemodernizer.chat.message.multiple_patch_descriptions=\
622+
I will be dividing my proposed changes into smaller sections. Here is a description of what each section entails:\n\n\
623+
? Minimal Compatible Library Upgrade to Java 17: This upgrades dependencies to the minimum compatible versions in Java 17. It also includes updated versions of Springboot as well as JUnit and PowerMockito frameworks.\n\n\
624+
? Popular Enterprise Specifications Application Frameworks: This group aims to migrate to the latest versions of popular enterprise specifications and application frameworks like Jakarta EE 10 (the new javax namespace), Hibernate 6.2 (a widely used ORM), and Micronaut 3 (a modern, lightweight full-stack framework).\n\n\
625+
? HTTP Client Utilities Web Frameworks: This section targets upgrades for HTTP client libraries (Apache HTTP Client 5), Apache Commons utilities (Collections, IO, Lang, Math), and web frameworks (Struts 6.0). The goal is to modernize these commonly used libraries and frameworks to their latest versions, ensuring compatibility with Java 17.\n\n\
626+
? Testing Tools Frameworks: This set upgrades targets testing tools and frameworks like ArchUnit, Mockito, TestContainers, and Cucumber. Additionally, it updates build tools like Jenkins plugins and the Maven Wrapper. The goal is to bring the testing ecosystem and build tooling up-to-date with the latest versions and best practices.\n\n\
627+
? Miscellaneous Processing Documentation: This group covers a diverse set of upgrades spanning ORMs (JpaRepository), XML processing (JAXB namespace), application servers (WebSphere to Liberty migration), API documentation (Swagger to SpringDoc/OpenAPI), and utilities (Okio, OkHttp, LaunchDarkly)
621628
codemodernizer.chat.message.transform_cancelled_by_user=I cancelled your transformation. If you want to start another transformation, choose **Start a new transformation**.
622629
codemodernizer.chat.message.transform_in_progress=If I run into any issues, I might pause the transformation to get input from you on how to proceed.
623630
codemodernizer.chat.message.transform_stopped_by_user=I stopped your transformation. If you want to start another transformation, choose **Start a new transformation**.
@@ -733,7 +740,6 @@ codemodernizer.notification.warn.zip_creation_failed=Amazon Q could not zip the
733740
codemodernizer.notification.warn.zip_creation_failed.reasons.unknown=An unexpected error occurred
734741
codemodernizer.notification.warn.zip_too_large.content=Sorry, your project size exceeds the Amazon Q Code Transformation upload limit of 2GB.
735742
codemodernizer.notification.warn.zip_too_large.title=Project size exceeds limit
736-
codemodernizer.patch.name=Patch with code changes required to upgrade to Java 17
737743
codemodernizer.toolwindow.banner.action.diff=View diff
738744
codemodernizer.toolwindow.banner.action.feedback=Provide Feedback
739745
codemodernizer.toolwindow.banner.action.plan=View transformation plan

0 commit comments

Comments
 (0)