From d0d04fe3c5dc7b132520faa41d303b5b72db7589 Mon Sep 17 00:00:00 2001 From: Maxim Hayes Date: Mon, 13 Jan 2025 15:23:12 -0500 Subject: [PATCH] revert: Q new user view badge handler Reverts [259ca31](https://github.com/aws/aws-toolkit-vscode/commit/259ca31b827690ee3d96e4b44550ac8e4045b0c6#diff-53367fa008dcbcfc4cc4e6a9c97bae43ea889adfdec82209a996e7228cdf2c72) Its purpose was to nudge inline completion users to the new chat feature. The codepath is now no longer possible in new versions. --- packages/amazonq/package.json | 5 -- packages/amazonq/src/app/chat/activation.ts | 1 - packages/core/src/amazonq/index.ts | 1 - .../core/src/amazonq/util/viewBadgeHandler.ts | 83 ------------------- packages/core/src/amazonq/webview/webView.ts | 16 ---- packages/core/src/shared/globalState.ts | 1 - 6 files changed, 107 deletions(-) delete mode 100644 packages/core/src/amazonq/util/viewBadgeHandler.ts diff --git a/packages/amazonq/package.json b/packages/amazonq/package.json index caad3f85306..8981ba83502 100644 --- a/packages/amazonq/package.json +++ b/packages/amazonq/package.json @@ -218,11 +218,6 @@ "id": "aws.AmazonQChatView", "name": "%AWS.amazonq.chat%", "when": "!aws.isWebExtHost && !aws.amazonq.showLoginView" - }, - { - "id": "aws.AmazonQNeverShowBadge", - "name": "", - "when": "false" } ], "aws-codewhisperer-reference-log": [ diff --git a/packages/amazonq/src/app/chat/activation.ts b/packages/amazonq/src/app/chat/activation.ts index f7b3f9a0fa5..49205c75c7d 100644 --- a/packages/amazonq/src/app/chat/activation.ts +++ b/packages/amazonq/src/app/chat/activation.ts @@ -61,7 +61,6 @@ export async function activate(context: ExtensionContext) { void vscode.env.openExternal(vscode.Uri.parse(amazonq.amazonQHelpUrl)) }) - await amazonq.activateBadge() void setupLsp() void setupAuthNotification() } diff --git a/packages/core/src/amazonq/index.ts b/packages/core/src/amazonq/index.ts index 584042a8462..cd4ec424365 100644 --- a/packages/core/src/amazonq/index.ts +++ b/packages/core/src/amazonq/index.ts @@ -24,7 +24,6 @@ export { init as featureDevChatAppInit } from '../amazonqFeatureDev/app' export { init as gumbyChatAppInit } from '../amazonqGumby/app' export { init as testChatAppInit } from '../amazonqTest/app' export { init as docChatAppInit } from '../amazonqDoc/app' -export { activateBadge } from './util/viewBadgeHandler' export { amazonQHelpUrl } from '../shared/constants' export { listCodeWhispererCommandsWalkthrough } from '../codewhisperer/ui/statusBarMenu' export { focusAmazonQPanel, focusAmazonQPanelKeybinding } from '../codewhispererChat/commands/registerCommands' diff --git a/packages/core/src/amazonq/util/viewBadgeHandler.ts b/packages/core/src/amazonq/util/viewBadgeHandler.ts deleted file mode 100644 index 3d066b18472..00000000000 --- a/packages/core/src/amazonq/util/viewBadgeHandler.ts +++ /dev/null @@ -1,83 +0,0 @@ -/*! - * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. - * SPDX-License-Identifier: Apache-2.0 - */ - -import { window, TreeItem, TreeView, ViewBadge } from 'vscode' -import { getLogger } from '../../shared/logger' -import globals from '../../shared/extensionGlobals' -import { AuthUtil } from '../../codewhisperer/util/authUtil' - -let badgeHelperView: TreeView | undefined - -/** - * invisible view meant exclusively to handle the view badge, note declaration has `"when": false`. - * webviews can provide a badge (you can hack it to show strings!), BUT: - * webview views can't show badges until they are loaded, - * so our best option is to use a do-nothing tree view and show a '1' - */ -export async function activateBadge() { - badgeHelperView = window.createTreeView('aws.AmazonQNeverShowBadge', { - treeDataProvider: { - getChildren: () => [], - getTreeItem: () => new TreeItem(''), - }, - }) - await showInitialViewBadge() -} - -/** - * Changes the view badge for the hidden view connected to the Amazon Q view - * @param badge ViewBadge to show, or undefined to blank the badge - */ -export function changeViewBadge(badge?: ViewBadge) { - if (badgeHelperView) { - badgeHelperView.badge = badge - } else { - getLogger().error('Attempted to call changeViewBadge before badgeHelperView set.') - } -} - -/** - * Removes the view badge from the badge helper view and prevents it from showing up ever again - */ -export function deactivateInitialViewBadge() { - globals.globalState.tryUpdate('hasAlreadyOpenedAmazonQ', true) - changeViewBadge() -} - -/** - * Show users a '1' badge on the Amazon Q icon if {@link shouldShowBadge} is true. - * - * This is intended to target users who are already using CWSPR and - * are autoupdating to a version of the extension with Q, - * since they may not know it exists otherwise. - */ -async function showInitialViewBadge() { - if (await shouldShowBadge()) { - changeViewBadge({ - value: 1, - tooltip: '', - }) - } -} - -/** - * Determines if a user should see an attract badge to entice them to use Amazon Q - * Shows a badge on the Amazon Q View Container IF: - * * the user has never, ever clicked into Amazon Q - * * The user has codewhispererCore auth and not codewhispererChat auth - * - * @returns True if the badge should be shown, false otherwise - */ -export async function shouldShowBadge(): Promise { - const hasAlreadyShown = globals.globalState.get('hasAlreadyOpenedAmazonQ') - if (!hasAlreadyShown) { - const state = await AuthUtil.instance.getChatAuthState() - if (state.codewhispererCore === 'connected' && state.codewhispererChat !== 'connected') { - return true - } - } - - return false -} diff --git a/packages/core/src/amazonq/webview/webView.ts b/packages/core/src/amazonq/webview/webView.ts index 50b8477847a..74f60cbf67b 100644 --- a/packages/core/src/amazonq/webview/webView.ts +++ b/packages/core/src/amazonq/webview/webView.ts @@ -19,8 +19,6 @@ import { dispatchAppsMessagesToWebView, dispatchWebViewMessagesToApps } from './ import { MessageListener } from '../messages/messageListener' import { MessagePublisher } from '../messages/messagePublisher' import { TabType } from './ui/storages/tabsStorage' -import { deactivateInitialViewBadge, shouldShowBadge } from '../util/viewBadgeHandler' -import { telemetry } from '../../shared/telemetry/telemetry' import { amazonqMark } from '../../shared/performance/marks' export class AmazonQChatViewProvider implements WebviewViewProvider { @@ -66,19 +64,5 @@ export class AmazonQChatViewProvider implements WebviewViewProvider { ) performance.mark(amazonqMark.open) - - // badge is shown, emit telemetry for first time an existing, unscoped user tries Q - // note: this will fire on any not-properly-scoped Q entry. - // this means we can't tie it directly to the badge although it is hinted at - if (await shouldShowBadge()) { - telemetry.ui_click.emit({ - elementId: 'amazonq_tryAmazonQ', - passive: false, - }) - } - // if a user EVER enters Q, we should never show the badge again. - // the webview view only loads if the user clicks the view container, - // so we can essentially use this as a guarantee that a user has entered Q. - deactivateInitialViewBadge() } } diff --git a/packages/core/src/shared/globalState.ts b/packages/core/src/shared/globalState.ts index 5662c3e608e..645929b918f 100644 --- a/packages/core/src/shared/globalState.ts +++ b/packages/core/src/shared/globalState.ts @@ -58,7 +58,6 @@ export type globalKey = | 'dev.beta' | 'globalsMostRecentVersion' | 'gumby.wasQCodeTransformationUsed' - | 'hasAlreadyOpenedAmazonQ' | 'isExtensionFirstUse' | 'lastExtensionVersion' | 'lastSelectedRegion'