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(home): restore marketing entry hierarchy (#18528)

Innei901ff7e6de27
diff --git a/src/business/client/features/useHomePromoLine.ts b/src/business/client/features/useHomePromoLine.ts
index a1433edca3d..df674060d85 100644
--- a/src/business/client/features/useHomePromoLine.ts
+++ b/src/business/client/features/useHomePromoLine.ts
@@ -1,8 +1,9 @@
import type { ReactNode } from 'react';
/**
- * The promo the home portrait speaks. Returning a node (rather than rendering
- * one) is what lets the caller know a promo is live, so it can hold back the
- * daily brief — and hand the brief back the moment the promo is dismissed.
+ * The time-sensitive promotion shown in Home's header. Returning a node lets
+ * the Home layout know whether a campaign is live, so it can keep the Agent's
+ * daily-brief bubble out of the same attention lane until the campaign is
+ * dismissed or expires.
*/
export const useHomePromoLine = (): ReactNode | undefined => undefined;
diff --git a/src/features/Home/HomeHeader.tsx b/src/features/Home/HomeHeader.tsx
index 5eac2cd6e07..aa0379d7e65 100644
--- a/src/features/Home/HomeHeader.tsx
+++ b/src/features/Home/HomeHeader.tsx
@@ -1,5 +1,6 @@
import { Flexbox, Text } from '@lobehub/ui';
import { createStaticStyles } from 'antd-style';
+import type { ReactNode } from 'react';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
@@ -26,10 +27,37 @@ const styles = createStaticStyles(({ css }) => ({
line-height: 1.4;
letter-spacing: -0.01em;
`,
+ promo: css`
+ overflow: hidden;
+ justify-self: center;
+
+ min-width: 0;
+ max-width: 100%;
+
+ white-space: nowrap;
+
+ @container home (width <= 720px) {
+ justify-self: end;
+ max-width: 280px;
+ }
+ `,
+ spacer: css`
+ @container home (width <= 720px) {
+ display: none;
+ }
+ `,
toolbar: css`
+ display: grid;
+ grid-template-columns: minmax(0, 1fr) minmax(0, 480px) minmax(0, 1fr);
+ align-items: center;
+
width: 100%;
min-width: 0;
min-height: 48px;
+
+ @container home (width <= 720px) {
+ grid-template-columns: minmax(0, 1fr) auto;
+ }
`,
}));
@@ -41,9 +69,10 @@ const getGreetingKey = (hour: number): 'afternoon' | 'evening' | 'morning' => {
interface HomeHeaderProps {
centered?: boolean;
+ promo?: ReactNode;
}
-const HomeHeader = memo<HomeHeaderProps>(({ centered }) => {
+const HomeHeader = memo<HomeHeaderProps>(({ centered, promo }) => {
const { t } = useTranslation('home');
const displayName = useUserStore(userProfileSelectors.displayUserName);
const isLogin = useUserStore(authSelectors.isLogin);
@@ -62,9 +91,11 @@ const HomeHeader = memo<HomeHeaderProps>(({ centered }) => {
{centered ? (
<AgentSelect />
) : (
- <Flexbox horizontal align={'center'} className={styles.toolbar} gap={16}>
+ <div className={styles.toolbar}>
<AgentSelect />
- </Flexbox>
+ {promo && <div className={styles.promo}>{promo}</div>}
+ <div aria-hidden className={styles.spacer} />
+ </div>
)}
<Text as={'h1'} className={styles.greeting} weight={600}>
{greeting}
diff --git a/src/features/Home/NewModelShortcuts/analytics.ts b/src/features/Home/NewModelShortcuts/analytics.ts
new file mode 100644
index 00000000000..d6c39faad68
--- /dev/null
+++ b/src/features/Home/NewModelShortcuts/analytics.ts
@@ -0,0 +1,30 @@
+import type { AnalyticsManager } from '@lobehub/analytics';
+
+import type { HomeNewModelItem } from '@/business/client/hooks/useHomeNewModels';
+import { trackProductUsageEvent } from '@/libs/analytics/productUsageEvent';
+
+export const HOME_MODEL_SHORTCUT_CLICKED_EVENT = 'home_model_shortcut_clicked';
+
+interface TrackHomeModelShortcutClickedParams {
+ analytics?: AnalyticsManager | null;
+ item: HomeNewModelItem;
+ provider?: string;
+}
+
+export const trackHomeModelShortcutClicked = ({
+ analytics,
+ item,
+ provider,
+}: TrackHomeModelShortcutClickedParams) =>
+ trackProductUsageEvent(
+ {
+ name: HOME_MODEL_SHORTCUT_CLICKED_EVENT,
+ properties: {
+ ...(provider && { provider }),
+ model: item.model,
+ model_type: item.type,
+ spm: 'homepage.model_shortcut.clicked',
+ },
+ },
+ { analytics },
+ );
diff --git a/src/features/Home/NewModelShortcuts/index.tsx b/src/features/Home/NewModelShortcuts/index.tsx
new file mode 100644
index 00000000000..f1c6deb7bc1
--- /dev/null
+++ b/src/features/Home/NewModelShortcuts/index.tsx
@@ -0,0 +1,202 @@
+import { Jimeng, Moonshot, OpenAI, ZAI } from '@lobehub/icons';
+import { Flexbox, Skeleton, Text } from '@lobehub/ui';
+import { Button } from '@lobehub/ui/base-ui';
+import { App } from 'antd';
+import { createStaticStyles, cx } from 'antd-style';
+import { Bot } from 'lucide-react';
+import type { ComponentType } from 'react';
+import { useCallback, useState } from 'react';
+import { useTranslation } from 'react-i18next';
+
+import type { BusinessModelModeConfig } from '@/business/client/hooks/useBusinessAgentMode';
+import { useBusinessModelModeConfig } from '@/business/client/hooks/useBusinessAgentMode';
+import type { HomeNewModelItem } from '@/business/client/hooks/useHomeNewModels';
+import { useHomeNewModels } from '@/business/client/hooks/useHomeNewModels';
+import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
+import { usePermission } from '@/hooks/usePermission';
+import { agentService } from '@/services/agent';
+import { useAgentStore } from '@/store/agent';
+import { agentByIdSelectors } from '@/store/agent/selectors';
+
+import { useResolvedHomeAgentId } from '../AgentSelect/useResolvedHomeAgentId';
+import { trackHomeModelShortcutClicked } from './analytics';
+import { NEW_GLM_MODEL, NEW_IMAGE_MODEL, NEW_KIMI_MODEL, NEW_VIDEO_MODEL } from './starterModels';
+import { useStarterModelDefaults } from './useStarterModelDefaults';
+
+const styles = createStaticStyles(({ css, cssVar }) => ({
+ active: css`
+ color: ${cssVar.colorText};
+ background: ${cssVar.colorFillSecondary};
+ `,
+ button: css`
+ height: 40px;
+ padding-inline: 12px;
+ border: 0;
+ border-radius: ${cssVar.borderRadius};
+
+ color: ${cssVar.colorTextSecondary};
+
+ background: transparent;
+ box-shadow: none !important;
+
+ &:hover {
+ color: ${cssVar.colorText} !important;
+ background: ${cssVar.colorFillTertiary} !important;
+ }
+ `,
+ container: css`
+ flex-wrap: wrap;
+ min-height: 40px;
+ `,
+ label: css`
+ flex: none;
+ font-size: 12px;
+ color: ${cssVar.colorTextSecondary};
+ `,
+}));
+
+const getShortcutKey = (item: HomeNewModelItem) => `${item.type}:${item.model}`;
+const getShortcutProvider = (item: HomeNewModelItem, fallbackProvider: string) =>
+ item.provider ?? fallbackProvider;
+const skeletonWidths = [112, 150, 126, 138];
+const modelIcons: Record<string, ComponentType<{ size: number }>> = {
+ [NEW_GLM_MODEL]: ZAI.Avatar,
+ [NEW_IMAGE_MODEL]: OpenAI.Avatar,
+ [NEW_KIMI_MODEL]: Moonshot.Avatar,
+ [NEW_VIDEO_MODEL]: Jimeng.Avatar,
+};
+
+export const NewModelShortcuts = () => {
+ const { t } = useTranslation('home');
+ const navigate = useWorkspaceAwareNavigate();
+ const { message } = App.useApp();
+ const { agentId: activeAgentId } = useResolvedHomeAgentId();
+ const { allowed: canCreateContent } = usePermission('create_content');
+ const updateAgentConfigById = useAgentStore((state) => state.updateAgentConfigById);
+ const currentModel = useAgentStore((state) =>
+ agentByIdSelectors.getAgentModelById(activeAgentId ?? '')(state),
+ );
+ const currentProvider = useAgentStore((state) =>
+ agentByIdSelectors.getAgentModelProviderById(activeAgentId ?? '')(state),
+ );
+ const [switchingKey, setSwitchingKey] = useState<string | null>(null);
+ const { defaultHomeNewModels, fallbackChatProvider } = useStarterModelDefaults();
+ const { isLoading, items } = useHomeNewModels([...defaultHomeNewModels]);
+ const applyBusinessModelModeConfig = useBusinessModelModeConfig();
+
+ const handleClick = useCallback(
+ async (item: HomeNewModelItem) => {
+ if (!canCreateContent) return;
+
+ const key = getShortcutKey(item);
+ const selectedProvider =
+ item.type === 'chat' ? getShortcutProvider(item, fallbackChatProvider) : item.provider;
+ void trackHomeModelShortcutClicked({ item, provider: selectedProvider });
+
+ if (item.type === 'video') {
+ navigate(`/video?model=${item.model}`);
+ return;
+ }
+
+ if (item.type === 'image') {
+ navigate(`/image?model=${item.model}`);
+ return;
+ }
+
+ if (!activeAgentId || switchingKey) return;
+
+ setSwitchingKey(key);
+ const provider = getShortcutProvider(item, fallbackChatProvider);
+ try {
+ // Hydrate before the optimistic write so updating the selected model
+ // cannot drop fields the Home surface has not loaded yet.
+ let agentState = useAgentStore.getState();
+ if (!agentState.agentMap[activeAgentId]) {
+ const config = await agentService.getAgentConfigById(activeAgentId);
+ if (config) agentState.internal_dispatchAgentMap(activeAgentId, config);
+ agentState = useAgentStore.getState();
+ }
+
+ const nextConfig: BusinessModelModeConfig = applyBusinessModelModeConfig({
+ model: item.model,
+ provider,
+ });
+ const shouldUpdateAgentMode =
+ nextConfig.chatConfig?.enableAgentMode === false &&
+ agentByIdSelectors.getAgentEnableModeById(activeAgentId)(agentState);
+
+ if (currentModel === item.model && currentProvider === provider && !shouldUpdateAgentMode) {
+ message.info(t('starter.modelInUse', { name: item.title }));
+ return;
+ }
+
+ try {
+ await updateAgentConfigById(activeAgentId, nextConfig, { rethrow: true });
+ message.success(t('starter.modelSwitched', { name: item.title }));
+ } catch {
+ // The agent store reports persistence failures at the action boundary.
+ }
+ } finally {
+ setSwitchingKey(null);
+ }
+ },
+ [
+ activeAgentId,
+ applyBusinessModelModeConfig,
+ canCreateContent,
+ currentModel,
+ currentProvider,
+ fallbackChatProvider,
+ message,
+ navigate,
+ switchingKey,
+ t,
+ updateAgentConfigById,
+ ],
+ );
+
+ if (!canCreateContent || (!isLoading && items.length === 0)) return null;
+
+ return (
+ <Flexbox horizontal align={'center'} className={styles.container} gap={8} justify={'center'}>
+ <Text className={styles.label}>{t('starter.newLabel')}</Text>
+ {isLoading
+ ? defaultHomeNewModels.map((item, index) => (
+ <Skeleton.Button
+ active
+ key={getShortcutKey(item)}
+ style={{
+ borderRadius: 8,
+ height: 40,
+ width: skeletonWidths[index] ?? 126,
+ }}
+ />
+ ))
+ : items.map((item) => {
+ const key = getShortcutKey(item);
+ const provider =
+ item.type === 'chat' ? getShortcutProvider(item, fallbackChatProvider) : undefined;
+ const isCurrent =
+ item.type === 'chat' && item.model === currentModel && provider === currentProvider;
+ const isSwitching = switchingKey === key;
+ const ModelIcon = modelIcons[item.iconModel ?? item.model] ?? Bot;
+ const button = (
+ <Button
+ aria-pressed={item.type === 'chat' ? isCurrent : undefined}
+ className={cx(styles.button, isCurrent && styles.active)}
+ disabled={!!switchingKey && !isSwitching}
+ icon={<ModelIcon size={18} />}
+ key={key}
+ loading={isSwitching}
+ type={'text'}
+ onClick={() => handleClick(item)}
+ >
+ {item.title}
+ </Button>
+ );
+
+ return button;
+ })}
+ </Flexbox>
+ );
+};
diff --git a/src/features/Home/NewModelShortcuts/starterModels.ts b/src/features/Home/NewModelShortcuts/starterModels.ts
new file mode 100644
index 00000000000..00e19a2c180
--- /dev/null
+++ b/src/features/Home/NewModelShortcuts/starterModels.ts
@@ -0,0 +1,69 @@
+import type { HomeNewModelItem } from '@/business/client/hooks/useHomeNewModels';
+
+// Chat
+export const NEW_GLM_MODEL = 'glm-5.2';
+export const NEW_GLM_MODEL_NAME = 'GLM-5.2';
+export const NEW_KIMI_MODEL = 'kimi-k2.7-code';
+export const NEW_KIMI_MODEL_NAME = 'Kimi K2.7 Code';
+
+export const BUSINESS_CHAT_PROVIDER = 'lobehub';
+export const OSS_GLM_PROVIDER = 'zhipu';
+export const OSS_KIMI_PROVIDER = 'moonshot';
+
+// Image
+export const NEW_IMAGE_MODEL = 'gpt-image-2';
+export const NEW_IMAGE_MODEL_NAME = 'GPT Image 2';
+
+// Video
+export const NEW_VIDEO_MODEL = 'dreamina-seedance-2-0-260128';
+export const NEW_VIDEO_MODEL_NAME = 'Seedance 2.0';
+
+export const BUSINESS_HOME_NEW_MODELS = [
+ {
+ model: NEW_GLM_MODEL,
+ provider: BUSINESS_CHAT_PROVIDER,
+ title: NEW_GLM_MODEL_NAME,
+ type: 'chat',
+ },
+ {
+ model: NEW_KIMI_MODEL,
+ provider: BUSINESS_CHAT_PROVIDER,
+ title: NEW_KIMI_MODEL_NAME,
+ type: 'chat',
+ },
+ {
+ model: NEW_IMAGE_MODEL,
+ title: NEW_IMAGE_MODEL_NAME,
+ type: 'image',
+ },
+ {
+ model: NEW_VIDEO_MODEL,
+ title: NEW_VIDEO_MODEL_NAME,
+ type: 'video',
+ },
+] as const satisfies HomeNewModelItem[];
+
+export const OSS_HOME_NEW_MODELS = [
+ {
+ model: NEW_GLM_MODEL,
+ provider: OSS_GLM_PROVIDER,
+ title: NEW_GLM_MODEL_NAME,
+ type: 'chat',
+ },
+ {
+ model: NEW_KIMI_MODEL,
+ provider: OSS_KIMI_PROVIDER,
+ title: NEW_KIMI_MODEL_NAME,
+ type: 'chat',
+ },
+ {
+ model: NEW_IMAGE_MODEL,
+ title: NEW_IMAGE_MODEL_NAME,
+ type: 'image',
+ },
+ {
+ model: NEW_VIDEO_MODEL,
+ title: NEW_VIDEO_MODEL_NAME,
+ type: 'video',
+ },
+] as const satisfies HomeNewModelItem[];
diff --git a/src/features/Home/NewModelShortcuts/useStarterModelDefaults.ts b/src/features/Home/NewModelShortcuts/useStarterModelDefaults.ts
new file mode 100644
index 00000000000..7ebd6393be0
--- /dev/null
+++ b/src/features/Home/NewModelShortcuts/useStarterModelDefaults.ts
@@ -0,0 +1,17 @@
+import { serverConfigSelectors, useServerConfigStore } from '@/store/serverConfig';
+
+import {
+ BUSINESS_CHAT_PROVIDER,
+ BUSINESS_HOME_NEW_MODELS,
+ OSS_GLM_PROVIDER,
+ OSS_HOME_NEW_MODELS,
+} from './starterModels';
+
+export const useStarterModelDefaults = () => {
+ const enableBusinessFeatures = useServerConfigStore(serverConfigSelectors.enableBusinessFeatures);
+
+ return {
+ defaultHomeNewModels: enableBusinessFeatures ? BUSINESS_HOME_NEW_MODELS : OSS_HOME_NEW_MODELS,
+ fallbackChatProvider: enableBusinessFeatures ? BUSINESS_CHAT_PROVIDER : OSS_GLM_PROVIDER,
+ };
+};
diff --git a/src/features/Home/PortraitBubble/bubbleLine.test.ts b/src/features/Home/PortraitBubble/bubbleLine.test.ts
deleted file mode 100644
index 15d72f31f8c..00000000000
--- a/src/features/Home/PortraitBubble/bubbleLine.test.ts
+++ /dev/null
@@ -1,18 +0,0 @@
-import { describe, expect, it } from 'vitest';
-
-import { resolveBubbleLine } from './bubbleLine';
-
-describe('resolveBubbleLine', () => {
- it('lets a promo interrupt the brief', () => {
- expect(resolveBubbleLine({ hasBrief: true, hasPromo: true })).toBe('promo');
- });
-
- it('hands the brief back once the promo is gone', () => {
- expect(resolveBubbleLine({ hasBrief: true, hasPromo: false })).toBe('brief');
- });
-
- it('falls back to the static line rather than going mute', () => {
- expect(resolveBubbleLine({ hasBrief: false, hasPromo: false })).toBe('fallback');
- expect(resolveBubbleLine({ hasBrief: false, hasPromo: true })).toBe('promo');
- });
-});
diff --git a/src/features/Home/PortraitBubble/bubbleLine.ts b/src/features/Home/PortraitBubble/bubbleLine.ts
deleted file mode 100644
index d6b6cdbe9eb..00000000000
--- a/src/features/Home/PortraitBubble/bubbleLine.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-export type BubbleLineKind = 'brief' | 'fallback' | 'promo';
-
-interface BubbleLineInput {
- hasBrief: boolean;
- hasPromo: boolean;
-}
-
-/**
- * The portrait has one mouth, so its lines queue rather than stack: a promo
- * interrupts the brief, and dismissing the promo hands the brief back instead
- * of leaving the agent mute.
- */
-export const resolveBubbleLine = ({ hasPromo, hasBrief }: BubbleLineInput): BubbleLineKind => {
- if (hasPromo) return 'promo';
- if (hasBrief) return 'brief';
- return 'fallback';
-};
diff --git a/src/features/Home/PortraitBubble/index.tsx b/src/features/Home/PortraitBubble/index.tsx
index 96be0699c07..f5f89785ef9 100644
--- a/src/features/Home/PortraitBubble/index.tsx
+++ b/src/features/Home/PortraitBubble/index.tsx
@@ -2,12 +2,10 @@ import { createStaticStyles } from 'antd-style';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
-import { useHomePromoLine } from '@/business/client/features/useHomePromoLine';
import { useHomeDailyBrief } from '@/hooks/useHomeDailyBrief';
import GreetingLine from '../GreetingLine';
import { parseGreetingLine } from '../welcomeText';
-import { resolveBubbleLine } from './bubbleLine';
const styles = createStaticStyles(({ css, cssVar }) => ({
// Prose, not a row of chips: a flex container would make the brief's entity
@@ -65,30 +63,19 @@ const styles = createStaticStyles(({ css, cssVar }) => ({
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
`,
- promo: css`
- display: flex;
- gap: 8px;
- align-items: center;
- `,
}));
const PortraitBubble = memo(() => {
const { t } = useTranslation('home');
- const promo = useHomePromoLine();
const { currentPair } = useHomeDailyBrief();
const parsed = currentPair?.welcome ? parseGreetingLine(currentPair.welcome) : undefined;
- const kind = resolveBubbleLine({ hasBrief: Boolean(parsed?.plain), hasPromo: Boolean(promo) });
return (
<div className={styles.bubble}>
- {kind === 'promo' && <div className={styles.promo}>{promo}</div>}
- {kind === 'brief' && parsed && (
- <div className={styles.line}>
- <GreetingLine parsed={parsed} />
- </div>
- )}
- {kind === 'fallback' && <div className={styles.line}>{t('dashboard.greeting.subtitle')}</div>}
+ <div className={styles.line}>
+ {parsed?.plain ? <GreetingLine parsed={parsed} /> : t('dashboard.greeting.subtitle')}
+ </div>
</div>
);
});
diff --git a/src/features/Home/__tests__/portraitVisibility.test.tsx b/src/features/Home/__tests__/portraitVisibility.test.tsx
index ff8fdac6c73..9213689e1c1 100644
--- a/src/features/Home/__tests__/portraitVisibility.test.tsx
+++ b/src/features/Home/__tests__/portraitVisibility.test.tsx
@@ -1,4 +1,5 @@
import { cleanup, render, screen } from '@testing-library/react';
+import type { ReactNode } from 'react';
import { afterEach, describe, expect, it, vi } from 'vitest';
import { PortalViewType } from '@/store/chat/slices/portal/initialState';
@@ -6,6 +7,7 @@ import { PortalViewType } from '@/store/chat/slices/portal/initialState';
interface RenderHomeOptions {
isLogin?: boolean;
portalViewType?: PortalViewType;
+ promo?: ReactNode;
search?: string;
showHomePortrait?: boolean;
}
@@ -14,6 +16,13 @@ const stub = (testId: string) => ({ default: () => <div data-testid={testId} />
const modeStub = (testId: string) => ({
default: ({ mode }: { mode?: string }) => <div data-mode={mode} data-testid={testId} />,
});
+const homeHeaderStub = {
+ default: ({ promo }: { promo?: ReactNode }) => (
+ <div data-testid={'home-header'}>
+ {promo && <div data-testid={'home-header-promo'}>{promo}</div>}
+ </div>
+ ),
+};
function translate() {
return { i18n: { language: 'en-US' }, t: (key: string) => key };
@@ -22,6 +31,7 @@ function translate() {
const renderHome = async ({
isLogin = true,
portalViewType,
+ promo,
search = '',
showHomePortrait,
}: RenderHomeOptions = {}) => {
@@ -29,12 +39,18 @@ const renderHome = async ({
window.history.replaceState(null, '', `/${search}`);
vi.doMock('react-i18next', () => ({ useTranslation: translate }));
- vi.doMock('../HomeHeader', () => stub('home-header'));
+ vi.doMock('../HomeHeader', () => homeHeaderStub);
vi.doMock('../HomeModeContent', () => modeStub('home-mode-content'));
vi.doMock('../HomePortrait', () => stub('home-portrait'));
vi.doMock('../InputArea', () => modeStub('home-input-area'));
+ vi.doMock('../NewModelShortcuts', () => ({
+ NewModelShortcuts: () => <div data-testid={'new-model-shortcuts'} />,
+ }));
vi.doMock('../PortraitBubble', () => stub('portrait-bubble'));
vi.doMock('../AcceptancePortalDrawer', () => stub('acceptance-portal-drawer'));
+ vi.doMock('@/business/client/features/useHomePromoLine', () => ({
+ useHomePromoLine: vi.fn(() => promo),
+ }));
vi.doMock('@/features/HomeInbox', () => stub('home-inbox'));
function selectFromChatStore(selector: (state: unknown) => unknown) {
return selector({ portalViewType });
@@ -69,8 +85,10 @@ afterEach(() => {
vi.doUnmock('../HomeModeContent');
vi.doUnmock('../HomePortrait');
vi.doUnmock('../InputArea');
+ vi.doUnmock('../NewModelShortcuts');
vi.doUnmock('../PortraitBubble');
vi.doUnmock('../AcceptancePortalDrawer');
+ vi.doUnmock('@/business/client/features/useHomePromoLine');
vi.doUnmock('@/features/HomeInbox');
vi.doUnmock('@/store/chat');
vi.doUnmock('@/store/chat/selectors');
@@ -93,6 +111,14 @@ describe('Home portrait visibility', () => {
expect(screen.getByTestId('portrait-bubble')).toBeInTheDocument();
}, 20000);
+ it('shows a live promotion in the header without competing with the portrait bubble', async () => {
+ await renderHome({ promo: <span>Campaign</span> });
+
+ expect(screen.getByTestId('home-header-promo')).toHaveTextContent('Campaign');
+ expect(screen.getByTestId('home-portrait')).toBeInTheDocument();
+ expect(screen.queryByTestId('portrait-bubble')).not.toBeInTheDocument();
+ }, 20000);
+
it('takes the bubble down with the portrait when the preference is off', async () => {
await renderHome({ showHomePortrait: false });
@@ -113,6 +139,7 @@ describe('Home portrait visibility', () => {
expect(screen.getByTestId('home-input-area')).toHaveAttribute('data-mode', 'chat');
expect(screen.getByTestId('home-mode-content')).toHaveAttribute('data-mode', 'chat');
+ expect(screen.getByTestId('new-model-shortcuts')).toBeInTheDocument();
}, 20000);
it('opens the home dashboard in task mode for the post-onboarding entry', async () => {
@@ -120,6 +147,7 @@ describe('Home portrait visibility', () => {
expect(screen.getByTestId('home-input-area')).toHaveAttribute('data-mode', 'task');
expect(screen.getByTestId('home-mode-content')).toHaveAttribute('data-mode', 'task');
+ expect(screen.queryByTestId('new-model-shortcuts')).not.toBeInTheDocument();
expect(window.location.search).toBe('');
}, 20000);
diff --git a/src/features/Home/index.tsx b/src/features/Home/index.tsx
index 65392492140..4f95e885936 100644
--- a/src/features/Home/index.tsx
+++ b/src/features/Home/index.tsx
@@ -4,6 +4,7 @@ import { Flexbox } from '@lobehub/ui';
import { createStaticStyles, cx } from 'antd-style';
import { lazy, memo, Suspense, useCallback, useEffect, useState } from 'react';
+import { useHomePromoLine } from '@/business/client/features/useHomePromoLine';
import HomeInbox from '@/features/HomeInbox';
import { useChatStore } from '@/store/chat';
import { chatPortalSelectors } from '@/store/chat/selectors';
@@ -20,6 +21,7 @@ import HomeHeader from './HomeHeader';
import HomeModeContent from './HomeModeContent';
import HomePortrait from './HomePortrait';
import InputArea from './InputArea';
+import { NewModelShortcuts } from './NewModelShortcuts';
import PortraitBubble from './PortraitBubble';
import { RAIL_INBOX_PROPS, resolveRailVisibility } from './railVisibility';
import type { HomeMode } from './types';
@@ -297,6 +299,7 @@ const Home = memo(() => {
const showHomeRail = useGlobalStore(systemStatusSelectors.showHomeRail);
const showHomePortrait = useGlobalStore(systemStatusSelectors.showHomePortrait);
const hiddenWidgets = useGlobalStore(systemStatusSelectors.hiddenHomeWidgets);
+ const promo = useHomePromoLine();
const minimal = isHomeMinimalLayout({ hiddenWidgets, showPortrait: showHomePortrait });
const [mode, setMode] = useState<HomeMode>(() =>
resolveInitialHomeMode(typeof window === 'undefined' ? '' : window.location.search),
@@ -315,6 +318,7 @@ const Home = memo(() => {
const railVisible = resolveRailVisibility({ hiddenWidgets, isLogin, showHomeRail });
const railCollapsed = !railVisible;
const portraitVisible = Boolean(isLogin && showHomePortrait);
+ const promoVisible = Boolean(promo);
useEffect(() => {
clearOnboardingHomeModeParam();
@@ -354,9 +358,12 @@ const Home = memo(() => {
return (
<Flexbox className={styles.grid}>
<div className={cx(styles.header, styles.content, railCollapsed && styles.contentCollapsed)}>
- <HomeHeader />
- {/* The bubble is the portrait's line, so it goes wherever the portrait goes. */}
- {portraitVisible && (
+ <HomeHeader promo={promo} />
+ {/* A campaign and the Agent's brief are both sentence-like floating
+ content in the same attention lane. They take turns instead of
+ competing; dismissing or expiring the campaign hands the lane back
+ to the portrait without changing the campaign's Cloud-owned policy. */}
+ {portraitVisible && !promoVisible && (
<div className={cx(styles.bubbleSlot, railCollapsed && styles.bubbleSlotCollapsed)}>
<PortraitBubble />
</div>
@@ -374,14 +381,15 @@ const Home = memo(() => {
data-testid={'home-main'}
gap={24}
>
- <div className={styles.inputArea}>
+ <Flexbox className={styles.inputArea} gap={12}>
<InputArea
inputValue={inputValue}
mode={mode}
onInputValueChange={handleInputValueChange}
onModeChange={setMode}
/>
- </div>
+ {mode === 'chat' && <NewModelShortcuts />}
+ </Flexbox>
<HomeModeContent
inlineRail={railCollapsed && isLogin}
mode={mode}