From 354bd94b0549858808645008f1d01a1fd03c1a94 Mon Sep 17 00:00:00 2001 From: Naman Kumar Date: Fri, 25 Jul 2025 14:37:38 +0530 Subject: [PATCH] Remove Cody deprecation notice --- vscode/webviews/CodyPanel.tsx | 2 +- vscode/webviews/components/Notices.story.tsx | 36 --- vscode/webviews/components/Notices.tsx | 255 +------------------ 3 files changed, 8 insertions(+), 285 deletions(-) diff --git a/vscode/webviews/CodyPanel.tsx b/vscode/webviews/CodyPanel.tsx index 80731462a1af..49dbf62bded0 100644 --- a/vscode/webviews/CodyPanel.tsx +++ b/vscode/webviews/CodyPanel.tsx @@ -138,7 +138,7 @@ export const CodyPanel: FunctionComponent = ({ orientation="vertical" className={styles.outerContainer} > - + {/* Hide tab bar in editor chat panels. */} {config.webviewType !== 'editor' && ( -// Mock user data -const baseUser = { - isDotComUser: true, - isCodyProUser: false, - user: { - id: 'user-1', - username: 'test-user', - displayName: 'Test User', - avatarURL: '', - organizations: [], - endpoint: 'https://example.com', - }, - IDE: CodyIDE.VSCode, -} - export const SgTeammateNotice: Story = { args: { - user: { - ...baseUser, - user: { - ...baseUser.user, - organizations: [ - { - name: 'sourcegraph', - id: 'sourcegraph-01', - }, - ], - }, - }, instanceNotices: [], }, } export const NoNotices: Story = { args: { - user: { - ...baseUser, - isDotComUser: false, - }, instanceNotices: [], }, } export const WebUserNoNotices: Story = { args: { - user: { - ...baseUser, - IDE: CodyIDE.Web, - }, instanceNotices: [], }, } diff --git a/vscode/webviews/components/Notices.tsx b/vscode/webviews/components/Notices.tsx index 935fa329d0ab..3199da20edcd 100644 --- a/vscode/webviews/components/Notices.tsx +++ b/vscode/webviews/components/Notices.tsx @@ -1,18 +1,6 @@ -import { CodyIDE, type CodyNotice, isWorkspaceInstance } from '@sourcegraph/cody-shared' -import { S2_URL } from '@sourcegraph/cody-shared/src/sourcegraph-api/environments' -import { - ArrowLeftRightIcon, - ArrowRightIcon, - BuildingIcon, - EyeIcon, - HeartIcon, - XIcon, -} from 'lucide-react' -import { type FunctionComponent, type ReactNode, useCallback, useMemo, useState } from 'react' -import SourcegraphIcon from '../../resources/sourcegraph-mark.svg' -import type { UserAccountInfo } from '../Chat' -import { CodyLogo } from '../icons/CodyLogo' -import { getVSCodeAPI } from '../utils/VSCodeApi' +import type { CodyNotice } from '@sourcegraph/cody-shared' +import { XIcon } from 'lucide-react' +import { type FunctionComponent, useCallback, useMemo, useState } from 'react' import { useTelemetryRecorder } from '../utils/telemetry' import { MarkdownFromCody } from './MarkdownFromCody' import { useLocalStorage } from './hooks' @@ -24,42 +12,19 @@ interface Notice { content: JSX.Element } -type NoticeVariants = 'default' | 'warning' -type NoticeIDs = - | 'DogfoodS2' - | 'TeamsUpgrade' - | 'DeepCodyDotCom' - | 'DeepCodyEnterprise' - | 'CodyDeprecation' - interface NoticesProps { - user: UserAccountInfo instanceNotices: CodyNotice[] } const storageKey = 'DismissedWelcomeNotices' -// Cody deprecation message constants -const CODY_DEPRECATION_MESSAGES = { - ENTERPRISE_STARTER_WITH_CODY: - "Cody in Enterprise Starter is being sunset. You can continue using Cody until July 23rd. Your code indexing and code search capabilities will not be affected. We encourage you to try Amp, Sourcegraph's new agentic coding tool.", - ENTERPRISE_STARTER_WITHOUT_CODY: - "Cody in Enterprise Starter is being sunset. Because you signed up after 6/25, your account doesn't have Cody, we encourage you to try Amp, Sourcegraph's new agentic coding tool.", - PRO_USER: - "Cody Pro is being sunset. You can continue using Cody until July 23rd, and your subscription will not renew. We encourage you to try Amp, Sourcegraph's new agentic coding tool.", - FREE_USER_WITH_CODY: - "Cody Free is being sunset. You can continue using Cody until July 23rd. We encourage you to try Amp, Sourcegraph's new agentic coding tool.", - FREE_USER_WITHOUT_CODY: - "Cody Free is being sunset. Because you signed up after 6/25, your account doesn't have Cody. We encourage you to try Amp, Sourcegraph's new agentic coding tool.", -} as const - -export const Notices: React.FC = ({ user, instanceNotices }) => { +export const Notices: React.FC = ({ instanceNotices }) => { const telemetryRecorder = useTelemetryRecorder() // dismissed notices from local storage const [dismissedNotices, setDismissedNotices] = useLocalStorage(storageKey, '') // session-only dismissal - for notices we want to show if the user logs out and logs back in. - const [sessionDismissedNotices, setSessionDismissedNotices] = useState([]) + const [_, setSessionDismissedNotices] = useState([]) const dismissNotice = useCallback( (noticeId: string, type: 'sessional' | 'permanent' = 'permanent') => { @@ -77,28 +42,6 @@ export const Notices: React.FC = ({ user, instanceNotices }) => { [telemetryRecorder, setDismissedNotices] ) - // Helper function to get the CodyDeprecation message based on user type and site Cody enablement - const getCodyDeprecationMessage = useCallback(() => { - if (isWorkspaceInstance(user.user.endpoint)) { - // For workspace instances, check if the site has Cody enabled - const hasCodyEnabled = user.siteHasCodyEnabled === true - if (hasCodyEnabled) { - return CODY_DEPRECATION_MESSAGES.ENTERPRISE_STARTER_WITH_CODY - } - return CODY_DEPRECATION_MESSAGES.ENTERPRISE_STARTER_WITHOUT_CODY - } - if (user.isCodyProUser) { - return CODY_DEPRECATION_MESSAGES.PRO_USER - } - // For free users, check if they have a subscription - const hasSubscription = - user.currentUserCodySubscription !== null && user.currentUserCodySubscription !== undefined - if (hasSubscription && user.currentUserCodySubscription?.status !== 'CANCELED') { - return CODY_DEPRECATION_MESSAGES.FREE_USER_WITH_CODY - } - return CODY_DEPRECATION_MESSAGES.FREE_USER_WITHOUT_CODY - }, [user]) - const notices: Notice[] = useMemo( () => [ ...instanceNotices.map(notice => ({ @@ -112,86 +55,16 @@ export const Notices: React.FC = ({ user, instanceNotices }) => { /> ), })), - /** - * Cody Deprecation Notice - */ - { - id: 'CodyDeprecation', - isVisible: user.isDotComUser || isWorkspaceInstance(user.user.endpoint), - content: ( - dismissNotice('CodyDeprecation', 'sessional')} - actions={[ - { - label: 'Try Amp', - variant: 'default', - href: 'https://ampcode.com', - }, - { - label: 'Learn more', - variant: 'ghost', - href: 'https://sourcegraph.com/blog/changes-to-cody-free-pro-and-enterprise-starter-plans', - }, - ]} - /> - ), - }, - /** - * For Sourcegraph team members who are using Sourcegraph.com to remind them that we want to be dogfooding S2. - */ - { - id: 'DogfoodS2', - isVisible: - user.isDotComUser && - user.user.organizations?.some(org => org.name === 'sourcegraph') && - user.IDE !== CodyIDE.Web, - content: ( - dismissNotice('DogfoodS2', 'sessional')} - actions={[ - { - label: 'Switch to S2', - onClick: () => - getVSCodeAPI().postMessage({ - command: 'auth', - authKind: 'switch', - endpoint: S2_URL.href, - }), - variant: 'default', - icon: , - iconPosition: 'end', - }, - { - label: 'Dismiss', - onClick: () => dismissNotice('DogfoodS2', 'sessional'), - variant: 'secondary', - }, - ]} - /> - ), - }, ], - [user, dismissNotice, instanceNotices, getCodyDeprecationMessage] + [dismissNotice, instanceNotices] ) - // First, modify the activeNotice useMemo to add conditional logic for DogfoodS2 const activeNotice = useMemo( () => notices.find(notice => { - if (notice.id === 'DogfoodS2' || notice.id === 'CodyDeprecation') { - return notice.isVisible && !sessionDismissedNotices.includes(notice.id) - } return notice.isVisible && !dismissedNotices?.includes(notice.id) }), - [dismissedNotices, sessionDismissedNotices, notices] + [dismissedNotices, notices] ) if (!activeNotice) { @@ -203,120 +76,6 @@ export const Notices: React.FC = ({ user, instanceNotices }) => { ) } -interface NoticeContentProps { - variant: NoticeVariants - id: NoticeIDs - title: string - message: string - actions: Array<{ - label: string - onClick?: () => void - href?: string - variant: 'default' | 'ghost' | 'secondary' - icon?: ReactNode - iconPosition?: 'start' | 'end' - }> - onDismiss: () => void - info?: string - footer?: string -} - -const NoticeContent: FunctionComponent = ({ - variant, - title, - message, - actions, - id, - info, - footer, - onDismiss, -}) => { - const telemetryRecorder = useTelemetryRecorder() - - const bgColor = { - default: 'tw-bg-accent tw-bg-opacity-50 tw-text-accent-foreground', - warning: 'tw-bg-red-700 tw-text-white', - }[variant] - - const header = { - DeepCodyDotCom: ( - <> - - - ), - DeepCodyEnterprise: ( - <> - - - ), - DogfoodS2: ( - <> - - - - - ), - TeamsUpgrade: ( - <> - - - Sourcegraph Logo - - ), - CodyDeprecation: null, - }[id] - - return ( - - ) -} - interface MarkdownNotice { title: string content: string