Skip to content

Commit 2d8bbb2

Browse files
authored
fix(amazonq): fix issue where history load crashes LSP
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 43c1c65 commit 2d8bbb2

File tree

1 file changed

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

1 file changed

+4
-9
lines changed

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

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

71-
// TODO: Remove this once chat has been integrated with agents
72-
fun post(message: String) =
73-
jcefBrowser
74-
.cefBrowser
75-
.executeJavaScript("window.postMessage(JSON.stringify($message))", jcefBrowser.cefBrowser.url, 0)
76-
7771
// Load the chat web app into the jcefBrowser
7872
private fun loadWebView(
7973
isCodeTransformAvailable: Boolean,
@@ -117,10 +111,11 @@ class Browser(parent: Disposable, private val webUri: URI, val project: Project)
117111
val postMessageToJavaJsCode = receiveMessageQuery.inject("JSON.stringify(message)")
118112
val connectorAdapterPath = "http://mynah/js/connectorAdapter.js"
119113
generateQuickActionConfig()
114+
// https://github.com/highlightjs/highlight.js/issues/1387
120115
// language=HTML
121116
val jsScripts = """
122-
<script type="text/javascript" src="$connectorAdapterPath"></script>
123-
<script type="text/javascript" src="$webUri" defer onload="init()"></script>
117+
<script type="text/javascript" charset="UTF-8" src="$connectorAdapterPath"></script>
118+
<script type="text/javascript" charset="UTF-8" src="$webUri" defer onload="init()"></script>
124119
125120
<script type="text/javascript">
126121
@@ -154,7 +149,7 @@ class Browser(parent: Disposable, private val webUri: URI, val project: Project)
154149
pairProgrammingAcknowledged: ${!MeetQSettings.getInstance().amazonQChatPairProgramming}
155150
},
156151
hybridChatConnector,
157-
{}
152+
"[]"
158153
159154
);
160155
}

0 commit comments

Comments
 (0)