Skip to content

fix(chat): When user close the information card, it would close permanently #7078

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: feature/agentic-chat
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/core/src/amazonq/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ export function createMynahUI(
amazonQEnabled: boolean,
featureConfigsSerialized: [string, FeatureContext][],
welcomeCount: number,
disabledCommands?: string[]
disabledCommands?: string[],
dismissedCards?: boolean
) {
if (typeof window !== 'undefined') {
const mynahUI = require('./webview/ui/main')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export class WebViewContentGenerator {
const disabledCommandsString = isSM ? `['/dev', '/transform', '/test', '/review', '/doc']` : '[]'
const disclaimerAcknowledged = !AmazonQPromptSettings.instance.isPromptEnabled('amazonQChatDisclaimer')
const welcomeLoadCount = globals.globalState.tryGet('aws.amazonq.welcomeChatShowCount', Number, 0)
const dismissedCards = globals.globalState.tryGet('aws.amazonq.dismissedCards', Boolean, false)

// only show profile card when the two conditions
// 1. profile count >= 2
Expand All @@ -112,7 +113,8 @@ export class WebViewContentGenerator {
${regionProfileString},
${disabledCommandsString},
${isSMUS},
${isSM}
${isSM},
${dismissedCards}
);
}
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ export function dispatchWebViewMessagesToApps(
void globals.globalState.tryUpdate('aws.amazonq.welcomeChatShowCount', currentLoadCount + 1)
return
}
case 'message-dismissed': {
if (msg.messageId === 'programmerModeCardId') {
void globals.globalState.tryUpdate('aws.amazonq.dismissedCards', true)
}
return
}
}

if (msg.type === 'error') {
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/amazonq/webview/ui/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,6 @@ type MessageCommand =
| 'detailed-list-filter-change'
| 'detailed-list-item-select'
| 'detailed-list-action-click'
| 'message-dismissed'

export type ExtensionMessage = Record<string, any> & { command: MessageCommand }
10 changes: 10 additions & 0 deletions packages/core/src/amazonq/webview/ui/connector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ export interface ConnectorProps {
}
onSelectTab: (tabID: string, eventID: string) => void
onExportChat: (tabID: string, format: 'markdown' | 'html') => string
onMessageDismiss?: (tabId: string, messageId: string) => void
tabsStorage: TabsStorage
}

Expand Down Expand Up @@ -707,6 +708,15 @@ export class Connector {
return false
}

onMessageDismiss = (tabId: string, messageId: string): void => {
this.sendMessageToExtension({
command: 'message-dismissed',
tabId: tabId,
messageId,
tabType: this.tabsStorage.getTab(tabId)?.type,
})
}

onTabBarButtonClick = async (tabId: string, buttonId: string, eventId?: string) => {
this.sendMessageToExtension({
command: 'tab-bar-button-clicked',
Expand Down
11 changes: 10 additions & 1 deletion packages/core/src/amazonq/webview/ui/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ export const createMynahUI = (
regionProfile: RegionProfile | undefined,
disabledCommands?: string[],
isSMUS?: boolean,
isSM?: boolean
isSM?: boolean,
dismissedCards?: boolean
) => {
let disclaimerCardActive = !disclaimerAcknowledged
// eslint-disable-next-line prefer-const
Expand Down Expand Up @@ -166,6 +167,7 @@ export const createMynahUI = (
disabledCommands,
commandHighlight: highlightCommand,
regionProfile,
dismissedCards,
})

// eslint-disable-next-line prefer-const
Expand Down Expand Up @@ -263,6 +265,7 @@ export const createMynahUI = (
disabledCommands,
commandHighlight: highlightCommand,
regionProfile,
dismissedCards,
})

featureConfigs = tryNewMap(featureConfigsSerialized)
Expand Down Expand Up @@ -1001,6 +1004,12 @@ export const createMynahUI = (
onPromptInputOptionChange: (tabId, optionsValues) => {
connector.onPromptInputOptionChange(tabId, optionsValues)
},
onMessageDismiss: (tabId, messageId) => {
if (messageId === 'programmerModeCardId') {
tabDataGenerator.dismissedCards = true
}
connector.onMessageDismiss(tabId, messageId)
},
onFileClick: connector.onFileClick,
tabs: {
'tab-1': {
Expand Down
41 changes: 27 additions & 14 deletions packages/core/src/amazonq/webview/ui/tabs/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ import { qChatIntroMessageForSMUS, TabTypeDataMap } from './constants'
import { agentWalkthroughDataModel } from '../walkthrough/agent'
import { FeatureContext } from '../../../../shared/featureConfig'
import { RegionProfile } from '../../../../codewhisperer/models/model'

export interface TabDataGeneratorProps {
isFeatureDevEnabled: boolean
isGumbyEnabled: boolean
isScanEnabled: boolean
isTestEnabled: boolean
isDocEnabled: boolean
dismissedCards?: boolean
disabledCommands?: string[]
commandHighlight?: FeatureContext
regionProfile?: RegionProfile
Expand All @@ -28,6 +28,7 @@ export class TabDataGenerator {
public quickActionsGenerator: QuickActionGenerator
private highlightCommand?: FeatureContext
private regionProfile?: RegionProfile
public dismissedCards?: boolean

constructor(props: TabDataGeneratorProps) {
this.followUpsGenerator = new FollowUpGenerator()
Expand All @@ -41,6 +42,7 @@ export class TabDataGenerator {
})
this.highlightCommand = props.commandHighlight
this.regionProfile = props.regionProfile
this.dismissedCards = props.dismissedCards
}

public getTabData(
Expand All @@ -56,18 +58,25 @@ export class TabDataGenerator {
if (tabType === 'welcome') {
return {}
}
const programmerModeCard: ChatItem | undefined = {
type: ChatItemType.ANSWER,
title: 'NEW FEATURE',
header: {
icon: 'code-block',
iconStatus: 'primary',
body: '## Pair Programmer',
},
fullWidth: true,
canBeDismissed: true,
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.',
}

const programmerModeCardId = 'programmerModeCardId'

const isProgrammerModeCardDismissed = this.dismissedCards
const programmerModeCard: ChatItem | undefined = !isProgrammerModeCardDismissed
? ({
type: ChatItemType.ANSWER,
title: 'NEW FEATURE',
messageId: programmerModeCardId,
header: {
icon: 'code-block',
iconStatus: 'primary',
body: '## Pair Programmer',
},
fullWidth: true,
canBeDismissed: true,
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.',
} as ChatItem)
: undefined

const regionProfileCard: ChatItem | undefined =
this.regionProfile === undefined
Expand Down Expand Up @@ -97,7 +106,11 @@ Enter \`/\` to view quick actions. Use \`@\` to add saved prompts, files, folder
contextCommands: this.getContextCommands(tabType),
chatItems: needWelcomeMessages
? [
...(tabType === 'cwc' || tabType === 'unknown' ? [programmerModeCard] : []),
...(tabType === 'cwc' || tabType === 'unknown'
? programmerModeCard
? [programmerModeCard]
: []
: []),
...(regionProfileCard ? [regionProfileCard] : []),
{
type: ChatItemType.ANSWER,
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/shared/globalState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export type globalKey =
| 'aws.toolkit.lambda.walkthroughSelected'
| 'aws.toolkit.lambda.walkthroughCompleted'
| 'aws.toolkit.appComposer.templateToOpenOnStart'
| 'aws.amazonq.dismissedCards'

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