Skip to content

Commit 62802aa

Browse files
author
Viktor Shesternyak
committed
fix(amazonq): /doc enable text input in edit mode for retries and use it instead of retry button
1 parent dac6c74 commit 62802aa

File tree

3 files changed

+40
-27
lines changed

3 files changed

+40
-27
lines changed

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqDoc/DocConstants.kt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33

44
package software.aws.toolkits.jetbrains.services.amazonqDoc
55

6+
import software.aws.toolkits.jetbrains.services.amazonqDoc.messages.FollowUp
7+
import software.aws.toolkits.jetbrains.services.amazonqDoc.messages.FollowUpStatusType
8+
import software.aws.toolkits.jetbrains.services.amazonqDoc.messages.FollowUpTypes
9+
import software.aws.toolkits.resources.message
10+
611
const val FEATURE_EVALUATION_PRODUCT_NAME = "DocGeneration"
712

813
const val FEATURE_NAME = "Amazon Q Documentation Generation"
@@ -25,3 +30,17 @@ enum class ModifySourceFolderErrorReason(
2530

2631
override fun toString(): String = reasonText
2732
}
33+
34+
35+
val NEW_SESSION_FOLLOWUPS: List<FollowUp> = listOf(
36+
FollowUp(
37+
pillText = message("amazonqDoc.prompt.reject.new_task"),
38+
type = FollowUpTypes.NEW_TASK,
39+
status = FollowUpStatusType.Info
40+
),
41+
FollowUp(
42+
pillText = message("amazonqDoc.prompt.reject.close_session"),
43+
type = FollowUpTypes.CLOSE_SESSION,
44+
status = FollowUpStatusType.Info
45+
))
46+

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqDoc/controller/DocController.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ class DocController(
380380
tabId = message.tabId,
381381
errMessage = message("amazonqFeatureDev.exception.open_diff_failed"),
382382
retries = 0,
383-
conversationId = session.conversationIdUnsafe,
383+
conversationId = session.conversationIdUnsafe
384384
)
385385
}
386386
}
@@ -432,7 +432,7 @@ class DocController(
432432
tabId = tabId,
433433
errMessage = message ?: message("amazonqFeatureDev.exception.request_failed"),
434434
retries = retriesRemaining(session),
435-
conversationId = session?.conversationIdUnsafe,
435+
conversationId = session?.conversationIdUnsafe
436436
)
437437
}
438438
}
@@ -887,7 +887,7 @@ class DocController(
887887
tabId = tabId,
888888
errMessage = message ?: message("amazonqFeatureDev.exception.retry_request_failed"),
889889
retries = retriesRemaining(session),
890-
conversationId = session?.conversationIdUnsafe
890+
conversationId = session?.conversationIdUnsafe,
891891
)
892892
} finally {
893893
// Finish processing the event

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqDoc/messages/DocMessagePublisherExtensions.kt

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import software.aws.toolkits.jetbrains.services.amazonq.auth.AuthNeededState
77
import software.aws.toolkits.jetbrains.services.amazonq.messages.MessagePublisher
88
import software.aws.toolkits.jetbrains.services.amazonqCodeTest.messages.ProgressField
99
import software.aws.toolkits.jetbrains.services.amazonqCodeTest.messages.PromptProgressMessage
10+
import software.aws.toolkits.jetbrains.services.amazonqDoc.NEW_SESSION_FOLLOWUPS
1011
import software.aws.toolkits.jetbrains.services.amazonqFeatureDev.session.CodeReferenceGenerated
1112
import software.aws.toolkits.jetbrains.services.amazonqFeatureDev.session.DeletedFileInfo
1213
import software.aws.toolkits.jetbrains.services.amazonqFeatureDev.session.NewFileZipInfo
@@ -160,36 +161,29 @@ suspend fun MessagePublisher.sendErrorToUser(
160161
) {
161162
val conversationIdText = if (conversationId == null) "" else "\n\nConversation ID: **$conversationId**"
162163

163-
var followUps = listOf(
164-
FollowUp(
165-
pillText = message("amazonqDoc.prompt.reject.new_task"),
166-
type = FollowUpTypes.NEW_TASK,
167-
status = FollowUpStatusType.Info
168-
),
169-
FollowUp(
170-
pillText = message("amazonqDoc.prompt.reject.close_session"),
171-
type = FollowUpTypes.CLOSE_SESSION,
172-
status = FollowUpStatusType.Info
173-
)
174-
);
175-
176-
this.sendChatInputEnabledMessage(tabId, enabled = isEnableChatInput)
177-
if (isEnableChatInput) {
178-
this.sendUpdatePlaceholder(tabId, message("amazonqDoc.edit.placeholder"))
179-
followUps = Collections.emptyList()
180-
}
181-
182164
this.sendAnswer(
183165
tabId = tabId,
184166
messageType = DocMessageType.Answer,
185167
message = errMessage + conversationIdText,
186168
)
187169

188-
this.sendAnswer(
189-
tabId = tabId,
190-
messageType = DocMessageType.SystemPrompt,
191-
followUp = followUps
192-
)
170+
if (isEnableChatInput) {
171+
this.sendAnswer(
172+
tabId = tabId,
173+
messageType = DocMessageType.SystemPrompt,
174+
followUp = Collections.emptyList()
175+
)
176+
this.sendUpdatePlaceholder(tabId, message("amazonqDoc.edit.placeholder"))
177+
} else {
178+
this.sendAnswer(
179+
tabId = tabId,
180+
messageType = DocMessageType.SystemPrompt,
181+
followUp = NEW_SESSION_FOLLOWUPS
182+
)
183+
this.sendUpdatePlaceholder(tabId, message("amazonqDoc.prompt.placeholder"))
184+
}
185+
186+
this.sendChatInputEnabledMessage(tabId, enabled = isEnableChatInput)
193187
}
194188

195189
suspend fun MessagePublisher.sendMonthlyLimitError(tabId: String) {

0 commit comments

Comments
 (0)