Skip to content

Commit 8b512d9

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 8b512d9

File tree

4 files changed

+41
-29
lines changed

4 files changed

+41
-29
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"type" : "bugfix",
3-
"description" : "AmazonQ doc agent: Enable text input in edit mode for retries and use it instead of retry button"
3+
"description" : "Amazon Q /doc: Ask for user prompt if error occurs while updating documentation"
44
}

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 & 4 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
}
@@ -428,10 +428,9 @@ class DocController(
428428
messenger.sendUpdatePlaceholder(tabId, message("amazonqDoc.prompt.placeholder"))
429429
} catch (err: Exception) {
430430
val message = createUserFacingErrorMessage(err.message)
431-
messenger.sendError(
431+
messenger.sendErrorToUser(
432432
tabId = tabId,
433433
errMessage = message ?: message("amazonqFeatureDev.exception.request_failed"),
434-
retries = retriesRemaining(session),
435434
conversationId = session?.conversationIdUnsafe,
436435
)
437436
}
@@ -887,7 +886,7 @@ class DocController(
887886
tabId = tabId,
888887
errMessage = message ?: message("amazonqFeatureDev.exception.retry_request_failed"),
889888
retries = retriesRemaining(session),
890-
conversationId = session?.conversationIdUnsafe
889+
conversationId = session?.conversationIdUnsafe,
891890
)
892891
} finally {
893892
// 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)