Skip to content

Commit 242b965

Browse files
committed
user wont see the programmer mode card after they close it
1 parent 67a3b4b commit 242b965

File tree

8 files changed

+63
-17
lines changed

8 files changed

+63
-17
lines changed

packages/core/src/amazonq/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ export function createMynahUI(
6161
amazonQEnabled: boolean,
6262
featureConfigsSerialized: [string, FeatureContext][],
6363
welcomeCount: number,
64-
disabledCommands?: string[]
64+
disabledCommands?: string[],
65+
dismissedCards?: boolean
6566
) {
6667
if (typeof window !== 'undefined') {
6768
const mynahUI = require('./webview/ui/main')

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ export class WebViewContentGenerator {
8686
const disabledCommandsString = isSM ? `['/dev', '/transform', '/test', '/review', '/doc']` : '[]'
8787
const disclaimerAcknowledged = !AmazonQPromptSettings.instance.isPromptEnabled('amazonQChatDisclaimer')
8888
const welcomeLoadCount = globals.globalState.tryGet('aws.amazonq.welcomeChatShowCount', Number, 0)
89+
const dismissedCards = globals.globalState.tryGet('aws.amazonq.dismissedCards', Boolean, false)
8990

9091
// only show profile card when the two conditions
9192
// 1. profile count >= 2
@@ -112,7 +113,8 @@ export class WebViewContentGenerator {
112113
${regionProfileString},
113114
${disabledCommandsString},
114115
${isSMUS},
115-
${isSM}
116+
${isSM},
117+
${dismissedCards}
116118
);
117119
}
118120
</script>

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,14 @@ export function dispatchWebViewMessagesToApps(
8686
void globals.globalState.tryUpdate('aws.amazonq.welcomeChatShowCount', currentLoadCount + 1)
8787
return
8888
}
89+
case 'message-dismissed': {
90+
// eslint-disable-next-line aws-toolkits/no-console-log
91+
console.log('message-dismissed', msg)
92+
if (msg.messageId === 'programmerModeCardId') {
93+
void globals.globalState.tryUpdate('aws.amazonq.dismissedCards', true)
94+
}
95+
return
96+
}
8997
}
9098

9199
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: 7 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?: boolean
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,
169171
})
170172

171173
// eslint-disable-next-line prefer-const
@@ -263,6 +265,7 @@ export const createMynahUI = (
263265
disabledCommands,
264266
commandHighlight: highlightCommand,
265267
regionProfile,
268+
dismissedCards,
266269
})
267270

268271
featureConfigs = tryNewMap(featureConfigsSerialized)
@@ -1001,6 +1004,9 @@ export const createMynahUI = (
10011004
onPromptInputOptionChange: (tabId, optionsValues) => {
10021005
connector.onPromptInputOptionChange(tabId, optionsValues)
10031006
},
1007+
onMessageDismiss: (tabId, messageId) => {
1008+
connector.onMessageDismiss(tabId, messageId)
1009+
},
10041010
onFileClick: connector.onFileClick,
10051011
tabs: {
10061012
'tab-1': {

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

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ 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-
1514
export interface TabDataGeneratorProps {
1615
isFeatureDevEnabled: boolean
1716
isGumbyEnabled: boolean
1817
isScanEnabled: boolean
1918
isTestEnabled: boolean
2019
isDocEnabled: boolean
20+
dismissedCards?: boolean
2121
disabledCommands?: string[]
2222
commandHighlight?: FeatureContext
2323
regionProfile?: RegionProfile
@@ -28,6 +28,7 @@ export class TabDataGenerator {
2828
public quickActionsGenerator: QuickActionGenerator
2929
private highlightCommand?: FeatureContext
3030
private regionProfile?: RegionProfile
31+
private dismissedCards?: boolean
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(
@@ -49,25 +51,36 @@ export class TabDataGenerator {
4951
taskName?: string,
5052
isSMUS?: boolean
5153
): MynahUIDataModel {
54+
// eslint-disable-next-line aws-toolkits/no-console-log
55+
console.log('tabType', tabType)
5256
if (tabType === 'agentWalkthrough') {
5357
return agentWalkthroughDataModel
5458
}
5559

5660
if (tabType === 'welcome') {
5761
return {}
5862
}
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-
}
63+
64+
const programmerModeCardId = 'programmerModeCardId'
65+
66+
const isProgrammerModeCardDismissed = this.dismissedCards
67+
// eslint-disable-next-line aws-toolkits/no-console-log
68+
console.log('trueOrFalse', isProgrammerModeCardDismissed)
69+
const programmerModeCard: ChatItem | undefined = !isProgrammerModeCardDismissed
70+
? ({
71+
type: ChatItemType.ANSWER,
72+
title: 'NEW FEATURE',
73+
messageId: programmerModeCardId,
74+
header: {
75+
icon: 'code-block',
76+
iconStatus: 'primary',
77+
body: '## Pair Programmer',
78+
},
79+
fullWidth: true,
80+
canBeDismissed: true,
81+
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.',
82+
} as ChatItem)
83+
: undefined
7184

7285
const regionProfileCard: ChatItem | undefined =
7386
this.regionProfile === undefined
@@ -97,7 +110,11 @@ Enter \`/\` to view quick actions. Use \`@\` to add saved prompts, files, folder
97110
contextCommands: this.getContextCommands(tabType),
98111
chatItems: needWelcomeMessages
99112
? [
100-
...(tabType === 'cwc' || tabType === 'unknown' ? [programmerModeCard] : []),
113+
...(tabType === 'cwc' || tabType === 'unknown'
114+
? programmerModeCard
115+
? [programmerModeCard]
116+
: []
117+
: []),
101118
...(regionProfileCard ? [regionProfileCard] : []),
102119
{
103120
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)