Skip to content

Commit 734406c

Browse files
authored
fix(amazonq): implement window/showMessageRequest and change text per feedback (#5807)
1 parent f90644c commit 734406c

File tree

2 files changed

+31
-11
lines changed

2 files changed

+31
-11
lines changed

plugins/amazonq/shared/jetbrains-community/resources/software/aws/toolkits/resources/AmazonQBundle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ amazonqInlineChat.popup.title=Enter Instructions for Q
99
amazonq.refresh.panel=Refresh Chat Session
1010
amazonq.title=Amazon Q
1111
amazonq.workspace.settings.open.prompt=Workspace index is now enabled. You can disable it from Amazon Q settings.
12-
action.q.manage.subscription.text=Manage Subscription
12+
action.q.manage.subscription.text=Manage Q Developer Pro Subscription
1313
action.q.profile.usage.text=You changed your profile
1414
action.q.profile.usage=You''re using the ''<b>{0}</b>'' profile for Amazon Q.
1515
action.q.switchProfiles.text=Change Profile

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

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
// Copyright 2025 Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
33
@file:Suppress("BannedImports")
4+
45
package software.aws.toolkits.jetbrains.services.amazonq.lsp
56

67
import com.intellij.diff.DiffContentFactory
78
import com.intellij.diff.requests.SimpleDiffRequest
89
import com.intellij.ide.BrowserUtil
10+
import com.intellij.notification.NotificationAction
911
import com.intellij.notification.NotificationType
1012
import com.intellij.openapi.application.ApplicationManager
1113
import com.intellij.openapi.fileChooser.FileChooserFactory
@@ -112,19 +114,28 @@ class AmazonQLanguageClientImpl(private val project: Project) : AmazonQLanguageC
112114
}
113115

114116
override fun showMessage(messageParams: MessageParams) {
115-
val type = when (messageParams.type) {
116-
MessageType.Error -> NotificationType.ERROR
117-
MessageType.Warning -> NotificationType.WARNING
118-
MessageType.Info, MessageType.Log -> NotificationType.INFORMATION
119-
}
120-
121-
notify(type, message("q.window.title"), getCleanedContent(messageParams.message, true), project, emptyList())
117+
notify(messageParams.type.toNotificationType(), message("q.window.title"), getCleanedContent(messageParams.message, true), project, emptyList())
122118
}
123119

124-
override fun showMessageRequest(requestParams: ShowMessageRequestParams): CompletableFuture<MessageActionItem?>? {
125-
println(requestParams)
120+
override fun showMessageRequest(requestParams: ShowMessageRequestParams): CompletableFuture<MessageActionItem?> {
121+
val future = CompletableFuture<MessageActionItem?>()
122+
if (requestParams.actions.isNullOrEmpty()) {
123+
future.complete(null)
124+
}
125+
126+
notify(
127+
requestParams.type.toNotificationType(),
128+
message("q.window.title"),
129+
getCleanedContent(requestParams.message, true),
130+
project,
131+
requestParams.actions.map { item ->
132+
NotificationAction.createSimple(item.title) {
133+
future.complete(item)
134+
}
135+
}
136+
)
126137

127-
return CompletableFuture.completedFuture(null)
138+
return future
128139
}
129140

130141
override fun logMessage(message: MessageParams) {
@@ -280,6 +291,7 @@ class AmazonQLanguageClientImpl(private val project: Project) : AmazonQLanguageC
280291
)
281292
)
282293
}
294+
283295
AmazonQLspConstants.LSP_Q_CONFIGURATION_KEY -> {
284296
add(
285297
AmazonQLspConfiguration(
@@ -327,6 +339,12 @@ class AmazonQLanguageClientImpl(private val project: Project) : AmazonQLanguageC
327339

328340
private fun File.toVirtualFile() = LocalFileSystem.getInstance().findFileByIoFile(this)
329341

342+
private fun MessageType.toNotificationType() = when (this) {
343+
MessageType.Error -> NotificationType.ERROR
344+
MessageType.Warning -> NotificationType.WARNING
345+
MessageType.Info, MessageType.Log -> NotificationType.INFORMATION
346+
}
347+
330348
override fun openFileDiff(params: OpenFileDiffParams): CompletableFuture<Unit> =
331349
CompletableFuture.supplyAsync(
332350
{
@@ -352,6 +370,7 @@ class AmazonQLanguageClientImpl(private val project: Project) : AmazonQLanguageC
352370
contentFactory.create(project, originalContent, virtualFile) to
353371
contentFactory.createEmpty()
354372
}
373+
355374
else -> {
356375
val newContent = params.fileContent.orEmpty()
357376
isNewFile = newContent == originalContent
@@ -360,6 +379,7 @@ class AmazonQLanguageClientImpl(private val project: Project) : AmazonQLanguageC
360379
contentFactory.createEmpty() to
361380
contentFactory.create(project, newContent, virtualFile)
362381
}
382+
363383
else -> {
364384
contentFactory.create(project, originalContent, virtualFile) to
365385
contentFactory.create(project, newContent, virtualFile)

0 commit comments

Comments
 (0)