Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -38,7 +38,8 @@ class CodeTestChatApp(private val scope: CoroutineScope) : AmazonQApp {
"tab-was-removed" to IncomingCodeTestMessage.TabRemoved::class,
"start-test-gen" to IncomingCodeTestMessage.StartTestGen::class,
"response-body-link-click" to IncomingCodeTestMessage.ClickedLink::class,
"button-click" to IncomingCodeTestMessage.ButtonClicked::class
"button-click" to IncomingCodeTestMessage.ButtonClicked::class,
"auth-follow-up-was-clicked" to IncomingCodeTestMessage.AuthFollowUpWasClicked::class
)

scope.launch {
Expand Down Expand Up @@ -79,6 +80,7 @@ class CodeTestChatApp(private val scope: CoroutineScope) : AmazonQApp {
is IncomingCodeTestMessage.StartTestGen -> inboundAppMessagesHandler.processStartTestGen(message)
is IncomingCodeTestMessage.ClickedLink -> inboundAppMessagesHandler.processLinkClick(message)
is IncomingCodeTestMessage.ButtonClicked -> inboundAppMessagesHandler.processButtonClickedMessage(message)
is IncomingCodeTestMessage.AuthFollowUpWasClicked -> inboundAppMessagesHandler.processAuthFollowUpClick(message)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@ interface InboundAppMessagesHandler {
suspend fun processTabRemovedMessage(message: IncomingCodeTestMessage.TabRemoved)

suspend fun processButtonClickedMessage(message: IncomingCodeTestMessage.ButtonClicked)

suspend fun processAuthFollowUpClick(message: IncomingCodeTestMessage.AuthFollowUpWasClicked)
}
Original file line number Diff line number Diff line change
Expand Up @@ -954,6 +954,14 @@ class CodeTestChatController(
}
}

override suspend fun processAuthFollowUpClick(message: IncomingCodeTestMessage.AuthFollowUpWasClicked) {
codeTestChatHelper.sendUpdatePromptProgress(message.tabId, null)
authController.handleAuth(context.project, message.authType)
codeTestChatHelper.sendAuthenticationInProgressMessage(message.tabId) // show user that authentication is in progress
codeTestChatHelper.sendChatInputEnabledMessage(false) // disable the input field while authentication is in progress
sessionCleanUp(codeTestChatHelper.getActiveSession().tabId)
}

private suspend fun updateBuildAndExecuteProgressCard(
currentStatus: BuildAndExecuteProgressStatus,
messageId: String?,
Expand Down Expand Up @@ -1210,6 +1218,17 @@ class CodeTestChatController(
* */
private suspend fun handleChat(tabId: String, message: String) {
val session = codeTestChatHelper.getActiveSession()
session.projectRoot
val credentialState = authController.getAuthNeededStates(context.project).amazonQ
if (credentialState != null) {
messenger.sendAuthNeededException(
tabId = tabId,
triggerId = UUID.randomUUID().toString(),
credentialState = credentialState,
)
session.isAuthenticating = true
return
}
LOG.debug {
"$FEATURE_NAME: " +
"Processing message: $message " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package software.aws.toolkits.jetbrains.services.amazonqCodeTest.controller

import software.aws.toolkits.jetbrains.services.amazonq.messages.MessagePublisher
import software.aws.toolkits.jetbrains.services.amazonqCodeTest.messages.ChatInputEnabledMessage
import software.aws.toolkits.jetbrains.services.amazonqCodeTest.messages.CodeTestAddAnswerMessage
import software.aws.toolkits.jetbrains.services.amazonqCodeTest.messages.CodeTestChatMessage
import software.aws.toolkits.jetbrains.services.amazonqCodeTest.messages.CodeTestChatMessageContent
Expand All @@ -15,6 +16,8 @@
import software.aws.toolkits.jetbrains.services.amazonqCodeTest.session.Session
import software.aws.toolkits.jetbrains.services.amazonqCodeTest.storage.ChatSessionStorage
import software.aws.toolkits.jetbrains.services.cwc.messages.ChatMessageType
import software.aws.toolkits.jetbrains.services.cwc.messages.FollowUp
import software.aws.toolkits.resources.message

Check warning on line 20 in plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqCodeTest/controller/CodeTestChatHelper.kt

View workflow job for this annotation

GitHub Actions / qodana

Usage of redundant or deprecated syntax or deprecated symbols

Remove deprecated symbol import

Check warning

Code scanning / QDJVMC

Usage of redundant or deprecated syntax or deprecated symbols Warning

Remove deprecated symbol import
import java.util.UUID

class CodeTestChatHelper(
Expand Down Expand Up @@ -153,4 +156,27 @@
)
)
}

suspend fun sendChatInputEnabledMessage(isEnabled: Boolean) {
if (isInvalidSession()) return
messagePublisher.publish(ChatInputEnabledMessage(activeCodeTestTabId as String, enabled = isEnabled))

Check warning on line 162 in plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqCodeTest/controller/CodeTestChatHelper.kt

View workflow job for this annotation

GitHub Actions / qodana

Usage of redundant or deprecated syntax or deprecated symbols

No cast needed

Check warning

Code scanning / QDJVMC

Usage of redundant or deprecated syntax or deprecated symbols Warning

No cast needed
}

suspend fun sendAuthenticationInProgressMessage(
tabId: String,
messageId: String? = null,
followUp: List<FollowUp>? = null,
canBeVoted: Boolean? = false,
) {
val chatMessage =
CodeTestChatMessage(
tabId = tabId,
messageId = messageId ?: UUID.randomUUID().toString(),
messageType = ChatMessageType.Answer,
message = message("amazonqFeatureDev.follow_instructions_for_authentication"),

Check warning on line 176 in plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqCodeTest/controller/CodeTestChatHelper.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

Check warning

Code scanning / QDJVMC

Usage of redundant or deprecated syntax or deprecated symbols Warning

'message(String, vararg Any): String' is deprecated. Use extension-specific localization bundle instead
followUps = followUp,
canBeVoted = canBeVoted ?: false,
)
messagePublisher.publish(chatMessage)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ sealed interface IncomingCodeTestMessage : CodeTestBaseMessage {
@JsonProperty("tabID") val tabId: String,
@JsonProperty("actionID") val actionID: String,
) : IncomingCodeTestMessage

data class AuthFollowUpWasClicked(
@JsonProperty("tabID") val tabId: String,
val authType: AuthFollowUpType,
) : IncomingCodeTestMessage
}

data class UpdatePlaceholderMessage(
Expand Down
Loading