Skip to content

Commit 17c34c7

Browse files
committed
Merge remote-tracking branch 'origin/feature/q-lsp-chat' into feature/remote-chat-lsp
2 parents a6f4103 + dbeec62 commit 17c34c7

File tree

6 files changed

+26
-10
lines changed

6 files changed

+26
-10
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ class BrowserConnector(
479479
} catch (_: CancellationException) {
480480
LOG.warn { "Cancelled chat generation" }
481481
} catch (e: Exception) {
482-
LOG.error(e) { "Failed to send chat message" }
482+
LOG.warn(e) { "Failed to send chat message" }
483483
browser.postChat(chatCommunicationManager.getErrorUiMessage(tabId, e, partialResultToken))
484484
}
485485
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ class ThemeBrowserAdapter {
4242
append(CssVariable.TextColorWeak, theme.inactiveText)
4343
append(CssVariable.TextColorDisabled, theme.inactiveText)
4444

45-
append(CssVariable.Background, theme.background)
45+
append(CssVariable.Background, theme.editorBackground)
4646
append(CssVariable.BackgroundAlt, theme.background)
4747
append(CssVariable.CardBackground, theme.editorBackground)
48-
append(CssVariable.CardBackgroundAlt, theme.editorBackground)
48+
append(CssVariable.CardBackgroundAlt, theme.background)
4949
append(CssVariable.BorderDefault, theme.border)
5050
append(CssVariable.TabActive, theme.activeTab)
5151

plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/language/CodeWhispererLanguageManager.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ class CodeWhispererLanguageManager {
148148
listOf("vue") to CodeWhispererVue.INSTANCE,
149149
listOf("ps1", "psm1") to CodeWhispererPowershell.INSTANCE,
150150
listOf("r") to CodeWhispererR.INSTANCE,
151-
listOf("abap", "acds") to CodeWhispererAbap.INSTANCE,
151+
listOf("abap") to CodeWhispererAbap.INSTANCE,
152152
).map {
153153
val exts = it.first
154154
val lang = it.second

plugins/amazonq/codewhisperer/jetbrains-community/tst/software/aws/toolkits/jetbrains/services/codewhisperer/CodeWhispererLanguageManagerTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ class CodeWhispererLanguageManagerTest {
137137
testGetProgrammingLanguageUtil<CodeWhispererSwift>(listOf("foo"), listOf("swift"))
138138
testGetProgrammingLanguageUtil<CodeWhispererSystemVerilog>(listOf("foo"), listOf("sv", "svh", "vh"))
139139
testGetProgrammingLanguageUtil<CodeWhispererVue>(listOf("foo"), listOf("vue"))
140-
testGetProgrammingLanguageUtil<CodeWhispererAbap>(listOf("foo"), listOf("abap", "acds"))
140+
testGetProgrammingLanguageUtil<CodeWhispererAbap>(listOf("foo"), listOf("abap"))
141141
}
142142

143143
@Test

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ import software.aws.toolkits.jetbrains.utils.getCleanedContent
5959
import software.aws.toolkits.jetbrains.utils.notify
6060
import software.aws.toolkits.resources.message
6161
import java.io.File
62+
import java.net.URLDecoder
63+
import java.nio.charset.StandardCharsets
6264
import java.nio.file.Files
6365
import java.nio.file.Paths
6466
import java.util.UUID
@@ -147,19 +149,22 @@ class AmazonQLanguageClientImpl(private val project: Project) : AmazonQLanguageC
147149
return CompletableFuture.completedFuture(ShowDocumentResult(false))
148150
}
149151

152+
// The filepath sent by the server contains unicode characters which need to be
153+
// decoded for JB file handling APIs to be handle to handle file operations
154+
val fileToOpen = URLDecoder.decode(params.uri, StandardCharsets.UTF_8.name())
150155
if (params.external == true) {
151-
BrowserUtil.open(params.uri)
156+
BrowserUtil.open(fileToOpen)
152157
return CompletableFuture.completedFuture(ShowDocumentResult(true))
153158
}
154159

155160
ApplicationManager.getApplication().invokeLater {
156161
try {
157-
val virtualFile = VirtualFileManager.getInstance().findFileByUrl(params.uri)
158-
?: throw IllegalArgumentException("Cannot find file: ${params.uri}")
162+
val virtualFile = VirtualFileManager.getInstance().findFileByUrl(fileToOpen)
163+
?: throw IllegalArgumentException("Cannot find file: $fileToOpen")
159164

160165
FileEditorManager.getInstance(project).openFile(virtualFile, true)
161166
} catch (e: Exception) {
162-
LOG.warn { "Failed to show document: ${params.uri}" }
167+
LOG.warn { "Failed to show document: $fileToOpen" }
163168
}
164169
}
165170

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,17 @@
44
package software.aws.toolkits.jetbrains.services.amazonq.lsp.flareChat
55

66
import com.google.gson.Gson
7+
import com.google.gson.JsonObject
78
import com.intellij.openapi.components.Service
89
import com.intellij.openapi.components.service
910
import com.intellij.openapi.project.Project
1011
import kotlinx.coroutines.CompletableDeferred
1112
import kotlinx.coroutines.CoroutineScope
1213
import kotlinx.coroutines.launch
1314
import org.eclipse.lsp4j.ProgressParams
15+
import org.eclipse.lsp4j.jsonrpc.ResponseErrorException
1416
import software.aws.toolkits.core.utils.getLogger
17+
import software.aws.toolkits.core.utils.tryOrNull
1518
import software.aws.toolkits.core.utils.warn
1619
import software.aws.toolkits.jetbrains.core.credentials.ToolkitConnectionManager
1720
import software.aws.toolkits.jetbrains.core.credentials.pinning.QConnection
@@ -22,6 +25,7 @@ import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.LSPAny
2225
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat.AuthFollowUpClickedParams
2326
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat.AuthFollowupType
2427
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat.CHAT_ERROR_PARAMS
28+
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat.ChatMessage
2529
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat.ErrorParams
2630
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat.GetSerializedChatResult
2731
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat.SEND_CHAT_COMMAND_PROMPT
@@ -122,8 +126,15 @@ class ChatCommunicationManager(private val cs: CoroutineScope) {
122126
token?.let {
123127
removePartialChatMessage(it)
124128
}
129+
var errorMessage: String? = null
130+
if (exception is ResponseErrorException) {
131+
errorMessage = tryOrNull {
132+
Gson().fromJson(exception.responseError.data as JsonObject, ChatMessage::class.java).body
133+
} ?: exception.responseError.message
134+
}
135+
125136
val errorTitle = "An error occurred while processing your request."
126-
val errorMessage = "Details: ${exception.message}"
137+
errorMessage = errorMessage ?: "Details: ${exception.message}"
127138
val errorParams = Gson().toJson(ErrorParams(tabId, null, errorMessage, errorTitle)).toString()
128139
val isPartialResult = false
129140
val uiMessage = """

0 commit comments

Comments
 (0)