Skip to content

Commit 29b1a6c

Browse files
authored
fix(amazonq): align /doc messages with vscode (#5191)
* Aligns a few /doc chat messages with strings from the vscode extension * Fixes a bug where the checklist progress view wasn't showing up * As part of this, I added support for disabling the "Stop" button at the bottom of the chat window when an async event is in progress. Similar to this vscode commit: aws/aws-toolkit-vscode@9c89c53#diff-8eb911f0ec050013422c6b3bd03c793a30f8c6ecf0eb63297cf4f10611b0274dR3
1 parent 74b27eb commit 29b1a6c

File tree

8 files changed

+51
-49
lines changed

8 files changed

+51
-49
lines changed

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

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ import software.aws.toolkits.jetbrains.services.amazonqDoc.messages.updateFileCo
6666
import software.aws.toolkits.jetbrains.services.amazonqDoc.session.DocSession
6767
import software.aws.toolkits.jetbrains.services.amazonqDoc.session.PrepareDocGenerationState
6868
import software.aws.toolkits.jetbrains.services.amazonqDoc.storage.ChatSessionStorage
69+
import software.aws.toolkits.jetbrains.services.amazonqDoc.util.getFollowUpOptions
6970
import software.aws.toolkits.jetbrains.services.amazonqFeatureDev.CodeIterationLimitException
7071
import software.aws.toolkits.jetbrains.services.amazonqFeatureDev.MonthlyConversationLimitError
7172
import software.aws.toolkits.jetbrains.services.amazonqFeatureDev.session.CodeReferenceGenerated
@@ -813,7 +814,6 @@ class DocController(
813814

814815
when (session.sessionState.phase) {
815816
SessionStatePhase.CODEGEN -> {
816-
messenger.sendUpdatePromptProgress(tabId, inProgress(progress = 10))
817817
onCodeGeneration(session, message, tabId, mode)
818818
}
819819
else -> null
@@ -904,29 +904,7 @@ class DocController(
904904
messenger.sendAnswer(
905905
messageType = DocMessageType.SystemPrompt,
906906
tabId = followUpMessage.tabId,
907-
followUp = listOf(
908-
FollowUp(
909-
pillText = message("amazonqDoc.prompt.review.accept"),
910-
prompt = message("amazonqDoc.prompt.review.accept"),
911-
status = FollowUpStatusType.Success,
912-
type = FollowUpTypes.ACCEPT_CHANGES,
913-
icon = FollowUpIcons.Ok,
914-
),
915-
FollowUp(
916-
pillText = message("amazonqDoc.prompt.review.changes"),
917-
prompt = message("amazonqDoc.prompt.review.changes"),
918-
status = FollowUpStatusType.Info,
919-
type = FollowUpTypes.MAKE_CHANGES,
920-
icon = FollowUpIcons.Info,
921-
),
922-
FollowUp(
923-
pillText = message("general.reject"),
924-
prompt = message("general.reject"),
925-
status = FollowUpStatusType.Error,
926-
type = FollowUpTypes.REJECT_CHANGES,
927-
icon = FollowUpIcons.Cancel,
928-
)
929-
)
907+
followUp = getFollowUpOptions(session.sessionState.phase)
930908
)
931909

932910
processOpenDiff(

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

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

66
import com.intellij.notification.NotificationAction
7+
import software.aws.toolkits.jetbrains.services.amazonqDoc.inProgress
78
import software.aws.toolkits.jetbrains.services.amazonqDoc.messages.DocMessageType
89
import software.aws.toolkits.jetbrains.services.amazonqDoc.messages.FollowUp
910
import software.aws.toolkits.jetbrains.services.amazonqDoc.messages.FollowUpStatusType
@@ -14,19 +15,27 @@ import software.aws.toolkits.jetbrains.services.amazonqDoc.messages.sendChatInpu
1415
import software.aws.toolkits.jetbrains.services.amazonqDoc.messages.sendCodeResult
1516
import software.aws.toolkits.jetbrains.services.amazonqDoc.messages.sendSystemPrompt
1617
import software.aws.toolkits.jetbrains.services.amazonqDoc.messages.sendUpdatePlaceholder
18+
import software.aws.toolkits.jetbrains.services.amazonqDoc.messages.sendUpdatePromptProgress
1719
import software.aws.toolkits.jetbrains.services.amazonqDoc.session.DocSession
1820
import software.aws.toolkits.jetbrains.services.amazonqDoc.session.PrepareDocGenerationState
21+
import software.aws.toolkits.jetbrains.services.amazonqDoc.util.getFollowUpOptions
1922
import software.aws.toolkits.jetbrains.services.amazonqFeatureDev.messages.sendSystemPrompt
2023
import software.aws.toolkits.jetbrains.services.amazonqFeatureDev.session.CodeReferenceGenerated
2124
import software.aws.toolkits.jetbrains.services.amazonqFeatureDev.session.DeletedFileInfo
2225
import software.aws.toolkits.jetbrains.services.amazonqFeatureDev.session.NewFileZipInfo
23-
import software.aws.toolkits.jetbrains.services.amazonqFeatureDev.util.InsertAction
24-
import software.aws.toolkits.jetbrains.services.amazonqFeatureDev.util.getFollowUpOptions
2526
import software.aws.toolkits.jetbrains.utils.notifyInfo
2627
import software.aws.toolkits.resources.message
2728

2829
suspend fun DocController.onCodeGeneration(session: DocSession, message: String, tabId: String, mode: Mode) {
2930
try {
31+
messenger.sendAsyncEventProgress(tabId, inProgress = true)
32+
messenger.sendUpdatePromptProgress(tabId, inProgress(progress = 10, message("amazonqDoc.progress_message.scanning")))
33+
messenger.sendAnswer(
34+
message = docGenerationProgressMessage(DocGenerationStep.UPLOAD_TO_S3, this.mode),
35+
messageType = DocMessageType.AnswerPart,
36+
tabId = tabId,
37+
)
38+
3039
val sessionMessage = if (mode == Mode.CREATE) {
3140
message(
3241
"amazonqDoc.session.create"
@@ -80,25 +89,27 @@ suspend fun DocController.onCodeGeneration(session: DocSession, message: String,
8089
return
8190
}
8291

92+
messenger.sendAnswer(
93+
message = docGenerationProgressMessage(DocGenerationStep.COMPLETE, mode),
94+
messageType = DocMessageType.AnswerPart,
95+
tabId = tabId,
96+
)
97+
8398
messenger.sendCodeResult(tabId = tabId, uploadId = uploadId, filePaths = filePaths, deletedFiles = deletedFiles, references = references)
8499

85100
if (remainingIterations != null && totalIterations != null) {
86101
messenger.sendAnswer(
87102
tabId = tabId,
88103
messageType = DocMessageType.Answer,
89-
message = if (remainingIterations == 0) {
90-
message("amazonqFeatureDev.code_generation.iteration_zero")
104+
message = if (this.mode === Mode.CREATE) {
105+
message("amazonqDoc.answer.readmeCreated")
91106
} else {
92-
message(
93-
"amazonqFeatureDev.code_generation.iteration_counts",
94-
remainingIterations,
95-
totalIterations
96-
)
107+
"${message("amazonqDoc.answer.readmeUpdated")} ${message("amazonqDoc.answer.codeResult")}"
97108
}
98109
)
99110
}
100111

101-
messenger.sendSystemPrompt(tabId = tabId, followUp = getFollowUpOptions(session.sessionState.phase, InsertAction.ALL))
112+
messenger.sendSystemPrompt(tabId = tabId, followUp = getFollowUpOptions(session.sessionState.phase))
102113

103114
messenger.sendUpdatePlaceholder(tabId = tabId, newPlaceholder = message("amazonqFeatureDev.placeholder.after_code_generation"))
104115
} finally {

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

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,29 @@ fun getFollowUpOptions(phase: SessionStatePhase?): List<FollowUp> {
1515
SessionStatePhase.CODEGEN -> {
1616
return listOf(
1717
FollowUp(
18-
pillText = message("amazonqDoc.follow_up.insert_code"),
19-
type = FollowUpTypes.INSERT_CODE,
18+
pillText = message("amazonqDoc.prompt.review.accept"),
19+
prompt = message("amazonqDoc.prompt.review.accept"),
20+
status = FollowUpStatusType.Success,
21+
type = FollowUpTypes.ACCEPT_CHANGES,
2022
icon = FollowUpIcons.Ok,
21-
status = FollowUpStatusType.Success
2223
),
2324
FollowUp(
24-
pillText = message("amazonqDoc.follow_up.provide_feedback_and_regenerate"),
25-
type = FollowUpTypes.PROVIDE_FEEDBACK_AND_REGENERATE_CODE,
26-
icon = FollowUpIcons.Refresh,
27-
status = FollowUpStatusType.Info
25+
pillText = message("amazonqDoc.prompt.review.changes"),
26+
prompt = message("amazonqDoc.prompt.review.changes"),
27+
status = FollowUpStatusType.Info,
28+
type = FollowUpTypes.MAKE_CHANGES,
29+
icon = FollowUpIcons.Info,
30+
),
31+
FollowUp(
32+
pillText = message("general.reject"),
33+
prompt = message("general.reject"),
34+
status = FollowUpStatusType.Error,
35+
type = FollowUpTypes.REJECT_CHANGES,
36+
icon = FollowUpIcons.Cancel,
2837
)
2938
)
3039
}
40+
3141
else -> return emptyList()
3242
}
3343
}

plugins/amazonq/mynah-ui/src/mynah-ui/ui/apps/docChatConnector.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export interface ConnectorProps {
1919
sendMessageToExtension: (message: ExtensionMessage) => void
2020
onMessageReceived?: (tabID: string, messageData: any, needToShowAPIDocsTab: boolean) => void
2121
onUpdatePromptProgress: (tabID: string, progressField: ProgressField) => void
22-
onAsyncEventProgress: (tabID: string, inProgress: boolean, message: string) => void
22+
onAsyncEventProgress: (tabID: string, inProgress: boolean, message: string, cancelButtonWhenLoading?: boolean) => void
2323
onChatAnswerReceived?: (tabID: string, message: ChatItem) => void
2424
sendFeedback?: (tabId: string, feedbackPayload: FeedbackPayload) => void | undefined
2525
onError: (tabID: string, message: string, title: string) => void

plugins/amazonq/mynah-ui/src/mynah-ui/ui/apps/featureDevChatConnector.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ interface ChatPayload {
1818
export interface ConnectorProps {
1919
sendMessageToExtension: (message: ExtensionMessage) => void
2020
onMessageReceived?: (tabID: string, messageData: any, needToShowAPIDocsTab: boolean) => void
21-
onAsyncEventProgress: (tabID: string, inProgress: boolean, message: string) => void
21+
onAsyncEventProgress: (tabID: string, inProgress: boolean, message: string, cancelButtonWhenLoading?: boolean) => void
2222
onChatAnswerReceived?: (tabID: string, message: ChatItem) => void
2323
onChatAnswerUpdated?: (tabID: string, message: ChatItem) => void
2424
sendFeedback?: (tabId: string, feedbackPayload: FeedbackPayload) => void | undefined
@@ -249,7 +249,7 @@ export class Connector {
249249
}
250250

251251
if (messageData.type === 'asyncEventProgressMessage') {
252-
this.onAsyncEventProgress(messageData.tabID, messageData.inProgress, messageData.message ?? undefined)
252+
this.onAsyncEventProgress(messageData.tabID, messageData.inProgress, messageData.message ?? undefined, true)
253253
return
254254
}
255255

plugins/amazonq/mynah-ui/src/mynah-ui/ui/connector.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export interface ConnectorProps {
6161
onCodeTransformMessageUpdate: (tabID: string, messageId: string, chatItem: Partial<ChatItem>) => void
6262
onRunTestMessageReceived?: (tabID: string, showRunTestMessage: boolean) => void
6363
onWelcomeFollowUpClicked: (tabID: string, welcomeFollowUpType: WelcomeFollowupType) => void
64-
onAsyncEventProgress: (tabID: string, inProgress: boolean, message: string | undefined) => void
64+
onAsyncEventProgress: (tabID: string, inProgress: boolean, message: string | undefined, cancelButtonWhenLoading?: boolean) => void
6565
onCWCContextCommandMessage: (message: ChatItem, command?: string) => string | undefined
6666
onCWCOnboardingPageInteractionMessage: (message: ChatItem) => string | undefined
6767
onOpenSettingsMessage: (tabID: string) => void

plugins/amazonq/mynah-ui/src/mynah-ui/ui/main.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,12 +184,12 @@ export const createMynahUI = (
184184
promptInputDisabledState: tabsStorage.isTabDead(tabID) || !enabled,
185185
})
186186
},
187-
onAsyncEventProgress: (tabID: string, inProgress: boolean, message: string | undefined) => {
187+
onAsyncEventProgress: (tabID: string, inProgress: boolean, message: string | undefined, cancelButtonWhenLoading: boolean = false) => {
188188
if (inProgress) {
189189
mynahUI.updateStore(tabID, {
190190
loadingChat: true,
191191
promptInputDisabledState: true,
192-
cancelButtonWhenLoading: true,
192+
cancelButtonWhenLoading,
193193
})
194194
if (message) {
195195
mynahUI.updateLastChatAnswer(tabID, {

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,11 @@ action.aws.toolkit.toolwindow.newConnection.text=Add Another Connection...
3838
action.dynamic.open.text=Open Resource...
3939
action.q.openchat.text=Open Chat Panel
4040
amazonqChat.project_context.index_in_progress=By the way, I'm still indexing this project for full context from your workspace. I may have a better response in a few minutes when it's complete if you'd like to try again then.
41-
amazonqDoc.edit.message=Please describe the changes you would like to make to your documentation. For example, you can ask me to add a section, remove a section, make a correction, expand upon something, etc.
42-
amazonqDoc.edit.placeholder=Describe your documentation request
41+
amazonqDoc.answer.codeResult=You can accept the changes to your files, or describe any additional changes you'd like me to make.
42+
amazonqDoc.answer.readmeCreated=I've created a README for your code.
43+
amazonqDoc.answer.readmeUpdated=I've updated your README.
44+
amazonqDoc.edit.message=Okay, let's work on your README. Describe the changes you would like to make. For example, you can ask me to:\n- Correct something\n- Expand on something\n- Add a section\n- Remove a section
45+
amazonqDoc.edit.placeholder=Describe documentation changes
4346
amazonqDoc.error.generating=Unable to generate changes.
4447
amazonqDoc.error_text=I'm sorry, I ran into an issue while trying to generate your documentation. Please try again.
4548
amazonqDoc.exception.content_length_error=Your workspace is too large for me to review. Your workspace must be within the quota, even if you choose a smaller folder. For more information on quotas, see the <a href="https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/doc-generation.html#quotas" target="_blank">Amazon Q Developer documentation.</a>

0 commit comments

Comments
 (0)