Skip to content

Commit 8088c98

Browse files
committed
update webviewContent
1 parent fe55a01 commit 8088c98

File tree

5 files changed

+23
-13
lines changed

5 files changed

+23
-13
lines changed

packages/core/src/amazonq/webview/generators/webViewContent.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ export class WebViewContentGenerator {
8787
const disclaimerAcknowledged = !AmazonQPromptSettings.instance.isPromptEnabled('amazonQChatDisclaimer')
8888
const welcomeLoadCount = globals.globalState.tryGet('aws.amazonq.welcomeChatShowCount', Number, 0)
8989

90+
const dismissedCards = globals.globalState.tryGet('aws.amazonq.dismissedCards', Array, [])
91+
const dismissedCardsString = JSON.stringify(dismissedCards)
92+
9093
// only show profile card when the two conditions
9194
// 1. profile count >= 2
9295
// 2. not default (fallback) which has empty arn
@@ -113,6 +116,7 @@ export class WebViewContentGenerator {
113116
${disabledCommandsString},
114117
${isSMUS},
115118
${isSM}
119+
${dismissedCardsString}
116120
);
117121
}
118122
</script>

packages/core/src/amazonq/webview/messages/messageDispatcher.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,15 @@ export function dispatchWebViewMessagesToApps(
8787
return
8888
}
8989
case 'message-dismissed': {
90-
if (msg.messageId) {
91-
const dismissedCards = globals.globalState.tryGet('aws.amazonq.dismissedCards', Array, [])
92-
if (!dismissedCards.includes(msg.messageId)) {
93-
dismissedCards.push(msg.messageId)
94-
void globals.globalState.tryUpdate('aws.amazonq.dismissedCards', dismissedCards)
95-
}
96-
}
90+
// eslint-disable-next-line aws-toolkits/no-console-log
91+
console.log('message-dismissed', msg)
92+
const dismissedCards = globals.globalState.tryGet('aws.amazonq.dismissedCards', Array, [])
93+
dismissedCards.push(msg.messageId)
94+
void globals.globalState.tryUpdate('aws.amazonq.dismissedCards', [...dismissedCards, msg.messageId])
95+
// eslint-disable-next-line aws-toolkits/no-console-log
96+
console.log('dismissedCards', dismissedCards)
97+
const a = 1 + 1
98+
return
9799
}
98100
}
99101

packages/core/src/amazonq/webview/ui/connector.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ export class Connector {
711711
onMessageDismiss = (tabId: string, messageId: string): void => {
712712
this.sendMessageToExtension({
713713
command: 'message-dismissed',
714-
tabID: tabId,
714+
tabId: tabId,
715715
messageId,
716716
tabType: this.tabsStorage.getTab(tabId)?.type,
717717
})

packages/core/src/amazonq/webview/ui/main.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ export const createMynahUI = (
5252
regionProfile: RegionProfile | undefined,
5353
disabledCommands?: string[],
5454
isSMUS?: boolean,
55-
isSM?: boolean
55+
isSM?: boolean,
56+
dismissedCards?: string[]
5657
) => {
5758
let disclaimerCardActive = !disclaimerAcknowledged
5859
// eslint-disable-next-line prefer-const
@@ -166,6 +167,7 @@ export const createMynahUI = (
166167
disabledCommands,
167168
commandHighlight: highlightCommand,
168169
regionProfile,
170+
dismissedCards: dismissedCards || [],
169171
})
170172

171173
// eslint-disable-next-line prefer-const
@@ -251,6 +253,7 @@ export const createMynahUI = (
251253
disabledCommands,
252254
commandHighlight: highlightCommand,
253255
regionProfile,
256+
dismissedCards: dismissedCards || [],
254257
})
255258

256259
featureConfigs = tryNewMap(featureConfigsSerialized)

packages/core/src/amazonq/webview/ui/tabs/generator.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import { qChatIntroMessageForSMUS, TabTypeDataMap } from './constants'
1111
import { agentWalkthroughDataModel } from '../walkthrough/agent'
1212
import { FeatureContext } from '../../../../shared/featureConfig'
1313
import { RegionProfile } from '../../../../codewhisperer/models/model'
14-
import globals from '../../../../shared/extensionGlobals'
1514
export interface TabDataGeneratorProps {
1615
isFeatureDevEnabled: boolean
1716
isGumbyEnabled: boolean
@@ -21,13 +20,15 @@ export interface TabDataGeneratorProps {
2120
disabledCommands?: string[]
2221
commandHighlight?: FeatureContext
2322
regionProfile?: RegionProfile
23+
dismissedCards?: string[]
2424
}
2525

2626
export class TabDataGenerator {
2727
private followUpsGenerator: FollowUpGenerator
2828
public quickActionsGenerator: QuickActionGenerator
2929
private highlightCommand?: FeatureContext
3030
private regionProfile?: RegionProfile
31+
private dismissedCards?: string[]
3132

3233
constructor(props: TabDataGeneratorProps) {
3334
this.followUpsGenerator = new FollowUpGenerator()
@@ -41,6 +42,7 @@ export class TabDataGenerator {
4142
})
4243
this.highlightCommand = props.commandHighlight
4344
this.regionProfile = props.regionProfile
45+
this.dismissedCards = props.dismissedCards
4446
}
4547

4648
public getTabData(
@@ -57,10 +59,9 @@ export class TabDataGenerator {
5759
return {}
5860
}
5961

60-
const programmerModeCardId = 'programmerModeCard'
62+
const programmerModeCardId = 'programmerModeCardId'
6163

62-
const dismissedCards = globals.globalState.tryGet('aws.amazonq.dismissedCards', Array, [])
63-
const isProgrammerModeCardDismissed = dismissedCards.includes(programmerModeCardId)
64+
const isProgrammerModeCardDismissed = this.dismissedCards?.includes(programmerModeCardId)
6465
const programmerModeCard: ChatItem | undefined = !isProgrammerModeCardDismissed
6566
? ({
6667
type: ChatItemType.ANSWER,

0 commit comments

Comments
 (0)