Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

✨ feat(billboard): add in-app CTA actions and unify promo card into Billboard (#18146)

Innei2c7ac5f7f716
diff --git a/locales/en-US/common.json b/locales/en-US/common.json
index 7f73f27bbae..e4240b64ab6 100644
--- a/locales/en-US/common.json
+++ b/locales/en-US/common.json
@@ -428,9 +428,6 @@
"pinOff": "Unpin",
"privacy": "Privacy Policy",
"pro": "Pro",
- "productHunt.actionLabel": "Support us",
- "productHunt.description": "Support us on Product Hunt. Your support means a lot to us!",
- "productHunt.title": "We're on Product Hunt!",
"promptTransform.action": "Refine Idea",
"promptTransform.actions.rewrite": "Expand Details",
"promptTransform.actions.translate": "Translate",
diff --git a/locales/zh-CN/common.json b/locales/zh-CN/common.json
index 413d88f6377..12667e5ca2f 100644
--- a/locales/zh-CN/common.json
+++ b/locales/zh-CN/common.json
@@ -428,9 +428,6 @@
"pinOff": "取消置顶",
"privacy": "隐私政策",
"pro": "Pro",
- "productHunt.actionLabel": "支持我们",
- "productHunt.description": "在 Product Hunt 上支持我们,您的支持对我们意义重大!",
- "productHunt.title": "我们登上 Product Hunt 了!",
"promptTransform.action": "优化创意",
"promptTransform.actions.rewrite": "丰富细节",
"promptTransform.actions.translate": "翻译",
diff --git a/packages/edge-config/src/types.ts b/packages/edge-config/src/types.ts
index 74b798c2ec4..d7e51a477e6 100644
--- a/packages/edge-config/src/types.ts
+++ b/packages/edge-config/src/types.ts
@@ -14,6 +14,16 @@ export interface BillboardItemLocaleFields {
* Billboard carousel item (a single content entry for the operations card in the bottom-left of the Home sidebar)
*/
export interface BillboardItem {
+ /**
+ * In-app action enum configured on the platform. When set to a value the app
+ * recognizes, the CTA runs the corresponding in-app logic instead of opening
+ * `linkUrl`. Allowed values (defined app-side in `src/features/Billboard/actions.ts`):
+ * `openChangelog` (open the changelog modal), `openFeedback` (open the feedback modal),
+ * `resetOnboarding` (web only — reset onboarding progress and re-enter the flow;
+ * desktop clients ignore it and fall back to `linkUrl`).
+ * Unrecognized values are ignored by the client and fall back to `linkUrl`.
+ */
+ action?: string | null;
cover?: string | null;
description: string;
/**
diff --git a/packages/locales/src/default/common.ts b/packages/locales/src/default/common.ts
index d08f420ffd6..833882712f8 100644
--- a/packages/locales/src/default/common.ts
+++ b/packages/locales/src/default/common.ts
@@ -510,9 +510,6 @@ export default {
'pin': 'Pin',
'pinOff': 'Unpin',
'privacy': 'Privacy Policy',
- 'productHunt.actionLabel': 'Support us',
- 'productHunt.description': 'Support us on Product Hunt. Your support means a lot to us!',
- 'productHunt.title': "We're on Product Hunt!",
'regenerate': 'Regenerate',
'releaseNotes': 'Version Details',
'rename': 'Rename',
diff --git a/packages/types/src/serverConfig.ts b/packages/types/src/serverConfig.ts
index b7c016eb160..2db5ddfa5aa 100644
--- a/packages/types/src/serverConfig.ts
+++ b/packages/types/src/serverConfig.ts
@@ -136,6 +136,12 @@ export interface GlobalBillboardItemLocaleFields {
}
export interface GlobalBillboardItem {
+ /**
+ * In-app action enum as delivered by the platform (unvalidated string).
+ * The client narrows it at runtime against the registry in
+ * `src/features/Billboard/actions.ts`; unrecognized values fall back to `linkUrl`.
+ */
+ action?: string | null;
cover?: string | null;
description: string;
/**
diff --git a/src/components/HighlightNotification/index.test.tsx b/src/components/HighlightNotification/index.test.tsx
deleted file mode 100644
index 4418fd09772..00000000000
--- a/src/components/HighlightNotification/index.test.tsx
+++ /dev/null
@@ -1,27 +0,0 @@
-import { fireEvent, render, screen } from '@testing-library/react';
-import { describe, expect, it, vi } from 'vitest';
-
-import HighlightNotification from '.';
-
-describe('HighlightNotification', () => {
- it('keeps long notification copy clear of the visible close action', () => {
- const onClose = vi.fn();
- const title = 'WeChat Integration Service Update';
- const description =
- 'Using WeChat integration will require a paid plan starting from July 10. Learn More';
-
- render(
- <HighlightNotification open description={description} title={title} onClose={onClose} />,
- );
-
- const copy = screen.getByText(title).parentElement;
- const closeButton = screen.getByRole('button');
-
- expect(copy).toHaveStyle({ paddingInlineEnd: '32px' });
- expect(screen.getByText(description)).toBeVisible();
- expect(closeButton).toBeVisible();
-
- fireEvent.click(closeButton);
- expect(onClose).toHaveBeenCalledOnce();
- });
-});
diff --git a/src/components/HighlightNotification/index.tsx b/src/components/HighlightNotification/index.tsx
deleted file mode 100644
index fdc4724068d..00000000000
--- a/src/components/HighlightNotification/index.tsx
+++ /dev/null
@@ -1,145 +0,0 @@
-'use client';
-
-import { HeartFilled } from '@ant-design/icons';
-import { ActionIcon, Flexbox } from '@lobehub/ui';
-import { Button } from '@lobehub/ui/base-ui';
-import { createStaticStyles, cssVar } from 'antd-style';
-import { X } from 'lucide-react';
-import type { HTMLAttributeAnchorTarget, ReactNode } from 'react';
-import { memo } from 'react';
-
-export interface HighlightNotificationProps {
- actionHref?: string;
- actionIcon?: ReactNode;
- actionLabel?: ReactNode;
- actionTarget?: HTMLAttributeAnchorTarget;
- description?: ReactNode;
- image?: string;
- onAction?: () => void;
- onActionClick?: () => void;
- onClose?: () => void;
- open?: boolean;
- title?: ReactNode;
-}
-
-const styles = createStaticStyles(({ css }) => ({
- action: css`
- display: block;
- width: 100%;
- margin-block-start: 8px;
- `,
- actionContent: css`
- display: inline-flex;
- gap: 8px;
- align-items: center;
- justify-content: center;
-
- width: 100%;
- `,
- card: css`
- position: fixed;
- z-index: 1000;
- inset-block-end: 56px;
- inset-inline-start: 8px;
-
- overflow: hidden;
-
- width: 300px;
- max-width: calc(100vw - 32px);
- padding: 0;
- border: 1px solid ${cssVar.colorBorder};
- border-radius: 12px;
-
- background: ${cssVar.colorBgContainer};
- box-shadow: 0 4px 24px rgb(0 0 0 / 12%);
- `,
- closeButton: css`
- position: absolute;
- inset-block-start: 8px;
- inset-inline-end: 8px;
- `,
- description: css`
- font-size: 14px;
- color: ${cssVar.colorTextSecondary};
- `,
- image: css`
- width: 100%;
- height: auto;
- border-block-end: 1px solid ${cssVar.colorBorderSecondary};
- `,
- title: css`
- font-size: 16px;
- font-weight: 600;
- color: ${cssVar.colorText};
- `,
-}));
-
-const HighlightNotification = memo<HighlightNotificationProps>(
- ({
- actionHref,
- actionIcon = <HeartFilled />,
- actionLabel,
- actionTarget = '_blank',
- description,
- image,
- onAction,
- onActionClick,
- onClose,
- open,
- title,
- }) => {
- if (!open) return null;
-
- const actionContent = actionLabel ? (
- <span className={styles.actionContent}>
- {actionIcon && <span>{actionIcon}</span>}
- <span>{actionLabel}</span>
- </span>
- ) : null;
-
- return (
- <Flexbox className={styles.card}>
- <ActionIcon className={styles.closeButton} icon={X} size={14} onClick={onClose} />
- <Flexbox gap={0}>
- {image && <img alt="" className={styles.image} src={image} />}
- <Flexbox gap={4} padding={12}>
- {(title || description) && (
- <Flexbox gap={4} style={{ paddingInlineEnd: 32 }}>
- {title && <div className={styles.title}>{title}</div>}
- {description && <div className={styles.description}>{description}</div>}
- </Flexbox>
- )}
- {actionLabel && actionHref && (
- <a
- className={styles.action}
- href={actionHref}
- rel="noopener noreferrer"
- target={actionTarget}
- onClick={onActionClick}
- >
- <Button block size="small" type="primary">
- {actionContent}
- </Button>
- </a>
- )}
- {actionLabel && !actionHref && (
- <Button
- block
- className={styles.action}
- size="small"
- type="primary"
- onClick={onAction}
- >
- {actionContent}
- </Button>
- )}
- </Flexbox>
- </Flexbox>
- </Flexbox>
- );
- },
-);
-
-HighlightNotification.displayName = 'HighlightNotification';
-
-export default HighlightNotification;
diff --git a/src/features/Billboard/Carousel.tsx b/src/features/Billboard/Carousel.tsx
index b8dbceb024e..db02e3bff78 100644
--- a/src/features/Billboard/Carousel.tsx
+++ b/src/features/Billboard/Carousel.tsx
@@ -21,6 +21,7 @@ import { useTranslation } from 'react-i18next';
import type { GlobalBillboard, GlobalBillboardItem } from '@/types/serverConfig';
+import { resolveBillboardAction, runBillboardAction } from './actions';
import { resolveBillboardItem } from './locale';
type BillboardItem = GlobalBillboardItem;
@@ -142,18 +143,35 @@ const ItemContent = memo<{ billboardSlug: string; item: BillboardItem; position:
[item, i18n.language],
);
- const handleCtaClick = useCallback(() => {
- analytics?.track({
- name: 'billboard_cta_clicked',
- properties: {
- billboard_slug: billboardSlug,
- item_id: item.id,
- link_url: item.linkUrl,
- position,
- spm: 'billboard.cta.clicked',
- },
- });
- }, [analytics, billboardSlug, item.id, item.linkUrl, position]);
+ const action = resolveBillboardAction(item.action);
+
+ const trackCtaClick = useCallback(
+ (extra: Record<string, unknown>) => {
+ analytics?.track({
+ name: 'billboard_cta_clicked',
+ properties: {
+ billboard_slug: billboardSlug,
+ item_id: item.id,
+ position,
+ spm: 'billboard.cta.clicked',
+ ...extra,
+ },
+ });
+ },
+ [analytics, billboardSlug, item.id, position],
+ );
+
+ const handleActionClick = useCallback(() => {
+ if (!action) return;
+ trackCtaClick({ action });
+ // handlers may be async (e.g. resetOnboarding persists before navigating);
+ // a failed action must never surface as an unhandled rejection on the card
+ void Promise.resolve(runBillboardAction(action)).catch(() => {});
+ }, [action, trackCtaClick]);
+
+ const handleLinkClick = useCallback(() => {
+ trackCtaClick({ link_url: item.linkUrl });
+ }, [trackCtaClick, item.linkUrl]);
const titleRef = useRef<HTMLDivElement>(null);
const descRef = useRef<HTMLDivElement>(null);
@@ -203,18 +221,24 @@ const ItemContent = memo<{ billboardSlug: string; item: BillboardItem; position:
) : (
descNode
))}
- {item.linkUrl && (
- <a
- className={styles.action}
- href={item.linkUrl}
- rel="noopener noreferrer"
- target="_blank"
- onClick={handleCtaClick}
- >
- <Button block size="small" type="primary">
- {resolved.linkLabel ?? t('billboard.learnMore')}
- </Button>
- </a>
+ {action ? (
+ <Button block className={styles.action} type="primary" onClick={handleActionClick}>
+ {resolved.linkLabel ?? t('billboard.learnMore')}
+ </Button>
+ ) : (
+ item.linkUrl && (
+ <a
+ className={styles.action}
+ href={item.linkUrl}
+ rel="noopener noreferrer"
+ target="_blank"
+ onClick={handleLinkClick}
+ >
+ <Button block type="primary">
+ {resolved.linkLabel ?? t('billboard.learnMore')}
+ </Button>
+ </a>
+ )
)}
</Flexbox>
</Flexbox>
diff --git a/src/features/Billboard/actions.test.ts b/src/features/Billboard/actions.test.ts
new file mode 100644
index 00000000000..977a9d128b9
--- /dev/null
+++ b/src/features/Billboard/actions.test.ts
@@ -0,0 +1,113 @@
+import type * as LobechatConst from '@lobechat/const';
+import { beforeEach, describe, expect, it, vi } from 'vitest';
+
+import {
+ BILLBOARD_ACTIONS,
+ isBillboardAction,
+ resolveBillboardAction,
+ runBillboardAction,
+} from './actions';
+
+const { openChangelogModal, openFeedbackModal, resetOnboarding } = vi.hoisted(() => ({
+ openChangelogModal: vi.fn(),
+ openFeedbackModal: vi.fn(),
+ resetOnboarding: vi.fn(),
+}));
+
+vi.mock('@/components/ChangelogModal', () => ({
+ default: openChangelogModal,
+ openChangelogModal,
+}));
+
+vi.mock('@/components/FeedbackModal', () => ({
+ default: openFeedbackModal,
+ openFeedbackModal,
+}));
+
+vi.mock('@/store/user', () => ({
+ getUserStoreState: () => ({ resetOnboarding }),
+}));
+
+beforeEach(() => {
+ vi.clearAllMocks();
+});
+
+describe('isBillboardAction', () => {
+ it('should accept every registered action', () => {
+ for (const action of BILLBOARD_ACTIONS) {
+ expect(isBillboardAction(action)).toBe(true);
+ }
+ });
+
+ it('should reject unknown strings', () => {
+ expect(isBillboardAction('openSettings')).toBe(false);
+ expect(isBillboardAction('')).toBe(false);
+ expect(isBillboardAction('OPENCHANGELOG')).toBe(false);
+ });
+
+ it('should reject non-string values', () => {
+ expect(isBillboardAction(null)).toBe(false);
+ expect(isBillboardAction(undefined)).toBe(false);
+ expect(isBillboardAction(0)).toBe(false);
+ expect(isBillboardAction({})).toBe(false);
+ });
+});
+
+describe('resolveBillboardAction', () => {
+ it('should resolve every registered action on web', () => {
+ for (const action of BILLBOARD_ACTIONS) {
+ expect(resolveBillboardAction(action)).toBe(action);
+ }
+ });
+
+ it('should return null for unknown values so the CTA falls back to linkUrl', () => {
+ expect(resolveBillboardAction('notARealAction')).toBeNull();
+ expect(resolveBillboardAction(null)).toBeNull();
+ expect(resolveBillboardAction(undefined)).toBeNull();
+ });
+
+ it('should not resolve web-only actions on desktop', async () => {
+ vi.resetModules();
+ vi.doMock('@lobechat/const', async (importOriginal) => ({
+ ...((await importOriginal()) as typeof LobechatConst),
+ isDesktop: true,
+ }));
+
+ try {
+ const desktopActions = await import('./actions');
+ expect(desktopActions.resolveBillboardAction('resetOnboarding')).toBeNull();
+ expect(desktopActions.resolveBillboardAction('openChangelog')).toBe('openChangelog');
+ } finally {
+ vi.doUnmock('@lobechat/const');
+ vi.resetModules();
+ }
+ });
+});
+
+describe('runBillboardAction', () => {
+ it('should open the changelog modal for openChangelog', () => {
+ runBillboardAction('openChangelog');
+
+ expect(openChangelogModal).toHaveBeenCalledTimes(1);
+ expect(openFeedbackModal).not.toHaveBeenCalled();
+ });
+
+ it('should open the feedback modal for openFeedback', () => {
+ runBillboardAction('openFeedback');
+
+ expect(openFeedbackModal).toHaveBeenCalledTimes(1);
+ expect(openChangelogModal).not.toHaveBeenCalled();
+ });
+
+ it('should reset onboarding progress for resetOnboarding', async () => {
+ await runBillboardAction('resetOnboarding');
+
+ expect(resetOnboarding).toHaveBeenCalledTimes(1);
+ });
+
+ it('should have a runnable handler for every registered action', async () => {
+ for (const action of BILLBOARD_ACTIONS) {
+ await expect(Promise.resolve(runBillboardAction(action))).resolves.not.toThrow();
+ }
+ });
+});
diff --git a/src/features/Billboard/actions.ts b/src/features/Billboard/actions.ts
new file mode 100644
index 00000000000..f2d188eb2cf
--- /dev/null
+++ b/src/features/Billboard/actions.ts
@@ -0,0 +1,50 @@
+import { isDesktop } from '@lobechat/const';
+
+import { openChangelogModal } from '@/components/ChangelogModal';
+import { openFeedbackModal } from '@/components/FeedbackModal';
+import { getUserStoreState } from '@/store/user';
+
+/**
+ * In-app CTA actions a billboard item can trigger. The platform configures one
+ * of these enum values in the item's `action` field; the client runs the
+ * registered handler instead of opening `linkUrl`.
+ *
+ * Keep in sync with the ops platform enum (`src/const/billboard.ts` in lobe-ops).
+ */
+export const BILLBOARD_ACTIONS = ['openChangelog', 'openFeedback', 'resetOnboarding'] as const;
+
+export type BillboardAction = (typeof BILLBOARD_ACTIONS)[number];
+
+/** Actions only meaningful on the web SPA (desktop has its own onboarding flow). */
+const WEB_ONLY_ACTIONS: readonly BillboardAction[] = ['resetOnboarding'];
+
+export const isBillboardAction = (value: unknown): value is BillboardAction =>
+ typeof value === 'string' && (BILLBOARD_ACTIONS as readonly string[]).includes(value);
+
+/**
+ * Narrow a platform-configured value to an action this client can actually run:
+ * unknown values and actions unavailable on the current platform both return
+ * null, so the CTA falls back to `linkUrl`.
+ */
+export const resolveBillboardAction = (value: unknown): BillboardAction | null => {
+ if (!isBillboardAction(value)) return null;
+ if (isDesktop && WEB_ONLY_ACTIONS.includes(value)) return null;
+ return value;
+};
+
+const billboardActionHandlers: Record<BillboardAction, () => Promise<void> | void> = {
+ openChangelog: () => {
+ openChangelogModal();
+ },
+ openFeedback: () => {
+ openFeedbackModal();
+ },
+ resetOnboarding: async () => {
+ await getUserStoreState().resetOnboarding();
+ window.location.href = '/onboarding';
+ },
+};
+
+export const runBillboardAction = (action: BillboardAction): Promise<void> | void => {
+ return billboardActionHandlers[action]();
+};
diff --git a/src/features/HomeSidebar/Footer/index.test.tsx b/src/features/HomeSidebar/Footer/index.test.tsx
index 0dcd9472b47..cc7157c74ab 100644
--- a/src/features/HomeSidebar/Footer/index.test.tsx
+++ b/src/features/HomeSidebar/Footer/index.test.tsx
@@ -13,9 +13,6 @@ vi.mock('react-i18next', () => ({
({
'changelog': 'Changelog',
'getApp': 'Get App',
- 'productHunt.actionLabel': 'Support us',
- 'productHunt.description': 'Support us on Product Hunt.',
- 'productHunt.title': "We're on Product Hunt!",
'userPanel.discord': 'Discord',
'userPanel.docs': 'Docs',
'userPanel.feedback': 'Feedback',
@@ -32,40 +29,17 @@ interface RenderFooterOptions {
enableBusinessFeatures?: boolean;
hideGitHub?: boolean;
homeSidebar?: boolean;
- serverConfigInit?: boolean;
}
-let mockGlobalState: Record<string, unknown>;
let mockServerConfigState: Record<string, unknown>;
let mockUserState: Record<string, unknown>;
-interface MockStoreHook {
- (selector: (state: Record<string, unknown>) => unknown): unknown;
- getState: () => Record<string, unknown>;
-}
-
-const createGlobalState = () => ({
- status: {
- readNotificationSlugs: [],
- },
- updateSystemStatus: vi.fn((patch: { readNotificationSlugs?: string[] }) => {
- mockGlobalState = {
- ...mockGlobalState,
- status: {
- ...(mockGlobalState.status as Record<string, unknown>),
- ...patch,
- },
- };
- }),
-});
-
const renderFooter = async ({
billboardItems = [],
desktop = false,
enableBusinessFeatures = false,
homeSidebar = false,
hideGitHub = true,
- serverConfigInit = true,
}: RenderFooterOptions = {}) => {
vi.resetModules();
analyticsTrack.mockReset();
@@ -75,10 +49,8 @@ const renderFooter = async ({
setItem: vi.fn(),
});
- mockGlobalState = createGlobalState();
mockServerConfigState = {
enableBusinessFeatures,
- serverConfigInit,
};
mockUserState = {
defaultSettings: {},
@@ -109,37 +81,6 @@ const renderFooter = async ({
default: vi.fn(),
openFeedbackModal: vi.fn(),
}));
- vi.doMock('@/components/HighlightNotification', () => ({
- default: (props: {
- actionLabel?: string;
- description?: string;
- onAction?: () => void;
- onActionClick?: () => void;
- onClose?: () => void;
- open?: boolean;
- title?: string;
- }) =>
- props.open ? (
- <div data-testid="highlight-notification">
- <div>{props.title}</div>
- <div>{props.description}</div>
- <button type="button" onClick={props.onClose}>
- Close promo
- </button>
- {props.actionLabel && (
- <button
- type="button"
- onClick={() => {
- if (props.onAction) props.onAction();
- else props.onActionClick?.();
- }}
- >
- {props.actionLabel}
- </button>
- )}
- </div>
- ) : null,
- }));
vi.doMock('@/features/Billboard', () => ({
default: () => null,
}));
@@ -176,13 +117,6 @@ const renderFooter = async ({
vi.doMock('@/hooks/useNavLayout', () => ({
useNavLayout: createNavLayoutState,
}));
- const selectFromGlobalStore = ((selector: (state: Record<string, unknown>) => unknown) =>
- selector(mockGlobalState)) as MockStoreHook;
- vi.doMock('@/store/global', () => {
- selectFromGlobalStore.getState = () => mockGlobalState;
-
- return { useGlobalStore: selectFromGlobalStore };
- });
function selectFromServerConfigStore(selector: (state: Record<string, unknown>) => unknown) {
return selector(mockServerConfigState);
}
@@ -218,14 +152,12 @@ afterEach(() => {
vi.doUnmock('@lobehub/analytics/react');
vi.doUnmock('@/components/ChangelogModal');
vi.doUnmock('@/components/FeedbackModal');
- vi.doUnmock('@/components/HighlightNotification');
vi.doUnmock('@/features/Billboard');
vi.doUnmock('@/features/Billboard/MenuItems');
vi.doUnmock('@/features/NavPanel');
vi.doUnmock('@/features/User/UserPanel/ThemeButton');
vi.doUnmock('@/features/Workspace/WorkspaceLink');
vi.doUnmock('@/hooks/useNavLayout');
- vi.doUnmock('@/store/global');
vi.doUnmock('@/store/serverConfig');
vi.doUnmock('@/store/user');
});
diff --git a/src/features/HomeSidebar/Footer/index.tsx b/src/features/HomeSidebar/Footer/index.tsx
index 26ef63c123d..8a2c1d7b2c5 100644
--- a/src/features/HomeSidebar/Footer/index.tsx
+++ b/src/features/HomeSidebar/Footer/index.tsx
@@ -13,19 +13,16 @@ import {
Feather,
FileClockIcon,
FlaskConical,
- Rocket,
Send,
Settings2,
SettingsIcon,
} from 'lucide-react';
-import type { ReactNode } from 'react';
-import { memo, useCallback, useEffect, useMemo, useState } from 'react';
+import { memo, useCallback, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import { useHasActiveWorkspace } from '@/business/client/hooks/useHasActiveWorkspace';
import { openChangelogModal } from '@/components/ChangelogModal';
import { openFeedbackModal } from '@/components/FeedbackModal';
-import HighlightNotification from '@/components/HighlightNotification';
import { DOCUMENTS_REFER_URL, GITHUB } from '@/const/url';
import Billboard from '@/features/Billboard';
import { useBillboardMenuItems } from '@/features/Billboard/MenuItems';
@@ -33,34 +30,10 @@ import { useActiveNavKey } from '@/features/NavPanel/useActiveNavKey';
import ThemeButton from '@/features/User/UserPanel/ThemeButton';
import WorkspaceLink from '@/features/Workspace/WorkspaceLink';
import { useNavLayout } from '@/hooks/useNavLayout';
-import { useGlobalStore } from '@/store/global';
-import { systemStatusSelectors } from '@/store/global/selectors/systemStatus';
import { serverConfigSelectors, useServerConfigStore } from '@/store/serverConfig';
import { useUserStore } from '@/store/user';
import { userGeneralSettingsSelectors } from '@/store/user/slices/settings/selectors/general';
-import { resolveFooterPromotionState } from './promotionPipeline';
-
-const PRODUCT_HUNT_NOTIFICATION = {
- actionHref: 'https://www.producthunt.com/products/lobehub?launch=lobehub',
- endTime: new Date('2026-02-01T00:00:00Z'),
- image: 'https://hub-apac-1.lobeobjects.space/og/lobehub-ph.png',
- slug: 'product-hunt-2026',
- startTime: new Date('2026-01-27T08:00:00Z'),
-} as const;
-
-interface PromotionCard {
- actionHref?: string;
- actionIcon?: ReactNode;
- actionLabel: string;
- description: string;
- image?: string;
- onAction?: () => void;
- onActionClick?: () => void;
- onClose: () => void;
- title: string;
-}
-
type FooterMenuItems = NonNullable<MenuProps['items']>;
/**
@@ -109,41 +82,8 @@ const Footer = memo(() => {
const activeNavKey = useActiveNavKey();
const isHomeSidebar = activeNavKey === 'home';
const billboardMenuItems = useBillboardMenuItems();
- const serverConfigInit = useServerConfigStore((s) => s.serverConfigInit);
const enableBusinessFeatures = useServerConfigStore(serverConfigSelectors.enableBusinessFeatures);
const isDevMode = useUserStore((s) => userGeneralSettingsSelectors.config(s).isDevMode);
- const [isProductHuntCardOpen, setIsProductHuntCardOpen] = useState(false);
-
- const [isProductHuntNotificationRead, updateSystemStatus] = useGlobalStore((s) => [
- systemStatusSelectors.isNotificationRead(PRODUCT_HUNT_NOTIFICATION.slug)(s),
- s.updateSystemStatus,
- ]);
-
- const isWithinTimeWindow = useMemo(() => {
- const now = new Date();
- return now >= PRODUCT_HUNT_NOTIFICATION.startTime && now <= PRODUCT_HUNT_NOTIFICATION.endTime;
- }, []);
-
- const { shouldAutoShowProductHuntCard, shouldShowProductHuntMenuEntry } = useMemo(
- () =>
- resolveFooterPromotionState({
- isProductHuntNotificationRead,
- isWithinProductHuntWindow: isWithinTimeWindow,
- serverConfigInit,
- }),
- [isProductHuntNotificationRead, isWithinTimeWindow, serverConfigInit],
- );
-
- const trackPromotionEvent = useCallback(
- (eventName: string, properties: Record<string, string>) => {
- try {
- analytics?.track({ name: eventName, properties });
- } catch {
- // silently ignore tracking errors to avoid affecting business logic
- }
- },
- [analytics],
- );
const trackMenuClick = useCallback(
(key: string) => {
@@ -159,27 +99,6 @@ const Footer = memo(() => {
[analytics],
);
- const markNotificationRead = useCallback(
- (slug: string) => {
- const currentSlugs = useGlobalStore.getState().status.readNotificationSlugs || [];
-
- if (currentSlugs.includes(slug)) return;
-
- updateSystemStatus({ readNotificationSlugs: [...currentSlugs, slug] });
- },
- [updateSystemStatus],
- );
-
- useEffect(() => {
- if (!shouldAutoShowProductHuntCard) return;
-
- setIsProductHuntCardOpen(true);
- trackPromotionEvent('product_hunt_card_viewed', {
- spm: 'homepage.product_hunt.viewed',
- trigger: 'auto',
- });
- }, [isWithinTimeWindow, shouldAutoShowProductHuntCard, trackPromotionEvent]);
-
const handleOpenChangelogModal = useCallback(() => {
openChangelogModal();
}, []);
@@ -188,44 +107,6 @@ const Footer = memo(() => {
openFeedbackModal();
}, []);
- const handleOpenProductHuntCard = useCallback(() => {
- setIsProductHuntCardOpen(true);
- trackPromotionEvent('product_hunt_card_viewed', {
- spm: 'homepage.product_hunt.viewed',
- trigger: 'menu_click',
- });
- }, [trackPromotionEvent]);
-
- const handleCloseProductHuntCard = useCallback(() => {
- setIsProductHuntCardOpen(false);
- markNotificationRead(PRODUCT_HUNT_NOTIFICATION.slug);
- trackPromotionEvent('product_hunt_card_closed', {
- spm: 'homepage.product_hunt.closed',
- });
- }, [markNotificationRead, trackPromotionEvent]);
-
- const handleProductHuntActionClick = useCallback(() => {
- trackPromotionEvent('product_hunt_action_clicked', {
- spm: 'homepage.product_hunt.action_clicked',
- });
- }, [trackPromotionEvent]);
-
- const activePromotion = useMemo<PromotionCard | undefined>(() => {
- if (isProductHuntCardOpen) {
- return {
- actionHref: PRODUCT_HUNT_NOTIFICATION.actionHref,
- actionLabel: t('productHunt.actionLabel'),
- description: t('productHunt.description'),
- image: PRODUCT_HUNT_NOTIFICATION.image,
- onActionClick: handleProductHuntActionClick,
- onClose: handleCloseProductHuntCard,
- title: t('productHunt.title'),
- };
- }
-
- return undefined;
- }, [handleCloseProductHuntCard, handleProductHuntActionClick, isProductHuntCardOpen, t]);
-
const { helpMenuItems, trackedMenuKeys } = useMemo<{
helpMenuItems: MenuProps['items'];
trackedMenuKeys: string[];
@@ -322,16 +203,6 @@ const Footer = memo(() => {
},
]
: []),
- ...(shouldShowProductHuntMenuEntry
- ? [
- {
- icon: <Icon icon={Rocket} />,
- key: 'productHunt',
- label: 'Product Hunt',
- onClick: handleOpenProductHuntCard,
- },
- ]
- : []),
];
return {
@@ -352,9 +223,7 @@ const Footer = memo(() => {
enableBusinessFeatures,
handleOpenChangelogModal,
handleOpenFeedbackModal,
- handleOpenProductHuntCard,
isDevMode,
- shouldShowProductHuntMenuEntry,
t,
settingLabelKey,
billboardMenuItems,
@@ -425,20 +294,6 @@ const Footer = memo(() => {
)}
</Flexbox>
)}
- {activePromotion && (
- <HighlightNotification
- open
- actionHref={activePromotion.actionHref}
- actionIcon={activePromotion.actionIcon}
- actionLabel={activePromotion.actionLabel}
- description={activePromotion.description}
- image={activePromotion.image}
- title={activePromotion.title}
- onAction={activePromotion.onAction}
- onActionClick={activePromotion.onActionClick}
- onClose={activePromotion.onClose}
- />
- )}
{isHomeSidebar && <Billboard />}
</>
);
diff --git a/src/features/HomeSidebar/Footer/promotionPipeline.test.ts b/src/features/HomeSidebar/Footer/promotionPipeline.test.ts
deleted file mode 100644
index 96d1fc35e51..00000000000
--- a/src/features/HomeSidebar/Footer/promotionPipeline.test.ts
+++ /dev/null
@@ -1,38 +0,0 @@
-import { describe, expect, it } from 'vitest';
-
-import type { FooterPromotionContext } from './promotionPipeline';
-import { resolveFooterPromotionState } from './promotionPipeline';
-
-const createContext = (overrides: Partial<FooterPromotionContext> = {}) => ({
- isProductHuntNotificationRead: false,
- isWithinProductHuntWindow: true,
- serverConfigInit: true,
- ...overrides,
-});
-
-describe('resolveFooterPromotionState', () => {
- it('shows the product hunt card within the promotion window', () => {
- expect(resolveFooterPromotionState(createContext())).toEqual({
- shouldAutoShowProductHuntCard: true,
- shouldShowProductHuntMenuEntry: true,
- });
- });
-
- it('keeps the product hunt menu entry while suppressing auto-open after read', () => {
- expect(
- resolveFooterPromotionState(createContext({ isProductHuntNotificationRead: true })),
- ).toEqual({
- shouldAutoShowProductHuntCard: false,
- shouldShowProductHuntMenuEntry: true,
- });
- });
-
- it('returns an empty state outside the promotion window', () => {
- expect(
- resolveFooterPromotionState(createContext({ isWithinProductHuntWindow: false })),
- ).toEqual({
- shouldAutoShowProductHuntCard: false,
- shouldShowProductHuntMenuEntry: false,
- });
- });
-});
diff --git a/src/features/HomeSidebar/Footer/promotionPipeline.ts b/src/features/HomeSidebar/Footer/promotionPipeline.ts
deleted file mode 100644
index ec2f7023f69..00000000000
--- a/src/features/HomeSidebar/Footer/promotionPipeline.ts
+++ /dev/null
@@ -1,45 +0,0 @@
-interface FooterPromotionContext {
- isProductHuntNotificationRead: boolean;
- isWithinProductHuntWindow: boolean;
- serverConfigInit: boolean;
-}
-
-interface FooterPromotionState {
- shouldAutoShowProductHuntCard: boolean;
- shouldShowProductHuntMenuEntry: boolean;
-}
-
-type FooterPromotionPipelineStep = (
- context: FooterPromotionContext,
- state: FooterPromotionState,
-) => FooterPromotionState;
-
-const initialFooterPromotionState: FooterPromotionState = {
- shouldAutoShowProductHuntCard: false,
- shouldShowProductHuntMenuEntry: false,
-};
-
-const resolveProductHuntPromotion: FooterPromotionPipelineStep = (context, state) => {
- if (!context.isWithinProductHuntWindow) return state;
-
- return {
- ...state,
- shouldAutoShowProductHuntCard:
- context.serverConfigInit && !context.isProductHuntNotificationRead,
- shouldShowProductHuntMenuEntry: true,
- };
-};
-
-const footerPromotionPipeline = [
- resolveProductHuntPromotion,
-] as const satisfies readonly FooterPromotionPipelineStep[];
-
-export const resolveFooterPromotionState = (
- context: FooterPromotionContext,
-): FooterPromotionState =>
- footerPromotionPipeline.reduce(
- (state, step) => step(context, state),
- initialFooterPromotionState,
- );
-
-export type { FooterPromotionContext, FooterPromotionState };