Skip to content

Commit 4a29d0e

Browse files
Merge main into feature/q-lsp
2 parents 03441f1 + b440147 commit 4a29d0e

File tree

5 files changed

+55
-1
lines changed

5 files changed

+55
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ class CodeTestChatApp(private val scope: CoroutineScope) : AmazonQApp {
3838
"tab-was-removed" to IncomingCodeTestMessage.TabRemoved::class,
3939
"start-test-gen" to IncomingCodeTestMessage.StartTestGen::class,
4040
"response-body-link-click" to IncomingCodeTestMessage.ClickedLink::class,
41-
"button-click" to IncomingCodeTestMessage.ButtonClicked::class
41+
"button-click" to IncomingCodeTestMessage.ButtonClicked::class,
42+
"auth-follow-up-was-clicked" to IncomingCodeTestMessage.AuthFollowUpWasClicked::class
4243
)
4344

4445
scope.launch {
@@ -79,6 +80,7 @@ class CodeTestChatApp(private val scope: CoroutineScope) : AmazonQApp {
7980
is IncomingCodeTestMessage.StartTestGen -> inboundAppMessagesHandler.processStartTestGen(message)
8081
is IncomingCodeTestMessage.ClickedLink -> inboundAppMessagesHandler.processLinkClick(message)
8182
is IncomingCodeTestMessage.ButtonClicked -> inboundAppMessagesHandler.processButtonClickedMessage(message)
83+
is IncomingCodeTestMessage.AuthFollowUpWasClicked -> inboundAppMessagesHandler.processAuthFollowUpClick(message)
8284
}
8385
}
8486

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,6 @@ interface InboundAppMessagesHandler {
2121
suspend fun processTabRemovedMessage(message: IncomingCodeTestMessage.TabRemoved)
2222

2323
suspend fun processButtonClickedMessage(message: IncomingCodeTestMessage.ButtonClicked)
24+
25+
suspend fun processAuthFollowUpClick(message: IncomingCodeTestMessage.AuthFollowUpWasClicked)
2426
}

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -954,6 +954,14 @@ class CodeTestChatController(
954954
}
955955
}
956956

957+
override suspend fun processAuthFollowUpClick(message: IncomingCodeTestMessage.AuthFollowUpWasClicked) {
958+
codeTestChatHelper.sendUpdatePromptProgress(message.tabId, null)
959+
authController.handleAuth(context.project, message.authType)
960+
codeTestChatHelper.sendAuthenticationInProgressMessage(message.tabId) // show user that authentication is in progress
961+
codeTestChatHelper.sendChatInputEnabledMessage(false) // disable the input field while authentication is in progress
962+
sessionCleanUp(codeTestChatHelper.getActiveSession().tabId)
963+
}
964+
957965
private suspend fun updateBuildAndExecuteProgressCard(
958966
currentStatus: BuildAndExecuteProgressStatus,
959967
messageId: String?,
@@ -1210,6 +1218,17 @@ class CodeTestChatController(
12101218
* */
12111219
private suspend fun handleChat(tabId: String, message: String) {
12121220
val session = codeTestChatHelper.getActiveSession()
1221+
session.projectRoot
1222+
val credentialState = authController.getAuthNeededStates(context.project).amazonQ
1223+
if (credentialState != null) {
1224+
messenger.sendAuthNeededException(
1225+
tabId = tabId,
1226+
triggerId = UUID.randomUUID().toString(),
1227+
credentialState = credentialState,
1228+
)
1229+
session.isAuthenticating = true
1230+
return
1231+
}
12131232
LOG.debug {
12141233
"$FEATURE_NAME: " +
12151234
"Processing message: $message " +

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package software.aws.toolkits.jetbrains.services.amazonqCodeTest.controller
55

66
import software.aws.toolkits.jetbrains.services.amazonq.messages.MessagePublisher
7+
import software.aws.toolkits.jetbrains.services.amazonqCodeTest.messages.ChatInputEnabledMessage
78
import software.aws.toolkits.jetbrains.services.amazonqCodeTest.messages.CodeTestAddAnswerMessage
89
import software.aws.toolkits.jetbrains.services.amazonqCodeTest.messages.CodeTestChatMessage
910
import software.aws.toolkits.jetbrains.services.amazonqCodeTest.messages.CodeTestChatMessageContent
@@ -15,6 +16,8 @@ import software.aws.toolkits.jetbrains.services.amazonqCodeTest.messages.UpdateP
1516
import software.aws.toolkits.jetbrains.services.amazonqCodeTest.session.Session
1617
import software.aws.toolkits.jetbrains.services.amazonqCodeTest.storage.ChatSessionStorage
1718
import software.aws.toolkits.jetbrains.services.cwc.messages.ChatMessageType
19+
import software.aws.toolkits.jetbrains.services.cwc.messages.FollowUp
20+
import software.aws.toolkits.resources.message
1821
import java.util.UUID
1922

2023
class CodeTestChatHelper(
@@ -153,4 +156,27 @@ class CodeTestChatHelper(
153156
)
154157
)
155158
}
159+
160+
suspend fun sendChatInputEnabledMessage(isEnabled: Boolean) {
161+
if (isInvalidSession()) return
162+
messagePublisher.publish(ChatInputEnabledMessage(activeCodeTestTabId as String, enabled = isEnabled))
163+
}
164+
165+
suspend fun sendAuthenticationInProgressMessage(
166+
tabId: String,
167+
messageId: String? = null,
168+
followUp: List<FollowUp>? = null,
169+
canBeVoted: Boolean? = false,
170+
) {
171+
val chatMessage =
172+
CodeTestChatMessage(
173+
tabId = tabId,
174+
messageId = messageId ?: UUID.randomUUID().toString(),
175+
messageType = ChatMessageType.Answer,
176+
message = message("amazonqFeatureDev.follow_instructions_for_authentication"),
177+
followUps = followUp,
178+
canBeVoted = canBeVoted ?: false,
179+
)
180+
messagePublisher.publish(chatMessage)
181+
}
156182
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ sealed interface IncomingCodeTestMessage : CodeTestBaseMessage {
9494
@JsonProperty("tabID") val tabId: String,
9595
@JsonProperty("actionID") val actionID: String,
9696
) : IncomingCodeTestMessage
97+
98+
data class AuthFollowUpWasClicked(
99+
@JsonProperty("tabID") val tabId: String,
100+
val authType: AuthFollowUpType,
101+
) : IncomingCodeTestMessage
97102
}
98103

99104
data class UpdatePlaceholderMessage(

0 commit comments

Comments
 (0)