Skip to content

Commit 569d3bc

Browse files
committed
Merge remote-tracking branch 'origin/dogusata/add-description-to-feedback-form' into dogusata/add-description-to-feedback-form
2 parents a6673aa + dd79558 commit 569d3bc

File tree

9 files changed

+82
-3
lines changed

9 files changed

+82
-3
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type" : "feature",
3+
"description" : "Adds event listener for notifying UI that AB feature configurations have been resolved"
4+
}

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/cwc/App.kt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,21 @@
33

44
package software.aws.toolkits.jetbrains.services.cwc
55

6+
import com.intellij.openapi.application.ApplicationManager
67
import kotlinx.coroutines.flow.merge
78
import kotlinx.coroutines.launch
89
import software.aws.toolkits.jetbrains.core.coroutines.disposableCoroutineScope
10+
import software.aws.toolkits.jetbrains.services.amazonq.CodeWhispererFeatureConfigListener
911
import software.aws.toolkits.jetbrains.services.amazonq.apps.AmazonQApp
1012
import software.aws.toolkits.jetbrains.services.amazonq.apps.AmazonQAppInitContext
1113
import software.aws.toolkits.jetbrains.services.amazonq.messages.AmazonQMessage
1214
import software.aws.toolkits.jetbrains.services.amazonq.onboarding.OnboardingPageInteraction
15+
import software.aws.toolkits.jetbrains.services.amazonq.util.highlightCommand
1316
import software.aws.toolkits.jetbrains.services.cwc.commands.ActionRegistrar
1417
import software.aws.toolkits.jetbrains.services.cwc.commands.CodeScanIssueActionMessage
1518
import software.aws.toolkits.jetbrains.services.cwc.commands.ContextMenuActionMessage
1619
import software.aws.toolkits.jetbrains.services.cwc.controller.ChatController
20+
import software.aws.toolkits.jetbrains.services.cwc.messages.FeatureConfigsAvailableMessage
1721
import software.aws.toolkits.jetbrains.services.cwc.messages.IncomingCwcMessage
1822

1923
class App : AmazonQApp {
@@ -56,6 +60,21 @@ class App : AmazonQApp {
5660
scope.launch { handleMessage(message, inboundAppMessagesHandler) }
5761
}
5862
}
63+
64+
ApplicationManager.getApplication().messageBus.connect(this).subscribe(
65+
CodeWhispererFeatureConfigListener.TOPIC,
66+
object : CodeWhispererFeatureConfigListener {
67+
override fun publishFeatureConfigsAvailble() {
68+
scope.launch {
69+
context.messagesFromAppToUi.publish(
70+
FeatureConfigsAvailableMessage(
71+
highlightCommand = highlightCommand()
72+
)
73+
)
74+
}
75+
}
76+
}
77+
)
5978
}
6079

6180
private suspend fun handleMessage(message: AmazonQMessage, inboundAppMessagesHandler: InboundAppMessagesHandler) {

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/cwc/messages/CwcMessage.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import software.amazon.awssdk.services.codewhispererstreaming.model.UserIntent
1717
import software.aws.toolkits.jetbrains.services.amazonq.auth.AuthFollowUpType
1818
import software.aws.toolkits.jetbrains.services.amazonq.messages.AmazonQMessage
1919
import software.aws.toolkits.jetbrains.services.amazonq.onboarding.OnboardingPageInteractionType
20+
import software.aws.toolkits.jetbrains.services.amazonq.util.HighlightCommand
2021
import software.aws.toolkits.jetbrains.services.cwc.clients.chat.model.FollowUpType
2122
import java.time.Instant
2223

@@ -264,6 +265,14 @@ data class ErrorMessage(
264265
type = "errorMessage",
265266
)
266267

268+
data class FeatureConfigsAvailableMessage(
269+
val highlightCommand: HighlightCommand?,
270+
271+
) : UiMessage(
272+
null,
273+
type = "featureConfigsAvailableMessage",
274+
)
275+
267276
data class QuickActionMessage(
268277
val message: String,
269278
@JsonProperty("triggerID") val triggerId: String,

plugins/amazonq/mynah-ui/src/mynah-ui/ui/apps/cwChatConnector.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
import { ChatItemAction, ChatItemType, FeedbackPayload } from '@aws/mynah-ui-chat'
6+
import {ChatItemAction, ChatItemType, FeedbackPayload, QuickActionCommand} from '@aws/mynah-ui-chat'
77
import { ExtensionMessage } from '../commands'
88
import { CodeReference } from './amazonqCommonsConnector'
99
import { TabOpenType, TabsStorage } from '../storages/tabsStorage'
@@ -23,6 +23,9 @@ export interface ConnectorProps {
2323
onError: (tabID: string, message: string, title: string) => void
2424
onWarning: (tabID: string, message: string, title: string) => void
2525
onOpenSettingsMessage: (tabID: string) => void
26+
onFeatureConfigsAvailable: (
27+
highlightCommand?: QuickActionCommand
28+
) => void
2629
tabsStorage: TabsStorage
2730
}
2831

@@ -33,6 +36,7 @@ export class Connector {
3336
private readonly onChatAnswerReceived
3437
private readonly onCWCContextCommandMessage
3538
private readonly onOpenSettingsMessage
39+
private readonly onFeatureConfigsAvailable
3640
private readonly followUpGenerator: FollowUpGenerator
3741

3842
constructor(props: ConnectorProps) {
@@ -42,6 +46,7 @@ export class Connector {
4246
this.onError = props.onError
4347
this.onCWCContextCommandMessage = props.onCWCContextCommandMessage
4448
this.onOpenSettingsMessage = props.onOpenSettingsMessage
49+
this.onFeatureConfigsAvailable = props.onFeatureConfigsAvailable
4550
this.followUpGenerator = new FollowUpGenerator()
4651
}
4752

@@ -373,5 +378,12 @@ export class Connector {
373378
await this.processOpenSettingsMessage(messageData)
374379
return
375380
}
381+
382+
if (messageData.type === 'featureConfigsAvailableMessage') {
383+
this.onFeatureConfigsAvailable(
384+
messageData.highlightCommand,
385+
)
386+
return
387+
}
376388
}
377389
}

plugins/amazonq/mynah-ui/src/mynah-ui/ui/connector.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
Engagement,
1111
NotificationType,
1212
ProgressField,
13-
ChatPrompt,
13+
ChatPrompt, QuickActionCommand,
1414
} from '@aws/mynah-ui-chat'
1515
import { Connector as CWChatConnector } from './apps/cwChatConnector'
1616
import { Connector as FeatureDevChatConnector } from './apps/featureDevChatConnector'
@@ -84,6 +84,9 @@ export interface ConnectorProps {
8484
codeTestEnabled: boolean,
8585
authenticatingTabIDs: string[]
8686
) => void
87+
onFeatureConfigsAvailable: (
88+
highlightCommand?: QuickActionCommand
89+
) => void
8790
onNewTab: (tabType: TabType) => void
8891
onStartNewTransform: (tabID: string) => void
8992
onCodeTransformCommandMessageReceived: (message: ChatItem, command?: string) => void

plugins/amazonq/mynah-ui/src/mynah-ui/ui/main.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,17 @@ export const createMynahUI = (
552552
tabsStorage.updateTabStatus(tabID, 'free')
553553
}
554554
}
555+
},
556+
onFeatureConfigsAvailable: (
557+
highlightCommand?: QuickActionCommand
558+
): void => {
559+
tabDataGenerator.highlightCommand = highlightCommand
560+
561+
for (const tab of tabsStorage.getTabs()) {
562+
mynahUI.updateStore(tab.id, {
563+
contextCommands: tabDataGenerator.getTabData(tab.type, true).contextCommands
564+
})
565+
}
555566
}
556567
})
557568

plugins/amazonq/mynah-ui/src/mynah-ui/ui/tabs/generator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export interface TabDataGeneratorProps {
2121
export class TabDataGenerator {
2222
private followUpsGenerator: FollowUpGenerator
2323
public quickActionsGenerator: QuickActionGenerator
24-
private highlightCommand?: QuickActionCommand
24+
public highlightCommand?: QuickActionCommand
2525

2626
private tabTitle: Map<TabType, string> = new Map([
2727
['unknown', 'Chat'],
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package software.aws.toolkits.jetbrains.services.amazonq
5+
6+
import com.intellij.openapi.application.ApplicationManager
7+
import com.intellij.util.messages.Topic
8+
9+
interface CodeWhispererFeatureConfigListener {
10+
fun publishFeatureConfigsAvailble() {}
11+
12+
companion object {
13+
@Topic.AppLevel
14+
val TOPIC = Topic.create("feature configs listener", CodeWhispererFeatureConfigListener::class.java)
15+
16+
fun notifyUiFeatureConfigsAvailable() {
17+
ApplicationManager.getApplication().messageBus.syncPublisher(TOPIC).publishFeatureConfigsAvailble()
18+
}
19+
}
20+
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ class CodeWhispererFeatureConfigService {
8383
featureConfigs.remove(CUSTOMIZATION_ARN_OVERRIDE_NAME)
8484
}
8585
}
86+
CodeWhispererFeatureConfigListener.notifyUiFeatureConfigsAvailable()
8687
} catch (e: Exception) {
8788
LOG.debug(e) { "Error when fetching feature configs" }
8889
}

0 commit comments

Comments
 (0)