🤯 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
🐛 fix(app): include working panel into Lab feature, minor fixes (#13889)
Neko13d1b011b70a
diff --git a/locales/en-US/labs.json b/locales/en-US/labs.jsonindex 2522c807ae3..f26b2d5d43b 100644--- a/locales/en-US/labs.json+++ b/locales/en-US/labs.json@@ -1,4 +1,6 @@{+ "features.agentWorkingPanel.desc": "A place to view an agent's progress and accessible resources.",+ "features.agentWorkingPanel.title": "Working Panel","features.assistantMessageGroup.desc": "Group agent messages and their tool call results together for display","features.assistantMessageGroup.title": "Agent Message Grouping","features.gatewayMode.desc": "Execute agent tasks on the server via Gateway WebSocket instead of running locally. Enables faster execution and reduces client resource usage.",diff --git a/locales/zh-CN/labs.json b/locales/zh-CN/labs.jsonindex a3fc0d34d21..f47065402b1 100644--- a/locales/zh-CN/labs.json+++ b/locales/zh-CN/labs.json@@ -1,4 +1,6 @@{+ "features.agentWorkingPanel.desc": "在会话中查看当前助理可访问的资源和任务进度。",+ "features.agentWorkingPanel.title": "工作面板","features.assistantMessageGroup.desc": "将代理消息及其工具调用结果组合在一起显示","features.assistantMessageGroup.title": "代理消息分组","features.gatewayMode.desc": "通过 Gateway 在服务端执行 Agent 任务。可实现关闭浏览器后仍然执行 agent。",diff --git a/packages/const/src/user.ts b/packages/const/src/user.tsindex 7b58674186c..c8676deda6f 100644--- a/packages/const/src/user.ts+++ b/packages/const/src/user.ts@@ -14,6 +14,7 @@ export const DEFAULT_PREFERENCE: UserPreference = {topic: true,},lab: {+ enableAgentWorkingPanel: false,enableInputMarkdown: true,},topicDisplayMode: TopicDisplayMode.ByUpdatedTime,diff --git a/packages/types/src/user/preference.ts b/packages/types/src/user/preference.tsindex 04fd4d01056..dcbcfce2546 100644--- a/packages/types/src/user/preference.ts+++ b/packages/types/src/user/preference.ts@@ -38,6 +38,10 @@ export const UserGuideSchema = z.object({export type UserGuide = z.infer<typeof UserGuideSchema>;export const UserLabSchema = z.object({+ /**+ * enable agent working panel entry in chat header menu+ */+ enableAgentWorkingPanel: z.boolean().optional(),/*** enable server-side agent execution via Gateway WebSocket*/diff --git a/src/hooks/useHotkeys/globalScope.ts b/src/hooks/useHotkeys/globalScope.tsindex 917450479e9..f258b82dbad 100644--- a/src/hooks/useHotkeys/globalScope.ts+++ b/src/hooks/useHotkeys/globalScope.ts@@ -1,9 +1,12 @@import { INBOX_SESSION_ID } from '@lobechat/const';import { HotkeyEnum } from '@lobechat/types';+import { useLocation } from 'react-router-dom';import { useNavigateToAgent } from '@/hooks/useNavigateToAgent';import { usePinnedAgentState } from '@/hooks/usePinnedAgentState';import { useGlobalStore } from '@/store/global';+import { useUserStore } from '@/store/user';+import { labPreferSelectors } from '@/store/user/selectors';import { useHotkeyById } from './useHotkeyById';@@ -41,11 +44,23 @@ export const useToggleLeftPanelHotkey = () => {export const useToggleRightPanelHotkey = () => {const isZenMode = useGlobalStore((s) => s.status.zenMode);const toggleConfig = useGlobalStore((s) => s.toggleRightPanel);+ const { pathname } = useLocation();+ const enableAgentWorkingPanel = useUserStore(labPreferSelectors.enableAgentWorkingPanel);- return useHotkeyById(HotkeyEnum.ToggleRightPanel, () => toggleConfig(), {- enableOnContentEditable: true,- enabled: !isZenMode,- });+ return useHotkeyById(+ HotkeyEnum.ToggleRightPanel,+ () => {+ // TODO: Remove this labs-only guard once Working Panel is no longer an experimental feature.+ // Keep in sync with the related TODO in `src/routes/(main)/agent/features/Conversation/index.tsx`.+ const isChatRoute = pathname.startsWith('/agent') || pathname.startsWith('/chat');+ if (isChatRoute && !enableAgentWorkingPanel) return;+ toggleConfig();+ },+ {+ enableOnContentEditable: true,+ enabled: !isZenMode,+ },+ );};// CMDKdiff --git a/src/locales/default/labs.ts b/src/locales/default/labs.tsindex e3286b2a979..7291be0cc16 100644--- a/src/locales/default/labs.ts+++ b/src/locales/default/labs.ts@@ -1,4 +1,7 @@export default {+ 'features.agentWorkingPanel.desc':+ "A place to view an agent's progress and accessible resources.",+ 'features.agentWorkingPanel.title': 'Working Panel','features.assistantMessageGroup.desc':'Group agent messages and their tool call results together for display','features.assistantMessageGroup.title': 'Agent Message Grouping',diff --git a/src/routes/(main)/agent/features/Conversation/Header/HeaderActions/useMenu.tsx b/src/routes/(main)/agent/features/Conversation/Header/HeaderActions/useMenu.tsxindex fcdafca4d0e..9c926fa3d1d 100644--- a/src/routes/(main)/agent/features/Conversation/Header/HeaderActions/useMenu.tsx+++ b/src/routes/(main)/agent/features/Conversation/Header/HeaderActions/useMenu.tsx@@ -9,6 +9,8 @@ import { useTranslation } from 'react-i18next';import { useChatStore } from '@/store/chat';import { useGlobalStore } from '@/store/global';import { systemStatusSelectors } from '@/store/global/selectors';+import { useUserStore } from '@/store/user';+import { labPreferSelectors } from '@/store/user/selectors';export const useMenu = (): { menuItems: DropdownItem[] } => {const { t } = useTranslation('chat');@@ -19,34 +21,48 @@ export const useMenu = (): { menuItems: DropdownItem[] } => {s.toggleRightPanel,s.toggleWideScreen,]);+ const enableAgentWorkingPanel = useUserStore(labPreferSelectors.enableAgentWorkingPanel);const toggleNotebook = useChatStore((s) => s.toggleNotebook);- const menuItems = useMemo<DropdownItem[]>(- () => [+ const menuItems = useMemo<DropdownItem[]>(() => {+ const items: DropdownItem[] = [{icon: <Icon icon={FilePenIcon} />,key: 'notebook',label: tPortal('notebook.title'),onClick: () => toggleNotebook(),},- {+ ];++ if (enableAgentWorkingPanel) {+ items.push({icon: <Icon icon={PanelRightOpen} />,key: 'agent-workspace',label: t('workingPanel.title'),onClick: () => toggleRightPanel(),- },- {- checked: wideScreen,- icon: <Icon icon={Maximize2} />,- key: 'full-width',- label: t('viewMode.fullWidth'),- onCheckedChange: toggleWideScreen,- type: 'switch',- },- ],- [t, tPortal, wideScreen, toggleRightPanel, toggleWideScreen, toggleNotebook],- );+ });+ }++ items.push({+ checked: wideScreen,+ icon: <Icon icon={Maximize2} />,+ key: 'full-width',+ label: t('viewMode.fullWidth'),+ onCheckedChange: toggleWideScreen,+ type: 'switch',+ });++ return items;+ }, [+ enableAgentWorkingPanel,+ t,+ tPortal,+ toggleNotebook,+ toggleRightPanel,+ toggleWideScreen,+ wideScreen,+ ]);return { menuItems };};diff --git a/src/routes/(main)/agent/features/Conversation/WorkingSidebar/index.test.tsx b/src/routes/(main)/agent/features/Conversation/WorkingSidebar/index.test.tsxindex e972c56893d..d3c56697c86 100644--- a/src/routes/(main)/agent/features/Conversation/WorkingSidebar/index.test.tsx+++ b/src/routes/(main)/agent/features/Conversation/WorkingSidebar/index.test.tsx@@ -5,6 +5,8 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';import * as swr from '@/libs/swr';import { useGlobalStore } from '@/store/global';import { initialState } from '@/store/global/initialState';+import { useUserStore } from '@/store/user';+import { initialState as initialUserState } from '@/store/user/initialState';import Conversation from '../index';import AgentWorkingSidebar from './index';@@ -120,7 +122,18 @@ beforeEach(() => {error: undefined,isLoading: false,})) as unknown as typeof swr.useClientDataSWR);- useGlobalStore.setState(initialState);+ useGlobalStore.setState({+ ...initialState,+ isStatusInit: true,+ status: { ...initialState.status },+ });+ useUserStore.setState({+ ...initialUserState,+ preference: {+ ...initialUserState.preference,+ lab: { ...initialUserState.preference.lab, enableAgentWorkingPanel: false },+ },+ });});afterEach(() => {@@ -128,7 +141,23 @@ afterEach(() => {});describe('Conversation right panel mount', () => {- it('mounts the conversation-side right panel path and respects the existing global right-panel state', async () => {+ it('does not mount the conversation-side right panel path when working panel lab feature is disabled', () => {+ render(<Conversation />);++ expect(screen.getByText('chat-header')).toBeInTheDocument();+ expect(screen.getByText('conversation-area')).toBeInTheDocument();+ expect(screen.queryByTestId('right-panel')).not.toBeInTheDocument();+ expect(screen.queryByTestId('workspace-resources')).not.toBeInTheDocument();+ });++ it('mounts the conversation-side right panel path and defaults the right panel to collapsed when working panel lab feature is enabled', async () => {+ useUserStore.setState({+ preference: {+ ...useUserStore.getState().preference,+ lab: { ...useUserStore.getState().preference.lab, enableAgentWorkingPanel: true },+ },+ });+const { unmount } = render(<Conversation />);expect(screen.getByText('chat-header')).toBeInTheDocument();@@ -137,13 +166,13 @@ describe('Conversation right panel mount', () => {expect(screen.getByTestId('workspace-resources')).toBeInTheDocument();await waitFor(() => {- expect(screen.getByTestId('right-panel')).toHaveAttribute('data-expand', 'true');- expect(useGlobalStore.getState().status.showRightPanel).toBe(true);+ expect(screen.getByTestId('right-panel')).toHaveAttribute('data-expand', 'false');+ expect(useGlobalStore.getState().status.showRightPanel).toBe(false);});unmount();- expect(useGlobalStore.getState().status.showRightPanel).toBe(true);+ expect(useGlobalStore.getState().status.showRightPanel).toBe(false);});it('renders resources section and empty state', () => {diff --git a/src/routes/(main)/agent/features/Conversation/WorkingSidebar/index.tsx b/src/routes/(main)/agent/features/Conversation/WorkingSidebar/index.tsxindex f1fbbe9f886..9b2c9f9a102 100644--- a/src/routes/(main)/agent/features/Conversation/WorkingSidebar/index.tsx+++ b/src/routes/(main)/agent/features/Conversation/WorkingSidebar/index.tsx@@ -8,6 +8,7 @@ import RightPanel from '@/features/RightPanel';import { useGlobalStore } from '@/store/global';import AgentDocumentEditorPanel from './AgentDocumentEditorPanel';+import ProgressSection from './ProgressSection';import ResourcesSection from './ResourcesSection';interface AgentWorkingSidebarProps {@@ -46,7 +47,7 @@ const AgentWorkingSidebar = memo<AgentWorkingSidebarProps>(/><Flexbox gap={8} height={'100%'} style={{ overflowY: 'auto' }} width={'100%'}>{/* <AgentSummary /> */}- {/*<ProgressSection />*/}+ <ProgressSection /><ResourcesSectionselectedDocumentId={selectedDocumentId}onSelectDocument={onSelectDocument}diff --git a/src/routes/(main)/agent/features/Conversation/index.tsx b/src/routes/(main)/agent/features/Conversation/index.tsxindex a3cae546ac1..aadb865024b 100644--- a/src/routes/(main)/agent/features/Conversation/index.tsx+++ b/src/routes/(main)/agent/features/Conversation/index.tsx@@ -7,6 +7,8 @@ import { useAgentStore } from '@/store/agent';import { agentSelectors } from '@/store/agent/selectors';import { useGlobalStore } from '@/store/global';import { systemStatusSelectors } from '@/store/global/selectors';+import { useUserStore } from '@/store/user';+import { labPreferSelectors } from '@/store/user/selectors';import ConversationArea from './ConversationArea';import ChatHeader from './Header';@@ -20,6 +22,8 @@ const wrapperStyle: React.CSSProperties = {const ChatConversation = memo(() => {const showHeader = useGlobalStore(systemStatusSelectors.showChatHeader);+ const isStatusInit = useGlobalStore(systemStatusSelectors.isStatusInit);+ const enableAgentWorkingPanel = useUserStore(labPreferSelectors.enableAgentWorkingPanel);const [selectedDocumentId, setSelectedDocumentId] = useState<string | null>(null);const activeAgentId = useAgentStore((s) => s.activeAgentId);@@ -32,6 +36,11 @@ const ChatConversation = memo(() => {setSelectedDocumentId(null);}, [activeAgentId]);+ useEffect(() => {+ if (!isStatusInit) return;+ useGlobalStore.getState().toggleRightPanel(false);+ }, [isStatusInit]);+return (<Suspense fallback={<Loading debugId="Agent > ChatConversation" />}><DragUploadZone style={wrapperStyle} onUploadFiles={handleUploadFiles}>@@ -47,10 +56,14 @@ const ChatConversation = memo(() => {<ConversationArea /></TooltipGroup></Flexbox>- <AgentWorkingSidebar- selectedDocumentId={selectedDocumentId}- onSelectDocument={setSelectedDocumentId}- />+ {/* TODO: Remove this labs-only mount gate once Working Panel is no longer experimental.+ See the matching TODO in `src/hooks/useHotkeys/globalScope.ts`. */}+ {enableAgentWorkingPanel && (+ <AgentWorkingSidebar+ selectedDocumentId={selectedDocumentId}+ onSelectDocument={setSelectedDocumentId}+ />+ )}</Flexbox></DragUploadZone></Suspense>diff --git a/src/routes/(main)/settings/advanced/index.tsx b/src/routes/(main)/settings/advanced/index.tsxindex b1a36f6ce89..b3b4d571d65 100644--- a/src/routes/(main)/settings/advanced/index.tsx+++ b/src/routes/(main)/settings/advanced/index.tsx@@ -35,14 +35,19 @@ const Page = memo(() => {const [setSettings, isUserStateInit] = useUserStore((s) => [s.setSettings, s.isUserStateInit]);const [loading, setLoading] = useState(false);- const [isPreferenceInit, enableInputMarkdown, enableGatewayMode, updateLab] = useUserStore(- (s) => [- preferenceSelectors.isPreferenceInit(s),- labPreferSelectors.enableInputMarkdown(s),- labPreferSelectors.enableGatewayMode(s),- s.updateLab,- ],- );+ const [+ isPreferenceInit,+ enableInputMarkdown,+ enableGatewayMode,+ enableAgentWorkingPanel,+ updateLab,+ ] = useUserStore((s) => [+ preferenceSelectors.isPreferenceInit(s),+ labPreferSelectors.enableInputMarkdown(s),+ labPreferSelectors.enableGatewayMode(s),+ labPreferSelectors.enableAgentWorkingPanel(s),+ s.updateLab,+ ]);const hasGatewayUrl = useServerConfigStore((s) => !!s.serverConfig.agentGatewayUrl);@@ -118,6 +123,19 @@ const Page = memo(() => {label: tLabs('features.inputMarkdown.title'),minWidth: undefined,},+ {+ children: (+ <Switch+ checked={enableAgentWorkingPanel}+ loading={!isPreferenceInit}+ onChange={(checked: boolean) => updateLab({ enableAgentWorkingPanel: checked })}+ />+ ),+ className: styles.labItem,+ desc: tLabs('features.agentWorkingPanel.desc'),+ label: tLabs('features.agentWorkingPanel.title'),+ minWidth: undefined,+ },...(hasGatewayUrl? [{diff --git a/src/store/user/slices/preference/selectors/labPrefer.ts b/src/store/user/slices/preference/selectors/labPrefer.tsindex 5235e3e2dbf..853f4de3aba 100644--- a/src/store/user/slices/preference/selectors/labPrefer.ts+++ b/src/store/user/slices/preference/selectors/labPrefer.ts@@ -3,6 +3,8 @@ import { DEFAULT_PREFERENCE } from '@lobechat/const';import { type UserState } from '@/store/user/initialState';export const labPreferSelectors = {+ enableAgentWorkingPanel: (s: UserState): boolean =>+ s.preference.lab?.enableAgentWorkingPanel ?? false,enableGatewayMode: (s: UserState): boolean => s.preference.lab?.enableGatewayMode ?? false,enableInputMarkdown: (s: UserState): boolean =>s.preference.lab?.enableInputMarkdown ?? DEFAULT_PREFERENCE.lab!.enableInputMarkdown!,