Skip to content

fix(featureDev): File Rejection stopped working (with plan not disappearing on clicking Generate Code) #4529

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type" : "bugfix",
"description" : " fix(featureDev): File Rejection stopped working"
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ import software.aws.toolkits.jetbrains.services.amazonqFeatureDev.messages.Follo
import software.aws.toolkits.jetbrains.services.amazonqFeatureDev.messages.IncomingFeatureDevMessage
import software.aws.toolkits.jetbrains.services.amazonqFeatureDev.messages.initialExamples
import software.aws.toolkits.jetbrains.services.amazonqFeatureDev.messages.sendAnswer
import software.aws.toolkits.jetbrains.services.amazonqFeatureDev.messages.sendAnswerPart
import software.aws.toolkits.jetbrains.services.amazonqFeatureDev.messages.sendAsyncEventProgress
import software.aws.toolkits.jetbrains.services.amazonqFeatureDev.messages.sendAuthNeededException
import software.aws.toolkits.jetbrains.services.amazonqFeatureDev.messages.sendAuthenticationInProgressMessage
Expand Down Expand Up @@ -231,6 +230,7 @@ class FeatureDevController(
override suspend fun processFileClicked(message: IncomingFeatureDevMessage.FileClicked) {
val fileToUpdate = message.filePath
val session = getSessionInfo(message.tabId)
val messageId = message.messageId

var filePaths: List<NewFileZipInfo> = emptyList()
var deletedFiles: List<DeletedFileInfo> = emptyList()
Expand All @@ -245,7 +245,7 @@ class FeatureDevController(
filePaths.find { it.zipFilePath == fileToUpdate }?.let { it.rejected = !it.rejected }
deletedFiles.find { it.zipFilePath == fileToUpdate }?.let { it.rejected = !it.rejected }

messenger.updateFileComponent(message.tabId, filePaths, deletedFiles)
messenger.updateFileComponent(message.tabId, filePaths, deletedFiles, messageId)
}

private suspend fun newTabOpened(tabId: String) {
Expand Down Expand Up @@ -522,19 +522,16 @@ class FeatureDevController(

messenger.sendAnswer(
tabId = tabId,
messageType = FeatureDevMessageType.Answer,
messageType = FeatureDevMessageType.AnswerStream,
message = message("amazonqFeatureDev.create_plan"),
)

// Ensure that the loading icon stays showing
messenger.sendAsyncEventProgress(tabId = tabId, inProgress = true)

messenger.sendUpdatePlaceholder(tabId, message("amazonqFeatureDev.placeholder.generating_approach"))

val interactions = session.send(message)
messenger.sendUpdatePlaceholder(tabId, message("amazonqFeatureDev.placeholder.iterate_plan"))

messenger.sendAnswerPart(tabId = tabId, message = interactions.content, canBeVoted = interactions.interactionSucceeded)
messenger.sendAnswer(tabId = tabId, message = interactions.content, messageType = FeatureDevMessageType.Answer, canBeVoted = true)

if (interactions.interactionSucceeded) {
messenger.sendAnswer(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ data class UpdatePlaceholderMessage(
data class FileComponent(
@JsonProperty("tabID") override val tabId: String,
val filePaths: List<NewFileZipInfo>,
val deletedFiles: List<DeletedFileInfo>
val deletedFiles: List<DeletedFileInfo>,
val messageId: String
) : UiMessage(
tabId = tabId,
type = "updateFileComponent"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,12 @@ suspend fun MessagePublisher.sendSystemPrompt(
)
}

suspend fun MessagePublisher.updateFileComponent(tabId: String, filePaths: List<NewFileZipInfo>, deletedFiles: List<DeletedFileInfo>) {
suspend fun MessagePublisher.updateFileComponent(tabId: String, filePaths: List<NewFileZipInfo>, deletedFiles: List<DeletedFileInfo>, messageId: String) {
val fileComponentMessage = FileComponent(
tabId = tabId,
filePaths = filePaths,
deletedFiles = deletedFiles,
messageId = messageId,
)
this.publish(fileComponentMessage)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,6 @@ class FeatureDevControllerTest : FeatureDevTestBase() {

val newFileContentsCopy = newFileContents.toList()
newFileContentsCopy[0].rejected = !newFileContentsCopy[0].rejected
coVerify { messenger.updateFileComponent(testTabId, newFileContentsCopy, deletedFiles) }
coVerify { messenger.updateFileComponent(testTabId, newFileContentsCopy, deletedFiles, "") }
}
}
8 changes: 4 additions & 4 deletions plugins/amazonq/mynah-ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugins/amazonq/mynah-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"lintfix": "eslint -c .eslintrc.js --fix --ext .ts ."
},
"dependencies": {
"@aws/mynah-ui-chat": "npm:@aws/mynah-ui@4.9.0",
"@aws/mynah-ui-chat": "npm:@aws/mynah-ui@4.9.2",
"@types/node": "^14.18.5",
"fs-extra": "^10.0.1",
"ts-node": "^10.7.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export interface ConnectorProps {
onUpdateAuthentication: (featureDevEnabled: boolean, codeTransformEnabled: boolean, authenticatingTabIDs: string[]) => void
onNewTab: (tabType: TabType) => void
tabsStorage: TabsStorage
onFileComponentUpdate: (tabID: string, filePaths: DiffTreeFileInfo[], deletedFiles: DiffTreeFileInfo[]) => void
onFileComponentUpdate: (tabID: string, filePaths: DiffTreeFileInfo[], deletedFiles: DiffTreeFileInfo[], messageId: string) => void
}

export class Connector {
Expand Down Expand Up @@ -201,7 +201,7 @@ export class Connector {

handleMessageReceive = async (messageData: any): Promise<void> => {
if (messageData.type === 'updateFileComponent') {
this.onFileComponentUpdate(messageData.tabID, messageData.filePaths, messageData.deletedFiles)
this.onFileComponentUpdate(messageData.tabID, messageData.filePaths, messageData.deletedFiles, messageData.messageId)
return
}
if (messageData.type === 'errorMessage') {
Expand Down
2 changes: 1 addition & 1 deletion plugins/amazonq/mynah-ui/src/mynah-ui/ui/connector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export interface ConnectorProps {
onCWCOnboardingPageInteractionMessage: (message: ChatItem) => string | undefined
onError: (tabID: string, message: string, title: string) => void
onWarning: (tabID: string, message: string, title: string) => void
onFileComponentUpdate: (tabID: string, filePaths: DiffTreeFileInfo[], deletedFiles: DiffTreeFileInfo[]) => void
onFileComponentUpdate: (tabID: string, filePaths: DiffTreeFileInfo[], deletedFiles: DiffTreeFileInfo[], messageId: string) => void
onUpdatePlaceholder: (tabID: string, newPlaceholder: string) => void
onChatInputEnabled: (tabID: string, enabled: boolean) => void
onUpdateAuthentication: (featureDevEnabled: boolean, codeTransformEnabled: boolean, authenticatingTabIDs: string[]) => void
Expand Down
4 changes: 2 additions & 2 deletions plugins/amazonq/mynah-ui/src/mynah-ui/ui/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ export const createMynahUI = (ideApi: any, featureDevInitEnabled: boolean, codeT
onMessageReceived: (tabID: string, messageData: MynahUIDataModel) => {
mynahUI.updateStore(tabID, messageData)
},
onFileComponentUpdate: (tabID: string, filePaths: DiffTreeFileInfo[], deletedFiles: DiffTreeFileInfo[]) => {
onFileComponentUpdate: (tabID: string, filePaths: DiffTreeFileInfo[], deletedFiles: DiffTreeFileInfo[], messageId: string) => {
const updateWith: Partial<ChatItem> = {
type: ChatItemType.ANSWER,
fileList: {
Expand All @@ -285,7 +285,7 @@ export const createMynahUI = (ideApi: any, featureDevInitEnabled: boolean, codeT
actions: getActions([...filePaths, ...deletedFiles]),
},
}
mynahUI.updateLastChatAnswer(tabID, updateWith)
mynahUI.updateChatAnswerWithMessageId(tabID, messageId, updateWith)
},
onWarning: (tabID: string, message: string, title: string) => {
mynahUI.notify({
Expand Down
Loading