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): add Minimal / Balanced / Full presets to Home customization (#17948)

Innei5bac2bbdfc50
diff --git a/locales/en-US/home.json b/locales/en-US/home.json
index f45c96811c6..65634513af7 100644
--- a/locales/en-US/home.json
+++ b/locales/en-US/home.json
@@ -54,14 +54,20 @@
"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.preset.balanced.title": "Balanced",
+ "dashboard.customize.preset.full.title": "Full",
+ "dashboard.customize.preset.label": "Preset",
+ "dashboard.customize.preset.minimal.title": "Minimal",
"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.recents": "Recent threads",
"dashboard.customize.widget.running": "Running",
"dashboard.customize.widget.suggestions": "Suggestions",
+ "dashboard.customize.widget.tasks": "Tasks",
"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:",
diff --git a/locales/zh-CN/home.json b/locales/zh-CN/home.json
index 97ef4403800..7a536b0a97b 100644
--- a/locales/zh-CN/home.json
+++ b/locales/zh-CN/home.json
@@ -54,14 +54,20 @@
"dashboard.customize.increase": "增加{{label}}",
"dashboard.customize.portrait.desc": "在首页顶部旁显示你的智能体形象。",
"dashboard.customize.portrait.title": "形象装饰",
+ "dashboard.customize.preset.balanced.title": "适中",
+ "dashboard.customize.preset.full.title": "全部",
+ "dashboard.customize.preset.label": "预设",
+ "dashboard.customize.preset.minimal.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.recents": "最近话题",
"dashboard.customize.widget.running": "进行中",
"dashboard.customize.widget.suggestions": "推荐",
+ "dashboard.customize.widget.tasks": "任务",
"dashboard.customize.widget.unread": "未读",
"dashboard.empty.plan.description": "把目标拆解为清晰、可执行的下一步",
"dashboard.empty.plan.prompt": "帮我为以下目标制定一份切实可行的计划:",
diff --git a/packages/locales/src/default/home.ts b/packages/locales/src/default/home.ts
index af9c8ba9eee..f7dadd30347 100644
--- a/packages/locales/src/default/home.ts
+++ b/packages/locales/src/default/home.ts
@@ -59,14 +59,20 @@ export default {
'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.preset.balanced.title': 'Balanced',
+ 'dashboard.customize.preset.full.title': 'Full',
+ 'dashboard.customize.preset.label': 'Preset',
+ 'dashboard.customize.preset.minimal.title': 'Minimal',
'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.recents': 'Recent threads',
'dashboard.customize.widget.running': 'Running',
'dashboard.customize.widget.suggestions': 'Suggestions',
+ 'dashboard.customize.widget.tasks': 'Tasks',
'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:',
diff --git a/src/features/Home/CustomizeModal/Content.tsx b/src/features/Home/CustomizeModal/Content.tsx
index 72805ff80ec..8ad45af8809 100644
--- a/src/features/Home/CustomizeModal/Content.tsx
+++ b/src/features/Home/CustomizeModal/Content.tsx
@@ -8,6 +8,7 @@ import { memo } from 'react';
import { useTranslation } from 'react-i18next';
import CountStepper from './components/CountStepper';
+import PresetBar from './components/PresetBar';
import SettingRow from './components/SettingRow';
import { HOME_COUNT_MAX, HOME_COUNT_MIN, HOME_WIDGET_KEYS } from './config';
import { useHomeCustomization } from './useHomeCustomization';
@@ -16,7 +17,7 @@ const styles = createStaticStyles(({ css, cssVar }) => ({
body: css`
overflow-y: auto;
max-block-size: min(70vh, 560px);
- padding-block: 4px 20px;
+ padding-block: 12px 20px;
padding-inline: 20px;
`,
footer: css`
@@ -34,7 +35,9 @@ const CustomizeModalContent = memo(() => {
const { t } = useTranslation('home');
const { close } = useModalContext();
const {
+ applyPreset,
isWidgetHidden,
+ preset,
recentsCount,
reset,
setRecentsCount,
@@ -66,6 +69,10 @@ const CustomizeModalContent = memo(() => {
</Flexbox>
<Flexbox className={styles.body} gap={20}>
+ <SettingRow title={t('dashboard.customize.preset.label')}>
+ <PresetBar value={preset} onChange={applyPreset} />
+ </SettingRow>
+
<Flexbox gap={12}>
<Text fontSize={12} type={'secondary'} weight={600}>
{t('dashboard.customize.group.decoration')}
@@ -101,8 +108,10 @@ const CustomizeModalContent = memo(() => {
<Text fontSize={12} type={'secondary'} weight={600}>
{t('dashboard.customize.group.listSize')}
</Text>
+ {/* A section that isn't on the page has no length to tune. */}
<SettingRow title={t('dashboard.customize.recents.count.title')}>
<CountStepper
+ disabled={isWidgetHidden('recents')}
label={t('dashboard.customize.recents.count.title')}
max={HOME_COUNT_MAX}
min={HOME_COUNT_MIN}
@@ -112,6 +121,7 @@ const CustomizeModalContent = memo(() => {
</SettingRow>
<SettingRow title={t('dashboard.customize.tasks.count.title')}>
<CountStepper
+ disabled={isWidgetHidden('tasks')}
label={t('dashboard.customize.tasks.count.title')}
max={HOME_COUNT_MAX}
min={HOME_COUNT_MIN}
diff --git a/src/features/Home/CustomizeModal/components/CountStepper.tsx b/src/features/Home/CustomizeModal/components/CountStepper.tsx
index 5a9d7684a7f..d1765e26152 100644
--- a/src/features/Home/CustomizeModal/components/CountStepper.tsx
+++ b/src/features/Home/CustomizeModal/components/CountStepper.tsx
@@ -7,6 +7,7 @@ import { memo } from 'react';
import { useTranslation } from 'react-i18next';
export interface CountStepperProps {
+ disabled?: boolean;
label: string;
max: number;
min: number;
@@ -21,24 +22,30 @@ const styles = createStaticStyles(({ css }) => ({
`,
}));
-const CountStepper = memo<CountStepperProps>(({ label, value, min, max, onChange }) => {
+const CountStepper = memo<CountStepperProps>(({ disabled, 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}
+ disabled={disabled || value <= min}
icon={MinusIcon}
size={'small'}
onClick={() => onChange(value - 1)}
/>
- <Text aria-label={label} aria-live={'polite'} className={styles.value} weight={500}>
+ <Text
+ aria-label={label}
+ aria-live={'polite'}
+ className={styles.value}
+ type={disabled ? 'secondary' : undefined}
+ weight={500}
+ >
{value}
</Text>
<ActionIcon
aria-label={t('dashboard.customize.increase', { label })}
- disabled={value >= max}
+ disabled={disabled || value >= max}
icon={PlusIcon}
size={'small'}
onClick={() => onChange(value + 1)}
diff --git a/src/features/Home/CustomizeModal/components/PresetBar.tsx b/src/features/Home/CustomizeModal/components/PresetBar.tsx
new file mode 100644
index 00000000000..88246f8684f
--- /dev/null
+++ b/src/features/Home/CustomizeModal/components/PresetBar.tsx
@@ -0,0 +1,34 @@
+'use client';
+
+import { Segmented } from '@lobehub/ui/base-ui';
+import { memo } from 'react';
+import { useTranslation } from 'react-i18next';
+
+import { HOME_PRESET_KEYS, type HomePresetKey } from '../config';
+
+export interface PresetBarProps {
+ onChange: (key: HomePresetKey) => void;
+ value: HomePresetKey | undefined;
+}
+
+// No option carries this value, so the switches falling outside every preset
+// leave the bar with nothing highlighted — while the control stays controlled.
+const CUSTOM_VALUE = 'custom';
+
+const PresetBar = memo<PresetBarProps>(({ onChange, value }) => {
+ const { t } = useTranslation('home');
+
+ return (
+ <Segmented<string>
+ size={'small'}
+ value={value ?? CUSTOM_VALUE}
+ options={HOME_PRESET_KEYS.map((key) => ({
+ label: t(`dashboard.customize.preset.${key}.title`),
+ value: key,
+ }))}
+ onChange={(next) => onChange(next as HomePresetKey)}
+ />
+ );
+});
+
+export default PresetBar;
diff --git a/src/features/Home/CustomizeModal/config.ts b/src/features/Home/CustomizeModal/config.ts
index 3398e4d0fc1..a9c9abc45ac 100644
--- a/src/features/Home/CustomizeModal/config.ts
+++ b/src/features/Home/CustomizeModal/config.ts
@@ -1,5 +1,18 @@
-export const HOME_WIDGET_KEYS = ['needsYou', 'unread', 'running', 'news', 'suggestions'] as const;
+// The sections the inbox owns, which is also what the rail can host. Kept apart
+// from the full key list because the main column's own blocks (recents, tasks)
+// never appear in the rail — folding them in would keep the rail alive on the
+// strength of a section it cannot show.
+export const HOME_INBOX_WIDGET_KEYS = [
+ 'needsYou',
+ 'unread',
+ 'running',
+ 'news',
+ 'suggestions',
+] as const;
+export const HOME_WIDGET_KEYS = [...HOME_INBOX_WIDGET_KEYS, 'recents', 'tasks'] as const;
+
+export type HomeInboxWidgetKey = (typeof HOME_INBOX_WIDGET_KEYS)[number];
export type HomeWidgetKey = (typeof HOME_WIDGET_KEYS)[number];
export const HOME_CUSTOMIZE_DEFAULTS = {
@@ -12,6 +25,57 @@ export const HOME_CUSTOMIZE_DEFAULTS = {
export const HOME_COUNT_MIN = 3;
export const HOME_COUNT_MAX = 15;
+export const HOME_PRESET_KEYS = ['minimal', 'balanced', 'full'] as const;
+
+export type HomePresetKey = (typeof HOME_PRESET_KEYS)[number];
+
+interface HomePreset {
+ // Applied along with the preset, but left out of `resolveHomePreset`'s
+ // comparison: how much a list shows is a separate axis from which sections
+ // exist, and re-tuning it must not drop the page out of its preset.
+ count: number;
+ hiddenWidgets: readonly HomeWidgetKey[];
+ showPortrait: boolean;
+}
+
+export const HOME_PRESETS: Record<HomePresetKey, HomePreset> = {
+ balanced: {
+ count: 5,
+ hiddenWidgets: ['unread', 'running', 'news', 'suggestions'],
+ showPortrait: false,
+ },
+ full: { count: 8, hiddenWidgets: [], showPortrait: true },
+ minimal: { count: 5, hiddenWidgets: HOME_WIDGET_KEYS, showPortrait: false },
+};
+
+interface HomeVisibilityState {
+ hiddenWidgets: string[];
+ showPortrait: boolean;
+}
+
+const hiddenKeySet = ({ hiddenWidgets }: HomeVisibilityState): Set<string> =>
+ new Set(HOME_WIDGET_KEYS.filter((key) => hiddenWidgets.includes(key)));
+
+export const resolveHomePreset = (state: HomeVisibilityState): HomePresetKey | undefined => {
+ const hidden = hiddenKeySet(state);
+
+ return HOME_PRESET_KEYS.find((key) => {
+ const preset = HOME_PRESETS[key];
+
+ return (
+ preset.showPortrait === state.showPortrait &&
+ preset.hiddenWidgets.length === hidden.size &&
+ preset.hiddenWidgets.every((widget) => hidden.has(widget))
+ );
+ });
+};
+
+// Nothing is left to stack under the composer, so the page stops being a
+// dashboard: the greeting and the composer become one centered block. Derived
+// from the switches rather than stored, so it can never disagree with them.
+export const isHomeMinimalLayout = (state: HomeVisibilityState): boolean =>
+ !state.showPortrait && HOME_WIDGET_KEYS.every((key) => state.hiddenWidgets.includes(key));
+
// 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
diff --git a/src/features/Home/CustomizeModal/useHomeCustomization.test.ts b/src/features/Home/CustomizeModal/useHomeCustomization.test.ts
index ea1268b1caf..dc5179f2b70 100644
--- a/src/features/Home/CustomizeModal/useHomeCustomization.test.ts
+++ b/src/features/Home/CustomizeModal/useHomeCustomization.test.ts
@@ -1,6 +1,12 @@
import { describe, expect, it } from 'vitest';
-import { isWidgetSectionVisible } from './config';
+import {
+ HOME_PRESETS,
+ HOME_WIDGET_KEYS,
+ isHomeMinimalLayout,
+ isWidgetSectionVisible,
+ resolveHomePreset,
+} from './config';
import { clampHomeCount, toggleHiddenWidget } from './useHomeCustomization';
describe('toggleHiddenWidget', () => {
@@ -33,6 +39,65 @@ describe('clampHomeCount', () => {
});
});
+describe('resolveHomePreset', () => {
+ const stateOf = (key: keyof typeof HOME_PRESETS) => ({
+ hiddenWidgets: [...HOME_PRESETS[key].hiddenWidgets],
+ showPortrait: HOME_PRESETS[key].showPortrait,
+ });
+
+ it('names each preset from the switches it spells out', () => {
+ expect(resolveHomePreset(stateOf('minimal'))).toBe('minimal');
+ expect(resolveHomePreset(stateOf('balanced'))).toBe('balanced');
+ expect(resolveHomePreset(stateOf('full'))).toBe('full');
+ });
+
+ it('ignores the order the hidden widgets were stored in', () => {
+ expect(
+ resolveHomePreset({
+ hiddenWidgets: ['suggestions', 'news', 'unread', 'running'],
+ showPortrait: false,
+ }),
+ ).toBe('balanced');
+ });
+
+ it('ignores keys it does not know, so a stale entry cannot mask a preset', () => {
+ expect(resolveHomePreset({ hiddenWidgets: ['retiredWidget'], showPortrait: true })).toBe(
+ 'full',
+ );
+ });
+
+ it('names no preset once a single switch departs from one', () => {
+ expect(resolveHomePreset({ hiddenWidgets: ['news'], showPortrait: true })).toBeUndefined();
+ });
+
+ it('tells the presets apart by the portrait alone', () => {
+ expect(resolveHomePreset({ hiddenWidgets: [], showPortrait: false })).toBeUndefined();
+ });
+});
+
+describe('isHomeMinimalLayout', () => {
+ it('centers the page once every section and the portrait are off', () => {
+ expect(isHomeMinimalLayout({ hiddenWidgets: [...HOME_WIDGET_KEYS], showPortrait: false })).toBe(
+ true,
+ );
+ });
+
+ it('keeps the dashboard while the portrait still has a lane to sit in', () => {
+ expect(isHomeMinimalLayout({ hiddenWidgets: [...HOME_WIDGET_KEYS], showPortrait: true })).toBe(
+ false,
+ );
+ });
+
+ it('keeps the dashboard while one section still has something to stack', () => {
+ expect(
+ isHomeMinimalLayout({
+ hiddenWidgets: HOME_WIDGET_KEYS.filter((key) => key !== 'tasks'),
+ showPortrait: false,
+ }),
+ ).toBe(false);
+ });
+});
+
describe('isWidgetSectionVisible', () => {
it('hides a loading section governed by a hidden widget', () => {
expect(isWidgetSectionVisible('needsYou-loading', ['needsYou'])).toBe(false);
diff --git a/src/features/Home/CustomizeModal/useHomeCustomization.ts b/src/features/Home/CustomizeModal/useHomeCustomization.ts
index 8d93b70342a..310c2191b55 100644
--- a/src/features/Home/CustomizeModal/useHomeCustomization.ts
+++ b/src/features/Home/CustomizeModal/useHomeCustomization.ts
@@ -7,7 +7,11 @@ import {
HOME_COUNT_MAX,
HOME_COUNT_MIN,
HOME_CUSTOMIZE_DEFAULTS,
+ HOME_PRESETS,
+ type HomePresetKey,
type HomeWidgetKey,
+ isHomeMinimalLayout,
+ resolveHomePreset,
} from './config';
export const toggleHiddenWidget = (hidden: string[], key: HomeWidgetKey): string[] =>
@@ -17,8 +21,10 @@ export const clampHomeCount = (value: number): number =>
Math.min(HOME_COUNT_MAX, Math.max(HOME_COUNT_MIN, value));
interface HomeCustomization {
+ applyPreset: (key: HomePresetKey) => void;
hiddenWidgets: string[];
isWidgetHidden: (key: HomeWidgetKey) => boolean;
+ preset: HomePresetKey | undefined;
recentsCount: number;
reset: () => void;
setRecentsCount: (value: number) => void;
@@ -29,6 +35,13 @@ interface HomeCustomization {
toggleWidget: (key: HomeWidgetKey) => void;
}
+export const useHomeMinimalLayout = (): boolean => {
+ const hiddenWidgets = useGlobalStore(systemStatusSelectors.hiddenHomeWidgets);
+ const showPortrait = useGlobalStore(systemStatusSelectors.showHomePortrait);
+
+ return isHomeMinimalLayout({ hiddenWidgets, showPortrait });
+};
+
export const useHomeCustomization = (): HomeCustomization => {
const hiddenWidgets = useGlobalStore(systemStatusSelectors.hiddenHomeWidgets);
const recentsCount = useGlobalStore(systemStatusSelectors.homeRecentsCount);
@@ -64,6 +77,23 @@ export const useHomeCustomization = (): HomeCustomization => {
[updateSystemStatus],
);
+ const applyPreset = useCallback(
+ (key: HomePresetKey) => {
+ const preset = HOME_PRESETS[key];
+
+ updateSystemStatus(
+ {
+ hiddenHomeWidgets: [...preset.hiddenWidgets],
+ homeRecentsCount: preset.count,
+ homeTaskCount: preset.count,
+ showHomePortrait: preset.showPortrait,
+ },
+ 'homeCustomize',
+ );
+ },
+ [updateSystemStatus],
+ );
+
const reset = useCallback(() => {
updateSystemStatus(HOME_CUSTOMIZE_DEFAULTS, 'homeCustomize');
}, [updateSystemStatus]);
@@ -74,8 +104,10 @@ export const useHomeCustomization = (): HomeCustomization => {
);
return {
+ applyPreset,
hiddenWidgets,
isWidgetHidden,
+ preset: resolveHomePreset({ hiddenWidgets, showPortrait }),
recentsCount,
reset,
setRecentsCount,
diff --git a/src/features/Home/HomeHeader.tsx b/src/features/Home/HomeHeader.tsx
index e0cbc73ed1f..b0088828f2d 100644
--- a/src/features/Home/HomeHeader.tsx
+++ b/src/features/Home/HomeHeader.tsx
@@ -1,5 +1,5 @@
import { Flexbox, Text } from '@lobehub/ui';
-import { createStaticStyles } from 'antd-style';
+import { createStaticStyles, cx } from 'antd-style';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
@@ -26,6 +26,12 @@ const styles = createStaticStyles(({ css }) => ({
line-height: 1.4;
letter-spacing: -0.01em;
`,
+ // The measure is the layout's answer to the portrait, which the centered
+ // block does not have — so the headline runs to the block's own width.
+ greetingCentered: css`
+ max-width: none;
+ text-align: center;
+ `,
toolbar: css`
width: 100%;
min-width: 0;
@@ -39,7 +45,11 @@ const getGreetingKey = (hour: number): 'afternoon' | 'evening' | 'morning' => {
return 'evening';
};
-const HomeHeader = memo(() => {
+interface HomeHeaderProps {
+ centered?: boolean;
+}
+
+const HomeHeader = memo<HomeHeaderProps>(({ centered }) => {
const { t } = useTranslation('home');
const displayName = useUserStore(userProfileSelectors.displayUserName);
const isLogin = useUserStore(authSelectors.isLogin);
@@ -51,10 +61,16 @@ const HomeHeader = memo(() => {
return (
<Flexbox gap={16} justify={'center'}>
- <Flexbox horizontal align={'center'} className={styles.toolbar} gap={16}>
- <AgentSelect />
- </Flexbox>
- <Text as={'h1'} className={styles.greeting} weight={600}>
+ {!centered && (
+ <Flexbox horizontal align={'center'} className={styles.toolbar} gap={16}>
+ <AgentSelect />
+ </Flexbox>
+ )}
+ <Text
+ as={'h1'}
+ className={cx(styles.greeting, centered && styles.greetingCentered)}
+ weight={600}
+ >
{greeting}
</Text>
</Flexbox>
diff --git a/src/features/Home/HomeModeContent.tsx b/src/features/Home/HomeModeContent.tsx
index be7a5f67017..8f11b180967 100644
--- a/src/features/Home/HomeModeContent.tsx
+++ b/src/features/Home/HomeModeContent.tsx
@@ -280,6 +280,9 @@ const HomeModeContent = memo<HomeModeContentProps>(({ inlineRail, mode, onSugges
const authLoaded = useUserStore(authSelectors.isLoaded);
const myId = useUserStore(userProfileSelectors.userId);
const recentsCount = useGlobalStore(systemStatusSelectors.homeRecentsCount);
+ const hiddenWidgets = useGlobalStore(systemStatusSelectors.hiddenHomeWidgets);
+ const recentsHidden = hiddenWidgets.includes('recents');
+ const tasksHidden = hiddenWidgets.includes('tasks');
const cacheScope = useCacheScope();
// One page-level mine/team scope, shared by the inbox sections and Recent
@@ -294,7 +297,7 @@ const HomeModeContent = memo<HomeModeContentProps>(({ inlineRail, mode, onSugges
// client-filtering the top N of a team-wide feed could starve out the
// viewer's own topics entirely.
const recentsSWR = useClientDataSWR(
- isLogin
+ isLogin && !recentsHidden
? recentKeys.topicList(HOME_TOPIC_RECENT_LIMIT, cacheScope, teamView ? 'team' : 'mine')
: null,
() => recentService.getAll(HOME_TOPIC_RECENT_LIMIT, ['topic'], true, !teamView),
@@ -318,12 +321,15 @@ const HomeModeContent = memo<HomeModeContentProps>(({ inlineRail, mode, onSugges
const topicRecents = recentsSWR.data ?? [];
if (mode === 'chat') {
+ // With the recents section switched off nothing is fetched, so it reports as
+ // settled-and-empty rather than perpetually loading, and the remaining
+ // activity alone decides what this column is.
const state = resolveHomeChatContentState({
authLoaded: !!authLoaded,
- hasError: !!recentsSWR.error,
+ hasError: !recentsHidden && !!recentsSWR.error,
isLogin: !!isLogin,
recentsCount: topicRecents.length,
- recentsInit: recentsSWR.data !== undefined,
+ recentsInit: recentsHidden || recentsSWR.data !== undefined,
activityCount: mineRunningCount + mineUnreadCount + needsYouCount,
activityError: Boolean(inboxTopics.error || briefsSWR.error),
activityResolved:
@@ -337,11 +343,15 @@ const HomeModeContent = memo<HomeModeContentProps>(({ inlineRail, mode, onSugges
// exist. Mirror the expanded page instead: suggestions first, then whatever
// folded in (both sections render null when there is nothing to carry).
if (state === 'empty') {
- if (!inlineRail) return <EmptySuggestions onSelect={onSuggestionSelect} />;
+ // The starters are what the recents section shows when it has nothing to
+ // list, so switching that section off takes them with it.
+ const starters = recentsHidden ? null : <EmptySuggestions onSelect={onSuggestionSelect} />;
+
+ if (!inlineRail) return starters;
return (
<Flexbox gap={32}>
- <EmptySuggestions onSelect={onSuggestionSelect} />
+ {starters}
<HomeInbox inlineRail variant={'main'} />
<Recommendations variant={'main'} />
</Flexbox>
@@ -356,7 +366,7 @@ const HomeModeContent = memo<HomeModeContentProps>(({ inlineRail, mode, onSugges
variant={'main'}
onScopeChange={setScope}
/>
- {(state !== 'ready' || topicRecents.length > 0) && (
+ {!recentsHidden && (state !== 'ready' || topicRecents.length > 0) && (
<GroupBlock
actionAlwaysVisible
count={resolveRecentsBadgeCount(topicRecents.length, recentsCount)}
@@ -396,7 +406,7 @@ const HomeModeContent = memo<HomeModeContentProps>(({ inlineRail, mode, onSugges
if (!isLogin) return null;
if (mode === 'task') {
- if (!inlineRail) return <TaskContent />;
+ if (!inlineRail) return tasksHidden ? null : <TaskContent />;
// The rail's sections sit beside task mode while it is open, so a folded
// rail must not take them away here either: in flight and what happened
@@ -405,7 +415,7 @@ const HomeModeContent = memo<HomeModeContentProps>(({ inlineRail, mode, onSugges
return (
<Flexbox gap={32}>
<HomeInbox hideNeedsYou hideUnread inlineRail variant={'main'} />
- <TaskContent />
+ {!tasksHidden && <TaskContent />}
<Recommendations variant={'main'} />
</Flexbox>
);
diff --git a/src/features/Home/index.tsx b/src/features/Home/index.tsx
index 4d8dcb14693..f552e646185 100644
--- a/src/features/Home/index.tsx
+++ b/src/features/Home/index.tsx
@@ -13,6 +13,7 @@ import { taskDetailSelectors } from '@/store/task/selectors';
import { useUserStore } from '@/store/user';
import { authSelectors } from '@/store/user/slices/auth/selectors';
+import { isHomeMinimalLayout } from './CustomizeModal/config';
import HomeHeader from './HomeHeader';
import HomeModeContent from './HomeModeContent';
import HomePortrait from './HomePortrait';
@@ -53,6 +54,14 @@ const BUBBLE_GAP = 16;
const GREETING_LANE = COLLAPSED_CONTENT_OFFSET * 2 + PORTRAIT_LANE + BUBBLE_MAX_WIDTH + BUBBLE_GAP;
/** Under this the greeting, the bubble and the portrait cannot share a line. */
const BUBBLE_INLINE_MIN = 1080;
+const MINIMAL_STACK_GAP = 24;
+/**
+ * The greeting's line box — 22px at a 1.4 line-height, from HomeHeader. Its
+ * height plus the gap is what the block must shed below itself to land the
+ * composer, not the pair's midpoint, on the center of the lane.
+ */
+const MINIMAL_GREETING_LINE = Math.round(22 * 1.4);
+const MINIMAL_LIFT = MINIMAL_GREETING_LINE + MINIMAL_STACK_GAP;
const styles = createStaticStyles(({ css }) => ({
// Both rows size to their content and the page scrolls around the whole grid
@@ -160,6 +169,20 @@ const styles = createStaticStyles(({ css }) => ({
grid-area: 2 / 1;
min-width: 0;
`,
+ // Nothing stacks under the composer any more, so the page stops being a
+ // dashboard: greeting and composer read as one block, on a measure of their
+ // own rather than the dashboard's full span.
+ //
+ // The route centers this block with auto margins, which would put the pair's
+ // midpoint on the center and leave the composer — the thing you actually look
+ // at — sitting low. The trailing pad is counted into the centered box, so it
+ // lifts everything by half its height and hands the composer the center.
+ minimal: css`
+ width: 100%;
+ max-inline-size: 760px;
+ margin-inline: auto;
+ padding-block-end: ${MINIMAL_LIFT}px;
+ `,
portrait: css`
grid-area: 1 / 2;
transition: transform ${RAIL_TRANSITION_DURATION}ms ease-out;
@@ -245,6 +268,7 @@ const Home = memo(() => {
const showHomeRail = useGlobalStore(systemStatusSelectors.showHomeRail);
const showHomePortrait = useGlobalStore(systemStatusSelectors.showHomePortrait);
const hiddenWidgets = useGlobalStore(systemStatusSelectors.hiddenHomeWidgets);
+ const minimal = isHomeMinimalLayout({ hiddenWidgets, showPortrait: showHomePortrait });
const [mode, setMode] = useState<HomeMode>('chat');
const [inputValue, setInputValue] = useState('');
@@ -273,6 +297,21 @@ const Home = memo(() => {
[handleInputValueChange],
);
+ if (minimal)
+ return (
+ <Flexbox className={styles.minimal} gap={MINIMAL_STACK_GAP}>
+ <HomeHeader centered />
+ <div className={styles.inputArea}>
+ <InputArea
+ inputValue={inputValue}
+ mode={mode}
+ onInputValueChange={handleInputValueChange}
+ onModeChange={setMode}
+ />
+ </div>
+ </Flexbox>
+ );
+
return (
<Flexbox className={styles.grid}>
<div className={cx(styles.header, styles.content, railCollapsed && styles.contentCollapsed)}>
diff --git a/src/features/HomeInbox/hiddenWidgets.test.ts b/src/features/HomeInbox/hiddenWidgets.test.ts
index 0801637e8d3..356a8791973 100644
--- a/src/features/HomeInbox/hiddenWidgets.test.ts
+++ b/src/features/HomeInbox/hiddenWidgets.test.ts
@@ -74,6 +74,9 @@ describe('hasVisibleRailWidget', () => {
expect(hasVisibleRailWidget({ ...railColumn, hiddenWidgets: ['running', 'news'] })).toBe(true);
});
+ // Covers both kinds of section the rail never shows: the ones this column
+ // suppresses by prop, and the main column's own recents/tasks — counting
+ // either would keep an empty rail on screen forever.
it('drops the rail once every widget it hosts is off, ignoring the ones it never shows', () => {
expect(
hasVisibleRailWidget({ ...railColumn, hiddenWidgets: ['running', 'news', 'suggestions'] }),
diff --git a/src/features/HomeInbox/hiddenWidgets.ts b/src/features/HomeInbox/hiddenWidgets.ts
index e25ea01bc26..e47c24d395a 100644
--- a/src/features/HomeInbox/hiddenWidgets.ts
+++ b/src/features/HomeInbox/hiddenWidgets.ts
@@ -1,4 +1,7 @@
-import { HOME_WIDGET_KEYS, isWidgetSectionVisible } from '@/features/Home/CustomizeModal/config';
+import {
+ HOME_INBOX_WIDGET_KEYS,
+ isWidgetSectionVisible,
+} from '@/features/Home/CustomizeModal/config';
export const filterHiddenWidgetSections = <T extends { key: string }>(
sections: T[],
@@ -16,7 +19,7 @@ export const hasVisibleRailWidget = ({
hideNeedsYou,
hideUnread,
}: ColumnWidgetInput): boolean =>
- HOME_WIDGET_KEYS.some((key) => {
+ HOME_INBOX_WIDGET_KEYS.some((key) => {
if (hideNeedsYou && key === 'needsYou') return false;
if (hideUnread && key === 'unread') return false;
diff --git a/src/routes/(main)/home/index.tsx b/src/routes/(main)/home/index.tsx
index 14bec25e9e8..38754d4ac00 100644
--- a/src/routes/(main)/home/index.tsx
+++ b/src/routes/(main)/home/index.tsx
@@ -3,10 +3,15 @@ import { type FC } from 'react';
import HomePageTracker from '@/components/Analytics/HomePageTracker';
import HomeContent from '@/features/Home';
+import { useHomeMinimalLayout } from '@/features/Home/CustomizeModal/useHomeCustomization';
import HomeNavHeader from '@/features/Home/HomeNavHeader';
import WideScreenContainer from '@/features/WideScreenContainer';
const Home: FC = () => {
+ // Auto margins are what center a flex item inside the scroll lane, and they
+ // have to sit on the item itself — the dashboard never wants them.
+ const minimal = useHomeMinimalLayout();
+
return (
<>
<HomePageTracker />
@@ -24,7 +29,7 @@ const Home: FC = () => {
<WideScreenContainer
fullWidth
style={{ marginInline: 'auto', maxWidth: 1240 }}
- wrapperStyle={{ flex: 'none' }}
+ wrapperStyle={{ flex: 'none', marginBlock: minimal ? 'auto' : undefined }}
>
<HomeContent />
</WideScreenContainer>