Skip to content

Commit 475dfc8

Browse files
authored
fix(amazonq): fix issue where history load crashes LSP (#5690)
Chat UI bundle contains unicode, which is incorrectly loaded as ASCII when packaged as a webpack bundle. On Flare LSP request `aws/chat/openTab`, we forward the message to Mynah UI, which subsequently fails if the body contains Java-formatted markdown as it triggers the incorrectly parsed unicode. The Flare [chat wrapper](https://github.com/aws/language-servers/blame/547ecafb561fd3d6bf7a264def829160901dd23a/chat-client/src/client/mynahUi.ts#L989-L991) subsequently does not respond with the `onOpenTab` callback and the LSP times out and exits the process. Fix by explicitly loading assets as UTF-8
1 parent ffe192f commit 475dfc8

File tree

1 file changed

+4
-10
lines changed
  • plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/webview

1 file changed

+4
-10
lines changed

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

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,6 @@ class Browser(parent: Disposable, private val webUri: URI, val project: Project)
6969
.executeJavaScript("window.postMessage($message)", jcefBrowser.cefBrowser.url, 0)
7070
}
7171

72-
// TODO: Remove this once chat has been integrated with agents
73-
fun post(message: String) =
74-
jcefBrowser
75-
.cefBrowser
76-
.executeJavaScript("window.postMessage(JSON.stringify($message))", jcefBrowser.cefBrowser.url, 0)
77-
7872
// Load the chat web app into the jcefBrowser
7973
private fun loadWebView(
8074
isCodeTransformAvailable: Boolean,
@@ -118,10 +112,11 @@ class Browser(parent: Disposable, private val webUri: URI, val project: Project)
118112
val postMessageToJavaJsCode = receiveMessageQuery.inject("JSON.stringify(message)")
119113
val connectorAdapterPath = "http://mynah/js/connectorAdapter.js"
120114
generateQuickActionConfig()
115+
// https://github.com/highlightjs/highlight.js/issues/1387
121116
// language=HTML
122117
val jsScripts = """
123-
<script type="text/javascript" src="$connectorAdapterPath"></script>
124-
<script type="text/javascript" src="$webUri" defer onload="init()"></script>
118+
<script type="text/javascript" charset="UTF-8" src="$connectorAdapterPath"></script>
119+
<script type="text/javascript" charset="UTF-8" src="$webUri" defer onload="init()"></script>
125120
126121
<script type="text/javascript">
127122
@@ -155,8 +150,7 @@ class Browser(parent: Disposable, private val webUri: URI, val project: Project)
155150
pairProgrammingAcknowledged: ${!MeetQSettings.getInstance().amazonQChatPairProgramming}
156151
},
157152
hybridChatConnector,
158-
${CodeWhispererFeatureConfigService.getInstance().getFeatureConfigJsonString()}
159-
153+
${CodeWhispererFeatureConfigService.getInstance().getFeatureConfigJsonString()}
160154
);
161155
}
162156
</script>

0 commit comments

Comments
 (0)