Skip to content

Commit 82a818a

Browse files
authored
fix(featureDev): File Rejection stopped working (with plan not disappearing on clicking Generate Code) (#4529)
* fix(featureDev): File Rejection stopped working * return sendUpdatePlaceholder add changeLog * fix imports
1 parent 4a7e8f1 commit 82a818a

File tree

10 files changed

+23
-20
lines changed

10 files changed

+23
-20
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type" : "bugfix",
3+
"description" : " fix(featureDev): File Rejection stopped working"
4+
}

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqFeatureDev/controller/FeatureDevController.kt

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ import software.aws.toolkits.jetbrains.services.amazonqFeatureDev.messages.Follo
4444
import software.aws.toolkits.jetbrains.services.amazonqFeatureDev.messages.IncomingFeatureDevMessage
4545
import software.aws.toolkits.jetbrains.services.amazonqFeatureDev.messages.initialExamples
4646
import software.aws.toolkits.jetbrains.services.amazonqFeatureDev.messages.sendAnswer
47-
import software.aws.toolkits.jetbrains.services.amazonqFeatureDev.messages.sendAnswerPart
4847
import software.aws.toolkits.jetbrains.services.amazonqFeatureDev.messages.sendAsyncEventProgress
4948
import software.aws.toolkits.jetbrains.services.amazonqFeatureDev.messages.sendAuthNeededException
5049
import software.aws.toolkits.jetbrains.services.amazonqFeatureDev.messages.sendAuthenticationInProgressMessage
@@ -231,6 +230,7 @@ class FeatureDevController(
231230
override suspend fun processFileClicked(message: IncomingFeatureDevMessage.FileClicked) {
232231
val fileToUpdate = message.filePath
233232
val session = getSessionInfo(message.tabId)
233+
val messageId = message.messageId
234234

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

248-
messenger.updateFileComponent(message.tabId, filePaths, deletedFiles)
248+
messenger.updateFileComponent(message.tabId, filePaths, deletedFiles, messageId)
249249
}
250250

251251
private suspend fun newTabOpened(tabId: String) {
@@ -522,19 +522,16 @@ class FeatureDevController(
522522

523523
messenger.sendAnswer(
524524
tabId = tabId,
525-
messageType = FeatureDevMessageType.Answer,
525+
messageType = FeatureDevMessageType.AnswerStream,
526526
message = message("amazonqFeatureDev.create_plan"),
527527
)
528528

529-
// Ensure that the loading icon stays showing
530-
messenger.sendAsyncEventProgress(tabId = tabId, inProgress = true)
531-
532529
messenger.sendUpdatePlaceholder(tabId, message("amazonqFeatureDev.placeholder.generating_approach"))
533530

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

537-
messenger.sendAnswerPart(tabId = tabId, message = interactions.content, canBeVoted = interactions.interactionSucceeded)
534+
messenger.sendAnswer(tabId = tabId, message = interactions.content, messageType = FeatureDevMessageType.Answer, canBeVoted = true)
538535

539536
if (interactions.interactionSucceeded) {
540537
messenger.sendAnswer(

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqFeatureDev/messages/FeatureDevMessage.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@ data class UpdatePlaceholderMessage(
133133
data class FileComponent(
134134
@JsonProperty("tabID") override val tabId: String,
135135
val filePaths: List<NewFileZipInfo>,
136-
val deletedFiles: List<DeletedFileInfo>
136+
val deletedFiles: List<DeletedFileInfo>,
137+
val messageId: String
137138
) : UiMessage(
138139
tabId = tabId,
139140
type = "updateFileComponent"

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqFeatureDev/messages/FeatureDevMessagePublisherExtensions.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,12 @@ suspend fun MessagePublisher.sendSystemPrompt(
5858
)
5959
}
6060

61-
suspend fun MessagePublisher.updateFileComponent(tabId: String, filePaths: List<NewFileZipInfo>, deletedFiles: List<DeletedFileInfo>) {
61+
suspend fun MessagePublisher.updateFileComponent(tabId: String, filePaths: List<NewFileZipInfo>, deletedFiles: List<DeletedFileInfo>, messageId: String) {
6262
val fileComponentMessage = FileComponent(
6363
tabId = tabId,
6464
filePaths = filePaths,
6565
deletedFiles = deletedFiles,
66+
messageId = messageId,
6667
)
6768
this.publish(fileComponentMessage)
6869
}

plugins/amazonq/chat/jetbrains-community/tst/software/aws/toolkits/jetbrains/services/amazonqFeatureDev/controller/FeatureDevControllerTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,6 @@ class FeatureDevControllerTest : FeatureDevTestBase() {
388388

389389
val newFileContentsCopy = newFileContents.toList()
390390
newFileContentsCopy[0].rejected = !newFileContentsCopy[0].rejected
391-
coVerify { messenger.updateFileComponent(testTabId, newFileContentsCopy, deletedFiles) }
391+
coVerify { messenger.updateFileComponent(testTabId, newFileContentsCopy, deletedFiles, "") }
392392
}
393393
}

plugins/amazonq/mynah-ui/package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugins/amazonq/mynah-ui/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"lintfix": "eslint -c .eslintrc.js --fix --ext .ts ."
1313
},
1414
"dependencies": {
15-
"@aws/mynah-ui-chat": "npm:@aws/[email protected].0",
15+
"@aws/mynah-ui-chat": "npm:@aws/[email protected].2",
1616
"@types/node": "^14.18.5",
1717
"fs-extra": "^10.0.1",
1818
"ts-node": "^10.7.0",

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
@@ -28,7 +28,7 @@ export interface ConnectorProps {
2828
onUpdateAuthentication: (featureDevEnabled: boolean, codeTransformEnabled: boolean, authenticatingTabIDs: string[]) => void
2929
onNewTab: (tabType: TabType) => void
3030
tabsStorage: TabsStorage
31-
onFileComponentUpdate: (tabID: string, filePaths: DiffTreeFileInfo[], deletedFiles: DiffTreeFileInfo[]) => void
31+
onFileComponentUpdate: (tabID: string, filePaths: DiffTreeFileInfo[], deletedFiles: DiffTreeFileInfo[], messageId: string) => void
3232
}
3333

3434
export class Connector {
@@ -201,7 +201,7 @@ export class Connector {
201201

202202
handleMessageReceive = async (messageData: any): Promise<void> => {
203203
if (messageData.type === 'updateFileComponent') {
204-
this.onFileComponentUpdate(messageData.tabID, messageData.filePaths, messageData.deletedFiles)
204+
this.onFileComponentUpdate(messageData.tabID, messageData.filePaths, messageData.deletedFiles, messageData.messageId)
205205
return
206206
}
207207
if (messageData.type === 'errorMessage') {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export interface ConnectorProps {
4343
onCWCOnboardingPageInteractionMessage: (message: ChatItem) => string | undefined
4444
onError: (tabID: string, message: string, title: string) => void
4545
onWarning: (tabID: string, message: string, title: string) => void
46-
onFileComponentUpdate: (tabID: string, filePaths: DiffTreeFileInfo[], deletedFiles: DiffTreeFileInfo[]) => void
46+
onFileComponentUpdate: (tabID: string, filePaths: DiffTreeFileInfo[], deletedFiles: DiffTreeFileInfo[], messageId: string) => void
4747
onUpdatePlaceholder: (tabID: string, newPlaceholder: string) => void
4848
onChatInputEnabled: (tabID: string, enabled: boolean) => void
4949
onUpdateAuthentication: (featureDevEnabled: boolean, codeTransformEnabled: boolean, authenticatingTabIDs: 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
@@ -274,7 +274,7 @@ export const createMynahUI = (ideApi: any, featureDevInitEnabled: boolean, codeT
274274
onMessageReceived: (tabID: string, messageData: MynahUIDataModel) => {
275275
mynahUI.updateStore(tabID, messageData)
276276
},
277-
onFileComponentUpdate: (tabID: string, filePaths: DiffTreeFileInfo[], deletedFiles: DiffTreeFileInfo[]) => {
277+
onFileComponentUpdate: (tabID: string, filePaths: DiffTreeFileInfo[], deletedFiles: DiffTreeFileInfo[], messageId: string) => {
278278
const updateWith: Partial<ChatItem> = {
279279
type: ChatItemType.ANSWER,
280280
fileList: {
@@ -285,7 +285,7 @@ export const createMynahUI = (ideApi: any, featureDevInitEnabled: boolean, codeT
285285
actions: getActions([...filePaths, ...deletedFiles]),
286286
},
287287
}
288-
mynahUI.updateLastChatAnswer(tabID, updateWith)
288+
mynahUI.updateChatAnswerWithMessageId(tabID, messageId, updateWith)
289289
},
290290
onWarning: (tabID: string, message: string, title: string) => {
291291
mynahUI.notify({

0 commit comments

Comments
 (0)