🤯 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.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
✨ feat(home): add a Customize modal for the Home dashboard (#17912)
Innei9741b3321bc7
diff --git a/.agents/acceptance/probe-mock-patterns.md b/.agents/acceptance/probe-mock-patterns.mdindex b251bd2ea34..20d1d0c97b0 100644--- a/.agents/acceptance/probe-mock-patterns.md+++ b/.agents/acceptance/probe-mock-patterns.md@@ -172,20 +172,25 @@ Acceptance fixture through the local CLI, and capture the same route in separateauthenticated and storage-empty browser contexts. This proves both owner andshared-viewer rendering without depending on production browser cookies.-### The dev Electron main window runs the WEB entry — desktop-entry boot code is unverifiable in dev+### Which entry the dev Electron main window loads is NOT stable — measure it, never assume**Situation:** verifying anything that lives in `src/spa/entry.desktop.tsx` (bootstrapidentity, adapter registration, boot marks) on an `electron-dev.sh` instance.-**Doesn't work:** assuming the desktop instance loads the desktop entry. Measured on a-live dev instance, the **main window's entry script is `app://renderer/src/spa/entry.web.tsx`**,-while the **topicPopup window in the same instance correctly loads `entry.popup.tsx`**.-So Vite dev does resolve some MPA paths but the main window falls through to the root-`index.html`. (Mechanism not established — do not repeat the plausible-sounding-"`ViteRendererFallback` is a dumb proxy so everything falls back" explanation; the popup-result falsifies it.) Consequence: desktop-entry boot code never executes in dev, and a-deletion there passes every dev smoke test — which is exactly how one such call was lost-for a whole release.+**Doesn't work:** assuming any particular entry, in either direction. This has now been+measured with two different results on the same helper:++- Earlier: the main window's entry script was `app://renderer/src/spa/entry.web.tsx`+ while the topicPopup window in the same instance loaded `entry.popup.tsx` — so the+ main window fell through to the root `index.html`. Consequence at the time:+ desktop-entry boot code never executed in dev, and a deletion there passed every dev+ smoke test, which is how one such call was lost for a whole release.+- 2026-08-05, on `feat/home-customize-modal`: the main window loaded+ **`app://renderer/src/spa/entry.desktop.tsx`** — the fall-through did not reproduce.++Mechanism not established in either direction, and no bisect was done, so do not+assume the newer reading is permanent either. Treat the loaded entry as an unknown to+be measured per run — that is the durable rule; the specific value is not.**Works:** before claiming anything about a desktop entry, read the loaded entry scriptand branch on it:@@ -837,6 +842,7 @@ cache, so the renderer still shows the pre-write value (generic M18). Clear`lobechat-swr-cache*` + `lobehub-local-data` through`Page.addScriptToEvaluateOnNewDocument` and reload (see "Cold SWR cache" above),then assert `agentMap[id].agencyConfig` before drawing any conclusion.+### An unconverged lockfile puts two copies of a dep in the graph — every route using it dies at the ErrorBoundary**Situation:** after rebasing onto a canary that bumped a shared UI dependency anddiff --git a/locales/en-US/home.json b/locales/en-US/home.jsonindex 1cd3787ee71..d2f0a8749ba 100644--- a/locales/en-US/home.json+++ b/locales/en-US/home.json@@ -46,6 +46,23 @@"dashboard.chat.empty": "No recent conversations","dashboard.chat.recents": "Recent topics","dashboard.chat.running": "Running topics",+ "dashboard.customize.decrease": "Decrease {{label}}",+ "dashboard.customize.entry": "Customize",+ "dashboard.customize.group.decoration": "Decoration",+ "dashboard.customize.group.listSize": "List size",+ "dashboard.customize.group.sections": "Sections",+ "dashboard.customize.increase": "Increase {{label}}",+ "dashboard.customize.portrait.desc": "Show your agent portrait beside the top of Home.",+ "dashboard.customize.portrait.title": "Portrait decoration",+ "dashboard.customize.recents.count.title": "Recent threads",+ "dashboard.customize.reset": "Reset to defaults",+ "dashboard.customize.tasks.count.title": "Tasks",+ "dashboard.customize.title": "Customize Home",+ "dashboard.customize.widget.needsYou": "Needs you",+ "dashboard.customize.widget.news": "News",+ "dashboard.customize.widget.running": "Running",+ "dashboard.customize.widget.suggestions": "Suggestions",+ "dashboard.customize.widget.unread": "Unread","dashboard.empty.plan.description": "Break an outcome into clear next steps","dashboard.empty.plan.prompt": "Help me create a practical plan for:","dashboard.empty.plan.title": "Make a plan",diff --git a/locales/zh-CN/home.json b/locales/zh-CN/home.jsonindex d0016cbe27a..278ec1ee808 100644--- a/locales/zh-CN/home.json+++ b/locales/zh-CN/home.json@@ -46,6 +46,23 @@"dashboard.chat.empty": "暂无最近对话","dashboard.chat.recents": "最近话题","dashboard.chat.running": "正在运行",+ "dashboard.customize.decrease": "减少{{label}}",+ "dashboard.customize.entry": "自定义",+ "dashboard.customize.group.decoration": "装饰",+ "dashboard.customize.group.listSize": "列表条数",+ "dashboard.customize.group.sections": "区块",+ "dashboard.customize.increase": "增加{{label}}",+ "dashboard.customize.portrait.desc": "在首页顶部旁显示你的智能体形象。",+ "dashboard.customize.portrait.title": "形象装饰",+ "dashboard.customize.recents.count.title": "最近话题",+ "dashboard.customize.reset": "恢复默认",+ "dashboard.customize.tasks.count.title": "任务",+ "dashboard.customize.title": "自定义首页",+ "dashboard.customize.widget.needsYou": "需要你处理",+ "dashboard.customize.widget.news": "今日简报",+ "dashboard.customize.widget.running": "进行中",+ "dashboard.customize.widget.suggestions": "推荐",+ "dashboard.customize.widget.unread": "未读","dashboard.empty.plan.description": "把目标拆解为清晰、可执行的下一步","dashboard.empty.plan.prompt": "帮我为以下目标制定一份切实可行的计划:","dashboard.empty.plan.title": "制定计划",diff --git a/packages/locales/src/default/home.ts b/packages/locales/src/default/home.tsindex ee5f2423e64..b5a2a5fba95 100644--- a/packages/locales/src/default/home.ts+++ b/packages/locales/src/default/home.ts@@ -51,6 +51,23 @@ export default {'dashboard.chat.empty': 'No recent conversations','dashboard.chat.recents': 'Recent topics','dashboard.chat.running': 'Running topics',+ 'dashboard.customize.decrease': 'Decrease {{label}}',+ 'dashboard.customize.entry': 'Customize',+ 'dashboard.customize.group.decoration': 'Decoration',+ 'dashboard.customize.group.listSize': 'List size',+ 'dashboard.customize.group.sections': 'Sections',+ 'dashboard.customize.increase': 'Increase {{label}}',+ 'dashboard.customize.portrait.desc': 'Show your agent portrait beside the top of Home.',+ 'dashboard.customize.portrait.title': 'Portrait decoration',+ 'dashboard.customize.recents.count.title': 'Recent threads',+ 'dashboard.customize.reset': 'Reset to defaults',+ 'dashboard.customize.tasks.count.title': 'Tasks',+ 'dashboard.customize.title': 'Customize Home',+ 'dashboard.customize.widget.needsYou': 'Needs you',+ 'dashboard.customize.widget.news': 'News',+ 'dashboard.customize.widget.running': 'Running',+ 'dashboard.customize.widget.suggestions': 'Suggestions',+ 'dashboard.customize.widget.unread': 'Unread','dashboard.empty.plan.description': 'Break an outcome into clear next steps','dashboard.empty.plan.prompt': 'Help me create a practical plan for:','dashboard.empty.plan.title': 'Make a plan',diff --git a/src/features/Home/CustomizeButton.tsx b/src/features/Home/CustomizeButton.tsxnew file mode 100644index 00000000000..d93b7fde4ff--- /dev/null+++ b/src/features/Home/CustomizeButton.tsx@@ -0,0 +1,37 @@+import { Icon } from '@lobehub/ui';+import { Button } from '@lobehub/ui/base-ui';+import { createStaticStyles } from 'antd-style';+import { SlidersHorizontal } from 'lucide-react';+import { memo } from 'react';+import { useTranslation } from 'react-i18next';++import { openHomeCustomizeModal } from './CustomizeModal';++const styles = createStaticStyles(({ css }) => ({+ label: css`+ @media (width <= 1100px) {+ display: none;+ }+ `,+}));++const CustomizeButton = memo(() => {+ const { t } = useTranslation('home');+ const label = t('dashboard.customize.entry');++ return (+ <Button+ aria-label={label}+ icon={<Icon icon={SlidersHorizontal} size={14} />}+ shape={'round'}+ size={'small'}+ title={label}+ type={'fill'}+ onClick={() => openHomeCustomizeModal()}+ >+ <span className={styles.label}>{label}</span>+ </Button>+ );+});++export default CustomizeButton;diff --git a/src/features/Home/CustomizeModal/Content.tsx b/src/features/Home/CustomizeModal/Content.tsxnew file mode 100644index 00000000000..72805ff80ec--- /dev/null+++ b/src/features/Home/CustomizeModal/Content.tsx@@ -0,0 +1,140 @@+'use client';++import { ActionIcon, Flexbox, Text } from '@lobehub/ui';+import { Button, Switch, useModalContext } from '@lobehub/ui/base-ui';+import { createStaticStyles } from 'antd-style';+import { RotateCcw, XIcon } from 'lucide-react';+import { memo } from 'react';+import { useTranslation } from 'react-i18next';++import CountStepper from './components/CountStepper';+import SettingRow from './components/SettingRow';+import { HOME_COUNT_MAX, HOME_COUNT_MIN, HOME_WIDGET_KEYS } from './config';+import { useHomeCustomization } from './useHomeCustomization';++const styles = createStaticStyles(({ css, cssVar }) => ({+ body: css`+ overflow-y: auto;+ max-block-size: min(70vh, 560px);+ padding-block: 4px 20px;+ padding-inline: 20px;+ `,+ footer: css`+ padding-block: 12px;+ padding-inline: 12px 20px;+ border-block-start: 1px solid ${cssVar.colorBorderSecondary};+ `,+ header: css`+ padding-block: 16px 4px;+ padding-inline: 20px;+ `,+}));++const CustomizeModalContent = memo(() => {+ const { t } = useTranslation('home');+ const { close } = useModalContext();+ const {+ isWidgetHidden,+ recentsCount,+ reset,+ setRecentsCount,+ setTaskCount,+ showPortrait,+ taskCount,+ togglePortrait,+ toggleWidget,+ } = useHomeCustomization();++ return (+ <Flexbox>+ <Flexbox+ horizontal+ align={'center'}+ className={styles.header}+ gap={16}+ justify={'space-between'}+ >+ <Text as={'h2'} fontSize={16} weight={600}>+ {t('dashboard.customize.title')}+ </Text>+ <ActionIcon+ icon={XIcon}+ size={'small'}+ title={t('close', { ns: 'common' })}+ onClick={close}+ />+ </Flexbox>++ <Flexbox className={styles.body} gap={20}>+ <Flexbox gap={12}>+ <Text fontSize={12} type={'secondary'} weight={600}>+ {t('dashboard.customize.group.decoration')}+ </Text>+ <SettingRow+ description={t('dashboard.customize.portrait.desc')}+ title={t('dashboard.customize.portrait.title')}+ >+ <Switch+ aria-label={t('dashboard.customize.portrait.title')}+ checked={showPortrait}+ onChange={togglePortrait}+ />+ </SettingRow>+ </Flexbox>++ <Flexbox gap={12}>+ <Text fontSize={12} type={'secondary'} weight={600}>+ {t('dashboard.customize.group.sections')}+ </Text>+ {HOME_WIDGET_KEYS.map((key) => (+ <SettingRow key={key} title={t(`dashboard.customize.widget.${key}`)}>+ <Switch+ aria-label={t(`dashboard.customize.widget.${key}`)}+ checked={!isWidgetHidden(key)}+ onChange={() => toggleWidget(key)}+ />+ </SettingRow>+ ))}+ </Flexbox>++ <Flexbox gap={12}>+ <Text fontSize={12} type={'secondary'} weight={600}>+ {t('dashboard.customize.group.listSize')}+ </Text>+ <SettingRow title={t('dashboard.customize.recents.count.title')}>+ <CountStepper+ label={t('dashboard.customize.recents.count.title')}+ max={HOME_COUNT_MAX}+ min={HOME_COUNT_MIN}+ value={recentsCount}+ onChange={setRecentsCount}+ />+ </SettingRow>+ <SettingRow title={t('dashboard.customize.tasks.count.title')}>+ <CountStepper+ label={t('dashboard.customize.tasks.count.title')}+ max={HOME_COUNT_MAX}+ min={HOME_COUNT_MIN}+ value={taskCount}+ onChange={setTaskCount}+ />+ </SettingRow>+ </Flexbox>+ </Flexbox>++ <Flexbox horizontal align={'center'} className={styles.footer}>+ <Button+ htmlType={'button'}+ icon={<RotateCcw size={14} />}+ size={'small'}+ type={'text'}+ onClick={reset}+ >+ {t('dashboard.customize.reset')}+ </Button>+ </Flexbox>+ </Flexbox>+ );+});++export default CustomizeModalContent;diff --git a/src/features/Home/CustomizeModal/components/CountStepper.tsx b/src/features/Home/CustomizeModal/components/CountStepper.tsxnew file mode 100644index 00000000000..5a9d7684a7f--- /dev/null+++ b/src/features/Home/CustomizeModal/components/CountStepper.tsx@@ -0,0 +1,50 @@+'use client';++import { ActionIcon, Flexbox, Text } from '@lobehub/ui';+import { createStaticStyles } from 'antd-style';+import { MinusIcon, PlusIcon } from 'lucide-react';+import { memo } from 'react';+import { useTranslation } from 'react-i18next';++export interface CountStepperProps {+ label: string;+ max: number;+ min: number;+ onChange: (value: number) => void;+ value: number;+}++const styles = createStaticStyles(({ css }) => ({+ value: css`+ width: 20px;+ text-align: center;+ `,+}));++const CountStepper = memo<CountStepperProps>(({ label, value, min, max, onChange }) => {+ const { t } = useTranslation('home');++ return (+ <Flexbox horizontal align={'center'} gap={8}>+ <ActionIcon+ aria-label={t('dashboard.customize.decrease', { label })}+ disabled={value <= min}+ icon={MinusIcon}+ size={'small'}+ onClick={() => onChange(value - 1)}+ />+ <Text aria-label={label} aria-live={'polite'} className={styles.value} weight={500}>+ {value}+ </Text>+ <ActionIcon+ aria-label={t('dashboard.customize.increase', { label })}+ disabled={value >= max}+ icon={PlusIcon}+ size={'small'}+ onClick={() => onChange(value + 1)}+ />+ </Flexbox>+ );+});++export default CountStepper;diff --git a/src/features/Home/CustomizeModal/components/SettingRow.tsx b/src/features/Home/CustomizeModal/components/SettingRow.tsxnew file mode 100644index 00000000000..2b859620297--- /dev/null+++ b/src/features/Home/CustomizeModal/components/SettingRow.tsx@@ -0,0 +1,28 @@+'use client';++import { Flexbox, Text } from '@lobehub/ui';+import { memo, type ReactNode } from 'react';++export interface SettingRowProps {+ children?: ReactNode;+ description?: ReactNode;+ title: ReactNode;+}++const SettingRow = memo<SettingRowProps>(({ title, description, children }) => {+ return (+ <Flexbox horizontal align={'center'} gap={16} justify={'space-between'}>+ <Flexbox allowShrink gap={2}>+ <Text weight={500}>{title}</Text>+ {description && (+ <Text fontSize={13} type={'secondary'}>+ {description}+ </Text>+ )}+ </Flexbox>+ {children}+ </Flexbox>+ );+});++export default SettingRow;diff --git a/src/features/Home/CustomizeModal/config.ts b/src/features/Home/CustomizeModal/config.tsnew file mode 100644index 00000000000..3398e4d0fc1--- /dev/null+++ b/src/features/Home/CustomizeModal/config.ts@@ -0,0 +1,32 @@+export const HOME_WIDGET_KEYS = ['needsYou', 'unread', 'running', 'news', 'suggestions'] as const;++export type HomeWidgetKey = (typeof HOME_WIDGET_KEYS)[number];++export const HOME_CUSTOMIZE_DEFAULTS = {+ hiddenHomeWidgets: [] as string[],+ homeRecentsCount: 8,+ homeTaskCount: 8,+ showHomePortrait: true,+};++export const HOME_COUNT_MIN = 3;+export const HOME_COUNT_MAX = 15;++// An error banner covers every widget whose content it reports on, not just the+// one it is named after: the topic feed powers unread AND running, and the briefs+// fetch powers needsYou AND news. Narrowing either pair back to one key lets a+// hidden widget silence a failure that explains the other's absence.+const HOME_SECTION_WIDGET_COVERAGE: Record<string, HomeWidgetKey[]> = {+ 'needsYou': ['needsYou'],+ 'needsYou-error': ['needsYou', 'news'],+ 'needsYou-loading': ['needsYou'],+ 'news': ['news'],+ 'running': ['running'],+ 'topics-error': ['unread', 'running'],+ 'unread': ['unread'],+};++export const isWidgetSectionVisible = (sectionKey: string, hidden: string[]): boolean => {+ const covered = HOME_SECTION_WIDGET_COVERAGE[sectionKey];+ return !covered || covered.some((widget) => !hidden.includes(widget));+};diff --git a/src/features/Home/CustomizeModal/index.tsx b/src/features/Home/CustomizeModal/index.tsxnew file mode 100644index 00000000000..ac6491af836--- /dev/null+++ b/src/features/Home/CustomizeModal/index.tsx@@ -0,0 +1,17 @@+'use client';++import { createModal, type ModalInstance } from '@lobehub/ui/base-ui';++import CustomizeModalContent from './Content';++export const openHomeCustomizeModal = (): ModalInstance =>+ createModal({+ content: <CustomizeModalContent />,+ footer: null,+ maskClosable: true,+ styles: {+ content: { padding: 0 },+ },+ title: null,+ width: 'min(92vw, 460px)',+ });diff --git a/src/features/Home/CustomizeModal/useHomeCustomization.test.ts b/src/features/Home/CustomizeModal/useHomeCustomization.test.tsnew file mode 100644index 00000000000..ea1268b1caf--- /dev/null+++ b/src/features/Home/CustomizeModal/useHomeCustomization.test.ts@@ -0,0 +1,60 @@+import { describe, expect, it } from 'vitest';++import { isWidgetSectionVisible } from './config';+import { clampHomeCount, toggleHiddenWidget } from './useHomeCustomization';++describe('toggleHiddenWidget', () => {+ it('hides a visible widget', () => {+ expect(toggleHiddenWidget([], 'news')).toEqual(['news']);+ });++ it('shows a hidden widget', () => {+ expect(toggleHiddenWidget(['news'], 'news')).toEqual([]);+ });++ it('preserves other hidden widgets', () => {+ const result = toggleHiddenWidget(['news'], 'unread');+ expect(result).toContain('news');+ expect(result).toContain('unread');+ });+});++describe('clampHomeCount', () => {+ it('clamps below the minimum', () => {+ expect(clampHomeCount(2)).toBe(3);+ });++ it('clamps above the maximum', () => {+ expect(clampHomeCount(20)).toBe(15);+ });++ it('keeps an in-range value unchanged', () => {+ expect(clampHomeCount(8)).toBe(8);+ });+});++describe('isWidgetSectionVisible', () => {+ it('hides a loading section governed by a hidden widget', () => {+ expect(isWidgetSectionVisible('needsYou-loading', ['needsYou'])).toBe(false);+ });++ it('keeps the topic error banner while running still needs it', () => {+ expect(isWidgetSectionVisible('topics-error', ['unread'])).toBe(true);+ });++ it('hides the topic error banner only once unread and running are both hidden', () => {+ expect(isWidgetSectionVisible('topics-error', ['unread', 'running'])).toBe(false);+ });++ it('keeps the briefs error banner while news still needs it', () => {+ expect(isWidgetSectionVisible('needsYou-error', ['needsYou'])).toBe(true);+ });++ it('hides the briefs error banner only once needs-you and news are both hidden', () => {+ expect(isWidgetSectionVisible('needsYou-error', ['needsYou', 'news'])).toBe(false);+ });++ it('keeps an unmapped section visible', () => {+ expect(isWidgetSectionVisible('unknown-section', ['unread'])).toBe(true);+ });+});diff --git a/src/features/Home/CustomizeModal/useHomeCustomization.ts b/src/features/Home/CustomizeModal/useHomeCustomization.tsnew file mode 100644index 00000000000..8d93b70342a--- /dev/null+++ b/src/features/Home/CustomizeModal/useHomeCustomization.ts@@ -0,0 +1,88 @@+import { useCallback } from 'react';++import { useGlobalStore } from '@/store/global';+import { systemStatusSelectors } from '@/store/global/selectors';++import {+ HOME_COUNT_MAX,+ HOME_COUNT_MIN,+ HOME_CUSTOMIZE_DEFAULTS,+ type HomeWidgetKey,+} from './config';++export const toggleHiddenWidget = (hidden: string[], key: HomeWidgetKey): string[] =>+ hidden.includes(key) ? hidden.filter((item) => item !== key) : [...hidden, key];++export const clampHomeCount = (value: number): number =>+ Math.min(HOME_COUNT_MAX, Math.max(HOME_COUNT_MIN, value));++interface HomeCustomization {+ hiddenWidgets: string[];+ isWidgetHidden: (key: HomeWidgetKey) => boolean;+ recentsCount: number;+ reset: () => void;+ setRecentsCount: (value: number) => void;+ setTaskCount: (value: number) => void;+ showPortrait: boolean;+ taskCount: number;+ togglePortrait: () => void;+ toggleWidget: (key: HomeWidgetKey) => void;+}++export const useHomeCustomization = (): HomeCustomization => {+ const hiddenWidgets = useGlobalStore(systemStatusSelectors.hiddenHomeWidgets);+ const recentsCount = useGlobalStore(systemStatusSelectors.homeRecentsCount);+ const taskCount = useGlobalStore(systemStatusSelectors.homeTaskCount);+ const showPortrait = useGlobalStore(systemStatusSelectors.showHomePortrait);+ const updateSystemStatus = useGlobalStore((s) => s.updateSystemStatus);++ const toggleWidget = useCallback(+ (key: HomeWidgetKey) => {+ updateSystemStatus(+ { hiddenHomeWidgets: toggleHiddenWidget(hiddenWidgets, key) },+ 'homeCustomize',+ );+ },+ [hiddenWidgets, updateSystemStatus],+ );++ const togglePortrait = useCallback(() => {+ updateSystemStatus({ showHomePortrait: !showPortrait }, 'homeCustomize');+ }, [showPortrait, updateSystemStatus]);++ const setRecentsCount = useCallback(+ (value: number) => {+ updateSystemStatus({ homeRecentsCount: clampHomeCount(value) }, 'homeCustomize');+ },+ [updateSystemStatus],+ );++ const setTaskCount = useCallback(+ (value: number) => {+ updateSystemStatus({ homeTaskCount: clampHomeCount(value) }, 'homeCustomize');+ },+ [updateSystemStatus],+ );++ const reset = useCallback(() => {+ updateSystemStatus(HOME_CUSTOMIZE_DEFAULTS, 'homeCustomize');+ }, [updateSystemStatus]);++ const isWidgetHidden = useCallback(+ (key: HomeWidgetKey) => hiddenWidgets.includes(key),+ [hiddenWidgets],+ );++ return {+ hiddenWidgets,+ isWidgetHidden,+ recentsCount,+ reset,+ setRecentsCount,+ setTaskCount,+ showPortrait,+ taskCount,+ toggleWidget,+ togglePortrait,+ };+};diff --git a/src/features/Home/HomeModeContent.tsx b/src/features/Home/HomeModeContent.tsxindex e2868acdaf8..be7a5f67017 100644--- a/src/features/Home/HomeModeContent.tsx+++ b/src/features/Home/HomeModeContent.tsx@@ -27,6 +27,8 @@ import { type RecentItem } from '@/server/routers/lambda/recent';import { recentService } from '@/services/recent';import { useBriefStore } from '@/store/brief';import { briefListSelectors } from '@/store/brief/selectors';+import { useGlobalStore } from '@/store/global';+import { systemStatusSelectors } from '@/store/global/selectors';import { useTaskStore } from '@/store/task';import { taskListSelectors } from '@/store/task/selectors';import { useUserStore } from '@/store/user';@@ -109,7 +111,10 @@ const TASK_STATUSES = new Set<TaskStatus>(['running','scheduled',]);-const HOME_TOPIC_RECENT_LIMIT = 9;+export const HOME_TOPIC_RECENT_LIMIT = 15;++export const resolveRecentsBadgeCount = (fetched: number, shown: number): number | undefined =>+ Math.min(fetched, shown) || undefined;const normalizeTaskStatus = (status: string): TaskStatus =>TASK_STATUSES.has(status as TaskStatus) ? (status as TaskStatus) : 'backlog';@@ -240,10 +245,12 @@ const TaskContent = memo(() => {// filter. It must always show the complete task set.const tasksSWR = useFetchTaskList({ allAgents: true, visibility: 'all' });const tasks = useTaskStore(taskListSelectors.taskList);+ const tasksTotal = useTaskStore(taskListSelectors.taskListTotal);const tasksInit = useTaskStore(taskListSelectors.isTaskListInit);+ const taskCount = useGlobalStore(systemStatusSelectors.homeTaskCount);return (- <GroupBlock count={tasks.length || undefined} title={t('dashboard.task.title')}>+ <GroupBlock count={tasksTotal || undefined} title={t('dashboard.task.title')}>{tasksSWR.error && !tasksInit ? (<AsyncError error={tasksSWR.error} variant={'inline'} onRetry={tasksSWR.mutate} />) : !tasksInit ? (@@ -252,7 +259,7 @@ const TaskContent = memo(() => {<Text className={styles.empty}>{t('dashboard.task.empty')}</Text>) : (<Flexbox gap={4}>- {tasks.slice(0, 8).map((task) => (+ {tasks.slice(0, taskCount).map((task) => (<Rowdescription={task.description || task.identifier}href={taskDetailPath(task.identifier)}@@ -272,6 +279,7 @@ const HomeModeContent = memo<HomeModeContentProps>(({ inlineRail, mode, onSuggesconst isLogin = useUserStore(authSelectors.isLogin);const authLoaded = useUserStore(authSelectors.isLoaded);const myId = useUserStore(userProfileSelectors.userId);+ const recentsCount = useGlobalStore(systemStatusSelectors.homeRecentsCount);const cacheScope = useCacheScope();// One page-level mine/team scope, shared by the inbox sections and Recent@@ -351,7 +359,7 @@ const HomeModeContent = memo<HomeModeContentProps>(({ inlineRail, mode, onSugges{(state !== 'ready' || topicRecents.length > 0) && (<GroupBlockactionAlwaysVisible- count={topicRecents.length || undefined}+ count={resolveRecentsBadgeCount(topicRecents.length, recentsCount)}title={t('dashboard.chat.recents')}action={isTeam ? (@@ -373,7 +381,7 @@ const HomeModeContent = memo<HomeModeContentProps>(({ inlineRail, mode, onSugges<LoadingRows withTime />) : (<Flexbox gap={4}>- {topicRecents.slice(0, 8).map((item) => (+ {topicRecents.slice(0, recentsCount).map((item) => (<RecentTopicRow key={item.id} showAuthor={teamView} topic={item} />))}</Flexbox>diff --git a/src/features/Home/HomeNavHeader.tsx b/src/features/Home/HomeNavHeader.tsxindex 02321f6908f..d33d121b62f 100644--- a/src/features/Home/HomeNavHeader.tsx+++ b/src/features/Home/HomeNavHeader.tsx@@ -1,3 +1,4 @@+import { Flexbox } from '@lobehub/ui';import { createStaticStyles } from 'antd-style';import { memo } from 'react';@@ -7,7 +8,9 @@ import { systemStatusSelectors } from '@/store/global/selectors';import { useUserStore } from '@/store/user';import { authSelectors } from '@/store/user/slices/auth/selectors';+import CustomizeButton from './CustomizeButton';import RailToggle from './RailToggle';+import { canHostRail } from './railVisibility';// Floats over the dashboard instead of pushing it down: the controls live in// the page's top corners, where the content never reaches.@@ -27,13 +30,19 @@ const HomeNavHeader = memo(() => {s.toggleHomeRail,systemStatusSelectors.isStatusInit(s),]);+ const hiddenWidgets = useGlobalStore(systemStatusSelectors.hiddenHomeWidgets);return (<NavHeaderclassName={styles.header}right={isLogin && isStatusInit ? (- <RailToggle railVisible={showHomeRail} onToggle={toggleHomeRail} />+ <Flexbox horizontal align={'center'} gap={4}>+ <CustomizeButton />+ {canHostRail(hiddenWidgets) && (+ <RailToggle railVisible={showHomeRail} onToggle={toggleHomeRail} />+ )}+ </Flexbox>) : undefined}/>diff --git a/src/features/Home/__tests__/homeTopicRecentLimit.test.ts b/src/features/Home/__tests__/homeTopicRecentLimit.test.tsnew file mode 100644index 00000000000..619556d53e6--- /dev/null+++ b/src/features/Home/__tests__/homeTopicRecentLimit.test.ts@@ -0,0 +1,27 @@+import { describe, expect, it } from 'vitest';++import { HOME_COUNT_MAX, HOME_CUSTOMIZE_DEFAULTS } from '../CustomizeModal/config';+import { HOME_TOPIC_RECENT_LIMIT, resolveRecentsBadgeCount } from '../HomeModeContent';++describe('HOME_TOPIC_RECENT_LIMIT', () => {+ it('fetches the stepper max as a fixed constant, independent of the homeRecentsCount preference', () => {+ expect(HOME_TOPIC_RECENT_LIMIT).toBe(HOME_COUNT_MAX);+ expect(HOME_TOPIC_RECENT_LIMIT).toBe(15);+ });+});++describe('resolveRecentsBadgeCount', () => {+ it('counts the rows the list shows, not the larger set the page fetched', () => {+ expect(+ resolveRecentsBadgeCount(HOME_TOPIC_RECENT_LIMIT, HOME_CUSTOMIZE_DEFAULTS.homeRecentsCount),+ ).toBe(HOME_CUSTOMIZE_DEFAULTS.homeRecentsCount);+ });++ it('counts what arrived when the fetch returns fewer than the preference', () => {+ expect(resolveRecentsBadgeCount(3, 8)).toBe(3);+ });++ it('drops the badge when there is nothing to count', () => {+ expect(resolveRecentsBadgeCount(0, 8)).toBeUndefined();+ });+});diff --git a/src/features/Home/__tests__/portraitVisibility.test.tsx b/src/features/Home/__tests__/portraitVisibility.test.tsxnew file mode 100644index 00000000000..ed002a7b1ff--- /dev/null+++ b/src/features/Home/__tests__/portraitVisibility.test.tsx@@ -0,0 +1,95 @@+import { cleanup, render, screen } from '@testing-library/react';+import { afterEach, describe, expect, it, vi } from 'vitest';++interface RenderHomeOptions {+ isLogin?: boolean;+ showHomePortrait?: boolean;+}++const stub = (testId: string) => ({ default: () => <div data-testid={testId} /> });++function translate() {+ return { i18n: { language: 'en-US' }, t: (key: string) => key };+}++const renderHome = async ({ isLogin = true, showHomePortrait }: RenderHomeOptions = {}) => {+ vi.resetModules();++ vi.doMock('react-i18next', () => ({ useTranslation: translate }));+ vi.doMock('../HomeHeader', () => stub('home-header'));+ vi.doMock('../HomeModeContent', () => stub('home-mode-content'));+ vi.doMock('../HomePortrait', () => stub('home-portrait'));+ vi.doMock('../InputArea', () => stub('home-input-area'));+ vi.doMock('../PortraitBubble', () => stub('portrait-bubble'));+ vi.doMock('@/features/HomeInbox', () => stub('home-inbox'));+ vi.doMock('@/store/chat', () => ({+ useChatStore: {+ getState: () => ({ mainInputEditor: undefined }),+ setState: vi.fn(),+ },+ }));+ function selectFromGlobalStore(selector: (state: unknown) => unknown) {+ return selector({ status: { showHomePortrait } });+ }+ vi.doMock('@/store/global', () => ({ useGlobalStore: selectFromGlobalStore }));+ function selectFromUserStore(selector: (state: unknown) => unknown) {+ return selector({ isSignedIn: isLogin });+ }+ vi.doMock('@/store/user', () => ({ useUserStore: selectFromUserStore }));++ const { default: Home } = await import('../index');++ render(<Home />);+};++afterEach(() => {+ cleanup();+ vi.doUnmock('react-i18next');+ vi.doUnmock('../HomeHeader');+ vi.doUnmock('../HomeModeContent');+ vi.doUnmock('../HomePortrait');+ vi.doUnmock('../InputArea');+ vi.doUnmock('../PortraitBubble');+ vi.doUnmock('@/features/HomeInbox');+ vi.doUnmock('@/store/chat');+ vi.doUnmock('@/store/global');+ vi.doUnmock('@/store/user');+});++describe('Home portrait visibility', () => {+ it('shows the portrait and its bubble by default for a signed-in viewer', async () => {+ await renderHome();++ expect(screen.getByTestId('home-portrait')).toBeInTheDocument();+ expect(screen.getByTestId('portrait-bubble')).toBeInTheDocument();+ }, 20000);++ it('keeps the portrait when the preference is explicitly on', async () => {+ await renderHome({ showHomePortrait: true });++ expect(screen.getByTestId('home-portrait')).toBeInTheDocument();+ expect(screen.getByTestId('portrait-bubble')).toBeInTheDocument();+ }, 20000);++ it('takes the bubble down with the portrait when the preference is off', async () => {+ await renderHome({ showHomePortrait: false });++ expect(screen.queryByTestId('home-portrait')).not.toBeInTheDocument();+ expect(screen.queryByTestId('portrait-bubble')).not.toBeInTheDocument();+ }, 20000);++ it('leaves the rest of the dashboard standing without the portrait', async () => {+ await renderHome({ showHomePortrait: false });++ expect(screen.getByTestId('home-header')).toBeInTheDocument();+ expect(screen.getByTestId('home-main')).toBeInTheDocument();+ expect(screen.getByTestId('home-rail')).toBeInTheDocument();+ }, 20000);++ it('shows no portrait to a signed-out visitor even with the preference on', async () => {+ await renderHome({ isLogin: false, showHomePortrait: true });++ expect(screen.queryByTestId('home-portrait')).not.toBeInTheDocument();+ expect(screen.queryByTestId('portrait-bubble')).not.toBeInTheDocument();+ }, 20000);+});diff --git a/src/features/Home/index.tsx b/src/features/Home/index.tsxindex 39a570114d3..5e3ddc16f7b 100644--- a/src/features/Home/index.tsx+++ b/src/features/Home/index.tsx@@ -16,6 +16,7 @@ import HomeModeContent from './HomeModeContent';import HomePortrait from './HomePortrait';import InputArea from './InputArea';import PortraitBubble from './PortraitBubble';+import { RAIL_INBOX_PROPS, resolveRailVisibility } from './railVisibility';import type { HomeMode } from './types';/** Trailing gutter that keeps the rail's cards off the page's scroll lane. */@@ -233,10 +234,13 @@ const styles = createStaticStyles(({ css }) => ({const Home = memo(() => {const isLogin = useUserStore(authSelectors.isLogin);const showHomeRail = useGlobalStore(systemStatusSelectors.showHomeRail);+ const showHomePortrait = useGlobalStore(systemStatusSelectors.showHomePortrait);+ const hiddenWidgets = useGlobalStore(systemStatusSelectors.hiddenHomeWidgets);const [mode, setMode] = useState<HomeMode>('chat');const [inputValue, setInputValue] = useState('');- const railVisible = Boolean(isLogin && showHomeRail);+ const railVisible = resolveRailVisibility({ hiddenWidgets, isLogin, showHomeRail });const railCollapsed = !railVisible;+ const portraitVisible = Boolean(isLogin && showHomePortrait);const handleInputValueChange = useCallback((value: string) => {setInputValue(value);@@ -258,15 +262,15 @@ const Home = memo(() => {<Flexbox className={styles.grid}><div className={cx(styles.header, styles.content, railCollapsed && styles.contentCollapsed)}><HomeHeader />- {/* No portrait for signed-out visitors, so no one to speak the line. */}- {isLogin && (+ {/* The bubble is the portrait's line, so it goes wherever the portrait goes. */}+ {portraitVisible && (<div className={cx(styles.bubbleSlot, railCollapsed && styles.bubbleSlotCollapsed)}><PortraitBubble /></div>)}</div>- {isLogin && (+ {portraitVisible && (<div className={cx(styles.portrait, railCollapsed && styles.portraitCollapsed)}><HomePortrait /></div>@@ -301,7 +305,7 @@ const Home = memo(() => {id={'home-rail'}inert={railCollapsed}>- <HomeInbox hideNeedsYou hideUnread variant={'rail'} />+ <HomeInbox {...RAIL_INBOX_PROPS} variant={'rail'} /></aside>)}</Flexbox>diff --git a/src/features/Home/railVisibility.test.ts b/src/features/Home/railVisibility.test.tsnew file mode 100644index 00000000000..a4fedee8145--- /dev/null+++ b/src/features/Home/railVisibility.test.ts@@ -0,0 +1,57 @@+import { canHostRail, RAIL_INBOX_PROPS, resolveRailVisibility } from './railVisibility';++const signedIn = { isLogin: true, showHomeRail: true };++describe('resolveRailVisibility', () => {+ it('shows the rail to a signed-in viewer who has kept the preference on', () => {+ expect(resolveRailVisibility({ ...signedIn, hiddenWidgets: [] })).toBe(true);+ });++ it('hides the rail from a signed-out visitor', () => {+ expect(resolveRailVisibility({ hiddenWidgets: [], isLogin: false, showHomeRail: true })).toBe(+ false,+ );+ });++ it('hides the rail when the viewer collapsed it', () => {+ expect(resolveRailVisibility({ hiddenWidgets: [], isLogin: true, showHomeRail: false })).toBe(+ false,+ );+ });++ it('keeps the rail while one of the widgets it hosts is still on', () => {+ expect(resolveRailVisibility({ ...signedIn, hiddenWidgets: ['news', 'suggestions'] })).toBe(+ true,+ );+ });++ it('hides the rail once every widget it hosts is off, even with the preference on', () => {+ expect(+ resolveRailVisibility({ ...signedIn, hiddenWidgets: ['running', 'news', 'suggestions'] }),+ ).toBe(false);+ });++ it('does not let needs-you or unread keep the rail alive, since it never renders them', () => {+ expect(+ resolveRailVisibility({+ ...signedIn,+ hiddenWidgets: ['running', 'news', 'suggestions'],+ }),+ ).toBe(false);+ expect(RAIL_INBOX_PROPS).toEqual({ hideNeedsYou: true, hideUnread: true });+ });+});++describe('canHostRail', () => {+ it('answers only the widget question, so the toggle survives a collapsed rail', () => {+ expect(canHostRail([])).toBe(true);+ });++ it('goes false exactly when the rail has no widget left to show', () => {+ expect(canHostRail(['running', 'news', 'suggestions'])).toBe(false);+ });++ it('stays true while needs-you and unread are the only ones off', () => {+ expect(canHostRail(['needsYou', 'unread'])).toBe(true);+ });+});diff --git a/src/features/Home/railVisibility.ts b/src/features/Home/railVisibility.tsnew file mode 100644index 00000000000..f5988c180c6--- /dev/null+++ b/src/features/Home/railVisibility.ts@@ -0,0 +1,18 @@+import { hasVisibleRailWidget } from '@/features/HomeInbox/hiddenWidgets';++export const RAIL_INBOX_PROPS = { hideNeedsYou: true, hideUnread: true } as const;++interface RailVisibilityInput {+ hiddenWidgets: string[];+ isLogin?: boolean | null;+ showHomeRail?: boolean;+}++export const canHostRail = (hiddenWidgets: string[]): boolean =>+ hasVisibleRailWidget({ ...RAIL_INBOX_PROPS, hiddenWidgets });++export const resolveRailVisibility = ({+ hiddenWidgets,+ isLogin,+ showHomeRail,+}: RailVisibilityInput): boolean => Boolean(isLogin && showHomeRail && canHostRail(hiddenWidgets));diff --git a/src/features/HomeInbox/hiddenWidgets.test.ts b/src/features/HomeInbox/hiddenWidgets.test.tsnew file mode 100644index 00000000000..0801637e8d3--- /dev/null+++ b/src/features/HomeInbox/hiddenWidgets.test.ts@@ -0,0 +1,166 @@+import { describe, expect, it } from 'vitest';++import { filterHiddenWidgetSections, hasVisibleRailWidget } from './hiddenWidgets';+import { resolveInboxScopeToggleSection } from './scopeTogglePlacement';++const assembled = [+ { key: 'needsYou' },+ { key: 'topics-error' },+ { key: 'unread' },+ { key: 'running' },+ { key: 'news' },+];++const keysOf = (sections: { key: string }[]) => sections.map(({ key }) => key);++describe('filterHiddenWidgetSections', () => {+ it('keeps every assembled section when nothing is hidden', () => {+ expect(filterHiddenWidgetSections(assembled, [])).toEqual(assembled);+ });++ it('drops the needs-you section and its loading placeholder, but not its error banner', () => {+ const sections = [...assembled, { key: 'needsYou-error' }, { key: 'needsYou-loading' }];++ expect(keysOf(filterHiddenWidgetSections(sections, ['needsYou']))).toEqual([+ 'topics-error',+ 'unread',+ 'running',+ 'news',+ 'needsYou-error',+ ]);+ });++ it('drops the briefs error banner once news is hidden alongside needs-you', () => {+ const sections = [...assembled, { key: 'needsYou-error' }];++ expect(keysOf(filterHiddenWidgetSections(sections, ['needsYou', 'news']))).toEqual([+ 'topics-error',+ 'unread',+ 'running',+ ]);+ });++ it('keeps the topic error banner when only unread is hidden, since running shares the feed', () => {+ expect(keysOf(filterHiddenWidgetSections(assembled, ['unread']))).toEqual([+ 'needsYou',+ 'topics-error',+ 'running',+ 'news',+ ]);+ });++ it('drops the topic error banner once running is hidden alongside unread', () => {+ expect(keysOf(filterHiddenWidgetSections(assembled, ['unread', 'running']))).toEqual([+ 'needsYou',+ 'news',+ ]);+ });++ it('empties the inbox when every widget is hidden', () => {+ expect(+ filterHiddenWidgetSections(assembled, ['needsYou', 'unread', 'running', 'news']),+ ).toEqual([]);+ });+});++describe('hasVisibleRailWidget', () => {+ const railColumn = { hideNeedsYou: true, hideUnread: true };++ it('keeps the rail while nothing is hidden', () => {+ expect(hasVisibleRailWidget({ ...railColumn, hiddenWidgets: [] })).toBe(true);+ });++ it('keeps the rail while one of the widgets it hosts is still on', () => {+ expect(hasVisibleRailWidget({ ...railColumn, hiddenWidgets: ['running', 'news'] })).toBe(true);+ });++ it('drops the rail once every widget it hosts is off, ignoring the ones it never shows', () => {+ expect(+ hasVisibleRailWidget({ ...railColumn, hiddenWidgets: ['running', 'news', 'suggestions'] }),+ ).toBe(false);+ });++ it('drops the rail when every widget is off', () => {+ expect(+ hasVisibleRailWidget({+ ...railColumn,+ hiddenWidgets: ['needsYou', 'unread', 'running', 'news', 'suggestions'],+ }),+ ).toBe(false);+ });++ it('keeps a column that hosts needs-you and unread on the same hidden set', () => {+ expect(hasVisibleRailWidget({ hiddenWidgets: ['running', 'news', 'suggestions'] })).toBe(true);+ });+});++describe('resolveInboxScopeToggleSection', () => {+ const populated = { needsYouCount: 2, runningCount: 1, unreadCount: 3 };++ it('keeps the scope toggle on needs-you while that widget is visible', () => {+ expect(resolveInboxScopeToggleSection({ ...populated, hiddenWidgets: [] })).toBe('needsYou');+ });++ it('moves the scope toggle to unread when needs-you is hidden', () => {+ expect(resolveInboxScopeToggleSection({ ...populated, hiddenWidgets: ['needsYou'] })).toBe(+ 'unread',+ );+ });++ it('falls through to running when both leading widgets are hidden', () => {+ expect(+ resolveInboxScopeToggleSection({ ...populated, hiddenWidgets: ['needsYou', 'unread'] }),+ ).toBe('running');+ });++ it('gives up the scope toggle only once every host widget is hidden', () => {+ expect(+ resolveInboxScopeToggleSection({+ ...populated,+ hiddenWidgets: ['needsYou', 'unread', 'running'],+ }),+ ).toBeNull();+ });++ it('suppresses a section through the task-mode props as well as the hidden set', () => {+ expect(+ resolveInboxScopeToggleSection({+ ...populated,+ hiddenWidgets: [],+ hideNeedsYou: true,+ hideUnread: true,+ }),+ ).toBe('running');+ });++ it('still leads with unread in the main column when needs-you is hidden', () => {+ expect(+ resolveInboxScopeToggleSection({+ ...populated,+ hiddenWidgets: ['needsYou'],+ preferUnread: true,+ }),+ ).toBe('unread');+ });++ it('skips a hidden unread widget even when the main column prefers it', () => {+ expect(+ resolveInboxScopeToggleSection({+ ...populated,+ hiddenWidgets: ['unread'],+ preferUnread: true,+ }),+ ).toBe('needsYou');+ });++ it('skips sections with nothing in them and lands on the one that has content', () => {+ expect(+ resolveInboxScopeToggleSection({+ hiddenWidgets: [],+ needsYouCount: 0,+ runningCount: 0,+ unreadCount: 4,+ }),+ ).toBe('unread');+ });+});diff --git a/src/features/HomeInbox/hiddenWidgets.ts b/src/features/HomeInbox/hiddenWidgets.tsnew file mode 100644index 00000000000..e25ea01bc26--- /dev/null+++ b/src/features/HomeInbox/hiddenWidgets.ts@@ -0,0 +1,24 @@+import { HOME_WIDGET_KEYS, isWidgetSectionVisible } from '@/features/Home/CustomizeModal/config';++export const filterHiddenWidgetSections = <T extends { key: string }>(+ sections: T[],+ hiddenWidgets: string[],+): T[] => sections.filter(({ key }) => isWidgetSectionVisible(key, hiddenWidgets));++interface ColumnWidgetInput {+ hiddenWidgets: string[];+ hideNeedsYou?: boolean;+ hideUnread?: boolean;+}++export const hasVisibleRailWidget = ({+ hiddenWidgets,+ hideNeedsYou,+ hideUnread,+}: ColumnWidgetInput): boolean =>+ HOME_WIDGET_KEYS.some((key) => {+ if (hideNeedsYou && key === 'needsYou') return false;+ if (hideUnread && key === 'unread') return false;++ return !hiddenWidgets.includes(key);+ });diff --git a/src/features/HomeInbox/inboxBlockState.test.ts b/src/features/HomeInbox/inboxBlockState.test.tsnew file mode 100644index 00000000000..5e1c18c6112--- /dev/null+++ b/src/features/HomeInbox/inboxBlockState.test.ts@@ -0,0 +1,51 @@+import { resolveInboxBlockState } from './inboxBlockState';++const firstLoad = { hasError: false, hiddenWidgets: [], isBriefsInit: false, isLoading: true };+const failed = { hasError: true, hiddenWidgets: [], isBriefsInit: false, isLoading: false };++describe('resolveInboxBlockState', () => {+ it('shows skeletons on first load', () => {+ expect(resolveInboxBlockState(firstLoad)).toBe('skeleton');+ });++ it('shows the block error once the first load has failed and settled', () => {+ expect(resolveInboxBlockState(failed)).toBe('error');+ });++ it('keeps the skeletons while a failed load is being retried', () => {+ expect(resolveInboxBlockState({ ...failed, isLoading: true })).toBe('skeleton');+ });++ it('steps aside once the briefs have arrived', () => {+ expect(resolveInboxBlockState({ ...firstLoad, isBriefsInit: true })).toBeNull();+ });++ it('never takes over the main column, which carries these states as sections', () => {+ expect(resolveInboxBlockState({ ...firstLoad, isMain: true })).toBeNull();+ expect(resolveInboxBlockState({ ...failed, isMain: true })).toBeNull();+ });++ it('drops both states in the rail once news is off, since the rail never shows needs-you', () => {+ expect(+ resolveInboxBlockState({ ...firstLoad, hiddenWidgets: ['news'], hideNeedsYou: true }),+ ).toBeNull();+ expect(+ resolveInboxBlockState({ ...failed, hiddenWidgets: ['news'], hideNeedsYou: true }),+ ).toBeNull();+ });++ it('keeps them where needs-you still renders, even with news off', () => {+ expect(resolveInboxBlockState({ ...firstLoad, hiddenWidgets: ['news'] })).toBe('skeleton');+ });++ it('keeps them for news alone when only needs-you is off', () => {+ expect(resolveInboxBlockState({ ...firstLoad, hiddenWidgets: ['needsYou'] })).toBe('skeleton');+ });++ it('drops them once both brief-powered widgets are off', () => {+ expect(+ resolveInboxBlockState({ ...firstLoad, hiddenWidgets: ['needsYou', 'news'] }),+ ).toBeNull();+ expect(resolveInboxBlockState({ ...failed, hiddenWidgets: ['needsYou', 'news'] })).toBeNull();+ });+});diff --git a/src/features/HomeInbox/inboxBlockState.ts b/src/features/HomeInbox/inboxBlockState.tsnew file mode 100644index 00000000000..fdfb76e5b5f--- /dev/null+++ b/src/features/HomeInbox/inboxBlockState.ts@@ -0,0 +1,31 @@+import { isWidgetSectionVisible } from '@/features/Home/CustomizeModal/config';++export type InboxBlockState = 'error' | 'skeleton' | null;++interface InboxBlockStateInput {+ hasError: boolean;+ hiddenWidgets: string[];+ hideNeedsYou?: boolean;+ isBriefsInit: boolean;+ isLoading: boolean;+ isMain?: boolean;+}++const isBriefsBlockVisible = (hiddenWidgets: string[], hideNeedsYou?: boolean): boolean =>+ (!hideNeedsYou && isWidgetSectionVisible('needsYou', hiddenWidgets)) ||+ isWidgetSectionVisible('news', hiddenWidgets);++export const resolveInboxBlockState = ({+ hasError,+ hiddenWidgets,+ hideNeedsYou,+ isBriefsInit,+ isLoading,+ isMain,+}: InboxBlockStateInput): InboxBlockState => {+ if (isMain) return null;+ if (!isBriefsBlockVisible(hiddenWidgets, hideNeedsYou)) return null;+ if (isBriefsInit) return null;++ return hasError && !isLoading ? 'error' : 'skeleton';+};diff --git a/src/features/HomeInbox/index.tsx b/src/features/HomeInbox/index.tsxindex b8bfcd6bf89..a41cd5f56f5 100644--- a/src/features/HomeInbox/index.tsx+++ b/src/features/HomeInbox/index.tsx@@ -14,16 +14,20 @@ import Recommendations, { useRecommendationsVisible } from '@/features/Recommendimport { useCacheScope } from '@/libs/swr/useCacheScope';import { useBriefStore } from '@/store/brief';import { briefListSelectors } from '@/store/brief/selectors';+import { useGlobalStore } from '@/store/global';+import { systemStatusSelectors } from '@/store/global/selectors';import { useUserStore } from '@/store/user';import { authSelectors, userProfileSelectors } from '@/store/user/slices/auth/selectors';+import { filterHiddenWidgetSections } from './hiddenWidgets';+import { resolveInboxBlockState } from './inboxBlockState';import InboxBriefCard from './InboxBriefCard';import MarkAllReadButton from './MarkAllReadButton';import NeedsYouRailCard from './NeedsYouRailCard';import NewsList from './NewsList';import { ownsRailSections } from './railSectionPlacement';import RunningTasksCard from './RunningTasksCard';-import { filterTopicsForInboxScope, resolveScopeToggleSection } from './scopeTogglePlacement';+import { filterTopicsForInboxScope, resolveInboxScopeToggleSection } from './scopeTogglePlacement';import { splitBriefs } from './splitBriefs';import UnreadTopicList from './UnreadTopicList';import { useHomeInboxTopics } from './useHomeInboxTopics';@@ -120,6 +124,7 @@ const HomeInbox = memo<HomeInboxProps>((props) => {const topics = useHomeInboxTopics(isLogin);const recommendationsVisible = useRecommendationsVisible();+ const hiddenWidgets = useGlobalStore(systemStatusSelectors.hiddenHomeWidgets);// A team context is a workspace with more than the viewer in it. In personal// mode this map is empty, so `isTeam` is false and the whole mine/team layer@@ -148,9 +153,18 @@ const HomeInbox = memo<HomeInboxProps>((props) => {if (!isLogin) return null;+ const blockState = resolveInboxBlockState({+ hasError: Boolean(briefsSWR.error),+ hiddenWidgets,+ hideNeedsYou,+ isBriefsInit,+ isLoading: Boolean(briefsSWR.isLoading),+ isMain,+ });+// The brief feed is the primary content; a first-load failure blocks the whole// surface. No fabricated section heading — we don't know what's under it yet.- if (!isMain && briefsSWR.error && !isBriefsInit && !briefsSWR.isLoading) {+ if (blockState === 'error') {return (<AsyncErrorerror={briefsSWR.error}@@ -164,7 +178,7 @@ const HomeInbox = memo<HomeInboxProps>((props) => {// First load: bare skeletons, no group heading (loading must not assert a// "Needs you" section that may turn out empty). Recommendations keep their own.- if (!isMain && !isBriefsInit) {+ if (blockState === 'skeleton') {return (<Flexbox gap={12}><BriefCardSkeleton />@@ -189,11 +203,14 @@ const HomeInbox = memo<HomeInboxProps>((props) => {/>) : undefined;const toggleSectionKey = scopeToggle- ? resolveScopeToggleSection({- hasNeedsYou: !hideNeedsYou && needsYou.length > 0,- hasRunning: runningTopics.length > 0,- hasUnread: !hideUnread && unreadTopics.length > 0,+ ? resolveInboxScopeToggleSection({+ hiddenWidgets,+ hideNeedsYou,+ hideUnread,+ needsYouCount: needsYou.length,preferUnread: isMain,+ runningCount: runningTopics.length,+ unreadCount: unreadTopics.length,}): null;const placeToggle = (key: typeof toggleSectionKey): ReactNode =>@@ -312,15 +329,17 @@ const HomeInbox = memo<HomeInboxProps>((props) => {subtitle: t('inbox.news.subtitle'),});- if (sections.length === 0) {+ const visibleSections = filterHiddenWidgetSections(sections, hiddenWidgets);++ if (visibleSections.length === 0) {if (isMain) return null;if (isRail)- return (+ return recommendationsVisible ? (<Flexbox gap={12}><Recommendations variant={'rail'} /></Flexbox>- );+ ) : null;// With no titled block above it, the bare recommendations list doesn't need// the full section gap below the input area — offset the parent's gap so it@@ -338,7 +357,7 @@ const HomeInbox = memo<HomeInboxProps>((props) => {return (<Flexbox gap={isRail ? 12 : 32}>- {sections.map(({ action, badge, count, key, label, node, selfShelled, subtitle }) => {+ {visibleSections.map(({ action, badge, count, key, label, node, selfShelled, subtitle }) => {if (selfShelled) return <Fragment key={key}>{node}</Fragment>;if (isRail)diff --git a/src/features/HomeInbox/scopeTogglePlacement.ts b/src/features/HomeInbox/scopeTogglePlacement.tsindex d91620e2656..2516d20acf2 100644--- a/src/features/HomeInbox/scopeTogglePlacement.ts+++ b/src/features/HomeInbox/scopeTogglePlacement.ts@@ -19,6 +19,32 @@ export const resolveScopeToggleSection = ({return null;};+interface InboxScopeTogglePlacementInput {+ hiddenWidgets: string[];+ hideNeedsYou?: boolean;+ hideUnread?: boolean;+ needsYouCount: number;+ preferUnread?: boolean;+ runningCount: number;+ unreadCount: number;+}++export const resolveInboxScopeToggleSection = ({+ hiddenWidgets,+ hideNeedsYou,+ hideUnread,+ needsYouCount,+ preferUnread,+ runningCount,+ unreadCount,+}: InboxScopeTogglePlacementInput): 'needsYou' | 'running' | 'unread' | null =>+ resolveScopeToggleSection({+ hasNeedsYou: !hideNeedsYou && needsYouCount > 0 && !hiddenWidgets.includes('needsYou'),+ hasRunning: runningCount > 0 && !hiddenWidgets.includes('running'),+ hasUnread: !hideUnread && unreadCount > 0 && !hiddenWidgets.includes('unread'),+ preferUnread,+ });+export const filterTopicsForInboxScope = <T extends { userId?: string }>(topics: readonly T[],myId: string | undefined,diff --git a/src/features/Recommendations/index.tsx b/src/features/Recommendations/index.tsxindex d2cc63e3f44..008dcb3bd48 100644--- a/src/features/Recommendations/index.tsx+++ b/src/features/Recommendations/index.tsx@@ -11,6 +11,8 @@ import {} from '@/business/client/useDailyBriefRecommendationsUI';import GroupBlock from '@/features/Home/components/GroupBlock';import RailCard from '@/features/Home/components/RailCard';+import { useGlobalStore } from '@/store/global';+import { systemStatusSelectors } from '@/store/global/selectors';import { useEligibleActions } from './hooks/useEligibleActions';import { RecommendationCard } from './RecommendationCard';@@ -20,9 +22,15 @@ import { styles } from './style';const isTaskTemplatesVisible = (state: DailyBriefRecommendationsUIState): boolean =>state.mode !== 'hidden';+const useSuggestionsHidden = (): boolean =>+ useGlobalStore(systemStatusSelectors.hiddenHomeWidgets).includes('suggestions');+export const useRecommendationsVisible = (): boolean => {+ const hidden = useSuggestionsHidden();const taskTemplatesState = useDailyBriefRecommendationsUI();const { actions } = useEligibleActions();+ if (hidden) return false;+return actions.length > 0 || isTaskTemplatesVisible(taskTemplatesState);};@@ -33,6 +41,7 @@ interface RecommendationsProps {const Recommendations = memo<RecommendationsProps>(({ variant = 'default' }) => {const { t } = useTranslation('home');const { t: tCommon } = useTranslation('common');+ const hidden = useSuggestionsHidden();const taskTemplatesState = useDailyBriefRecommendationsUI();const { actions } = useEligibleActions();@@ -68,6 +77,7 @@ const Recommendations = memo<RecommendationsProps>(({ variant = 'default' }) =>}, [isRefreshing, onRefresh]);const showTaskTemplates = isTaskTemplatesVisible(taskTemplatesState);+ if (hidden) return null;if (actions.length === 0 && !showTaskTemplates) return null;// Rendered through the skeleton phase, not just in 'cards': the control thatdiff --git a/src/features/Recommendations/useRecommendationsVisible.test.ts b/src/features/Recommendations/useRecommendationsVisible.test.tsnew file mode 100644index 00000000000..817fe676033--- /dev/null+++ b/src/features/Recommendations/useRecommendationsVisible.test.ts@@ -0,0 +1,89 @@+import { renderHook } from '@testing-library/react';+import { afterEach, describe, expect, it, vi } from 'vitest';++interface LoadHookOptions {+ actions?: { id: string }[];+ hiddenHomeWidgets?: string[];+ mode?: string;+}++const loadHook = async ({+ actions = [],+ hiddenHomeWidgets = [],+ mode = 'hidden',+}: LoadHookOptions = {}) => {+ vi.resetModules();++ const renderNothing = () => null;++ vi.doMock('@/business/client/DailyBriefRecommendations', () => ({+ DailyBriefRecommendations: renderNothing,+ }));+ vi.doMock('./RecommendationCard', () => ({ RecommendationCard: renderNothing }));+ vi.doMock('@/features/Home/components/GroupBlock', () => ({ default: renderNothing }));+ vi.doMock('@/features/Home/components/RailCard', () => ({ default: renderNothing }));+ function translate() {+ return { i18n: { language: 'en-US' }, t: (key: string) => key };+ }+ vi.doMock('react-i18next', () => ({ useTranslation: translate }));+ function selectFromGlobalStore(selector: (state: unknown) => unknown) {+ return selector({ status: { hiddenHomeWidgets } });+ }+ vi.doMock('@/store/global', () => ({ useGlobalStore: selectFromGlobalStore }));+ function readTaskTemplatesUI() {+ return { mode };+ }+ vi.doMock('@/business/client/useDailyBriefRecommendationsUI', () => ({+ useDailyBriefRecommendationsUI: readTaskTemplatesUI,+ }));+ function readEligibleActions() {+ return { actions };+ }+ vi.doMock('./hooks/useEligibleActions', () => ({ useEligibleActions: readEligibleActions }));++ const { useRecommendationsVisible } = await import('./index');++ return renderHook(() => useRecommendationsVisible()).result.current;+};++afterEach(() => {+ vi.doUnmock('@/business/client/DailyBriefRecommendations');+ vi.doUnmock('@/business/client/useDailyBriefRecommendationsUI');+ vi.doUnmock('@/features/Home/components/GroupBlock');+ vi.doUnmock('@/features/Home/components/RailCard');+ vi.doUnmock('@/store/global');+ vi.doUnmock('react-i18next');+ vi.doUnmock('./hooks/useEligibleActions');+ vi.doUnmock('./RecommendationCard');+});++describe('useRecommendationsVisible', () => {+ it('shows suggestions when task templates have something to render', async () => {+ expect(await loadHook({ mode: 'cards' })).toBe(true);+ }, 20000);++ it('shows suggestions when an eligible action exists without task templates', async () => {+ expect(await loadHook({ actions: [{ id: 'connect-drive' }] })).toBe(true);+ }, 20000);++ it('hides suggestions when the widget is turned off, despite ready task templates', async () => {+ expect(await loadHook({ hiddenHomeWidgets: ['suggestions'], mode: 'cards' })).toBe(false);+ }, 20000);++ it('hides suggestions when the widget is turned off, despite an eligible action', async () => {+ expect(+ await loadHook({+ actions: [{ id: 'connect-drive' }],+ hiddenHomeWidgets: ['suggestions'],+ }),+ ).toBe(false);+ }, 20000);++ it('leaves suggestions alone when other widgets are the hidden ones', async () => {+ expect(await loadHook({ hiddenHomeWidgets: ['needsYou', 'news'], mode: 'cards' })).toBe(true);+ }, 20000);++ it('stays hidden with nothing to suggest and nothing turned off', async () => {+ expect(await loadHook()).toBe(false);+ }, 20000);+});diff --git a/src/store/global/initialState.test.ts b/src/store/global/initialState.test.tsindex 3eb61fec1c0..21ab38fa7b9 100644--- a/src/store/global/initialState.test.ts+++ b/src/store/global/initialState.test.ts@@ -21,21 +21,39 @@ describe('createInitialSystemStatus', () => {expect(status.showLeftPanel).toBe(false);});+ it('restores the Home customizations that decide layout on first paint', () => {+ seed({ hiddenHomeWidgets: ['news', 'suggestions'], showHomePortrait: false });++ const status = createInitialSystemStatus();++ expect(status.showHomePortrait).toBe(false);+ expect(status.hiddenHomeWidgets).toEqual(['news', 'suggestions']);+ });+it('falls back to defaults when nothing is persisted', () => {const status = createInitialSystemStatus();expect(status.leftPanelWidth).toBe(INITIAL_STATUS.leftPanelWidth);expect(status.showHomeRail).toBe(INITIAL_STATUS.showHomeRail);expect(status.showLeftPanel).toBe(INITIAL_STATUS.showLeftPanel);+ expect(status.showHomePortrait).toBe(INITIAL_STATUS.showHomePortrait);+ expect(status.hiddenHomeWidgets).toEqual(INITIAL_STATUS.hiddenHomeWidgets);});it('ignores persisted values of the wrong type', () => {- seed({ leftPanelWidth: '360', showLeftPanel: 'false' });+ seed({+ hiddenHomeWidgets: 'news',+ leftPanelWidth: '360',+ showHomePortrait: 'false',+ showLeftPanel: 'false',+ });const status = createInitialSystemStatus();expect(status.leftPanelWidth).toBe(INITIAL_STATUS.leftPanelWidth);expect(status.showLeftPanel).toBe(INITIAL_STATUS.showLeftPanel);+ expect(status.showHomePortrait).toBe(INITIAL_STATUS.showHomePortrait);+ expect(status.hiddenHomeWidgets).toEqual(INITIAL_STATUS.hiddenHomeWidgets);});it('survives a corrupted payload', () => {diff --git a/src/store/global/initialState.ts b/src/store/global/initialState.tsindex 2498dce550b..fbdd2ed115d 100644--- a/src/store/global/initialState.ts+++ b/src/store/global/initialState.ts@@ -206,6 +206,7 @@ export interface SystemStatus {* Group Agent Builder panel width*/groupAgentBuilderPanelWidth?: number;+ hiddenHomeWidgets?: string[];/*** Hidden sidebar sections*/@@ -213,11 +214,13 @@ export interface SystemStatus {hidePWAInstaller?: boolean;hideThreadLimitAlert?: boolean;hideTopicSharePrivacyWarning?: boolean;+ homeRecentsCount?: number;/*** Agent picked from the home AgentSelect dropdown. When unset the home page* falls back to the inbox agent. Persisted so the choice survives reloads.*/homeSelectedAgentId?: string;+ homeTaskCount?: number;imagePanelWidth: number;imageTopicPanelWidth?: number;imageTopicViewMode?: 'grid' | 'list';@@ -298,6 +301,7 @@ export interface SystemStatus {showAgentBuilderPanel?: boolean;showCommandMenu?: boolean;showFilePanel?: boolean;+ showHomePortrait?: boolean;/*** Visibility of the Home dashboard's activity and recommendations rail.* Independent from `showRightPanel` so Home preferences do not affect chat pages.@@ -513,9 +517,12 @@ export const INITIAL_STATUS = {fileManagerViewMode: 'list' as const,filePanelWidth: 320,groupAgentBuilderPanelWidth: 360,+ hiddenHomeWidgets: [],hidePWAInstaller: false,hideThreadLimitAlert: false,hideTopicSharePrivacyWarning: false,+ homeRecentsCount: 8,+ homeTaskCount: 8,imagePanelWidth: 320,imageTopicViewMode: 'grid' as const,imageTopicPanelWidth: 80,@@ -534,6 +541,7 @@ export const INITIAL_STATUS = {resourceManagerColumnWidths: DEFAULT_RESOURCE_MANAGER_COLUMN_WIDTHS,showCommandMenu: false,showFilePanel: true,+ showHomePortrait: true,showHotkeyHelper: false,showHomeRail: true,showImagePanel: true,@@ -575,10 +583,17 @@ export const createInitialSystemStatus = (): SystemStatus => {return {...INITIAL_STATUS,+ hiddenHomeWidgets: Array.isArray(persistedStatus.hiddenHomeWidgets)+ ? persistedStatus.hiddenHomeWidgets+ : INITIAL_STATUS.hiddenHomeWidgets,leftPanelWidth:typeof persistedStatus.leftPanelWidth === 'number'? persistedStatus.leftPanelWidth: INITIAL_STATUS.leftPanelWidth,+ showHomePortrait:+ typeof persistedStatus.showHomePortrait === 'boolean'+ ? persistedStatus.showHomePortrait+ : INITIAL_STATUS.showHomePortrait,showHomeRail:typeof persistedStatus.showHomeRail === 'boolean'? persistedStatus.showHomeRaildiff --git a/src/store/global/selectors/systemStatus.ts b/src/store/global/selectors/systemStatus.tsindex dc9ebb919d1..becdd80c013 100644--- a/src/store/global/selectors/systemStatus.ts+++ b/src/store/global/selectors/systemStatus.ts@@ -368,6 +368,10 @@ const mobileShowTopic = (s: GlobalState) => s.status.mobileShowTopic;const mobileShowPortal = (s: GlobalState) => s.status.mobileShowPortal;const showAgentBuilderPanel = (s: GlobalState) => s.status.showAgentBuilderPanel;const showHomeRail = (s: GlobalState) => s.status.showHomeRail ?? true;+const showHomePortrait = (s: GlobalState) => s.status.showHomePortrait ?? true;+const hiddenHomeWidgets = (s: GlobalState): string[] => s.status.hiddenHomeWidgets ?? [];+const homeRecentsCount = (s: GlobalState): number => s.status.homeRecentsCount ?? 8;+const homeTaskCount = (s: GlobalState): number => s.status.homeTaskCount ?? 8;const showRightPanel = (s: GlobalState) => s.status.showRightPanel;const showLeftPanel = (s: GlobalState) => s.status.showLeftPanel;const showPageAgentPanel = (s: GlobalState) => s.status.showPageAgentPanel;@@ -461,9 +465,12 @@ export const systemStatusSelectors = {filePanelWidth,getAgentSystemRoleExpanded,groupAgentBuilderPanelWidth,+ hiddenHomeWidgets,hiddenSidebarSections,hidePWAInstaller,+ homeRecentsCount,homeSelectedAgentId,+ homeTaskCount,imagePanelWidth,imageTopicViewMode,imageTopicPanelWidth,@@ -494,6 +501,7 @@ export const systemStatusSelectors = {sessionGroupKeys,showAgentBuilderPanel,showFilePanel,+ showHomePortrait,showHomeRail,showImagePanel,showImageTopicPanel,