Skip to content

Commit 13a044b

Browse files
committed
refactor
1 parent acb4ac7 commit 13a044b

File tree

1 file changed

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

1 file changed

+12
-17
lines changed

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

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -178,12 +178,7 @@ class BrowserConnector(
178178
uiReady.await()
179179

180180
// Chat options including history and quick actions need to be sent in once UI is ready
181-
val showChatOptions = """{
182-
"command": "chatOptions",
183-
"params": ${Gson().toJson(AwsServerCapabilitiesProvider.getInstance(project).getChatOptions())}
184-
}
185-
""".trimIndent()
186-
browser.postChat(showChatOptions)
181+
updateQuickActionsInBrowser(browser)
187182

188183
// Send inbound messages to the browser
189184
val inboundMessages = connections.map { it.messagesFromAppToUi.flow }.merge()
@@ -308,8 +303,7 @@ class BrowserConnector(
308303
RunOnceUtil.runOnceForApp("AmazonQ-UI-Ready") {
309304
MeetQSettings.getInstance().reinvent2024OnboardingCount += 1
310305
}
311-
// send feature flags to ui here in case reauth was needed
312-
updateFeatureFlagsInBrowser(browser)
306+
313307
invoke()
314308
}
315309
}
@@ -541,7 +535,7 @@ class BrowserConnector(
541535
browser.postChat(cancelMessage)
542536
}
543537

544-
private fun updateFeatureFlagsInBrowser(browser: Browser) {
538+
private fun updateQuickActionsInBrowser(browser: Browser) {
545539
val isFeatureDevAvailable = isFeatureDevAvailable(project)
546540
val isCodeTransformAvailable = isCodeTransformAvailable(project)
547541
val isDocAvailable = isDocAvailable(project)
@@ -551,8 +545,8 @@ class BrowserConnector(
551545
val script = """
552546
try {
553547
const tempConnector = connectorAdapter.initiateAdapter(
554-
false,
555-
true,
548+
false,
549+
true, // the two values are not used here, needed for constructor
556550
$isFeatureDevAvailable,
557551
$isCodeTransformAvailable,
558552
$isDocAvailable,
@@ -561,15 +555,16 @@ class BrowserConnector(
561555
{ postMessage: () => {} }
562556
);
563557
564-
const newGroups = tempConnector.initialQuickActions?.slice(0, 2) || [];
558+
const commands = tempConnector.initialQuickActions?.slice(0, 2) || [];
559+
const options = ${Gson().toJson(AwsServerCapabilitiesProvider.getInstance(project).getChatOptions())};
560+
options.quickActions.quickActionsCommandGroups = [
561+
...commands,
562+
...options.quickActions.quickActionsCommandGroups
563+
];
565564
566565
window.postMessage({
567566
command: "chatOptions",
568-
params: {
569-
quickActions: {
570-
quickActionsCommandGroups: newGroups
571-
}
572-
}
567+
params: options
573568
});
574569
} catch (e) {
575570
console.error("Error updating quick actions:", e);

0 commit comments

Comments
 (0)