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: refine agent sidebar navigation (#18325)

Arvin Xu1056cdf32b4e
diff --git a/locales/en-US/chat.json b/locales/en-US/chat.json
index 9e2b8a6c3c1..3189e0fc967 100644
--- a/locales/en-US/chat.json
+++ b/locales/en-US/chat.json
@@ -26,6 +26,7 @@
"agentDefaultMessage": "Hi, I’m **{{name}}**. One sentence is enough.\n\nWant me to match your workflow better? Go to [Agent Settings]({{url}}) and fill in the Agent Profile (you can edit it anytime).",
"agentDefaultMessageWithSystemRole": "Hi, I’m **{{name}}**. One sentence is enough—you're in control.",
"agentDefaultMessageWithoutEdit": "Hi, I’m **{{name}}**. One sentence is enough—you're in control.",
+ "agentDocument.backToAgent": "Back to {{name}}",
"agentDocument.backToChat": "Back to chat",
"agentDocument.emptyDescription": "Pick a document from the panel on the right, or create a new one to get started.",
"agentDocument.emptyTitle": "No document open",
@@ -2057,6 +2058,7 @@
"workingPanel.resources.renameError": "Failed to rename document",
"workingPanel.resources.renameSuccess": "Document renamed",
"workingPanel.resources.tree.convertToSkill": "Convert to skill",
+ "workingPanel.resources.tree.create": "Create",
"workingPanel.resources.tree.createError": "Failed to create",
"workingPanel.resources.tree.deleteSelected": "Delete selected ({{count}})",
"workingPanel.resources.tree.moveError": "Failed to move",
diff --git a/locales/zh-CN/chat.json b/locales/zh-CN/chat.json
index 92d980605ca..8d77885737b 100644
--- a/locales/zh-CN/chat.json
+++ b/locales/zh-CN/chat.json
@@ -26,6 +26,7 @@
"agentDefaultMessage": "你好,我是 **{{name}}**。从一句话开始就行。\n\n想让我更贴近你的工作方式:去 [助理设置]({{url}}) 补充助理档案(随时可改)",
"agentDefaultMessageWithSystemRole": "你好,我是 **{{name}}**。从一句话开始就行——决定权在你",
"agentDefaultMessageWithoutEdit": "你好,我是 **{{name}}**。从一句话开始就行——决定权在你",
+ "agentDocument.backToAgent": "返回 {{name}}",
"agentDocument.backToChat": "返回对话",
"agentDocument.emptyDescription": "从右侧面板选择一个文档,或新建一个开始编辑。",
"agentDocument.emptyTitle": "未打开任何文档",
@@ -2057,6 +2058,7 @@
"workingPanel.resources.renameError": "重命名失败",
"workingPanel.resources.renameSuccess": "重命名成功",
"workingPanel.resources.tree.convertToSkill": "转换为技能",
+ "workingPanel.resources.tree.create": "新建",
"workingPanel.resources.tree.createError": "创建失败",
"workingPanel.resources.tree.deleteSelected": "删除所选({{count}})",
"workingPanel.resources.tree.moveError": "移动失败",
diff --git a/packages/locales/src/default/chat.ts b/packages/locales/src/default/chat.ts
index 031e2c4d543..a61467b4d40 100644
--- a/packages/locales/src/default/chat.ts
+++ b/packages/locales/src/default/chat.ts
@@ -33,6 +33,7 @@ export default {
'agentDefaultMessageWithoutEdit':
"Hi, I’m **{{name}}**. One sentence is enough—you're in control.",
'agentDocument.backToChat': 'Back to chat',
+ 'agentDocument.backToAgent': 'Back to {{name}}',
'agentDocument.emptyDescription':
'Pick a document from the panel on the right, or create a new one to get started.',
'agentDocument.emptyTitle': 'No document open',
@@ -2190,6 +2191,7 @@ export default {
'workingPanel.resources.tree.deleteSelected': 'Delete selected ({{count}})',
'workingPanel.resources.tree.moveError': 'Failed to move',
'workingPanel.resources.tree.parentMissing': 'Parent folder is unavailable',
+ 'workingPanel.resources.tree.create': 'Create',
'workingPanel.resources.tree.newDocument': 'New document',
'workingPanel.resources.tree.newFolder': 'New folder',
'workingPanel.resources.tree.rename': 'Rename',
diff --git a/src/features/AgentDocumentPage/Header/index.tsx b/src/features/AgentDocumentPage/Header/index.tsx
index 927af8af63f..f8ccc099358 100644
--- a/src/features/AgentDocumentPage/Header/index.tsx
+++ b/src/features/AgentDocumentPage/Header/index.tsx
@@ -70,23 +70,23 @@ const Header = memo<HeaderProps>(
>
{resolvedTitle}
</Text>
- </Flexbox>
- }
- right={
- <Flexbox horizontal align={'center'} gap={4}>
- {documentId && <AutoSaveHint documentId={documentId} />}
- {documentId && <ShareButton documentId={documentId} />}
- <ToggleRightPanelButton hideWhenExpanded />
<DropdownMenu
iconSpaceMode={'group'}
items={menuItems}
- placement={'bottomRight'}
+ placement={'bottomLeft'}
popupProps={{ style: { minWidth: 200 } }}
>
<ActionIcon icon={MoreHorizontal} size={DESKTOP_HEADER_ICON_SMALL_SIZE} />
</DropdownMenu>
</Flexbox>
}
+ right={
+ <Flexbox horizontal align={'center'} gap={4}>
+ {documentId && <AutoSaveHint documentId={documentId} />}
+ {documentId && <ShareButton documentId={documentId} />}
+ <ToggleRightPanelButton hideWhenExpanded />
+ </Flexbox>
+ }
/>
);
},
diff --git a/src/features/AgentDocumentPage/Layout/index.tsx b/src/features/AgentDocumentPage/Layout/index.tsx
index 43bdc5f6b7d..6bf505a503d 100644
--- a/src/features/AgentDocumentPage/Layout/index.tsx
+++ b/src/features/AgentDocumentPage/Layout/index.tsx
@@ -3,21 +3,27 @@
import { Flexbox } from '@lobehub/ui';
import { Outlet } from 'react-router';
-import AgentDocumentRightPanel from '../RightPanel';
+import { NavPanelPortal } from '@/features/NavPanel/NavPanelPortal';
+
+import AgentDocumentSidebarContent from '../RightPanel';
const AgentDocumentLayout = () => (
- <Flexbox
- horizontal
- flex={1}
- height={'100%'}
- style={{ minHeight: 0, overflow: 'hidden', position: 'relative' }}
- width={'100%'}
- >
- <Flexbox flex={1} style={{ minHeight: 0, minWidth: 0 }}>
- <Outlet />
+ <>
+ <NavPanelPortal navKey="agent-docs">
+ <AgentDocumentSidebarContent />
+ </NavPanelPortal>
+ <Flexbox
+ horizontal
+ flex={1}
+ height={'100%'}
+ style={{ minHeight: 0, overflow: 'hidden', position: 'relative' }}
+ width={'100%'}
+ >
+ <Flexbox flex={1} style={{ minHeight: 0, minWidth: 0 }}>
+ <Outlet />
+ </Flexbox>
</Flexbox>
- <AgentDocumentRightPanel />
- </Flexbox>
+ </>
);
export default AgentDocumentLayout;
diff --git a/src/features/AgentDocumentPage/RightPanel/index.tsx b/src/features/AgentDocumentPage/RightPanel/index.tsx
index 52a374d73e8..f0c31c8584b 100644
--- a/src/features/AgentDocumentPage/RightPanel/index.tsx
+++ b/src/features/AgentDocumentPage/RightPanel/index.tsx
@@ -1,90 +1,76 @@
'use client';
-import { AGENT_DOCUMENT_CATEGORY, AGENT_DOCUMENT_SKILL_CATEGORY } from '@lobechat/const';
-import { ActionIcon, Flexbox } from '@lobehub/ui';
+import { agentDisplayName } from '@lobechat/types';
+import { Flexbox, Icon } from '@lobehub/ui';
import { createStaticStyles } from 'antd-style';
-import { PanelRightCloseIcon } from 'lucide-react';
-import { memo, useMemo, useState } from 'react';
+import { ChevronLeftIcon } from 'lucide-react';
+import { memo, type MouseEvent } from 'react';
import { useTranslation } from 'react-i18next';
-import { useParams } from 'react-router';
-import { DESKTOP_HEADER_ICON_SMALL_SIZE } from '@/const/layoutTokens';
+import { useActiveWorkspaceSlug } from '@/business/client/hooks/useActiveWorkspaceSlug';
import { isDesktop } from '@/const/version';
import AgentDocumentsGroup from '@/features/Conversation/WorkingSidebar/ResourcesSection/AgentDocumentsGroup';
-import RightPanel from '@/features/RightPanel';
+import { appNavigate } from '@/features/Electron/navigation/appNavigate';
+import SideBarLayout from '@/features/NavPanel/SideBarLayout';
+import ToggleLeftPanelButton from '@/features/NavPanel/ToggleLeftPanelButton';
+import { buildWorkspaceAwarePath } from '@/features/Workspace/workspaceAwarePath';
import { resolveExecutionTarget } from '@/helpers/executionTarget';
import { useIsGatewayModeEnabled } from '@/helpers/gatewayMode';
+import { useActiveRouteParams } from '@/hooks/useActiveRouteParams';
import { useEffectiveWorkingDirectory } from '@/hooks/useEffectiveWorkingDirectory';
-import { useClientDataSWR } from '@/libs/swr';
-import { agentDocumentService, agentDocumentSWRKeys } from '@/services/agentDocument';
import { useAgentStore } from '@/store/agent';
import { agentByIdSelectors, agentSelectors } from '@/store/agent/selectors';
-import { useGlobalStore } from '@/store/global';
-import { standardizeIdentifier } from '@/utils/identifier';
-
-type AgentDocumentPanelTab = 'documents' | 'skills';
const styles = createStaticStyles(({ css, cssVar }) => ({
- body: css`
- overflow-y: auto;
- flex: 1;
- min-height: 0;
- `,
- header: css`
- flex-shrink: 0;
- `,
- tab: css`
- cursor: pointer;
+ backLink: css`
+ display: flex;
+ gap: 2px;
+ align-items: center;
- padding-block: 4px;
- padding-inline: 10px;
- border: none;
+ width: fit-content;
+ padding-block: 3px;
+ padding-inline: 4px 6px;
border-radius: 6px;
- font-size: 13px;
+ font-size: 12px;
color: ${cssVar.colorTextTertiary};
+ text-decoration: none;
background: transparent;
transition:
- color 0.15s,
- background 0.15s;
+ color 150ms ease,
+ background 150ms ease;
&:hover {
- color: ${cssVar.colorText};
+ color: ${cssVar.colorTextSecondary};
+ background: ${cssVar.colorFillTertiary};
}
`,
- tabActive: css`
- color: ${cssVar.colorText};
- background: ${cssVar.colorFillTertiary};
- `,
- tabs: css`
- display: flex;
- gap: 4px;
- align-items: center;
+ body: css`
+ overflow-y: auto;
+ flex: 1;
+ min-height: 0;
`,
}));
-const TABS = [
- { key: 'documents', labelKey: 'workingPanel.resources.filter.documents' },
- { key: 'skills', labelKey: 'workingPanel.skills.title' },
-] as const satisfies readonly { key: AgentDocumentPanelTab; labelKey: string }[];
-
-const AgentDocumentRightPanel = memo(() => {
+const AgentDocumentSidebarContent = memo(() => {
const { t } = useTranslation('chat');
- // null = not yet picked by the user → follow the auto default below.
- const [pickedTab, setPickedTab] = useState<AgentDocumentPanelTab | null>(null);
- const { docId } = useParams<{ docId?: string }>();
- const toggleRightPanel = useGlobalStore((s) => s.toggleRightPanel);
- const activeAgentId = useAgentStore((s) => s.activeAgentId);
- const isHetero = useAgentStore(agentSelectors.isCurrentAgentHeterogeneous);
- const workingDirectory = useEffectiveWorkingDirectory(activeAgentId);
+ const activeWorkspaceSlug = useActiveWorkspaceSlug();
+ const { aid: agentId = '' } = useActiveRouteParams<{
+ aid?: string;
+ }>();
+ const agentMeta = useAgentStore(agentSelectors.getAgentMetaById(agentId));
+ const agentTitle = agentDisplayName(agentMeta, t('untitledAgent'));
+ const agentPath = buildWorkspaceAwarePath(`/agent/${agentId}`, activeWorkspaceSlug);
+ const isHetero = useAgentStore(agentByIdSelectors.isAgentHeterogeneousById(agentId));
+ const workingDirectory = useEffectiveWorkingDirectory(agentId);
const agencyConfig = useAgentStore((s) =>
- activeAgentId ? agentByIdSelectors.getAgencyConfigById(activeAgentId)(s) : undefined,
+ agentId ? agentByIdSelectors.getAgencyConfigById(agentId)(s) : undefined,
);
- const deviceRoutingAvailable = useIsGatewayModeEnabled(activeAgentId);
+ const deviceRoutingAvailable = useIsGatewayModeEnabled(agentId);
const isWorkspaceAgent = useAgentStore((s) =>
- activeAgentId ? agentByIdSelectors.isWorkspaceAgentById(activeAgentId)(s) : false,
+ agentId ? agentByIdSelectors.isWorkspaceAgentById(agentId)(s) : false,
);
const effectiveTarget = resolveExecutionTarget(agencyConfig, {
clientExecutionAvailable: isDesktop,
@@ -97,86 +83,47 @@ const AgentDocumentRightPanel = memo(() => {
? agencyConfig.boundDeviceId
: undefined;
- // Deduped against AgentDocumentsGroup's own fetch (same SWR key). When the
- // agent has no plain documents (e.g. only skills) we default to the Skills
- // tab so the panel doesn't open on an empty Documents view.
- const {
- data: documentList = [],
- error: documentListError,
- isLoading: isDocumentListLoading,
- } = useClientDataSWR(
- activeAgentId ? agentDocumentSWRKeys.documentsList(activeAgentId) : null,
- () => agentDocumentService.listDocuments({ agentId: activeAgentId! }),
- );
- const hasDocuments = useMemo(
- () => documentList.some((doc) => doc.category === AGENT_DOCUMENT_CATEGORY),
- [documentList],
- );
- // The open doc itself decides the default tab: a skill entry (SKILL.md or any
- // file inside a skill bundle) lands on Skills even when normal documents
- // exist — otherwise the skill-entry flow would open on the wrong tab.
- const isSkillEntry = useMemo(
- () =>
- docId
- ? documentList.some(
- (doc) =>
- standardizeIdentifier(doc.documentId) === docId &&
- doc.category === AGENT_DOCUMENT_SKILL_CATEGORY,
- )
- : false,
- [docId, documentList],
+ const handleBack = (event: MouseEvent<HTMLAnchorElement>) => {
+ if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey || event.button !== 0)
+ return;
+
+ event.preventDefault();
+ appNavigate(agentPath, { escape: true });
+ };
+
+ const header = (
+ <Flexbox
+ horizontal
+ align={'center'}
+ flex={'none'}
+ justify={'space-between'}
+ padding={'8px 6px'}
+ >
+ <a className={styles.backLink} href={agentPath} onClick={handleBack}>
+ <Icon icon={ChevronLeftIcon} size={14} />
+ {t('agentDocument.backToAgent', { name: agentTitle })}
+ </a>
+ <ToggleLeftPanelButton />
+ </Flexbox>
);
- const activeTab: AgentDocumentPanelTab =
- pickedTab ??
- (isSkillEntry || (!documentListError && !isDocumentListLoading && !hasDocuments)
- ? 'skills'
- : 'documents');
-
- return (
- <RightPanel stableLayout defaultWidth={360} maxWidth={720} minWidth={300}>
- <Flexbox height={'100%'} width={'100%'}>
- <Flexbox
- horizontal
- align={'center'}
- className={styles.header}
- height={44}
- justify={'space-between'}
- paddingInline={4}
- >
- <div className={styles.tabs}>
- {TABS.map((tab) => (
- <button
- className={`${styles.tab} ${activeTab === tab.key ? styles.tabActive : ''}`}
- key={tab.key}
- type="button"
- onClick={() => setPickedTab(tab.key)}
- >
- {t(tab.labelKey)}
- </button>
- ))}
- </div>
- <ActionIcon
- icon={PanelRightCloseIcon}
- size={DESKTOP_HEADER_ICON_SMALL_SIZE}
- onClick={() => toggleRightPanel(false)}
- />
- </Flexbox>
- <Flexbox className={styles.body} width={'100%'}>
- <AgentDocumentsGroup
- activeFilter={activeTab}
- deviceId={remoteDeviceId}
- openMode="route"
- showFilterTabs={false}
- showLocalProjectSkills={isDesktop}
- style={{ flex: 1, minHeight: 0 }}
- workingDirectory={workingDirectory}
- />
- </Flexbox>
- </Flexbox>
- </RightPanel>
+
+ const body = (
+ <Flexbox className={styles.body} width={'100%'}>
+ <AgentDocumentsGroup
+ activeFilter="documents"
+ deviceId={remoteDeviceId}
+ openMode="route"
+ showFilterTabs={false}
+ showLocalProjectSkills={false}
+ style={{ flex: 1, minHeight: 0 }}
+ workingDirectory={workingDirectory}
+ />
+ </Flexbox>
);
+
+ return <SideBarLayout body={body} header={header} />;
});
-AgentDocumentRightPanel.displayName = 'AgentDocumentRightPanel';
+AgentDocumentSidebarContent.displayName = 'AgentDocumentSidebarContent';
-export default AgentDocumentRightPanel;
+export default AgentDocumentSidebarContent;
diff --git a/src/features/AgentDocumentPage/index.test.tsx b/src/features/AgentDocumentPage/index.test.tsx
index 2f8242f1b23..e76ef424306 100644
--- a/src/features/AgentDocumentPage/index.test.tsx
+++ b/src/features/AgentDocumentPage/index.test.tsx
@@ -34,9 +34,9 @@ vi.mock('@/features/PageEditor', () => ({
},
}));
-vi.mock('@/features/WideScreenContainer', () => ({
+vi.mock('@/features/RightPanel', () => ({
default: ({ children }: { children?: ReactNode }) => (
- <div data-testid="wide-screen-container">{children}</div>
+ <aside data-testid="right-panel">{children}</aside>
),
}));
@@ -158,7 +158,7 @@ describe('AgentDocumentPage', () => {
it('renders FloatingChatPanel anchored on the URL agent + doc-scoped topic', () => {
render(<AgentDocumentPage documentId="docs_abc" />);
- const container = screen.getByTestId('wide-screen-container');
+ const container = screen.getByTestId('right-panel');
const panel = screen.getByTestId('floating-chat-panel');
expect(container).toContainElement(panel);
expect(panelProps.current).toMatchObject({
diff --git a/src/features/AgentDocumentPage/index.tsx b/src/features/AgentDocumentPage/index.tsx
index 8b27fb82f81..3186ee71eda 100644
--- a/src/features/AgentDocumentPage/index.tsx
+++ b/src/features/AgentDocumentPage/index.tsx
@@ -8,7 +8,7 @@ import { type ComposerTarget, createComposerTarget } from '@/features/Conversati
import FloatingChatPanel from '@/features/FloatingChatPanel';
import { useDocumentChatTopic } from '@/features/FloatingChatPanel/useDocumentChatTopic';
import { PageEditor } from '@/features/PageEditor';
-import WideScreenContainer from '@/features/WideScreenContainer';
+import RightPanel from '@/features/RightPanel';
import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
import { messageMapKey } from '@/store/chat/utils/messageMapKey';
@@ -118,7 +118,13 @@ const AgentDocumentPage = memo<AgentDocumentPageProps>(({ documentId }) => {
if (isNotFound) return null;
return (
- <Flexbox flex={1} height={'100%'} style={{ minHeight: 0, overflow: 'hidden' }} width={'100%'}>
+ <Flexbox
+ horizontal
+ flex={1}
+ height={'100%'}
+ style={{ minHeight: 0, overflow: 'hidden' }}
+ width={'100%'}
+ >
<Flexbox flex={1} style={{ minHeight: 0 }} width={'100%'}>
<PageEditor
fullWidthHeader
@@ -140,15 +146,18 @@ const AgentDocumentPage = memo<AgentDocumentPageProps>(({ documentId }) => {
/>
</Flexbox>
{chatAgentId && docChatTopicId && (
- <WideScreenContainer>
- <FloatingChatPanel
- agentDocumentId={item?.id}
- agentId={chatAgentId}
- documentId={documentId}
- key={`${chatAgentId}:${docChatTopicId}:${documentId}`}
- topicId={docChatTopicId}
- />
- </WideScreenContainer>
+ <RightPanel expand defaultWidth={400} maxWidth={720} minWidth={320}>
+ <Flexbox flex={1} height={'100%'} justify={'flex-end'} style={{ minHeight: 0 }}>
+ <FloatingChatPanel
+ agentDocumentId={item?.id}
+ agentId={chatAgentId}
+ documentId={documentId}
+ key={`${chatAgentId}:${docChatTopicId}:${documentId}`}
+ mode="embedded"
+ topicId={docChatTopicId}
+ />
+ </Flexbox>
+ </RightPanel>
)}
</Flexbox>
);
diff --git a/src/features/AgentDocumentsExplorer/DocumentExplorerToolbar.tsx b/src/features/AgentDocumentsExplorer/DocumentExplorerToolbar.tsx
index 6b991eddf79..6677ecec055 100644
--- a/src/features/AgentDocumentsExplorer/DocumentExplorerToolbar.tsx
+++ b/src/features/AgentDocumentsExplorer/DocumentExplorerToolbar.tsx
@@ -1,7 +1,8 @@
-import { ActionIcon, Flexbox, Text } from '@lobehub/ui';
+import { ActionIcon, Flexbox, Icon, Text } from '@lobehub/ui';
+import { type DropdownItem, DropdownMenu } from '@lobehub/ui/base-ui';
import { createStaticStyles } from 'antd-style';
-import { FilePlusIcon, FolderPlusIcon } from 'lucide-react';
-import { memo } from 'react';
+import { FilePlusIcon, FolderPlusIcon, PlusIcon } from 'lucide-react';
+import { memo, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
const styles = createStaticStyles(({ css, cssVar }) => ({
@@ -25,25 +26,36 @@ interface Props {
const DocumentExplorerToolbar = memo<Props>(({ onCreateDocument, onCreateFolder }) => {
const { t } = useTranslation('chat');
+ const createMenuItems = useMemo<DropdownItem[]>(
+ () => [
+ {
+ icon: <Icon icon={FilePlusIcon} />,
+ key: 'new-document',
+ label: t('workingPanel.resources.tree.newDocument'),
+ onClick: onCreateDocument,
+ },
+ {
+ icon: <Icon icon={FolderPlusIcon} />,
+ key: 'new-folder',
+ label: t('workingPanel.resources.tree.newFolder'),
+ onClick: onCreateFolder,
+ },
+ ],
+ [onCreateDocument, onCreateFolder, t],
+ );
+
return (
<Flexbox horizontal align={'center'} className={styles.toolbar} distribution={'space-between'}>
<Text className={styles.title} type={'secondary'}>
{t('workingPanel.resources.filter.documents')}
</Text>
- <Flexbox horizontal gap={2}>
- <ActionIcon
- icon={FolderPlusIcon}
- size={'small'}
- title={t('workingPanel.resources.tree.newFolder')}
- onClick={onCreateFolder}
- />
+ <DropdownMenu items={createMenuItems} placement={'bottomRight'}>
<ActionIcon
- icon={FilePlusIcon}
+ icon={PlusIcon}
size={'small'}
- title={t('workingPanel.resources.tree.newDocument')}
- onClick={onCreateDocument}
+ title={t('workingPanel.resources.tree.create')}
/>
- </Flexbox>
+ </DropdownMenu>
</Flexbox>
);
});
diff --git a/src/features/AgentDocumentsExplorer/DocumentExplorerTree.test.tsx b/src/features/AgentDocumentsExplorer/DocumentExplorerTree.test.tsx
index e8d0f8a5a0a..2182c821e06 100644
--- a/src/features/AgentDocumentsExplorer/DocumentExplorerTree.test.tsx
+++ b/src/features/AgentDocumentsExplorer/DocumentExplorerTree.test.tsx
@@ -23,8 +23,16 @@ const openDocumentMock = vi.hoisted(() => vi.fn());
const removeDocumentMock = vi.hoisted(() => vi.fn());
vi.mock('@lobehub/ui', () => ({
- ActionIcon: ({ onClick, title }: { onClick?: () => void; title?: string }) => (
- <button aria-label={title} onClick={onClick}>
+ ActionIcon: ({
+ icon,
+ onClick,
+ title,
+ }: {
+ icon?: { displayName?: string; name?: string };
+ onClick?: () => void;
+ title?: string;
+ }) => (
+ <button aria-label={title} data-icon={icon?.displayName ?? icon?.name} onClick={onClick}>
{title}
</button>
),
@@ -39,6 +47,22 @@ vi.mock('@lobehub/ui/icons', () => ({
vi.mock('@lobehub/ui/base-ui', () => ({
confirmModal: modalConfirm,
+ DropdownMenu: ({
+ children,
+ items,
+ }: {
+ children: ReactNode;
+ items: { key: string; label: string; onClick: () => void }[];
+ }) => (
+ <div>
+ {children}
+ {items.map((item) => (
+ <button data-testid={`create-menu-${item.key}`} key={item.key} onClick={item.onClick}>
+ {item.label}
+ </button>
+ ))}
+ </div>
+ ),
}));
vi.mock('antd', () => ({
@@ -199,6 +223,23 @@ describe('DocumentExplorerTree', () => {
removeDocumentMock.mockResolvedValue({ deleted: true, id: 'skill-bundle-row' });
});
+ it('uses one plus menu for creating documents and folders', () => {
+ render(
+ <DocumentExplorerTree agentId="agent-1" data={[createDocument({})]} mutate={vi.fn()} />,
+ { wrapper: MemoryRouter },
+ );
+
+ expect(
+ screen.getByRole('button', { name: 'workingPanel.resources.tree.create' }),
+ ).toHaveAttribute('data-icon', 'Plus');
+ expect(screen.getByTestId('create-menu-new-document')).toHaveTextContent(
+ 'workingPanel.resources.tree.newDocument',
+ );
+ expect(screen.getByTestId('create-menu-new-folder')).toHaveTextContent(
+ 'workingPanel.resources.tree.newFolder',
+ );
+ });
+
it('renders managed skill bundle as a folder with SKILL.md underneath', () => {
const data = [
createDocument({
diff --git a/src/features/AgentSidebar/Body.tsx b/src/features/AgentSidebar/Body.tsx
index 041a51be560..94cbcb45555 100644
--- a/src/features/AgentSidebar/Body.tsx
+++ b/src/features/AgentSidebar/Body.tsx
@@ -5,18 +5,13 @@ import { useAgentStore } from '@/store/agent';
import { useGlobalStore } from '@/store/global';
import { systemStatusSelectors } from '@/store/global/selectors';
-import TaskList from './Task';
import Topic from './Topic';
export enum ChatSidebarKey {
- Tasks = 'tasks',
Topic = 'topic',
}
-// Topic expanded, Tasks collapsed — the resting state for an agent with no
-// saved preference (matches the prior `defaultExpandedKeys={[Topic]}`).
const DEFAULT_EXPANDED: Record<string, boolean> = {
- [ChatSidebarKey.Tasks]: false,
[ChatSidebarKey.Topic]: true,
};
@@ -38,7 +33,6 @@ const Body = memo(() => {
updateSystemStatus({
expandAgentSidebarSectionsByAgent: {
[agentId]: {
- [ChatSidebarKey.Tasks]: keys.includes(ChatSidebarKey.Tasks),
[ChatSidebarKey.Topic]: keys.includes(ChatSidebarKey.Topic),
},
},
@@ -50,7 +44,6 @@ const Body = memo(() => {
return (
<Flexbox paddingInline={4}>
<Accordion expandedKeys={expandedKeys} gap={8} onExpandedChange={handleExpandedChange}>
- <TaskList itemKey={ChatSidebarKey.Tasks} />
<Topic
expanded={expandedKeys.includes(ChatSidebarKey.Topic)}
itemKey={ChatSidebarKey.Topic}
diff --git a/src/features/AgentSidebar/Header/Nav.test.tsx b/src/features/AgentSidebar/Header/Nav.test.tsx
index a26cdc0a5ce..5de40e29428 100644
--- a/src/features/AgentSidebar/Header/Nav.test.tsx
+++ b/src/features/AgentSidebar/Header/Nav.test.tsx
@@ -33,6 +33,7 @@ vi.mock('@lobehub/ui/icons', () => ({
}));
vi.mock('lucide-react', () => ({
+ ListTodoIcon: () => null,
MessageSquarePlusIcon: () => null,
MessagesSquareIcon: () => null,
SearchIcon: () => null,
@@ -229,7 +230,31 @@ describe('Agent sidebar header nav', () => {
expect(pushMock).toHaveBeenCalledWith('/agent/agt_eH4zL98zBx5u/goals');
});
- it('places topics above profile and goals in the agent navigation', () => {
+ it('navigates to the agent tasks page', () => {
+ usePathnameMock.mockReturnValue('/agent/agt_eH4zL98zBx5u');
+
+ render(<Nav />);
+ fireEvent.click(screen.getByRole('button', { name: 'tab.tasks' }));
+
+ expect(switchTopicMock).toHaveBeenCalledWith(null, { skipRefreshMessage: true });
+ expect(pushMock).toHaveBeenCalledWith('/agent/agt_eH4zL98zBx5u/tasks');
+ });
+
+ it.each(['/agent/agt_eH4zL98zBx5u/tasks', '/agent/agt_eH4zL98zBx5u/task/task_2FCHvjS7d4CA'])(
+ 'keeps the tasks entry active on %s',
+ (pathname) => {
+ usePathnameMock.mockReturnValue(pathname);
+
+ render(<Nav />);
+
+ expect(screen.getByRole('button', { name: 'tab.tasks' })).toHaveAttribute(
+ 'data-active',
+ 'true',
+ );
+ },
+ );
+
+ it('places topics above profile, goals, and tasks in the agent navigation', () => {
usePathnameMock.mockReturnValue('/agent/agt_eH4zL98zBx5u');
render(<Nav />);
@@ -237,5 +262,6 @@ describe('Agent sidebar header nav', () => {
const labels = screen.getAllByRole('button').map((button) => button.textContent);
expect(labels.indexOf('management.sidebarEntry')).toBeLessThan(labels.indexOf('tab.profile'));
expect(labels.indexOf('tab.profile')).toBeLessThan(labels.indexOf('goalList.title'));
+ expect(labels.indexOf('goalList.title')).toBeLessThan(labels.indexOf('tab.tasks'));
});
});
diff --git a/src/features/AgentSidebar/Header/Nav.tsx b/src/features/AgentSidebar/Header/Nav.tsx
index f154776e295..cfed8303d74 100644
--- a/src/features/AgentSidebar/Header/Nav.tsx
+++ b/src/features/AgentSidebar/Header/Nav.tsx
@@ -2,7 +2,13 @@
import { Flexbox } from '@lobehub/ui';
import { BotPromptIcon } from '@lobehub/ui/icons';
-import { MessageSquarePlusIcon, MessagesSquareIcon, SearchIcon, TargetIcon } from 'lucide-react';
+import {
+ ListTodoIcon,
+ MessageSquarePlusIcon,
+ MessagesSquareIcon,
+ SearchIcon,
+ TargetIcon,
+} from 'lucide-react';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
import urlJoin from 'url-join';
@@ -36,6 +42,7 @@ const Nav = memo(() => {
pathname.includes('/channel') ||
pathname.endsWith('/statistics');
const isGoalsActive = pathname.endsWith('/goals');
+ const isTasksActive = pathname.endsWith('/tasks') || pathname.includes('/task/');
// Topic IDs are prefixed `topics_`, so /agent/:aid/topics_abc would also match
// pathname.includes('/topics') — anchor to end to avoid that false positive.
const isTopicsActive = pathname.endsWith('/topics');
@@ -109,6 +116,15 @@ const Nav = memo(() => {
}}
/>
)}
+ <NavItem
+ active={isTasksActive}
+ icon={ListTodoIcon}
+ title={t('tab.tasks')}
+ onClick={() => {
+ switchTopic(null, { skipRefreshMessage: true });
+ router.push(urlJoin('/agent', agentId!, 'tasks'));
+ }}
+ />
</Flexbox>
);
});
diff --git a/src/features/ExplorerTree/view/ExplorerTree.test.tsx b/src/features/ExplorerTree/view/ExplorerTree.test.tsx
index e788a1109ca..a8cc45db47b 100644
--- a/src/features/ExplorerTree/view/ExplorerTree.test.tsx
+++ b/src/features/ExplorerTree/view/ExplorerTree.test.tsx
@@ -38,6 +38,7 @@ vi.mock('@lobehub/ui/icons', () => ({
vi.mock('@lobehub/ui/base-ui', () => ({
confirmModal: vi.fn(),
+ DropdownMenu: ({ children }: { children: ReactNode }) => children,
}));
vi.mock('antd', () => ({
diff --git a/src/features/FloatingChatPanel/ChatBody.test.tsx b/src/features/FloatingChatPanel/ChatBody.test.tsx
index c873ddbe553..fc3bbd24d0f 100644
--- a/src/features/FloatingChatPanel/ChatBody.test.tsx
+++ b/src/features/FloatingChatPanel/ChatBody.test.tsx
@@ -36,11 +36,19 @@ vi.mock('@lobehub/ui', () => ({
}));
vi.mock('@/features/Conversation', () => ({
- ChatList: () => <div data-testid="floating-chat-list">chat list</div>,
+ ChatList: ({ welcome }: { welcome?: ReactNode }) => (
+ <div data-testid="floating-chat-list">
+ chat list
+ {welcome}
+ </div>
+ ),
+}));
+vi.mock('@/features/AgentHome', () => ({
+ default: () => <div data-testid="agent-welcome">agent welcome</div>,
}));
describe('FloatingChatPanel ChatBody', () => {
- it('renders only the ChatList — the input row is owned by InputRow now', () => {
+ it('renders ChatList with the agent welcome while InputRow owns the input', () => {
render(<ChatBody />);
const body = screen.getByTestId('floating-chat-panel-body');
@@ -49,6 +57,7 @@ describe('FloatingChatPanel ChatBody', () => {
expect(body).toHaveAttribute('data-flex', '1');
expect(body).toHaveAttribute('data-height', '100%');
expect(body).toContainElement(list);
+ expect(list).toContainElement(screen.getByTestId('agent-welcome'));
expect(body).toHaveStyle({ overflow: 'hidden' });
expect(screen.queryByTestId('floating-chat-input')).toBeNull();
});
diff --git a/src/features/FloatingChatPanel/ChatBody.tsx b/src/features/FloatingChatPanel/ChatBody.tsx
index 89f5e5c056a..75864ad0f84 100644
--- a/src/features/FloatingChatPanel/ChatBody.tsx
+++ b/src/features/FloatingChatPanel/ChatBody.tsx
@@ -2,6 +2,7 @@
import { Flexbox } from '@lobehub/ui';
+import AgentHome from '@/features/AgentHome';
import { ChatList } from '@/features/Conversation';
const ChatBody = () => {
@@ -13,7 +14,7 @@ const ChatBody = () => {
style={{ minHeight: 0, overflow: 'hidden', position: 'relative' }}
width={'100%'}
>
- <ChatList />
+ <ChatList welcome={<AgentHome />} />
</Flexbox>
);
};
diff --git a/src/features/FloatingChatPanel/InputRow.test.tsx b/src/features/FloatingChatPanel/InputRow.test.tsx
index 846a9fd25db..9993023ab23 100644
--- a/src/features/FloatingChatPanel/InputRow.test.tsx
+++ b/src/features/FloatingChatPanel/InputRow.test.tsx
@@ -50,6 +50,12 @@ vi.mock('@lobehub/ui', () => ({
}));
describe('FloatingChatPanel InputRow', () => {
+ it('does not render the expand affordance when disabled', () => {
+ render(<InputRow isCollapsed={false} showExpandBar={false} onExpand={() => {}} />);
+
+ expect(screen.queryByTestId('floating-chat-panel-hover-bar')).not.toBeInTheDocument();
+ });
+
beforeEach(() => {
mockConversationState.current.chatInputOverlayHeight = 0;
});
diff --git a/src/features/FloatingChatPanel/InputRow.tsx b/src/features/FloatingChatPanel/InputRow.tsx
index d9b759d5d93..f9649298a25 100644
--- a/src/features/FloatingChatPanel/InputRow.tsx
+++ b/src/features/FloatingChatPanel/InputRow.tsx
@@ -72,9 +72,10 @@ const EXPANDED_RIGHT_ACTIONS: 'contextWindow'[] = ['contextWindow'];
export interface InputRowProps {
isCollapsed: boolean;
onExpand: () => void;
+ showExpandBar?: boolean;
}
-const InputRow = memo<InputRowProps>(({ isCollapsed, onExpand }) => {
+const InputRow = memo<InputRowProps>(({ isCollapsed, onExpand, showExpandBar = true }) => {
const s = styles;
const [renderedCollapsed, setRenderedCollapsed] = useState(isCollapsed);
const [focused, setFocused] = useState(false);
@@ -115,11 +116,13 @@ const InputRow = memo<InputRowProps>(({ isCollapsed, onExpand }) => {
onBlur={handleBlur}
onFocus={handleFocus}
>
- <HoverExpandBar
- bottomOffset={overlayHeight}
- visible={isCollapsed && focused}
- onExpand={onExpand}
- />
+ {showExpandBar && (
+ <HoverExpandBar
+ bottomOffset={overlayHeight}
+ visible={isCollapsed && focused}
+ onExpand={onExpand}
+ />
+ )}
<div className={s.surface}>
<ChatInput
allowExpand={false}
diff --git a/src/features/FloatingChatPanel/index.test.tsx b/src/features/FloatingChatPanel/index.test.tsx
index 66ea90e30df..9c322e29466 100644
--- a/src/features/FloatingChatPanel/index.test.tsx
+++ b/src/features/FloatingChatPanel/index.test.tsx
@@ -264,6 +264,29 @@ describe('FloatingChatPanel', () => {
expect(getByTestId('floating-chat-panel').dataset.collapsed).toBe('true');
});
+ it('starts expanded when defaultOpen is enabled', () => {
+ const { getByTestId } = render(
+ <FloatingChatPanel defaultOpen agentId="agent-1" topicId="topic-1" />,
+ );
+
+ expect(getByTestId('floating-panel-shell').dataset.open).toBe('true');
+ expect(getByTestId('floating-chat-panel').dataset.collapsed).toBe('false');
+ });
+
+ it('renders a full-height conversation without FloatingSheet chrome in embedded mode', () => {
+ const { getByTestId, queryByTestId } = render(
+ <FloatingChatPanel agentId="agent-1" mode="embedded" topicId="topic-1" />,
+ );
+
+ const panel = getByTestId('floating-chat-panel');
+ expect(panel.dataset.mode).toBe('embedded');
+ expect(panel.dataset.collapsed).toBe('false');
+ expect(panel).toContainElement(getByTestId('chat-body'));
+ expect(panel).toContainElement(getByTestId('chat-input'));
+ expect(queryByTestId('floating-panel-shell')).toBeNull();
+ expect(queryByTestId('floating-chat-panel-collapse-button')).toBeNull();
+ });
+
it('renders a minimal ChatInput while collapsed (no left/right actions)', () => {
const { getByTestId } = render(<FloatingChatPanel agentId="a" topicId="t" />);
const input = getByTestId('chat-input');
diff --git a/src/features/FloatingChatPanel/index.tsx b/src/features/FloatingChatPanel/index.tsx
index ac8455fc87b..fc95168786f 100644
--- a/src/features/FloatingChatPanel/index.tsx
+++ b/src/features/FloatingChatPanel/index.tsx
@@ -53,6 +53,11 @@ const styles = createStaticStyles(({ css, cssVar }) => ({
background: transparent;
}
`,
+ panelEmbedded: css`
+ flex: 1;
+ min-height: 0;
+ border-block-start: none;
+ `,
sheetSeamless: css`
border: none;
border-radius: 0;
@@ -79,6 +84,8 @@ export interface FloatingChatPanelProps {
agentDocumentId?: string;
agentId: string;
className?: string;
+ /** Whether the panel starts expanded. Defaults to collapsed for floating usages. */
+ defaultOpen?: boolean;
dismissible?: boolean;
/**
* Active document id for the conversation context. Passed through so the
@@ -130,6 +137,8 @@ const FloatingChatPanel = memo<FloatingChatPanelProps>(
agentDocumentId,
actionsBar,
hooks,
+ defaultOpen = false,
+ mode = 'overlay',
width = '100%',
@@ -171,8 +180,9 @@ const FloatingChatPanel = memo<FloatingChatPanelProps>(
const operationState = useOperationState(context);
const defaultActionsBar = useActionsBarConfig();
const resolvedActionsBar = actionsBar ?? defaultActionsBar;
+ const isEmbedded = mode === 'embedded';
- const [isCollapsed, setIsCollapsed] = useState(true);
+ const [isCollapsed, setIsCollapsed] = useState(!defaultOpen);
const [activeSnapPoint, setActiveSnapPoint] = useState<number>(MID_SNAP_POINT);
const expand = useCallback(() => {
@@ -262,14 +272,24 @@ const FloatingChatPanel = memo<FloatingChatPanelProps>(
onMessagesChange={handleMessagesChange}
>
<div
- className={styles.panel}
- data-collapsed={isCollapsed}
+ className={`${styles.panel} ${isEmbedded ? styles.panelEmbedded : ''}`}
+ data-collapsed={isEmbedded ? false : isCollapsed}
+ data-mode={mode}
data-testid="floating-chat-panel"
>
- <FloatingSheet {...sheetProps}>
- <ChatBody />
- </FloatingSheet>
- <InputRow isCollapsed={isCollapsed} onExpand={expand} />
+ {isEmbedded ? (
+ <>
+ <ChatBody />
+ <InputRow isCollapsed={false} showExpandBar={false} onExpand={expand} />
+ </>
+ ) : (
+ <>
+ <FloatingSheet {...sheetProps}>
+ <ChatBody />
+ </FloatingSheet>
+ <InputRow isCollapsed={isCollapsed} onExpand={expand} />
+ </>
+ )}
</div>
</ConversationProvider>
);
diff --git a/src/features/NavPanel/routeKey.test.ts b/src/features/NavPanel/routeKey.test.ts
index 61ab6994995..a6461c3b717 100644
--- a/src/features/NavPanel/routeKey.test.ts
+++ b/src/features/NavPanel/routeKey.test.ts
@@ -10,6 +10,9 @@ describe('resolveNavPanelKey', () => {
['/lobe-team/task/task-1', 'lobe-team', 'home'],
['/agent/agent-1', null, 'agent'],
['/lobe-team/agent/agent-1', 'lobe-team', 'agent'],
+ ['/agent/agent-1/docs', null, 'agent-docs'],
+ ['/agent/agent-1/docs/docs-1', null, 'agent-docs'],
+ ['/lobe-team/agent/agent-1/docs/docs-1', 'lobe-team', 'agent-docs'],
['/group/group-1', null, 'group'],
['/settings/profile', null, 'settings'],
['/lobe-team/settings/general', 'lobe-team', 'workspace-settings'],
diff --git a/src/features/NavPanel/routeKey.ts b/src/features/NavPanel/routeKey.ts
index ce012548d71..94353d1beb6 100644
--- a/src/features/NavPanel/routeKey.ts
+++ b/src/features/NavPanel/routeKey.ts
@@ -6,7 +6,7 @@ export const resolveNavPanelKey = (
const isWorkspaceRoute =
!!activeWorkspaceSlug && segments.length > 0 && segments[0] === activeWorkspaceSlug;
const routeSegments = isWorkspaceRoute ? segments.slice(1) : segments;
- const [rootSegment, childSegment] = routeSegments;
+ const [rootSegment, childSegment, grandchildSegment] = routeSegments;
if (rootSegment === 'settings') {
return isWorkspaceRoute ? 'workspace-settings' : 'settings';
@@ -14,7 +14,7 @@ export const resolveNavPanelKey = (
switch (rootSegment) {
case 'agent': {
- return 'agent';
+ return grandchildSegment === 'docs' ? 'agent-docs' : 'agent';
}
case 'community': {