Skip to content
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

feat(amazonq): Add acknowledgement button for disclaimer #5178

Merged
merged 1 commit into from
Dec 6, 2024
Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type" : "feature",
"description" : "Add acknowledgement button for Amazon Q Chat disclaimer"
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,13 @@
}
},
${MeetQSettings.getInstance().reinvent2024OnboardingCount < MAX_ONBOARDING_PAGE_COUNT},
${MeetQSettings.getInstance().disclaimerAcknowledged},

Check warning on line 90 in plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/webview/Browser.kt

View check run for this annotation

Codecov / codecov/patch

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/webview/Browser.kt#L90

Added line #L90 was not covered by tests
$isFeatureDevAvailable, // whether /dev is available
$isCodeTransformAvailable, // whether /transform is available
$isDocAvailable, // whether /doc is available
$isCodeScanAvailable, // whether /scan is available
$isCodeTestAvailable // whether /test is available
);
);
}
</script>
""".trimIndent()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@
}
}

"disclaimer-acknowledged" -> {
MeetQSettings.getInstance().disclaimerAcknowledged = true

Check warning on line 53 in plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/webview/BrowserConnector.kt

View check run for this annotation

Codecov / codecov/patch

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/webview/BrowserConnector.kt#L53

Added line #L53 was not covered by tests
}

// some weird issue preventing deserialization from working
"open-user-guide" -> {
BrowserUtil.browse(node.get("userGuideLink").asText())
Expand Down
1 change: 1 addition & 0 deletions plugins/amazonq/mynah-ui/src/mynah-ui/ui/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type MessageCommand =
| 'tab-was-removed'
| 'tab-was-changed'
| 'ui-is-ready'
| 'disclaimer-acknowledged'
| 'ui-focus'
| 'follow-up-was-clicked'
| 'auth-follow-up-was-clicked'
Expand Down
31 changes: 28 additions & 3 deletions plugins/amazonq/mynah-ui/src/mynah-ui/ui/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,20 @@ import { ChatPrompt, CodeSelectionType} from "@aws/mynah-ui-chat/dist/static";
import {welcomeScreenTabData} from "./walkthrough/welcome";
import { agentWalkthroughDataModel } from './walkthrough/agent'
import {createClickTelemetry, createOpenAgentTelemetry} from "./telemetry/actions";
import {disclaimerAcknowledgeButtonId, disclaimerCard} from "./texts/disclaimer";

export const createMynahUI = (
ideApi: any,
showWelcomePage: boolean,
disclaimerAcknowledged: boolean,
featureDevInitEnabled: boolean,
codeTransformInitEnabled: boolean,
docInitEnabled: boolean,
codeScanEnabled: boolean,
codeTestEnabled: boolean
) => {
let disclaimerCardActive = !disclaimerAcknowledged

// eslint-disable-next-line prefer-const
let mynahUI: MynahUI
// eslint-disable-next-line prefer-const
Expand Down Expand Up @@ -556,6 +560,7 @@ export const createMynahUI = (
// make sure to show/hide it accordingly
mynahUI.updateStore(tabID, {
quickActionCommands: tabDataGenerator.quickActionsGenerator.generateForTab('unknown'),
...(disclaimerCardActive ? { promptInputStickyCard: disclaimerCard } : {}),
})
connector.onTabAdd(tabID)
},
Expand Down Expand Up @@ -690,12 +695,32 @@ export const createMynahUI = (
tabs: {
'tab-1': {
isSelected: true,
store: showWelcomePage
? welcomeScreenTabData(tabDataGenerator).store
: tabDataGenerator.getTabData('cwc', true),
store: {
...(showWelcomePage
? welcomeScreenTabData(tabDataGenerator).store
: tabDataGenerator.getTabData('cwc', true)),
...(disclaimerCardActive ? { promptInputStickyCard: disclaimerCard } : {}),
},
},
},
onInBodyButtonClicked: (tabId, messageId, action, eventId) => {
if (action.id === disclaimerAcknowledgeButtonId) {
disclaimerCardActive = false
// post message to tell IDE that disclaimer is acknowledged
ideApi.postMessage({
command: 'disclaimer-acknowledged',
})

// create telemetry
ideApi.postMessage(createClickTelemetry('amazonq-disclaimer-acknowledge-button'))

// remove all disclaimer cards from all tabs
Object.keys(mynahUI.getAllTabs()).forEach((storeTabKey) => {
// eslint-disable-next-line no-null/no-null
mynahUI.updateStore(storeTabKey, { promptInputStickyCard: null })
})
}

if (action.id === 'quick-start') {
/**
* quick start is the action on the welcome page. When its
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ What would you like to work on?`,
return {
tabTitle: taskName ?? this.tabTitle.get(tabType),
promptInputInfo:
'Amazon Q Developer uses generative AI. You may need to verify responses. See the [AWS Responsible AI Policy](https://aws.amazon.com/machine-learning/responsible-ai/policy/). Amazon Q Developer processes data across all US Regions. See [here](https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/cross-region-inference.html) for more info. Amazon Q may retain chats to provide and maintain the service.',
'Amazon Q Developer uses generative AI. You may need to verify responses. See the [AWS Responsible AI Policy](https://aws.amazon.com/machine-learning/responsible-ai/policy/).',
quickActionCommands: this.quickActionsGenerator.generateForTab(tabType),
promptInputPlaceholder: this.tabInputPlaceholder.get(tabType),
contextCommands: this.tabContextCommand.get(tabType),
Expand Down
20 changes: 20 additions & 0 deletions plugins/amazonq/mynah-ui/src/mynah-ui/ui/texts/disclaimer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*!
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/

import { ChatItem, MynahIcons } from '@aws/mynah-ui-chat'

export const disclaimerAcknowledgeButtonId = 'amazonq-disclaimer-acknowledge-button-id'
export const disclaimerCard: Partial<ChatItem> = {
messageId: 'amazonq-disclaimer-card',
body: 'Amazon Q Developer uses generative AI. You may need to verify responses. See the [AWS Responsible AI Policy](https://aws.amazon.com/machine-learning/responsible-ai/policy/). Amazon Q Developer processes data across all US Regions. See [here](https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/cross-region-inference.html) for more info. Amazon Q may retain chats to provide and maintain the service.',
buttons: [
{
text: 'Acknowledge',
id: disclaimerAcknowledgeButtonId,
status: 'info',
icon: MynahIcons.OK,
},
],
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,18 @@
state.reinvent2024OnboardingCount = value
}

var disclaimerAcknowledged: Boolean
get() = state.disclaimerAcknowledged

Check warning on line 36 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/settings/MeetQSettings.kt

View check run for this annotation

Codecov / codecov/patch

plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/settings/MeetQSettings.kt#L36

Added line #L36 was not covered by tests
set(value) {
state.disclaimerAcknowledged = value
}

Check warning on line 39 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/settings/MeetQSettings.kt

View check run for this annotation

Codecov / codecov/patch

plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/settings/MeetQSettings.kt#L38-L39

Added lines #L38 - L39 were not covered by tests

companion object {
fun getInstance(): MeetQSettings = service()
}
}
data class MeetQSettingsConfiguration(
var shouldDisplayPage: Boolean = true,
var reinvent2024OnboardingCount: Int = 0,
var disclaimerAcknowledged: Boolean = false,

Check warning on line 48 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/settings/MeetQSettings.kt

View check run for this annotation

Codecov / codecov/patch

plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/settings/MeetQSettings.kt#L48

Added line #L48 was not covered by tests
)
Loading