Skip to content

Commit

Permalink
fix(amazonq): /doc remove retry folowup button to make it in synch wi…
Browse files Browse the repository at this point in the history
…th vscode plugin
  • Loading branch information
Viktor Shesternyak committed Jan 22, 2025
1 parent 83a69b2 commit 942579b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -376,10 +376,9 @@ class DocController(

else -> {
logger.error { "$FEATURE_NAME: OpenDiff event is received for a conversation that has ${session.sessionState.phase} phase" }
messenger.sendError(
messenger.sendErrorToUser(
tabId = message.tabId,
errMessage = message("amazonqFeatureDev.exception.open_diff_failed"),
retries = 0,
conversationId = session.conversationIdUnsafe
)
}
Expand Down Expand Up @@ -478,10 +477,9 @@ class DocController(
)
} catch (err: Exception) {
val message = createUserFacingErrorMessage("Failed to insert code changes: ${err.message}")
messenger.sendError(
messenger.sendErrorToUser(
tabId = tabId,
errMessage = message ?: message("amazonqFeatureDev.exception.insert_code_failed"),
retries = retriesRemaining(session),
conversationId = session?.conversationIdUnsafe
)
}
Expand Down Expand Up @@ -559,10 +557,9 @@ class DocController(

when (err) {
is RepoSizeError -> {
messenger.sendError(
messenger.sendErrorToUser(
tabId = tabId,
errMessage = err.message,
retries = retriesRemaining(session),
conversationId = session?.conversationIdUnsafe
)
messenger.sendSystemPrompt(
Expand All @@ -578,10 +575,9 @@ class DocController(
}

is ZipFileError -> {
messenger.sendError(
messenger.sendErrorToUser(
tabId = tabId,
errMessage = err.message,
retries = 0,
conversationId = session?.conversationIdUnsafe
)
}
Expand Down Expand Up @@ -673,10 +669,9 @@ class DocController(
else -> message("amazonqFeatureDev.error_text")
}

messenger.sendError(
messenger.sendErrorToUser(
tabId = tabId,
errMessage = defaultMessage,
retries = retriesRemaining(session),
conversationId = session?.conversationIdUnsafe
)
}
Expand Down Expand Up @@ -773,9 +768,12 @@ class DocController(
) {
return
}

if (filePaths.isEmpty() && deletedFiles.isEmpty()) {
handleEmptyFiles(followUpMessage, session)
messenger.sendErrorToUser(
followUpMessage.tabId,
message("amazonqDoc.error.generating"),
conversationId = session.conversationId
)
return
}

Expand Down Expand Up @@ -830,37 +828,6 @@ class DocController(
}
}

private suspend fun handleEmptyFiles(
message: IncomingDocMessage.FollowupClicked,
session: DocSession,
) {
messenger.sendAnswer(
message = message("amazonqDoc.error.generating"),
messageType = DocMessageType.Answer,
tabId = message.tabId,
canBeVoted = true
)

messenger.sendAnswer(
messageType = DocMessageType.SystemPrompt,
tabId = message.tabId,
followUp = if (retriesRemaining(session) > 0) {
listOf(
FollowUp(
pillText = message("amazonqFeatureDev.follow_up.retry"),
type = FollowUpTypes.RETRY,
status = FollowUpStatusType.Warning
)
)
} else {
emptyList()
}
)

// Lock the chat input until they explicitly click retry
messenger.sendChatInputEnabledMessage(tabId = message.tabId, enabled = false)
}

private suspend fun retryRequests(tabId: String) {
var session: DocSession? = null
docGenerationTask = DocGenerationTask()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@ package software.aws.toolkits.jetbrains.services.amazonqDoc.controller
import com.intellij.notification.NotificationAction
import software.aws.toolkits.jetbrains.services.amazonqDoc.inProgress
import software.aws.toolkits.jetbrains.services.amazonqDoc.messages.DocMessageType
import software.aws.toolkits.jetbrains.services.amazonqDoc.messages.FollowUp
import software.aws.toolkits.jetbrains.services.amazonqDoc.messages.FollowUpStatusType
import software.aws.toolkits.jetbrains.services.amazonqDoc.messages.FollowUpTypes
import software.aws.toolkits.jetbrains.services.amazonqDoc.messages.sendAnswer
import software.aws.toolkits.jetbrains.services.amazonqDoc.messages.sendAsyncEventProgress
import software.aws.toolkits.jetbrains.services.amazonqDoc.messages.sendChatInputEnabledMessage
import software.aws.toolkits.jetbrains.services.amazonqDoc.messages.sendCodeResult
import software.aws.toolkits.jetbrains.services.amazonqDoc.messages.sendErrorToUser
import software.aws.toolkits.jetbrains.services.amazonqDoc.messages.sendSystemPrompt
import software.aws.toolkits.jetbrains.services.amazonqDoc.messages.sendUpdatePlaceholder
import software.aws.toolkits.jetbrains.services.amazonqDoc.messages.sendUpdatePromptProgress
Expand Down Expand Up @@ -73,26 +71,12 @@ suspend fun DocController.onCodeGeneration(session: DocSession, message: String,

// Atm this is the only possible path as codegen is mocked to return empty.
if (filePaths.size or deletedFiles.size == 0) {
messenger.sendAnswer(
tabId = tabId,
messageType = DocMessageType.Answer,
message = message("amazonqFeatureDev.code_generation.no_file_changes")
)
messenger.sendSystemPrompt(
tabId = tabId,
followUp = if (retriesRemaining(session) > 0) {
listOf(
FollowUp(
pillText = message("amazonqFeatureDev.follow_up.retry"),
type = FollowUpTypes.RETRY,
status = FollowUpStatusType.Warning
)
)
} else {
emptyList()
}
messenger.sendErrorToUser(
tabId,
message("amazonqDoc.error.generating"),
conversationId = session.conversationId
)
messenger.sendChatInputEnabledMessage(tabId = tabId, enabled = false) // Lock chat input until retry is clicked.

return
}

Expand Down

0 comments on commit 942579b

Please sign in to comment.