Skip to content

Commit c6ac2dc

Browse files
authored
fix(amazonq): change to use promptStickyCard to for image verification notification (#5907)
1 parent 6f84a1f commit c6ac2dc

File tree

3 files changed

+26
-11
lines changed

3 files changed

+26
-11
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" : "change to use promptStickyCard to for image verification notification"
4+
}

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/toolwindow/AmazonQPanel.kt

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -173,12 +173,15 @@ class AmazonQPanel(val project: Project, private val scope: CoroutineScope) : Di
173173
0
174174
)
175175

176-
val errorJson = OBJECT_MAPPER.writeValueAsString(errorMessages)
177-
browserInstance.jcefBrowser.cefBrowser.executeJavaScript(
178-
"window.handleNativeNotify('$errorJson')",
179-
browserInstance.jcefBrowser.cefBrowser.url,
180-
0
181-
)
176+
if (errorMessages.isNotEmpty()) {
177+
val errorJson = OBJECT_MAPPER.writeValueAsString(errorMessages)
178+
browserInstance.jcefBrowser.cefBrowser.executeJavaScript(
179+
"window.handleNativeNotify('$errorJson')",
180+
browserInstance.jcefBrowser.cefBrowser.url,
181+
0
182+
)
183+
}
184+
182185
dtde.dropComplete(true)
183186
} else {
184187
dtde.dropComplete(false)

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/webview/Browser.kt

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,19 @@ class Browser(parent: Disposable, private val webUri: URI, val project: Project)
175175
176176
window.handleNativeNotify = function(errorMessages) {
177177
const messages = JSON.parse(errorMessages);
178-
messages.forEach(msg => {
179-
qChat.notify({
180-
content: msg
181-
})
182-
});
178+
let message = messages.join('\n');
179+
qChat.updateStore(qChat.getSelectedTabId(), {
180+
promptInputStickyCard: {
181+
messageId: 'image-verification-banner',
182+
header: {
183+
icon: 'warning',
184+
iconStatus: 'warning',
185+
body: '### Invalid Image',
186+
},
187+
body: message,
188+
canBeDismissed: true,
189+
},
190+
})
183191
};
184192
}
185193
</script>

0 commit comments

Comments
 (0)