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.

♻️ refactor: refactor implement

YuTengjing34d059ffae1d
diff --git a/src/server/services/nextAuthUser/index.ts b/src/server/services/nextAuthUser/index.ts
index 9397e626f40..d4af2d0023b 100644
--- a/src/server/services/nextAuthUser/index.ts
+++ b/src/server/services/nextAuthUser/index.ts
@@ -15,7 +15,6 @@ import {
import { pino } from '@/libs/logger';
import { merge } from '@/utils/merge';
-import { AgentService } from '../agent';
import {
mapAdapterUserToLobeUser,
mapAuthenticatorQueryResutlToAdapterAuthenticator,
@@ -132,10 +131,6 @@ export class NextAuthUserService {
}),
);
- // 3. Create an inbox session for the user
- const agentService = new AgentService(this.db, uid);
- await agentService.createInbox();
-
return { ...user, id: uid };
};
diff --git a/src/services/trace.ts b/src/services/trace.ts
index d396878111e..11162ba2952 100644
--- a/src/services/trace.ts
+++ b/src/services/trace.ts
@@ -1,6 +1,6 @@
import { API_ENDPOINTS } from '@/services/_url';
import { useUserStore } from '@/store/user';
-import { preferenceSelectors } from '@/store/user/selectors';
+import { userGeneralSettingsSelectors } from '@/store/user/selectors';
import { TraceEventBasePayload, TraceEventPayloads } from '@/types/trace';
class TraceService {
@@ -17,7 +17,7 @@ class TraceService {
};
traceEvent = async (data: TraceEventPayloads & TraceEventBasePayload) => {
- const enabled = preferenceSelectors.userAllowTrace(useUserStore.getState());
+ const enabled = userGeneralSettingsSelectors.telemetry(useUserStore.getState());
if (!enabled) return;
diff --git a/src/store/aiInfra/slices/aiModel/action.test.ts b/src/store/aiInfra/slices/aiModel/action.test.ts
index 38d2c343c8d..7b90729a1d6 100644
--- a/src/store/aiInfra/slices/aiModel/action.test.ts
+++ b/src/store/aiInfra/slices/aiModel/action.test.ts
@@ -2,6 +2,7 @@ import { act, renderHook, waitFor } from '@testing-library/react';
import { AiProviderModelListItem } from 'model-bank';
import { mutate } from 'swr';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+import { withSWR } from '~test-utils';
import { aiModelService } from '@/services/aiModel';
@@ -493,8 +494,9 @@ describe('AiModelAction', () => {
vi.spyOn(aiModelService, 'getAiProviderModelList').mockResolvedValue(mockModels);
- const { result } = renderHook(() =>
- useStore.getState().useFetchAiProviderModels('test-provider'),
+ const { result } = renderHook(
+ () => useStore.getState().useFetchAiProviderModels('test-provider'),
+ { wrapper: withSWR },
);
await waitFor(() => {
@@ -518,7 +520,9 @@ describe('AiModelAction', () => {
vi.spyOn(aiModelService, 'getAiProviderModelList').mockResolvedValue(mockModels);
- renderHook(() => useStore.getState().useFetchAiProviderModels('test-provider'));
+ renderHook(() => useStore.getState().useFetchAiProviderModels('test-provider'), {
+ wrapper: withSWR,
+ });
await waitFor(() => {
const state = useStore.getState();
@@ -550,7 +554,9 @@ describe('AiModelAction', () => {
const setStateSpy = vi.spyOn(useStore, 'setState');
- renderHook(() => useStore.getState().useFetchAiProviderModels('test-provider'));
+ renderHook(() => useStore.getState().useFetchAiProviderModels('test-provider'), {
+ wrapper: withSWR,
+ });
await waitFor(() => {
expect(aiModelService.getAiProviderModelList).toHaveBeenCalled();
@@ -592,7 +598,9 @@ describe('AiModelAction', () => {
vi.spyOn(aiModelService, 'getAiProviderModelList').mockResolvedValue(newModels);
- renderHook(() => useStore.getState().useFetchAiProviderModels('test-provider'));
+ renderHook(() => useStore.getState().useFetchAiProviderModels('test-provider'), {
+ wrapper: withSWR,
+ });
await waitFor(() => {
const state = useStore.getState();
diff --git a/src/store/global/action.test.ts b/src/store/global/action.test.ts
index 9d017137dfd..d5ff4d19e93 100644
--- a/src/store/global/action.test.ts
+++ b/src/store/global/action.test.ts
@@ -31,32 +31,32 @@ afterEach(() => {
});
describe('createPreferenceSlice', () => {
- describe('toggleChatSideBar', () => {
+ describe('toggleRightPanel', () => {
it('should toggle chat sidebar', () => {
const { result } = renderHook(() => useGlobalStore());
act(() => {
- useGlobalStore.getState().updateSystemStatus({ showChatSideBar: false });
- result.current.toggleChatSideBar();
+ useGlobalStore.getState().updateSystemStatus({ showRightPanel: false });
+ result.current.toggleRightPanel();
});
- expect(result.current.status.showChatSideBar).toBe(true);
+ expect(result.current.status.showRightPanel).toBe(true);
});
it('should set chat sidebar to specified value', () => {
const { result } = renderHook(() => useGlobalStore());
act(() => {
useGlobalStore.setState({ isStatusInit: true });
- result.current.toggleChatSideBar(true);
+ result.current.toggleRightPanel(true);
});
- expect(result.current.status.showChatSideBar).toBe(true);
+ expect(result.current.status.showRightPanel).toBe(true);
act(() => {
- result.current.toggleChatSideBar(false);
+ result.current.toggleRightPanel(false);
});
- expect(result.current.status.showChatSideBar).toBe(false);
+ expect(result.current.status.showRightPanel).toBe(false);
});
});
@@ -273,7 +273,7 @@ describe('createPreferenceSlice', () => {
result.current.switchBackToChat(sessionId);
});
- expect(navigate).toHaveBeenCalledWith('/chat?session=session-id');
+ expect(navigate).toHaveBeenCalledWith('/agent/session-id');
});
});
diff --git a/src/store/global/actions/__tests__/general.test.ts b/src/store/global/actions/__tests__/general.test.ts
index 3819977b343..ee6b73e1b67 100644
--- a/src/store/global/actions/__tests__/general.test.ts
+++ b/src/store/global/actions/__tests__/general.test.ts
@@ -153,6 +153,36 @@ describe('generalActionSlice', () => {
});
});
+ describe('useInitSystemStatus', () => {
+ it('should reset transient UI states when loading from localStorage', async () => {
+ const mockStatus = {
+ ...initialState.status,
+ showCommandMenu: true,
+ showHotkeyHelper: true,
+ noWideScreen: false,
+ };
+
+ const { result } = renderHook(() => useGlobalStore());
+ const getFromLocalStorageSpy = vi
+ .spyOn(result.current.statusStorage, 'getFromLocalStorage')
+ .mockResolvedValueOnce(mockStatus);
+
+ const { result: hookResult } = renderHook(() => useGlobalStore().useInitSystemStatus(), {
+ wrapper: withSWR,
+ });
+
+ await act(async () => {
+ await hookResult.current.data;
+ });
+
+ expect(getFromLocalStorageSpy).toHaveBeenCalled();
+ expect(useGlobalStore.getState().isStatusInit).toBe(true);
+ expect(useGlobalStore.getState().status.showCommandMenu).toBe(false);
+ expect(useGlobalStore.getState().status.showHotkeyHelper).toBe(false);
+ expect(useGlobalStore.getState().status.noWideScreen).toBe(false);
+ });
+ });
+
describe('useCheckLatestVersion', () => {
it('should not fetch version when check is disabled', () => {
const getLatestVersionSpy = vi.spyOn(globalService, 'getLatestVersion');
diff --git a/src/store/global/actions/general.ts b/src/store/global/actions/general.ts
index 785d49b4d2c..999822945f4 100644
--- a/src/store/global/actions/general.ts
+++ b/src/store/global/actions/general.ts
@@ -20,8 +20,8 @@ import type { GlobalStore } from '../store';
const n = setNamespace('g');
export interface GlobalGeneralAction {
- openSessionInNewWindow: (sessionId: string) => Promise<void>;
- openTopicInNewWindow: (sessionId: string, topicId: string) => Promise<void>;
+ openAgentInNewWindow: (agentId: string) => Promise<void>;
+ openTopicInNewWindow: (agentId: string, topicId: string) => Promise<void>;
switchLocale: (locale: LocaleMode, params?: { skipBroadcast?: boolean }) => void;
switchThemeMode: (themeMode: ThemeMode, params?: { skipBroadcast?: boolean }) => void;
updateSystemStatus: (status: Partial<SystemStatus>, action?: any) => void;
@@ -35,45 +35,65 @@ export const generalActionSlice: StateCreator<
[],
GlobalGeneralAction
> = (set, get) => ({
- openSessionInNewWindow: async (sessionId: string) => {
- if (!isDesktop) return;
-
- try {
- const { ensureElectronIpc } = await import('@/utils/electron/ipc');
- const url = `/chat?session=${sessionId}&mode=single`;
-
- const result = await ensureElectronIpc().windows.createMultiInstanceWindow({
- path: url,
- templateId: 'chatSingle',
- uniqueId: `chat_${sessionId}`,
- });
-
- if (!result.success) {
- console.error('Failed to open session in new window:', result.error);
+ openAgentInNewWindow: async (agentId: string) => {
+ const url = `/agent/${agentId}${isDesktop ? '?mode=single' : ''}`;
+
+ if (isDesktop) {
+ try {
+ const { ensureElectronIpc } = await import('@/utils/electron/ipc');
+ const path = `/agent/${agentId}?mode=single`;
+
+ const result = await ensureElectronIpc().windows.createMultiInstanceWindow({
+ path,
+ templateId: 'chatSingle',
+ uniqueId: `chat_${agentId}`,
+ });
+
+ if (!result.success) {
+ console.error('Failed to open agent in new window:', result.error);
+ }
+ } catch (error) {
+ console.error('Error opening agent in new window:', error);
}
- } catch (error) {
- console.error('Error opening session in new window:', error);
+ } else {
+ // Open in popup window for browser
+ const width = 1200;
+ const height = 800;
+ const left = (window.screen.width - width) / 2;
+ const top = (window.screen.height - height) / 2;
+ const features = `width=${width},height=${height},left=${left},top=${top},resizable=yes,scrollbars=yes,status=yes`;
+ window.open(url, `agent_${agentId}`, features);
}
},
- openTopicInNewWindow: async (sessionId: string, topicId: string) => {
- if (!isDesktop) return;
+ openTopicInNewWindow: async (agentId: string, topicId: string) => {
+ const url = `/agent/${agentId}?topic=${topicId}${isDesktop ? '&mode=single' : ''}`;
- try {
- const { ensureElectronIpc } = await import('@/utils/electron/ipc');
- const url = `/chat?session=${sessionId}&topic=${topicId}&mode=single`;
+ if (isDesktop) {
+ try {
+ const { ensureElectronIpc } = await import('@/utils/electron/ipc');
+ const path = `/agent/${agentId}?topic=${topicId}&mode=single`;
- const result = await ensureElectronIpc().windows.createMultiInstanceWindow({
- path: url,
- templateId: 'chatSingle',
- uniqueId: `chat_${sessionId}_${topicId}`,
- });
+ const result = await ensureElectronIpc().windows.createMultiInstanceWindow({
+ path,
+ templateId: 'chatSingle',
+ uniqueId: `chat_${agentId}_${topicId}`,
+ });
- if (!result.success) {
- console.error('Failed to open topic in new window:', result.error);
+ if (!result.success) {
+ console.error('Failed to open topic in new window:', result.error);
+ }
+ } catch (error) {
+ console.error('Error opening topic in new window:', error);
}
- } catch (error) {
- console.error('Error opening topic in new window:', error);
+ } else {
+ // Open in popup window for browser
+ const width = 1200;
+ const height = 800;
+ const left = (window.screen.width - width) / 2;
+ const top = (window.screen.height - height) / 2;
+ const features = `width=${width},height=${height},left=${left},top=${top},resizable=yes,scrollbars=yes,status=yes`;
+ window.open(url, `agent_${agentId}_topic_${topicId}`, features);
}
},
@@ -103,6 +123,7 @@ export const generalActionSlice: StateCreator<
(async () => {
try {
const { ensureElectronIpc } = await import('@/utils/electron/ipc');
+
await ensureElectronIpc().system.updateThemeModeHandler(themeMode);
} catch (error) {
console.error('Failed to update theme in main process:', error);
@@ -153,7 +174,14 @@ export const generalActionSlice: StateCreator<
onSuccess: (status) => {
set({ isStatusInit: true }, false, 'setStatusInit');
- get().updateSystemStatus(status, 'initSystemStatus');
+ // Reset transient UI states that should not persist across page reloads
+ const statusWithResetTransientStates = {
+ ...status,
+ showCommandMenu: false,
+ showHotkeyHelper: false,
+ };
+
+ get().updateSystemStatus(statusWithResetTransientStates, 'initSystemStatus');
},
},
),
diff --git a/src/store/global/actions/workspacePane.ts b/src/store/global/actions/workspacePane.ts
index 4ada9c27488..fbad84fd227 100644
--- a/src/store/global/actions/workspacePane.ts
+++ b/src/store/global/actions/workspacePane.ts
@@ -11,11 +11,13 @@ const n = setNamespace('w');
export interface GlobalWorkspacePaneAction {
switchBackToChat: (sessionId?: string) => void;
toggleAgentSystemRoleExpand: (agentId: string, expanded?: boolean) => void;
- toggleChatSideBar: (visible?: boolean) => void;
+ toggleCommandMenu: (visible?: boolean) => void;
toggleExpandInputActionbar: (expand?: boolean) => void;
toggleExpandSessionGroup: (id: string, expand: boolean) => void;
+ toggleLeftPanel: (visible?: boolean) => void;
toggleMobilePortal: (visible?: boolean) => void;
toggleMobileTopic: (visible?: boolean) => void;
+ toggleRightPanel: (visible?: boolean) => void;
toggleSystemRole: (visible?: boolean) => void;
toggleWideScreen: (enable?: boolean) => void;
toggleZenMode: () => void;
@@ -47,11 +49,12 @@ export const globalWorkspaceSlice: StateCreator<
n('toggleAgentSystemRoleExpand', { agentId, expanded: nextExpanded }),
);
},
- toggleChatSideBar: (newValue) => {
- const showChatSideBar =
- typeof newValue === 'boolean' ? newValue : !get().status.showChatSideBar;
- get().updateSystemStatus({ showChatSideBar }, n('toggleAgentPanel', newValue));
+ toggleCommandMenu: (visible) => {
+ const currentVisible = get().status.showCommandMenu;
+ get().updateSystemStatus({
+ showCommandMenu: typeof visible === 'boolean' ? visible : !currentVisible,
+ });
},
toggleExpandInputActionbar: (newValue) => {
const expandInputActionbar =
@@ -72,6 +75,10 @@ export const globalWorkspaceSlice: StateCreator<
});
get().updateSystemStatus({ expandSessionGroupKeys: nextExpandSessionGroup });
},
+ toggleLeftPanel: (newValue) => {
+ const showLeftPanel = typeof newValue === 'boolean' ? newValue : !get().status.showLeftPanel;
+ get().updateSystemStatus({ showLeftPanel }, n('toggleLeftPanel', newValue));
+ },
toggleMobilePortal: (newValue) => {
const mobileShowPortal =
typeof newValue === 'boolean' ? newValue : !get().status.mobileShowPortal;
@@ -84,6 +91,12 @@ export const globalWorkspaceSlice: StateCreator<
get().updateSystemStatus({ mobileShowTopic }, n('toggleMobileTopic', newValue));
},
+
+ toggleRightPanel: (newValue) => {
+ const showRightPanel = typeof newValue === 'boolean' ? newValue : !get().status.showRightPanel;
+
+ get().updateSystemStatus({ showRightPanel }, n('toggleRightPanel', newValue));
+ },
toggleSystemRole: (newValue) => {
const showSystemRole = typeof newValue === 'boolean' ? newValue : !get().status.mobileShowTopic;
diff --git a/src/store/global/initialState.ts b/src/store/global/initialState.ts
index 53fac3501b8..41a2c8e11c2 100644
--- a/src/store/global/initialState.ts
+++ b/src/store/global/initialState.ts
@@ -8,11 +8,14 @@ import { AsyncLocalStorage } from '@/utils/localStorage';
export enum SidebarTabKey {
Chat = 'chat',
- Discover = 'discover',
- Files = 'knowledge',
+ Community = 'community',
+ Home = 'home',
Image = 'image',
Knowledge = 'knowledge',
Me = 'me',
+ Memory = 'memory',
+ Pages = 'pages',
+ Resource = 'resource',
Setting = 'settings',
}
@@ -33,21 +36,30 @@ export enum GroupSettingsTabs {
}
export enum SettingsTabs {
+ APIKey = 'apikey',
About = 'about',
Agent = 'agent',
Common = 'common',
Hotkey = 'hotkey',
Image = 'image',
LLM = 'llm',
+ Memory = 'memory',
+ Profile = 'profile',
Provider = 'provider',
Proxy = 'proxy',
+ Security = 'security',
+ Stats = 'stats',
Storage = 'storage',
- SystemAgent = 'system-agent',
TTS = 'tts',
+ Usage = 'usage',
}
+/**
+ * @deprecated Use SettingsTabs instead
+ */
export enum ProfileTabs {
APIKey = 'apikey',
+ Memory = 'memory',
Profile = 'profile',
Security = 'security',
Stats = 'stats',
@@ -55,12 +67,18 @@ export enum ProfileTabs {
}
export interface SystemStatus {
+ /**
+ * number of agents (defaultList) to display
+ */
+ agentPageSize?: number;
chatInputHeight?: number;
disabledModelProvidersSortType?: string;
disabledModelsSortType?: string;
expandInputActionbar?: boolean;
// which sessionGroup should expand
expandSessionGroupKeys: string[];
+ // which topicGroup should expand
+ expandTopicGroupKeys?: string[];
fileManagerViewMode?: 'list' | 'masonry';
filePanelWidth: number;
hideGemini2_5FlashImagePreviewChineseWarning?: boolean;
@@ -84,17 +102,22 @@ export interface SystemStatus {
*/
lastSelectedImageProvider?: string;
latestChangelogId?: string;
+ leftPanelWidth: number;
mobileShowPortal?: boolean;
mobileShowTopic?: boolean;
noWideScreen?: boolean;
+ /**
+ * number of pages (documents) to display per page
+ */
+ pagePageSize?: number;
portalWidth: number;
- sessionsWidth: number;
- showChatSideBar?: boolean;
+ showCommandMenu?: boolean;
showFilePanel?: boolean;
showHotkeyHelper?: boolean;
showImagePanel?: boolean;
showImageTopicPanel?: boolean;
- showSessionPanel?: boolean;
+ showLeftPanel?: boolean;
+ showRightPanel?: boolean;
showSystemRole?: boolean;
systemRoleExpandedMap: Record<string, boolean>;
/**
@@ -105,6 +128,10 @@ export interface SystemStatus {
* 是否使用短格式显示 token
*/
tokenDisplayFormatShort?: boolean;
+ /**
+ * number of topics to display per page
+ */
+ topicPageSize?: number;
zenMode?: boolean;
}
@@ -132,6 +159,7 @@ export interface GlobalState {
}
export const INITIAL_STATUS = {
+ agentPageSize: 10,
chatInputHeight: 64,
disabledModelProvidersSortType: 'default',
disabledModelsSortType: 'default',
@@ -145,20 +173,23 @@ export const INITIAL_STATUS = {
imagePanelWidth: 320,
imageTopicPanelWidth: 80,
knowledgeBaseModalViewMode: 'list' as const,
+ leftPanelWidth: 320,
mobileShowTopic: false,
noWideScreen: true,
+ pagePageSize: 20,
portalWidth: 400,
- sessionsWidth: 320,
- showChatSideBar: true,
+ showCommandMenu: false,
showFilePanel: true,
showHotkeyHelper: false,
showImagePanel: true,
showImageTopicPanel: true,
- showSessionPanel: true,
+ showLeftPanel: true,
+ showRightPanel: true,
showSystemRole: false,
systemRoleExpandedMap: {},
themeMode: 'auto',
tokenDisplayFormatShort: true,
+ topicPageSize: 20,
zenMode: false,
} satisfies SystemStatus;
diff --git a/src/store/global/selectors/systemStatus.test.ts b/src/store/global/selectors/systemStatus.test.ts
index 55b1bb2c637..a9e3965b791 100644
--- a/src/store/global/selectors/systemStatus.test.ts
+++ b/src/store/global/selectors/systemStatus.test.ts
@@ -40,13 +40,13 @@ describe('systemStatusSelectors', () => {
showSystemRole: true,
mobileShowTopic: true,
mobileShowPortal: true,
- showChatSideBar: true,
- showSessionPanel: true,
+ showRightPanel: true,
+ showLeftPanel: true,
showFilePanel: true,
hidePWAInstaller: true,
isShowCredit: true,
zenMode: false,
- sessionsWidth: 300,
+ leftPanelWidth: 300,
portalWidth: 500,
filePanelWidth: 400,
inputHeight: 150,
@@ -58,14 +58,14 @@ describe('systemStatusSelectors', () => {
expect(systemStatusSelectors.showSystemRole(s)).toBe(true);
expect(systemStatusSelectors.mobileShowTopic(s)).toBe(true);
expect(systemStatusSelectors.mobileShowPortal(s)).toBe(true);
- expect(systemStatusSelectors.showChatSideBar(s)).toBe(true);
- expect(systemStatusSelectors.showSessionPanel(s)).toBe(true);
+ expect(systemStatusSelectors.showRightPanel(s)).toBe(true);
+ expect(systemStatusSelectors.showLeftPanel(s)).toBe(true);
expect(systemStatusSelectors.showFilePanel(s)).toBe(true);
expect(systemStatusSelectors.hidePWAInstaller(s)).toBe(true);
expect(systemStatusSelectors.isShowCredit(s)).toBe(true);
expect(systemStatusSelectors.showChatHeader(s)).toBe(true);
expect(systemStatusSelectors.inZenMode(s)).toBe(false);
- expect(systemStatusSelectors.sessionWidth(s)).toBe(300);
+ expect(systemStatusSelectors.leftPanelWidth(s)).toBe(300);
expect(systemStatusSelectors.portalWidth(s)).toBe(500);
expect(systemStatusSelectors.filePanelWidth(s)).toBe(400);
expect(systemStatusSelectors.wideScreen(s)).toBe(false);
@@ -75,8 +75,8 @@ describe('systemStatusSelectors', () => {
const zenState = merge(s, {
status: { zenMode: true },
});
- expect(systemStatusSelectors.showChatSideBar(zenState)).toBe(false);
- expect(systemStatusSelectors.showSessionPanel(zenState)).toBe(false);
+ expect(systemStatusSelectors.showRightPanel(zenState)).toBe(false);
+ expect(systemStatusSelectors.showLeftPanel(zenState)).toBe(false);
expect(systemStatusSelectors.showChatHeader(zenState)).toBe(false);
});
diff --git a/src/store/global/selectors/systemStatus.ts b/src/store/global/selectors/systemStatus.ts
index 5851ab76ae7..e207d8d23a9 100644
--- a/src/store/global/selectors/systemStatus.ts
+++ b/src/store/global/selectors/systemStatus.ts
@@ -5,11 +5,19 @@ export const systemStatus = (s: GlobalState) => s.status;
const sessionGroupKeys = (s: GlobalState): string[] =>
s.status.expandSessionGroupKeys || INITIAL_STATUS.expandSessionGroupKeys;
+const topicGroupKeys = (s: GlobalState): string[] | undefined => s.status.expandTopicGroupKeys;
+
+const topicPageSize = (s: GlobalState): number => s.status.topicPageSize || 20;
+
+const agentPageSize = (s: GlobalState): number => s.status.agentPageSize || 10;
+
+const pagePageSize = (s: GlobalState): number => s.status.pagePageSize || 20;
+
const showSystemRole = (s: GlobalState) => s.status.showSystemRole;
const mobileShowTopic = (s: GlobalState) => s.status.mobileShowTopic;
const mobileShowPortal = (s: GlobalState) => s.status.mobileShowPortal;
-const showChatSideBar = (s: GlobalState) => !s.status.zenMode && s.status.showChatSideBar;
-const showSessionPanel = (s: GlobalState) => !s.status.zenMode && s.status.showSessionPanel;
+const showRightPanel = (s: GlobalState) => !s.status.zenMode && s.status.showRightPanel;
+const showLeftPanel = (s: GlobalState) => !s.status.zenMode && s.status.showLeftPanel;
const showFilePanel = (s: GlobalState) => s.status.showFilePanel;
const showImagePanel = (s: GlobalState) => s.status.showImagePanel;
const showImageTopicPanel = (s: GlobalState) => s.status.showImageTopicPanel;
@@ -20,7 +28,7 @@ const language = (s: GlobalState) => s.status.language || 'auto';
const showChatHeader = (s: GlobalState) => !s.status.zenMode;
const inZenMode = (s: GlobalState) => s.status.zenMode;
-const sessionWidth = (s: GlobalState) => s.status.sessionsWidth;
+const leftPanelWidth = (s: GlobalState) => s.status.leftPanelWidth;
const portalWidth = (s: GlobalState) => s.status.portalWidth || 400;
const filePanelWidth = (s: GlobalState) => s.status.filePanelWidth;
const imagePanelWidth = (s: GlobalState) => s.status.imagePanelWidth;
@@ -34,7 +42,7 @@ const getAgentSystemRoleExpanded =
(agentId: string) =>
(s: GlobalState): boolean => {
const map = s.status.systemRoleExpandedMap || {};
- return map[agentId] !== false; // 角色设定默认为展开状态
+ return map[agentId] === true; // 角色设定默认为折叠状态
};
const disabledModelProvidersSortType = (s: GlobalState) =>
@@ -44,6 +52,7 @@ const tokenDisplayFormatShort = (s: GlobalState) =>
s.status.tokenDisplayFormatShort !== undefined ? s.status.tokenDisplayFormatShort : true;
export const systemStatusSelectors = {
+ agentPageSize,
chatInputHeight,
disabledModelProvidersSortType,
disabledModelsSortType,
@@ -57,20 +66,23 @@ export const systemStatusSelectors = {
isShowCredit,
isStatusInit,
language,
+ leftPanelWidth,
mobileShowPortal,
mobileShowTopic,
+ pagePageSize,
portalWidth,
sessionGroupKeys,
- sessionWidth,
showChatHeader,
- showChatSideBar,
showFilePanel,
showImagePanel,
showImageTopicPanel,
- showSessionPanel,
+ showLeftPanel,
+ showRightPanel,
showSystemRole,
systemStatus,
themeMode,
tokenDisplayFormatShort,
+ topicGroupKeys,
+ topicPageSize,
wideScreen,
};
diff --git a/src/store/image/slices/generationBatch/action.ts b/src/store/image/slices/generationBatch/action.ts
index 53a8a55e1de..3029f29af98 100644
--- a/src/store/image/slices/generationBatch/action.ts
+++ b/src/store/image/slices/generationBatch/action.ts
@@ -1,4 +1,4 @@
-import { isEqual } from 'lodash-es';
+import { isEqual } from 'es-toolkit/compat';
import { useRef } from 'react';
import { SWRResponse, mutate } from 'swr';
import { StateCreator } from 'zustand';