Skip to content

Commit 755d540

Browse files
authored
Merge branch 'main' into overlay
2 parents fcb6a53 + c6ac2dc commit 755d540

File tree

7 files changed

+135
-89
lines changed

7 files changed

+135
-89
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+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type" : "bugfix",
3+
"description" : "Suppress IDE error when current editor context is not valid for Amazon Q"
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
@@ -220,12 +220,15 @@ class AmazonQPanel(val project: Project, private val scope: CoroutineScope) : Di
220220
0
221221
)
222222

223-
val errorJson = OBJECT_MAPPER.writeValueAsString(errorMessages)
224-
browserInstance.jcefBrowser.cefBrowser.executeJavaScript(
225-
"window.handleNativeNotify('$errorJson')",
226-
browserInstance.jcefBrowser.cefBrowser.url,
227-
0
228-
)
223+
if (errorMessages.isNotEmpty()) {
224+
val errorJson = OBJECT_MAPPER.writeValueAsString(errorMessages)
225+
browserInstance.jcefBrowser.cefBrowser.executeJavaScript(
226+
"window.handleNativeNotify('$errorJson')",
227+
browserInstance.jcefBrowser.cefBrowser.url,
228+
0
229+
)
230+
}
231+
229232
dtde.dropComplete(true)
230233
} else {
231234
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
window.setDragAndDropVisible = function(visibility) {

plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/textdocument/TextDocumentServiceHandler.kt

Lines changed: 75 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ import org.eclipse.lsp4j.TextDocumentContentChangeEvent
3333
import org.eclipse.lsp4j.TextDocumentIdentifier
3434
import org.eclipse.lsp4j.TextDocumentItem
3535
import org.eclipse.lsp4j.VersionedTextDocumentIdentifier
36+
import software.aws.toolkits.core.utils.getLogger
3637
import software.aws.toolkits.core.utils.tryOrNull
38+
import software.aws.toolkits.core.utils.warn
39+
import software.aws.toolkits.jetbrains.services.amazonq.lsp.AmazonQLanguageServer
3740
import software.aws.toolkits.jetbrains.services.amazonq.lsp.AmazonQLspService
3841
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat.ACTIVE_EDITOR_CHANGED_NOTIFICATION
3942
import software.aws.toolkits.jetbrains.services.amazonq.lsp.util.LspEditorUtil.getCursorState
@@ -98,40 +101,36 @@ class TextDocumentServiceHandler(
98101
}
99102
}
100103

101-
cs.launch {
102-
AmazonQLspService.executeAsyncIfRunning(project) { languageServer ->
103-
toUriString(file)?.let { uri ->
104-
languageServer.textDocumentService.didOpen(
105-
DidOpenTextDocumentParams().apply {
106-
textDocument = TextDocumentItem().apply {
107-
this.uri = uri
108-
text = file.inputStream.readAllBytes().decodeToString()
109-
languageId = file.fileType.name.lowercase()
110-
version = file.modificationStamp.toInt()
111-
}
104+
trySendIfValid { languageServer ->
105+
toUriString(file)?.let { uri ->
106+
languageServer.textDocumentService.didOpen(
107+
DidOpenTextDocumentParams().apply {
108+
textDocument = TextDocumentItem().apply {
109+
this.uri = uri
110+
text = file.inputStream.readAllBytes().decodeToString()
111+
languageId = file.fileType.name.lowercase()
112+
version = file.modificationStamp.toInt()
112113
}
113-
)
114-
}
114+
}
115+
)
115116
}
116117
}
117118
}
118119
}
119120

120121
override fun beforeDocumentSaving(document: Document) {
121-
cs.launch {
122-
AmazonQLspService.executeAsyncIfRunning(project) { languageServer ->
123-
val file = FileDocumentManager.getInstance().getFile(document) ?: return@executeAsyncIfRunning
124-
toUriString(file)?.let { uri ->
125-
languageServer.textDocumentService.didSave(
126-
DidSaveTextDocumentParams().apply {
127-
textDocument = TextDocumentIdentifier().apply {
128-
this.uri = uri
129-
}
130-
// TODO: should respect `textDocumentSync.save.includeText` server capability config
131-
text = document.text
122+
trySendIfValid { languageServer ->
123+
val file = FileDocumentManager.getInstance().getFile(document) ?: return@trySendIfValid
124+
toUriString(file)?.let { uri ->
125+
languageServer.textDocumentService.didSave(
126+
DidSaveTextDocumentParams().apply {
127+
textDocument = TextDocumentIdentifier().apply {
128+
this.uri = uri
132129
}
133-
)
134-
}
130+
// TODO: should respect `textDocumentSync.save.includeText` server capability config
131+
text = document.text
132+
}
133+
)
135134
}
136135
}
137136
}
@@ -141,23 +140,21 @@ class TextDocumentServiceHandler(
141140
val document = FileDocumentManager.getInstance().getCachedDocument(event.file) ?: return@forEach
142141

143142
handleFileOpened(event.file)
144-
cs.launch {
145-
AmazonQLspService.executeAsyncIfRunning(project) { languageServer ->
146-
toUriString(event.file)?.let { uri ->
147-
languageServer.textDocumentService.didChange(
148-
DidChangeTextDocumentParams().apply {
149-
textDocument = VersionedTextDocumentIdentifier().apply {
150-
this.uri = uri
151-
version = document.modificationStamp.toInt()
152-
}
153-
contentChanges = listOf(
154-
TextDocumentContentChangeEvent().apply {
155-
text = document.text
156-
}
157-
)
143+
trySendIfValid { languageServer ->
144+
toUriString(event.file)?.let { uri ->
145+
languageServer.textDocumentService.didChange(
146+
DidChangeTextDocumentParams().apply {
147+
textDocument = VersionedTextDocumentIdentifier().apply {
148+
this.uri = uri
149+
version = document.modificationStamp.toInt()
158150
}
159-
)
160-
}
151+
contentChanges = listOf(
152+
TextDocumentContentChangeEvent().apply {
153+
text = document.text
154+
}
155+
)
156+
}
157+
)
161158
}
162159
}
163160
}
@@ -179,17 +176,15 @@ class TextDocumentServiceHandler(
179176
tryOrNull { FileDocumentManager.getInstance().getDocument(file)?.removeDocumentListener(listener) }
180177
file.putUserData(KEY_REAL_TIME_EDIT_LISTENER, null)
181178

182-
cs.launch {
183-
AmazonQLspService.executeAsyncIfRunning(project) { languageServer ->
184-
toUriString(file)?.let { uri ->
185-
languageServer.textDocumentService.didClose(
186-
DidCloseTextDocumentParams().apply {
187-
textDocument = TextDocumentIdentifier().apply {
188-
this.uri = uri
189-
}
179+
trySendIfValid { languageServer ->
180+
toUriString(file)?.let { uri ->
181+
languageServer.textDocumentService.didClose(
182+
DidCloseTextDocumentParams().apply {
183+
textDocument = TextDocumentIdentifier().apply {
184+
this.uri = uri
190185
}
191-
)
192-
}
186+
}
187+
)
193188
}
194189
}
195190
}
@@ -221,24 +216,22 @@ class TextDocumentServiceHandler(
221216
}
222217

223218
private fun realTimeEdit(event: DocumentEvent) {
224-
cs.launch {
225-
AmazonQLspService.executeAsyncIfRunning(project) { languageServer ->
226-
val vFile = FileDocumentManager.getInstance().getFile(event.document) ?: return@executeAsyncIfRunning
227-
toUriString(vFile)?.let { uri ->
228-
languageServer.textDocumentService.didChange(
229-
DidChangeTextDocumentParams().apply {
230-
textDocument = VersionedTextDocumentIdentifier().apply {
231-
this.uri = uri
232-
version = event.document.modificationStamp.toInt()
233-
}
234-
contentChanges = listOf(
235-
TextDocumentContentChangeEvent().apply {
236-
text = event.document.text
237-
}
238-
)
219+
trySendIfValid { languageServer ->
220+
val vFile = FileDocumentManager.getInstance().getFile(event.document) ?: return@trySendIfValid
221+
toUriString(vFile)?.let { uri ->
222+
languageServer.textDocumentService.didChange(
223+
DidChangeTextDocumentParams().apply {
224+
textDocument = VersionedTextDocumentIdentifier().apply {
225+
this.uri = uri
226+
version = event.document.modificationStamp.toInt()
239227
}
240-
)
241-
}
228+
contentChanges = listOf(
229+
TextDocumentContentChangeEvent().apply {
230+
text = event.document.text
231+
}
232+
)
233+
}
234+
)
242235
}
243236
}
244237
// Process document changes here
@@ -247,7 +240,20 @@ class TextDocumentServiceHandler(
247240
override fun dispose() {
248241
}
249242

243+
private fun trySendIfValid(runnable: (AmazonQLanguageServer) -> Unit) {
244+
cs.launch {
245+
AmazonQLspService.executeAsyncIfRunning(project) { languageServer ->
246+
try {
247+
runnable(languageServer)
248+
} catch (e: Exception) {
249+
LOG.warn { "Invalid document: $e" }
250+
}
251+
}
252+
}
253+
}
254+
250255
companion object {
251256
private val KEY_REAL_TIME_EDIT_LISTENER = Key.create<DocumentListener>("amazonq.textdocument.realtimeedit.listener")
257+
private val LOG = getLogger<TextDocumentServiceHandler>()
252258
}
253259
}

plugins/amazonq/shared/jetbrains-community/tst/software/aws/toolkits/jetbrains/services/amazonq/lsp/textdocument/TextDocumentServiceHandlerTest.kt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,22 @@ class TextDocumentServiceHandlerTest {
188188
}
189189
}
190190

191+
@Test
192+
fun `fileOpened suppreses document read failure`() = runTest {
193+
sut = TextDocumentServiceHandler(projectRule.project, this)
194+
advanceUntilIdle()
195+
196+
val file = mockk<VirtualFile> {
197+
every { inputStream } throws RuntimeException("read failure")
198+
every { getUserData<Any>(any()) } returns null
199+
every { putUserData<Any>(any(), any()) } returns Unit
200+
every { isValid } returns false
201+
}
202+
sut.fileOpened(mockk(), file)
203+
204+
verify(exactly = 0) { mockTextDocumentService.didOpen(any()) }
205+
}
206+
191207
@Test
192208
fun `didClose runs on fileClosed`() = runTest {
193209
sut = TextDocumentServiceHandler(projectRule.project, this)

plugins/amazonq/src/main/resources/META-INF/plugin.xml

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,34 +7,39 @@
77
<description><![CDATA[
88
<p>The most capable generative AI-powered assistant for building, operating, and transforming software, with advanced capabilities for managing data and AI</p>
99
10-
<h2>Agent capabilities</h2>
10+
<h2>Agentic coding experience</h2>
11+
<p>Amazon Q Developer uses information across native and MCP server-based tools to intelligently perform actions beyond code suggestions, such as reading files, generating code diffs, and running commands based on your natural language instruction. Simply type your prompt in your preferred language and Q Developer will provide continuous status updates and iteratively apply changes based on your feedback, helping you accomplish tasks faster.</p>
12+
1113
<h3>Implement new features</h3>
12-
<p><code>/dev</code> to task Amazon Q with generating new code across your entire project and implement features.</p>
14+
<p>Generate new code across your entire project and implement features.</p>
1315
1416
<h3>Generate documentation</h3>
15-
<p><code>/doc</code> to task Amazon Q with writing API, technical design, and onboarding documentation.</p>
17+
<p>Write API, technical design, and onboarding documentation.</p>
1618
1719
<h3>Automate code reviews</h3>
18-
<p><code>/review</code> to ask Amazon Q to perform code reviews, flagging suspicious code patterns and assessing deployment risk.</p>
20+
<p>Perform code reviews, flagging suspicious code patterns and assessing deployment risk.</p>
1921
2022
<h3>Generate unit tests</h3>
21-
<p><code>/test</code> to ask Amazon Q to generate unit tests and add them to your project, helping you improve code quality, fast.</p>
23+
<p>Generate unit tests and add them to your project, helping you improve code quality, fast.</p>
2224
2325
<h3>Transform workloads</h3>
2426
<p><code>/transform</code> to upgrade your Java applications in minutes, not weeks.</p>
2527
2628
<h2>Core features</h2>
2729
30+
<h3>MCP support</h3>
31+
<p>Add Model Context Protocol (MCP) servers to give Amazon Q Developer access to important context.</p>
32+
33+
<h3>Inline suggestions</h3>
34+
<p>Receive real-time code suggestions ranging from snippets to full functions based on your comments and existing code.</p>
35+
<p><i><a href="https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/q-language-ide-support.html">15+ languages supported including Python, TypeScript, Rust, Terraform, AWS Cloudformation, and more</a></i></p>
36+
2837
<h3>Inline chat</h3>
2938
<p>Seamlessly initial chat within the inline coding experience. Select a section of code that you need assistance with and initiate chat within the editor to request actions such as "Optimize this code", "Add comments", or "Write tests".</p>
3039
3140
<h3>Chat</h3>
3241
<p>Generate code, explain code, and get answers about software development.</p>
3342
34-
<h3>Inline suggestions</h3>
35-
<p><Receive real-time code suggestions ranging from snippets to full functions based on your comments and existing code.</p>
36-
<p><i><a href="https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/q-language-ide-support.html">15+ languages supported including Python, TypeScript, Rust, Terraform, AWS Cloudformation, and more</a></i></p>
37-
3843
<h3>Code reference log</h3>
3944
<p>Attribute code from Amazon Q that is similar to training data. When code suggestions similar to training data are accepted, they will be added to the code reference log.</p>
4045

0 commit comments

Comments
 (0)