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): open Home in one column by default (#21817)

YuTengjingab5e48f25e60
diff --git a/e2e/src/steps/home/layout.steps.ts b/e2e/src/steps/home/layout.steps.ts
index 320a30b5286..8ed708cb857 100644
--- a/e2e/src/steps/home/layout.steps.ts
+++ b/e2e/src/steps/home/layout.steps.ts
@@ -68,6 +68,13 @@ Given('用户在受限宽度下打开 Home 页面', async function (this: Custom
// single rail card still overflows and exposes the real ScrollArea scrollbar.
await this.page.setViewportSize({ height: 360, width: 1500 });
await this.page.goto('/');
+ // Home opens in one column by default; this scenario is about the two-column
+ // layout, so store the rail preference and reload, as a user who opened it would.
+ await this.page.evaluate(() => {
+ const status = JSON.parse(localStorage.getItem('LOBE_SYSTEM_STATUS') ?? '{}');
+ localStorage.setItem('LOBE_SYSTEM_STATUS', JSON.stringify({ ...status, showHomeRail: true }));
+ });
+ await this.page.reload();
await expect(this.page.locator('[data-testid="home-rail"]:visible')).toBeVisible({
timeout: WAIT_TIMEOUT,
diff --git a/src/features/Home/__tests__/portraitVisibility.test.tsx b/src/features/Home/__tests__/portraitVisibility.test.tsx
index c26a087364a..292fc916a45 100644
--- a/src/features/Home/__tests__/portraitVisibility.test.tsx
+++ b/src/features/Home/__tests__/portraitVisibility.test.tsx
@@ -13,6 +13,7 @@ interface RenderHomeOptions {
promo?: ReactNode;
search?: string;
showHomePortrait?: boolean;
+ showHomeRail?: boolean;
}
const stub = (testId: string) => ({ default: () => <div data-testid={testId} /> });
@@ -49,6 +50,7 @@ const renderHome = async ({
promo,
search = '',
showHomePortrait,
+ showHomeRail,
}: RenderHomeOptions = {}) => {
vi.resetModules();
window.history.replaceState(null, '', `/${search}`);
@@ -76,7 +78,9 @@ const renderHome = async ({
},
}));
function selectFromGlobalStore(selector: (state: unknown) => unknown) {
- return selector({ status: { hiddenHomeWidgets: hiddenWidgets, showHomePortrait } });
+ return selector({
+ status: { hiddenHomeWidgets: hiddenWidgets, showHomePortrait, showHomeRail },
+ });
}
vi.doMock('@/store/global', () => ({ useGlobalStore: selectFromGlobalStore }));
function selectFromUserStore(selector: (state: unknown) => unknown) {
@@ -215,9 +219,16 @@ describe('Home portrait visibility', () => {
});
describe('Home rail layout', () => {
- it('paints the rail inbox in the first commit, without a suspended empty frame', async () => {
+ it('opens in one column when the browser has no stored rail choice', async () => {
await renderHome();
+ expect(screen.getByTestId('home-rail')).toHaveAttribute('data-collapsed', 'true');
+ expect(screen.getByTestId('home-main')).toHaveAttribute('data-rail-collapsed', 'true');
+ }, 20000);
+
+ it('paints the rail inbox in the first commit, without a suspended empty frame', async () => {
+ await renderHome({ showHomeRail: true });
+
expect(screen.getByTestId('home-rail')).toContainElement(screen.getByTestId('home-inbox'));
expect(screen.getByTestId('home-main')).toHaveAttribute('data-rail-collapsed', 'false');
}, 20000);
@@ -231,6 +242,7 @@ describe('Home rail layout', () => {
return <div data-testid={'home-inbox'} />;
},
}),
+ showHomeRail: true,
});
expect(screen.getByTestId('home-main')).toHaveAttribute('data-rail-collapsed', 'false');
diff --git a/src/store/global/actions/workspacePane.ts b/src/store/global/actions/workspacePane.ts
index 995ba880580..9764180b991 100644
--- a/src/store/global/actions/workspacePane.ts
+++ b/src/store/global/actions/workspacePane.ts
@@ -99,7 +99,7 @@ export class GlobalWorkspacePaneActionImpl {
};
toggleHomeRail = (newValue?: boolean): void => {
- const currentValue = this.#get().status.showHomeRail ?? true;
+ const currentValue = this.#get().status.showHomeRail ?? false;
const showHomeRail = typeof newValue === 'boolean' ? newValue : !currentValue;
this.#get().updateSystemStatus({ showHomeRail }, n('toggleHomeRail', newValue));
diff --git a/src/store/global/initialState.test.ts b/src/store/global/initialState.test.ts
index 192f0f45981..82ce624be20 100644
--- a/src/store/global/initialState.test.ts
+++ b/src/store/global/initialState.test.ts
@@ -40,6 +40,16 @@ describe('createInitialSystemStatus', () => {
expect(status.workingSidebarWidth).toBe(480);
});
+ it('opens Home in one column for a browser without a stored rail choice', () => {
+ expect(createInitialSystemStatus().showHomeRail).toBe(false);
+ });
+
+ it('keeps the rail open for browsers that already stored it', () => {
+ seed({ showHomeRail: true });
+
+ expect(createInitialSystemStatus().showHomeRail).toBe(true);
+ });
+
it('falls back to defaults when nothing is persisted', () => {
const status = createInitialSystemStatus();
diff --git a/src/store/global/initialState.ts b/src/store/global/initialState.ts
index 858685ba95c..42ad50afdac 100644
--- a/src/store/global/initialState.ts
+++ b/src/store/global/initialState.ts
@@ -635,7 +635,12 @@ export const INITIAL_STATUS = {
showFilePanel: true,
showHomePortrait: true,
showHotkeyHelper: false,
- showHomeRail: true,
+ /**
+ * One column by default: most people prefer the single-column Home. Only
+ * browsers without a stored preference get this, because `updateSystemStatus`
+ * persists the whole status, so earlier sessions already stored `true`.
+ */
+ showHomeRail: false,
showImagePanel: true,
showImageTopicPanel: true,
showAgentBuilderPanel: false,
diff --git a/src/store/global/selectors/systemStatus.ts b/src/store/global/selectors/systemStatus.ts
index 5c43f01876e..8a752af4d71 100644
--- a/src/store/global/selectors/systemStatus.ts
+++ b/src/store/global/selectors/systemStatus.ts
@@ -415,7 +415,7 @@ const showSystemRole = (s: GlobalState) => s.status.showSystemRole;
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 showHomeRail = (s: GlobalState) => s.status.showHomeRail ?? false;
const showHomePortrait = (s: GlobalState) => s.status.showHomePortrait ?? true;
const hiddenHomeWidgets = (s: GlobalState): string[] => s.status.hiddenHomeWidgets ?? [];
const homeGoalsCollapsed = (s: GlobalState): boolean => s.status.homeGoalsCollapsed ?? false;