Skip to content

Commit 93df478

Browse files
author
David Hasani
committed
final CSB commit
1 parent 5bffbc7 commit 93df478

File tree

6 files changed

+43
-17
lines changed

6 files changed

+43
-17
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ private val confirmOneOrMultipleDiffsSelectionButton = Button(
8989

9090
private val confirmCustomDependencyVersionsButton = Button(
9191
keepCardAfterClick = true,
92-
waitMandatoryFormItems = true, // TODO: what does this do?
92+
waitMandatoryFormItems = true,
9393
text = "Select file",
9494
id = CodeTransformButtonId.ConfirmCustomDependencyVersions.id,
9595
)
@@ -396,7 +396,7 @@ fun buildUserInputCustomDependencyVersionsChatContent() = CodeTransformChatMessa
396396
confirmCustomDependencyVersionsButton,
397397
continueTransformationButton,
398398
),
399-
type = CodeTransformChatMessageType.FinalizedAnswer,
399+
type = CodeTransformChatMessageType.PendingAnswer,
400400
)
401401

402402
fun buildPromptTargetJDKNameChatContent(version: String) = CodeTransformChatMessageContent(

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

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,22 @@
44
package software.aws.toolkits.jetbrains.services.codemodernizer.controller
55

66
import com.intellij.ide.BrowserUtil
7+
import com.intellij.openapi.application.ApplicationManager
78
import com.intellij.openapi.application.runInEdt
89
import com.intellij.openapi.fileChooser.FileChooser
910
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory
11+
import com.intellij.openapi.fileEditor.FileEditorManager
1012
import com.intellij.openapi.module.ModuleUtil
1113
import com.intellij.openapi.projectRoots.JavaSdkVersion
1214
import com.intellij.openapi.projectRoots.ProjectJdkTable
1315
import com.intellij.openapi.util.io.FileUtil.createTempDirectory
1416
import com.intellij.openapi.vfs.VirtualFile
1517
import com.intellij.openapi.vfs.readText
18+
import com.intellij.testFramework.LightVirtualFile
1619
import kotlinx.coroutines.delay
1720
import kotlinx.coroutines.runBlocking
1821
import kotlinx.coroutines.withContext
22+
import org.jetbrains.yaml.YAMLFileType
1923
import software.amazon.awssdk.services.codewhispererstreaming.model.TransformationDownloadArtifactType
2024
import software.aws.toolkits.core.utils.debug
2125
import software.aws.toolkits.core.utils.error
@@ -76,6 +80,7 @@ import software.aws.toolkits.jetbrains.services.codemodernizer.constants.buildTr
7680
import software.aws.toolkits.jetbrains.services.codemodernizer.constants.buildTransformStoppingChatContent
7781
import software.aws.toolkits.jetbrains.services.codemodernizer.constants.buildUserCancelledChatContent
7882
import software.aws.toolkits.jetbrains.services.codemodernizer.constants.buildUserHilSelection
83+
import software.aws.toolkits.jetbrains.services.codemodernizer.constants.buildUserInputCustomDependencyVersionsChatContent
7984
import software.aws.toolkits.jetbrains.services.codemodernizer.constants.buildUserInputLanguageUpgradeChatContent
8085
import software.aws.toolkits.jetbrains.services.codemodernizer.constants.buildUserInputOneOrMultipleDiffsChatIntroContent
8186
import software.aws.toolkits.jetbrains.services.codemodernizer.constants.buildUserInputOneOrMultipleDiffsFlagChatContent
@@ -93,7 +98,6 @@ import software.aws.toolkits.jetbrains.services.codemodernizer.messages.Authenti
9398
import software.aws.toolkits.jetbrains.services.codemodernizer.messages.CodeTransformChatMessage
9499
import software.aws.toolkits.jetbrains.services.codemodernizer.messages.CodeTransformCommandMessage
95100
import software.aws.toolkits.jetbrains.services.codemodernizer.messages.IncomingCodeTransformMessage
96-
import software.aws.toolkits.jetbrains.services.codemodernizer.model.CLIENT_SIDE_BUILD
97101
import software.aws.toolkits.jetbrains.services.codemodernizer.model.CodeModernizerArtifact
98102
import software.aws.toolkits.jetbrains.services.codemodernizer.model.CodeModernizerJobCompletedResult
99103
import software.aws.toolkits.jetbrains.services.codemodernizer.model.CodeTransformConversationState
@@ -430,23 +434,22 @@ class CodeTransformChatController(
430434

431435
override suspend fun processCodeTransformOneOrMultipleDiffs(message: IncomingCodeTransformMessage.CodeTransformConfirmOneOrMultipleDiffs) {
432436
val transformCapabilities = when (message.oneOrMultipleDiffsSelection) {
437+
// TODO: add CLIENT_SIDE_BUILD to both below when releasing CSB
433438
message("codemodernizer.chat.message.one_or_multiple_diffs_form.multiple_diffs") -> listOf(
434439
EXPLAINABILITY_V1,
435-
CLIENT_SIDE_BUILD,
436440
SELECTIVE_TRANSFORMATION_V1
437441
)
438442
else -> listOf(
439443
EXPLAINABILITY_V1,
440-
CLIENT_SIDE_BUILD
441444
)
442445
}
443446
telemetry.submitSelection(message.oneOrMultipleDiffsSelection)
444447
codeTransformChatHelper.addNewMessage(buildUserOneOrMultipleDiffsSelectionChatContent(message.oneOrMultipleDiffsSelection))
445448
codeModernizerManager.codeTransformationSession?.let {
446449
it.sessionContext.transformCapabilities = transformCapabilities
450+
codeModernizerManager.runLocalMavenBuild(context.project, it)
447451
}
448-
promptForTargetJdkName(message.tabId)
449-
// TODO: when custom 1P upgrades ready, delete line above and uncomment line below
452+
// TODO: when releasing CSB, delete "runLocalMavenBuild" line above and uncomment line below
450453
// promptForCustomYamlFile()
451454
}
452455

@@ -458,14 +461,14 @@ class CodeTransformChatController(
458461
val selectedFile = FileChooser.chooseFile(descriptor, null, null) ?: return@withContext
459462
val isValid = validateYamlFile(selectedFile.readText())
460463
if (!isValid) {
461-
codeTransformChatHelper.addNewMessage(buildCustomDependencyVersionsFileInvalidChatContent())
464+
codeTransformChatHelper.updateLastPendingMessage(buildCustomDependencyVersionsFileInvalidChatContent())
462465
codeTransformChatHelper.addNewMessage(buildStartNewTransformFollowup())
463466
return@withContext
464467
}
465468
codeModernizerManager.codeTransformationSession?.let {
466469
it.sessionContext.customDependencyVersionsFile = selectedFile
467470
}
468-
codeTransformChatHelper.addNewMessage(buildCustomDependencyVersionsFileValidChatContent())
471+
codeTransformChatHelper.updateLastPendingMessage(buildCustomDependencyVersionsFileValidChatContent())
469472
promptForTargetJdkName(message.tabId)
470473
}
471474
}
@@ -490,7 +493,6 @@ class CodeTransformChatController(
490493
}
491494
}
492495

493-
/*
494496
private suspend fun promptForCustomYamlFile() {
495497
codeTransformChatHelper.addNewMessage(buildUserInputCustomDependencyVersionsChatContent())
496498
val sampleYAML = """
@@ -518,7 +520,6 @@ dependencyManagement:
518520
FileEditorManager.getInstance(context.project).openFile(virtualFile, true)
519521
}
520522
}
521-
*/
522523

523524
override suspend fun processCodeTransformContinueAction(message: IncomingCodeTransformMessage.CodeTransformContinue) {
524525
codeTransformChatHelper.addNewMessage(buildContinueTransformationChatContent())

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ data class ZipManifest(
1010
val buildLogs: String = BUILD_LOG_PATH,
1111
val version: String = UPLOAD_ZIP_MANIFEST_VERSION,
1212
val hilCapabilities: List<String> = listOf(HIL_1P_UPGRADE_CAPABILITY),
13-
val transformCapabilities: List<String> = listOf(EXPLAINABILITY_V1, CLIENT_SIDE_BUILD),
13+
// TODO: add CLIENT_SIDE_BUILD to transformCapabilities when releasing CSB
14+
val transformCapabilities: List<String> = listOf(EXPLAINABILITY_V1),
1415
val customBuildCommand: String = MAVEN_BUILD_RUN_UNIT_TESTS,
1516
val requestedConversions: RequestedConversions? = null, // only used for SQL conversions for now
1617
)

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ data class PollingResult(
6464
val transformationPlan: TransformationPlan?,
6565
)
6666

67+
private const val isClientSideBuildEnabled = false
68+
6769
/**
6870
* Wrapper around [waitUntil] that polls the API DescribeMigrationJob to check the migration job status.
6971
*/
@@ -117,7 +119,8 @@ suspend fun JobId.pollTransformationStatusAndPlan(
117119
delay(sleepDurationMillis)
118120
newPlan = clientAdaptor.getCodeModernizationPlan(this).transformationPlan()
119121
}
120-
if (newStatus == TransformationStatus.TRANSFORMING && newPlan != null) {
122+
// TODO: remove flag when releasing CSB
123+
if (isClientSideBuildEnabled && newStatus == TransformationStatus.TRANSFORMING && newPlan != null) {
121124
attemptLocalBuild(newPlan, this, project)
122125
}
123126
if (newStatus != state) {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -642,8 +642,8 @@ codemodernizer.chat.message.download_failed_invalid_artifact=Sorry, I was unable
642642
codemodernizer.chat.message.download_failed_other=Sorry, I ran into an issue while trying to download your {0}. Please try again. {1}
643643
codemodernizer.chat.message.download_failed_ssl=Sorry, I couldn''t download your {0} because of an issue with your certificate. Please make sure all your certificates for your proxy client have been set up correctly for your IDE.
644644
codemodernizer.chat.message.download_failed_wildcard=Sorry, I couldn''t download your {0} because of an issue with your proxy client. Please check your IDE proxy settings and remove any wildcard (*) references, then restart your IDE.
645-
codemodernizer.chat.message.enter_jdk_name=Enter the name of the {0} you are using. You can find the name in Settings > Project Structure > Platform Settings > SDKs. If you do not see the name of your JDK in the SDK settings, add your JDK, and then return to this chat and enter the name here.
646-
codemodernizer.chat.message.enter_jdk_name_error=I could not find "{0}" in Settings > Project Structure > Platform Settings > SDKs. Please add the target JDK there and try again.
645+
codemodernizer.chat.message.enter_jdk_name=Enter the name of the {0} you are using. You can find the name in File > Project Structure > Platform Settings > SDKs. If you do not see the name of your JDK in the SDK settings, add your JDK, and then return to this chat and enter the name here.
646+
codemodernizer.chat.message.enter_jdk_name_error=I could not find "{0}" in File > Project Structure > Platform Settings > SDKs. Please add the target JDK there and try again.
647647
codemodernizer.chat.message.error_request=Request failed
648648
codemodernizer.chat.message.follow_up.new_transformation=Start a new transformation
649649
codemodernizer.chat.message.hil.cannot_resume=I ran into an issue trying to resume your transformation.
@@ -681,7 +681,7 @@ codemodernizer.chat.message.result.success=I successfully completed your transfo
681681
codemodernizer.chat.message.result.success.multiple_diffs=I successfully completed your transformation. You will be able to accept changes from one diff at a time. If you reject changes in one diff, you will not be able to view or accept changes in the other diffs. The transformation summary has details about the changes I'm proposing.
682682
codemodernizer.chat.message.result.zip_too_large=Sorry, your project size exceeds the Amazon Q Code Transformation upload limit of 2GB.
683683
codemodernizer.chat.message.resume_ongoing=I'm still transforming 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.
684-
codemodernizer.chat.message.skip_tests=I will build generated code in your local environment, not on the server side. For information on how I scan code to reduce security risks associated with building the code in your local environment, see the [Amazon Q Developer documentation](https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/code-transformation.html#java-local-builds).\n\nI will build your project using `mvn clean test` by default. If you would like me to build your project without running unit tests, I will use `mvn clean test-compile`.
684+
codemodernizer.chat.message.skip_tests=I will build your project using `mvn clean test` by default. If you would like me to build your project without running unit tests, I will use `mvn clean test-compile`.
685685
codemodernizer.chat.message.skip_tests_form.response=Okay, I will {0} when building your module.
686686
codemodernizer.chat.message.skip_tests_form.run_tests=Run unit tests
687687
codemodernizer.chat.message.skip_tests_form.skip=Skip unit tests

ui-tests-starter/tst-243+/software/aws/toolkits/jetbrains/uitests/transformTests/TransformChatTest.kt

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,25 @@ async function testNavigation() {
8181
const button = document.querySelector('button[action-id="codetransform-input-confirm-one-or-multiple-diffs"]')
8282
button.click()
8383
})
84-
84+
/*
85+
const selectCustomVersionsForm = await page.waitForSelector('button[action-id="codetransform-input-confirm-custom-dependency-versions"]', {
86+
timeout: 5000
87+
})
88+
console.log('Custom dependency versions file form appeared:', selectCustomVersionsForm !== null)
89+
90+
await page.evaluate(() => {
91+
const button = document.querySelector('button[action-id="codetransform-input-continue"]')
92+
button.click()
93+
})
94+
95+
await page.type('.mynah-chat-prompt-input', 'dummy-target-jdk-name-here')
96+
await page.keyboard.press('Enter')
97+
98+
const errorMessage = await page.waitForSelector('text/I could not find "dummy-target-jdk-name-here" in File > Project Structure > Platform Settings > SDKs.', {
99+
timeout: 5000
100+
})
101+
*/
102+
// TODO: delete errorMessage below, and uncomment the above when releasing CSB
85103
const errorMessage = await page.waitForSelector('text/Sorry, I couldn\'t run the Maven clean install command', {
86104
timeout: 5000
87105
})
@@ -149,6 +167,9 @@ class TransformChatTest {
149167
"Skip tests form appeared: true",
150168
"One or multiple diffs form appeared: true",
151169
"couldn't run the Maven clean install command"
170+
// TODO: delete line above, and uncomment lines below when releasing CSB
171+
// "I could not find \"dummy-target-jdk-name-here\"",
172+
// "Custom dependency versions file form appeared: true",
152173
)
153174
}
154175
}

0 commit comments

Comments
 (0)