Skip to content

Commit fe55a01

Browse files
committed
when user close the info card, it would dismiss permanently
1 parent f49baf2 commit fe55a01

File tree

6 files changed

+50
-14
lines changed

6 files changed

+50
-14
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,15 @@ export function dispatchWebViewMessagesToApps(
8686
void globals.globalState.tryUpdate('aws.amazonq.welcomeChatShowCount', currentLoadCount + 1)
8787
return
8888
}
89+
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+
}
97+
}
8998
}
9099

91100
if (msg.type === 'error') {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,6 @@ type MessageCommand =
5252
| 'detailed-list-filter-change'
5353
| 'detailed-list-item-select'
5454
| 'detailed-list-action-click'
55+
| 'message-dismissed'
5556

5657
export type ExtensionMessage = Record<string, any> & { command: MessageCommand }

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ export interface ConnectorProps {
119119
}
120120
onSelectTab: (tabID: string, eventID: string) => void
121121
onExportChat: (tabID: string, format: 'markdown' | 'html') => string
122+
onMessageDismiss?: (tabId: string, messageId: string) => void
122123
tabsStorage: TabsStorage
123124
}
124125

@@ -707,6 +708,15 @@ export class Connector {
707708
return false
708709
}
709710

711+
onMessageDismiss = (tabId: string, messageId: string): void => {
712+
this.sendMessageToExtension({
713+
command: 'message-dismissed',
714+
tabID: tabId,
715+
messageId,
716+
tabType: this.tabsStorage.getTab(tabId)?.type,
717+
})
718+
}
719+
710720
onTabBarButtonClick = async (tabId: string, buttonId: string, eventId?: string) => {
711721
this.sendMessageToExtension({
712722
command: 'tab-bar-button-clicked',

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -989,6 +989,9 @@ export const createMynahUI = (
989989
onPromptInputOptionChange: (tabId, optionsValues) => {
990990
connector.onPromptInputOptionChange(tabId, optionsValues)
991991
},
992+
onMessageDismiss: (tabId, messageId) => {
993+
connector.onMessageDismiss(tabId, messageId)
994+
},
992995
onFileClick: connector.onFileClick,
993996
tabs: {
994997
'tab-1': {

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

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ 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-
14+
import globals from '../../../../shared/extensionGlobals'
1515
export interface TabDataGeneratorProps {
1616
isFeatureDevEnabled: boolean
1717
isGumbyEnabled: boolean
@@ -56,18 +56,26 @@ export class TabDataGenerator {
5656
if (tabType === 'welcome') {
5757
return {}
5858
}
59-
const programmerModeCard: ChatItem | undefined = {
60-
type: ChatItemType.ANSWER,
61-
title: 'NEW FEATURE',
62-
header: {
63-
icon: 'code-block',
64-
iconStatus: 'primary',
65-
body: '## Pair Programmer',
66-
},
67-
fullWidth: true,
68-
canBeDismissed: true,
69-
body: 'Amazon Q Developer chat can now write code and run shell commands on your behalf. Disable Pair Programmer if you prefer a read-only experience.',
70-
}
59+
60+
const programmerModeCardId = 'programmerModeCard'
61+
62+
const dismissedCards = globals.globalState.tryGet('aws.amazonq.dismissedCards', Array, [])
63+
const isProgrammerModeCardDismissed = dismissedCards.includes(programmerModeCardId)
64+
const programmerModeCard: ChatItem | undefined = !isProgrammerModeCardDismissed
65+
? ({
66+
type: ChatItemType.ANSWER,
67+
title: 'NEW FEATURE',
68+
messageId: programmerModeCardId,
69+
header: {
70+
icon: 'code-block',
71+
iconStatus: 'primary',
72+
body: '## Pair Programmer',
73+
},
74+
fullWidth: true,
75+
canBeDismissed: true,
76+
body: 'Amazon Q Developer chat can now write code and run shell commands on your behalf. Disable Pair Programmer if you prefer a read-only experience.',
77+
} as ChatItem)
78+
: undefined
7179

7280
const regionProfileCard: ChatItem | undefined =
7381
this.regionProfile === undefined
@@ -97,7 +105,11 @@ Enter \`/\` to view quick actions. Use \`@\` to add saved prompts, files, folder
97105
contextCommands: this.getContextCommands(tabType),
98106
chatItems: needWelcomeMessages
99107
? [
100-
...(tabType === 'cwc' || tabType === 'unknown' ? [programmerModeCard] : []),
108+
...(tabType === 'cwc' || tabType === 'unknown'
109+
? programmerModeCard
110+
? [programmerModeCard]
111+
: []
112+
: []),
101113
...(regionProfileCard ? [regionProfileCard] : []),
102114
{
103115
type: ChatItemType.ANSWER,

packages/core/src/shared/globalState.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ export type globalKey =
7777
| 'aws.toolkit.lambda.walkthroughSelected'
7878
| 'aws.toolkit.lambda.walkthroughCompleted'
7979
| 'aws.toolkit.appComposer.templateToOpenOnStart'
80+
| 'aws.amazonq.dismissedCards'
8081

8182
/**
8283
* Extension-local (not visible to other vscode extensions) shared state which persists after IDE

0 commit comments

Comments
 (0)