🤯 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
💄 style(space-panel): split agent resources into Skills / Documents / Web tabs (#15057)
Arvin Xue78cbaf945c3
diff --git a/locales/en-US/chat.json b/locales/en-US/chat.jsonindex 6dc274d4758..4f92a4f3f76 100644--- a/locales/en-US/chat.json+++ b/locales/en-US/chat.json@@ -914,8 +914,8 @@"workingPanel.resources.deleteTitle": "Delete document?","workingPanel.resources.empty": "No documents yet. Documents associated with this agent will show up here.","workingPanel.resources.error": "Failed to load resources",- "workingPanel.resources.filter.all": "All","workingPanel.resources.filter.documents": "Documents",+ "workingPanel.resources.filter.skills": "Skills","workingPanel.resources.filter.web": "Web","workingPanel.resources.loading": "Loading resources...","workingPanel.resources.previewError": "Failed to load preview",diff --git a/locales/zh-CN/chat.json b/locales/zh-CN/chat.jsonindex 69e71dcc36c..8a42c119150 100644--- a/locales/zh-CN/chat.json+++ b/locales/zh-CN/chat.json@@ -914,8 +914,8 @@"workingPanel.resources.deleteTitle": "删除该文档?","workingPanel.resources.empty": "暂无文档。与此智能体关联的文档将显示在这里。","workingPanel.resources.error": "资源加载失败",- "workingPanel.resources.filter.all": "全部","workingPanel.resources.filter.documents": "文档",+ "workingPanel.resources.filter.skills": "Skills","workingPanel.resources.filter.web": "网页","workingPanel.resources.loading": "资源加载中…","workingPanel.resources.previewError": "预览加载失败",diff --git a/src/features/AgentDocumentsExplorer/SkillsList.tsx b/src/features/AgentDocumentsExplorer/SkillsList.tsxnew file mode 100644index 00000000000..9f36f3d7aa6--- /dev/null+++ b/src/features/AgentDocumentsExplorer/SkillsList.tsx@@ -0,0 +1,308 @@+import { Flexbox, Icon, Text, Tooltip } from '@lobehub/ui';+import { SkillsIcon } from '@lobehub/ui/icons';+import { createStaticStyles } from 'antd-style';+import { ChevronRightIcon, FileIcon, FolderIcon } from 'lucide-react';+import { memo, useCallback, useMemo, useState } from 'react';++export interface SkillListItem {+ description?: string;+ fileCount: number;+ files: string[];+ id: string;+ name: string;+}++interface SkillsListProps {+ items: SkillListItem[];+ onOpenFile?: (item: SkillListItem, relativePath: string) => void;+ onOpenSkill?: (item: SkillListItem) => void;+}++const styles = createStaticStyles(({ css, cssVar }) => ({+ chevron: css`+ flex-shrink: 0;+ color: ${cssVar.colorTextTertiary};+ transition: transform ${cssVar.motionDurationFast} ${cssVar.motionEaseInOut};+ `,+ chevronExpanded: css`+ transform: rotate(90deg);+ `,+ childItem: css`+ cursor: pointer;++ height: 26px;+ padding-inline-end: 8px;+ border-radius: 6px;++ font-size: 12px;+ color: ${cssVar.colorTextSecondary};++ &:hover {+ color: ${cssVar.colorText};+ background: ${cssVar.colorFillTertiary};+ }+ `,+ childItemIcon: css`+ flex-shrink: 0;+ color: ${cssVar.colorTextTertiary};+ `,+ description: css`+ max-width: 320px;+ font-size: 12px;+ line-height: 1.5;+ color: ${cssVar.colorTextSecondary};+ `,+ item: css`+ cursor: pointer;++ height: 28px;+ padding-inline: 4px 8px;+ border-radius: 6px;++ font-size: 13px;+ color: ${cssVar.colorTextSecondary};++ &:hover {+ color: ${cssVar.colorText};+ background: ${cssVar.colorFillTertiary};+ }+ `,+ itemCount: css`+ flex-shrink: 0;+ font-size: 12px;+ font-variant-numeric: tabular-nums;+ color: ${cssVar.colorTextTertiary};+ `,+ itemIcon: css`+ flex-shrink: 0;+ color: ${cssVar.colorTextTertiary};+ `,+ treeChevronSlot: css`+ display: flex;+ flex-shrink: 0;+ align-items: center;+ justify-content: center;++ width: 14px;+ height: 14px;+ `,+}));++interface TreeNode {+ children: TreeNode[];+ isDirectory: boolean;+ name: string;+ path: string;+}++const buildSkillTree = (paths: string[]): TreeNode[] => {+ const root: TreeNode = { children: [], isDirectory: true, name: '', path: '' };++ for (const fullPath of paths) {+ const parts = fullPath.split('/').filter(Boolean);+ let current = root;+ let accumPath = '';++ for (let i = 0; i < parts.length; i++) {+ const part = parts[i];+ accumPath = accumPath ? `${accumPath}/${part}` : part;+ const isDirectory = i < parts.length - 1;++ let child = current.children.find((c) => c.name === part);+ if (!child) {+ child = { children: [], isDirectory, name: part, path: accumPath };+ current.children.push(child);+ }+ current = child;+ }+ }++ const sortNode = (node: TreeNode) => {+ node.children.sort((a, b) => {+ if (a.isDirectory !== b.isDirectory) return a.isDirectory ? -1 : 1;+ return a.name.localeCompare(b.name);+ });+ for (const child of node.children) sortNode(child);+ };+ sortNode(root);++ return root.children;+};++const TREE_BASE_INSET = 24;+const TREE_DEPTH_INDENT = 14;++interface TreeRowProps {+ depth: number;+ expanded: Set<string>;+ node: TreeNode;+ onOpenFile: (relativePath: string) => void;+ onToggleFolder: (folderPath: string) => void;+}++const TreeRow = memo<TreeRowProps>(({ depth, expanded, node, onOpenFile, onToggleFolder }) => {+ const isOpen = expanded.has(node.path);+ const paddingInlineStart = TREE_BASE_INSET + depth * TREE_DEPTH_INDENT;++ if (node.isDirectory) {+ return (+ <>+ <Flexbox+ horizontal+ align={'center'}+ className={styles.childItem}+ gap={6}+ style={{ paddingInlineStart }}+ onClick={() => onToggleFolder(node.path)}+ >+ <span className={styles.treeChevronSlot}>+ <Icon+ className={`${styles.chevron} ${isOpen ? styles.chevronExpanded : ''}`}+ icon={ChevronRightIcon}+ size={12}+ />+ </span>+ <Icon className={styles.childItemIcon} icon={FolderIcon} size={12} />+ <Text ellipsis style={{ flex: 1, fontSize: 12, minWidth: 0 }}>+ {node.name}+ </Text>+ </Flexbox>+ {isOpen &&+ node.children.map((child) => (+ <TreeRow+ depth={depth + 1}+ expanded={expanded}+ key={child.path}+ node={child}+ onOpenFile={onOpenFile}+ onToggleFolder={onToggleFolder}+ />+ ))}+ </>+ );+ }++ return (+ <Flexbox+ horizontal+ align={'center'}+ className={styles.childItem}+ gap={6}+ style={{ paddingInlineStart }}+ title={node.path}+ onClick={() => onOpenFile(node.path)}+ >+ <span className={styles.treeChevronSlot} />+ <Icon className={styles.childItemIcon} icon={FileIcon} size={12} />+ <Text ellipsis style={{ flex: 1, fontSize: 12, minWidth: 0 }}>+ {node.name}+ </Text>+ </Flexbox>+ );+});++TreeRow.displayName = 'SkillsListTreeRow';++interface SkillRowProps {+ expanded: boolean;+ item: SkillListItem;+ onOpenFile?: (relativePath: string) => void;+ onOpenSkill?: () => void;+ onToggle: () => void;+}++const SkillRow = memo<SkillRowProps>(({ expanded, item, onOpenFile, onOpenSkill, onToggle }) => {+ const tree = useMemo(() => buildSkillTree(item.files), [item.files]);+ const [expandedFolders, setExpandedFolders] = useState<Set<string>>(() => new Set());++ const toggleFolder = useCallback((folderPath: string) => {+ setExpandedFolders((prev) => {+ const next = new Set(prev);+ if (next.has(folderPath)) next.delete(folderPath);+ else next.add(folderPath);+ return next;+ });+ }, []);++ return (+ <>+ <Tooltip+ placement={'left'}+ title={+ item.description ? (+ <span className={styles.description}>{item.description}</span>+ ) : undefined+ }+ >+ <Flexbox horizontal align={'center'} className={styles.item} gap={6}>+ <Flexbox+ align={'center'}+ justify={'center'}+ style={{ cursor: 'pointer', flexShrink: 0, height: 20, width: 20 }}+ onClick={(e) => {+ e.stopPropagation();+ onToggle();+ }}+ >+ <Icon+ className={`${styles.chevron} ${expanded ? styles.chevronExpanded : ''}`}+ icon={ChevronRightIcon}+ size={14}+ />+ </Flexbox>+ <Icon className={styles.itemIcon} icon={SkillsIcon} size={14} />+ <Text ellipsis style={{ flex: 1, minWidth: 0 }} onClick={onOpenSkill}>+ {item.name}+ </Text>+ <span className={styles.itemCount}>{item.fileCount}</span>+ </Flexbox>+ </Tooltip>+ {expanded &&+ onOpenFile &&+ tree.map((node) => (+ <TreeRow+ depth={0}+ expanded={expandedFolders}+ key={node.path}+ node={node}+ onOpenFile={onOpenFile}+ onToggleFolder={toggleFolder}+ />+ ))}+ </>+ );+});++SkillRow.displayName = 'SkillsListSkillRow';++const SkillsList = memo<SkillsListProps>(({ items, onOpenFile, onOpenSkill }) => {+ const [expanded, setExpanded] = useState<Set<string>>(() => new Set());++ const toggle = useCallback((id: string) => {+ setExpanded((prev) => {+ const next = new Set(prev);+ if (next.has(id)) next.delete(id);+ else next.add(id);+ return next;+ });+ }, []);++ return (+ <Flexbox gap={2}>+ {items.map((item) => (+ <SkillRow+ expanded={expanded.has(item.id)}+ item={item}+ key={item.id}+ onOpenFile={onOpenFile ? (relativePath) => onOpenFile(item, relativePath) : undefined}+ onOpenSkill={onOpenSkill ? () => onOpenSkill(item) : undefined}+ onToggle={() => toggle(item.id)}+ />+ ))}+ </Flexbox>+ );+});++SkillsList.displayName = 'SkillsList';++export default SkillsList;diff --git a/src/locales/default/chat.ts b/src/locales/default/chat.tsindex 6c8efcc2963..f2d1a457b89 100644--- a/src/locales/default/chat.ts+++ b/src/locales/default/chat.ts@@ -956,8 +956,8 @@ export default {'workingPanel.resources.empty':'No documents yet. Documents associated with this agent will show up here.','workingPanel.resources.error': 'Failed to load resources',- 'workingPanel.resources.filter.all': 'All','workingPanel.resources.filter.documents': 'Documents',+ 'workingPanel.resources.filter.skills': 'Skills','workingPanel.resources.filter.web': 'Web','workingPanel.resources.loading': 'Loading resources...','workingPanel.resources.previewError': 'Failed to load preview',diff --git a/src/routes/(main)/agent/features/Conversation/WorkingSidebar/ResourcesSection/AgentDocumentsGroup.test.tsx b/src/routes/(main)/agent/features/Conversation/WorkingSidebar/ResourcesSection/AgentDocumentsGroup.test.tsxindex c59f2805ed2..7412bf68f9f 100644--- a/src/routes/(main)/agent/features/Conversation/WorkingSidebar/ResourcesSection/AgentDocumentsGroup.test.tsx+++ b/src/routes/(main)/agent/features/Conversation/WorkingSidebar/ResourcesSection/AgentDocumentsGroup.test.tsx@@ -57,10 +57,11 @@ vi.mock('react-i18next', () => ({({'workingPanel.resources.empty': 'No agent documents yet','workingPanel.resources.error': 'Failed to load resources',- 'workingPanel.resources.filter.all': 'All','workingPanel.resources.filter.documents': 'Documents',+ 'workingPanel.resources.filter.skills': 'Skills','workingPanel.resources.filter.web': 'Web','workingPanel.resources.updatedAt': `Updated ${options?.time}`,+ 'workingPanel.skills.empty': 'No skills found',}) as Record<string, string>)[key] || key,}),@@ -77,6 +78,35 @@ vi.mock('@/features/AgentDocumentsExplorer', () => ({),}));+vi.mock('@/features/AgentDocumentsExplorer/SkillsList', () => {+ type Item = { fileCount: number; id: string; name: string };+ const SkillsList = ({+ items,+ onOpenFile,+ onOpenSkill,+ }: {+ items: Item[];+ onOpenFile?: (item: Item, relativePath: string) => void;+ onOpenSkill?: (item: Item) => void;+ }) => (+ <div data-testid="skills-list">+ {items.map((item) => (+ <div data-skill-id={item.id} key={item.id}>+ <button onClick={() => onOpenSkill?.(item)}>{item.name}</button>+ <span data-testid={`skill-${item.id}-count`}>{item.fileCount}</span>+ <button+ data-testid={`skill-${item.id}-open-skill-md`}+ onClick={() => onOpenFile?.(item, 'SKILL.md')}+ >+ open-skill-md+ </button>+ </div>+ ))}+ </div>+ );+ return { default: SkillsList };+});+vi.mock('@/services/agentDocument', () => ({agentDocumentSWRKeys: {documents: (agentId: string) => ['agent-documents', agentId],@@ -107,6 +137,62 @@ vi.mock('@/store/chat/selectors', () => ({},}));+const skillBundleRow = {+ createdAt: new Date('2026-05-09T00:00:00Z'),+ description: 'Use for YouTube comments',+ documentId: 'skill-bundle-doc',+ fileType: 'skills/bundle',+ filename: 'youtube-comment-retrieval-workflow',+ id: 'skill-bundle-row',+ parentId: null,+ sourceType: 'agent-signal',+ templateId: 'agent-skill',+ title: 'YouTube Comment Retrieval Workflow',+ updatedAt: new Date(),+};++const skillIndexRow = {+ createdAt: new Date('2026-05-09T00:00:00Z'),+ description: 'Use for YouTube comments',+ documentId: 'skill-index-doc',+ fileType: 'skills/index',+ filename: 'SKILL.md',+ id: 'skill-index-row',+ parentId: 'skill-bundle-doc',+ sourceType: 'agent-signal',+ templateId: 'agent-skill',+ title: 'SKILL.md',+ updatedAt: new Date(),+};++const fileDocRow = {+ createdAt: new Date('2026-04-16T00:00:00Z'),+ description: 'A short brief',+ documentId: 'doc-content-1',+ fileType: 'agent/document',+ filename: 'brief.md',+ id: 'doc-1',+ parentId: null,+ sourceType: 'file',+ templateId: null,+ title: 'Brief',+ updatedAt: new Date(),+};++const webDocRow = {+ createdAt: new Date('2026-04-16T00:00:00Z'),+ description: 'Crawled page',+ documentId: 'doc-content-2',+ fileType: 'article',+ filename: 'example.com',+ id: 'doc-2',+ parentId: null,+ sourceType: 'web',+ templateId: null,+ title: 'Example',+ updatedAt: new Date(),+};+describe('AgentDocumentsGroup', () => {beforeEach(() => {useClientDataSWR.mockReset();@@ -122,73 +208,29 @@ describe('AgentDocumentsGroup', () => {removeDocumentMock.mockResolvedValue({ deleted: true, id: 'doc-1' });});- it('renders documents and opens via openDocument', async () => {- useClientDataSWR.mockImplementation((key: unknown) => {- if (Array.isArray(key) && key[0] === 'agent-documents-list') {- return {- data: [- {- createdAt: new Date('2026-04-16T00:00:00Z'),- description: 'A short brief',- documentId: 'doc-content-1',- filename: 'brief.md',- id: 'doc-1',- sourceType: 'file',- templateId: 'claw',- title: 'Brief',- updatedAt: new Date(),- },- ],- error: undefined,- isLoading: false,- mutate: vi.fn(),- };- }-- return { data: undefined, error: undefined, isLoading: false, mutate: vi.fn() };+ it('defaults to the Skills tab and renders skill bundles via SkillsList', () => {+ useClientDataSWR.mockReturnValue({+ data: [skillBundleRow, skillIndexRow, fileDocRow, webDocRow],+ error: undefined,+ isLoading: false,+ mutate: vi.fn(),});render(<AgentDocumentsGroup />);- const item = screen.getByText('Brief');- expect(item).toBeInTheDocument();- expect(screen.getByText('A short brief')).toBeInTheDocument();- expect(screen.getByText('Updated a few seconds ago')).toBeInTheDocument();-- fireEvent.click(item);- expect(openDocument).toHaveBeenCalledWith('doc-content-1');+ const list = screen.getByTestId('skills-list');+ expect(list).toBeInTheDocument();+ expect(screen.getByText('YouTube Comment Retrieval Workflow')).toBeInTheDocument();+ // bundle's file children count (the SKILL.md row collapsed inside the expand panel)+ expect(screen.getByTestId('skill-skill-bundle-doc-count')).toHaveTextContent('1');+ // file / web docs should not leak into the skills tab+ expect(screen.queryByText('Brief')).not.toBeInTheDocument();+ expect(screen.queryByText('Example')).not.toBeInTheDocument();});- it('opens a managed skill bundle card through its SKILL.md document and hides the duplicate file', () => {+ it('opens the SKILL.md document when clicking a skill bundle row', () => {useClientDataSWR.mockReturnValue({- data: [- {- createdAt: new Date('2026-05-09T00:00:00Z'),- description: 'Use for YouTube comments',- documentId: 'skill-bundle-doc',- fileType: 'skills/bundle',- filename: 'youtube-comment-retrieval-workflow',- id: 'skill-bundle-row',- parentId: null,- sourceType: 'agent-signal',- templateId: 'agent-skill',- title: 'YouTube Comment Retrieval Workflow',- updatedAt: new Date(),- },- {- createdAt: new Date('2026-05-09T00:00:00Z'),- description: 'Use for YouTube comments',- documentId: 'skill-index-doc',- fileType: 'skills/index',- filename: 'SKILL.md',- id: 'skill-index-row',- parentId: 'skill-bundle-doc',- sourceType: 'agent-signal',- templateId: 'agent-skill',- title: 'SKILL.md',- updatedAt: new Date(),- },- ],+ data: [skillBundleRow, skillIndexRow],error: undefined,isLoading: false,mutate: vi.fn(),@@ -196,34 +238,13 @@ describe('AgentDocumentsGroup', () => {render(<AgentDocumentsGroup />);- const bundle = screen.getByText('YouTube Comment Retrieval Workflow');- expect(bundle).toBeInTheDocument();- expect(screen.queryByText('SKILL.md')).not.toBeInTheDocument();- expect(screen.queryByLabelText('delete')).not.toBeInTheDocument();-- fireEvent.click(bundle);-+ fireEvent.click(screen.getByText('YouTube Comment Retrieval Workflow'));expect(openDocument).toHaveBeenCalledWith('skill-index-doc');- expect(openDocument).not.toHaveBeenCalledWith('skill-bundle-doc');});- it('renders the empty state when only hidden managed skill index documents are available', () => {+ it('falls back to the bundle id when opening an orphan skill bundle', () => {useClientDataSWR.mockReturnValue({- data: [- {- createdAt: new Date('2026-05-09T00:00:00Z'),- description: 'Use for YouTube comments',- documentId: 'skill-index-doc',- fileType: 'skills/index',- filename: 'SKILL.md',- id: 'skill-index-row',- parentId: 'missing-skill-bundle-doc',- sourceType: 'agent-signal',- templateId: 'agent-skill',- title: 'SKILL.md',- updatedAt: new Date(),- },- ],+ data: [skillBundleRow], // no SKILL.md childerror: undefined,isLoading: false,mutate: vi.fn(),@@ -231,28 +252,27 @@ describe('AgentDocumentsGroup', () => {render(<AgentDocumentsGroup />);- expect(screen.getByText('No agent documents yet')).toBeInTheDocument();- expect(screen.queryByText('SKILL.md')).not.toBeInTheDocument();+ fireEvent.click(screen.getByText('YouTube Comment Retrieval Workflow'));+ expect(openDocument).toHaveBeenCalledWith('skill-bundle-doc');});- it('navigates to the page route when opening from a topic page', () => {- useMatchMock.mockReturnValue({- params: { aid: 'agent-1', topicId: 'topic-1' },+ it('opens a child file by relative path through onOpenFile', () => {+ useClientDataSWR.mockReturnValue({+ data: [skillBundleRow, skillIndexRow],+ error: undefined,+ isLoading: false,+ mutate: vi.fn(),});++ render(<AgentDocumentsGroup />);++ fireEvent.click(screen.getByTestId('skill-skill-bundle-doc-open-skill-md'));+ expect(openDocument).toHaveBeenCalledWith('skill-index-doc');+ });++ it('renders the document tree when switching to the Documents tab', () => {useClientDataSWR.mockReturnValue({- data: [- {- createdAt: new Date('2026-04-16T00:00:00Z'),- description: 'File doc',- documentId: 'doc-content-1',- filename: 'brief.md',- id: 'doc-1',- sourceType: 'file',- templateId: 'claw',- title: 'Brief',- updatedAt: null,- },- ],+ data: [skillBundleRow, skillIndexRow, fileDocRow, webDocRow],error: undefined,isLoading: false,mutate: vi.fn(),@@ -260,258 +280,115 @@ describe('AgentDocumentsGroup', () => {render(<AgentDocumentsGroup />);- fireEvent.click(screen.getByText('Brief'));+ fireEvent.click(screen.getByText('Documents'));- expect(useNavigateMock).toHaveBeenCalledWith('/agent/agent-1/topic-1/page/doc-content-1');- expect(openDocument).not.toHaveBeenCalled();+ const tree = screen.getByTestId('document-explorer-tree');+ expect(tree).toBeInTheDocument();+ // Skill bundle, skill index, and web items are filtered out before reaching+ // the tree — only the file-backed document survives.+ expect(tree).toHaveAttribute('data-doc-count', '1');});- it('allows opening and deleting an orphan managed skill bundle as a recovery path', async () => {+ it('renders web items as cards in the Web tab and supports deletion', async () => {const mutate = vi.fn().mockResolvedValue(undefined);useClientDataSWR.mockReturnValue({- data: [- {- createdAt: new Date('2026-05-09T00:00:00Z'),- description: 'Missing SKILL.md',- documentId: 'skill-bundle-doc',- fileType: 'skills/bundle',- filename: 'youtube-comment-retrieval-workflow',- id: 'skill-bundle-row',- parentId: null,- sourceType: 'agent-signal',- templateId: 'agent-skill',- title: 'YouTube Comment Retrieval Workflow',- updatedAt: new Date(),- },- ],+ data: [fileDocRow, webDocRow],error: undefined,isLoading: false,mutate,});render(<AgentDocumentsGroup />);+ fireEvent.click(screen.getByText('Web'));- const bundle = screen.getByText('YouTube Comment Retrieval Workflow');- expect(screen.getByLabelText('delete')).toBeInTheDocument();+ expect(screen.getByText('Example')).toBeInTheDocument();+ expect(screen.queryByText('Brief')).not.toBeInTheDocument();- fireEvent.click(bundle);- expect(openDocument).toHaveBeenCalledWith('skill-bundle-doc');+ fireEvent.click(screen.getByText('Example'));+ expect(openDocument).toHaveBeenCalledWith('doc-content-2');fireEvent.click(screen.getByLabelText('delete'));-const [firstConfirmCall] = modalConfirm.mock.calls;const [{ onOk }] = firstConfirmCall;await onOk();expect(removeDocumentMock).toHaveBeenCalledWith({agentId: 'agent-1',- documentId: 'skill-bundle-doc',- id: 'skill-bundle-row',+ documentId: 'doc-content-2',+ id: 'doc-2',topicId: undefined,});expect(mutate).toHaveBeenCalled();+ expect(messageSuccess).toHaveBeenCalledWith('workingPanel.resources.deleteSuccess');});- it('shows an error message when deleting a document fails', async () => {+ it('navigates to the page route when opening a web card from a topic page', () => {+ useMatchMock.mockReturnValue({ params: { aid: 'agent-1', topicId: 'topic-1' } });useClientDataSWR.mockReturnValue({- data: [- {- createdAt: new Date('2026-04-16T00:00:00Z'),- description: 'File doc',- documentId: 'doc-content-1',- filename: 'brief.md',- id: 'doc-1',- sourceType: 'file',- templateId: 'claw',- title: 'Brief',- updatedAt: new Date(),- },- ],+ data: [webDocRow],error: undefined,isLoading: false,mutate: vi.fn(),});- removeDocumentMock.mockRejectedValue(new Error('delete failed'));render(<AgentDocumentsGroup />);+ fireEvent.click(screen.getByText('Web'));+ fireEvent.click(screen.getByText('Example'));- fireEvent.click(screen.getByLabelText('delete'));-- const [firstConfirmCall] = modalConfirm.mock.calls;- const [{ onOk }] = firstConfirmCall;- await onOk();-- expect(messageError).toHaveBeenCalledWith('delete failed');+ expect(useNavigateMock).toHaveBeenCalledWith('/agent/agent-1/topic-1/page/doc-content-2');+ expect(openDocument).not.toHaveBeenCalled();});- it('renders grouped cards in tree view mode', () => {+ it('shows the skills empty state when no bundles are present', () => {useClientDataSWR.mockReturnValue({- data: [- {- createdAt: new Date('2026-04-16T00:00:00Z'),- description: 'File doc',- documentId: 'doc-content-1',- filename: 'brief.md',- id: 'doc-1',- sourceType: 'file',- templateId: 'claw',- title: 'Brief',- updatedAt: new Date(),- },- {- createdAt: new Date('2026-04-16T00:00:00Z'),- description: 'Crawled page',- documentId: 'doc-content-2',- filename: 'example.com',- id: 'doc-2',- sourceType: 'web',- templateId: null,- title: 'Example',- updatedAt: null,- },- ],+ data: [fileDocRow, webDocRow],error: undefined,isLoading: false,mutate: vi.fn(),});- render(<AgentDocumentsGroup viewMode="tree" />);+ render(<AgentDocumentsGroup />);- expect(screen.getByText('Documents')).toBeInTheDocument();- expect(screen.getByText('Web')).toBeInTheDocument();- expect(screen.getByText('Brief')).toBeInTheDocument();- expect(screen.getByText('Example')).toBeInTheDocument();- expect(screen.queryByTestId('document-explorer-tree')).not.toBeInTheDocument();+ expect(screen.getByText('No skills found')).toBeInTheDocument();+ expect(screen.queryByTestId('skills-list')).not.toBeInTheDocument();});- it('filters documents by source type via segmented tabs', () => {+ it('shows the web empty state when no web items are present', () => {useClientDataSWR.mockReturnValue({- data: [- {- createdAt: new Date('2026-04-16T00:00:00Z'),- description: 'File doc',- documentId: 'doc-content-1',- filename: 'brief.md',- id: 'doc-1',- sourceType: 'file',- templateId: 'claw',- title: 'Brief',- updatedAt: new Date(),- },- {- createdAt: new Date('2026-04-16T00:00:00Z'),- description: 'Crawled page',- documentId: 'doc-content-2',- filename: 'example.com',- id: 'doc-2',- sourceType: 'web',- templateId: null,- title: 'Example',- updatedAt: new Date(),- },- ],+ data: [fileDocRow],error: undefined,isLoading: false,mutate: vi.fn(),});render(<AgentDocumentsGroup />);-- expect(screen.getByText('Brief')).toBeInTheDocument();- expect(screen.getByText('Example')).toBeInTheDocument();- expect(screen.queryByTestId('document-explorer-tree')).not.toBeInTheDocument();-fireEvent.click(screen.getByText('Web'));- expect(screen.queryByText('Brief')).not.toBeInTheDocument();- expect(screen.getByText('Example')).toBeInTheDocument();- expect(screen.queryByTestId('document-explorer-tree')).not.toBeInTheDocument();-- fireEvent.click(screen.getByText('Documents'));-- const tree = screen.getByTestId('document-explorer-tree');- expect(tree).toBeInTheDocument();- expect(tree).toHaveAttribute('data-doc-count', '2');- expect(screen.queryByText('Brief')).not.toBeInTheDocument();- expect(screen.queryByText('Example')).not.toBeInTheDocument();- });-- it('passes page document and topic context when deleting from a topic page route', async () => {- const mutate = vi.fn().mockResolvedValue(undefined);- useMatchMock.mockReturnValue({- params: { aid: 'agent-1', docId: 'doc-content-1', topicId: 'topic-1' },- });- useClientDataSWR.mockReturnValue({- data: [- {- createdAt: new Date('2026-04-16T00:00:00Z'),- description: 'File doc',- documentId: 'doc-content-1',- filename: 'brief.md',- id: 'doc-1',- sourceType: 'file',- templateId: 'claw',- title: 'Brief',- updatedAt: new Date(),- },- ],- error: undefined,- isLoading: false,- mutate,- });-- render(<AgentDocumentsGroup />);-- fireEvent.click(screen.getByLabelText('delete'));-- expect(modalConfirm).toHaveBeenCalledWith(- expect.objectContaining({- cancelText: 'cancel',- centered: true,- okButtonProps: { danger: true, type: 'primary' },- okText: 'delete',- title: 'workingPanel.resources.deleteTitle',- }),- );-- const [firstConfirmCall] = modalConfirm.mock.calls;- const [{ onOk }] = firstConfirmCall;- await onOk();-- expect(closeDocument).toHaveBeenCalled();- expect(removeDocumentMock).toHaveBeenCalledWith({- agentId: 'agent-1',- documentId: 'doc-content-1',- id: 'doc-1',- topicId: 'topic-1',- });- expect(mutate).toHaveBeenCalled();- expect(messageSuccess).toHaveBeenCalledWith('workingPanel.resources.deleteSuccess');+ expect(screen.getByText('No agent documents yet')).toBeInTheDocument();});- it('renders empty state when no documents', () => {+ it('renders error state when SWR returns an error', () => {useClientDataSWR.mockReturnValue({data: [],- error: undefined,+ error: new Error('oops'),isLoading: false,mutate: vi.fn(),});render(<AgentDocumentsGroup />);- expect(screen.getByText('No agent documents yet')).toBeInTheDocument();+ expect(screen.getByText('Failed to load resources')).toBeInTheDocument();});- it('renders error state', () => {+ it('renders the loading spinner while data is being fetched', () => {useClientDataSWR.mockReturnValue({- data: [],- error: new Error('oops'),- isLoading: false,+ data: undefined,+ error: undefined,+ isLoading: true,mutate: vi.fn(),});render(<AgentDocumentsGroup />);-- expect(screen.getByText('Failed to load resources')).toBeInTheDocument();+ expect(screen.getByTestId('spin')).toBeInTheDocument();});});diff --git a/src/routes/(main)/agent/features/Conversation/WorkingSidebar/ResourcesSection/AgentDocumentsGroup.tsx b/src/routes/(main)/agent/features/Conversation/WorkingSidebar/ResourcesSection/AgentDocumentsGroup.tsxindex 4f372a8d1cc..4cdce0c52e3 100644--- a/src/routes/(main)/agent/features/Conversation/WorkingSidebar/ResourcesSection/AgentDocumentsGroup.tsx+++ b/src/routes/(main)/agent/features/Conversation/WorkingSidebar/ResourcesSection/AgentDocumentsGroup.tsx@@ -1,19 +1,21 @@import { ActionIcon, Center, Empty, Flexbox, Text } from '@lobehub/ui';+import { SkillsIcon } from '@lobehub/ui/icons';import { App, Spin } from 'antd';import { createStaticStyles, cx } from 'antd-style';import dayjs from 'dayjs';import relativeTime from 'dayjs/plugin/relativeTime';import type { LucideIcon } from 'lucide-react';-import { FileTextIcon, FolderIcon, GlobeIcon, Trash2Icon } from 'lucide-react';+import { FileTextIcon, GlobeIcon, Trash2Icon } from 'lucide-react';import type { CSSProperties, MouseEvent } from 'react';import { memo, useMemo, useState } from 'react';import { useTranslation } from 'react-i18next';import { useMatch, useNavigate } from 'react-router-dom';import { DocumentExplorerTree } from '@/features/AgentDocumentsExplorer';+import SkillsList, { type SkillListItem } from '@/features/AgentDocumentsExplorer/SkillsList';import {+ isFolderItem,isManagedSkillItem,- isOrphanSkillBundleItem,isSkillBundleItem,isSkillIndexItem,} from '@/features/AgentDocumentsExplorer/types';@@ -27,7 +29,7 @@ const PAGE_ROUTE_PATTERN = '/agent/:aid/:topicId/page/:docId?';dayjs.extend(relativeTime);-type ResourceFilter = 'all' | 'documents' | 'web';+type ResourceFilter = 'skills' | 'documents' | 'web';const styles = createStaticStyles(({ css, cssVar }) => ({container: css`@@ -48,14 +50,6 @@ const styles = createStaticStyles(({ css, cssVar }) => ({line-height: 1.5;color: ${cssVar.colorTextSecondary};`,- groupLabel: css`- padding-inline: 4px;-- font-size: 11px;- font-weight: 500;- text-transform: uppercase;- letter-spacing: 0.02em;- `,meta: css`font-size: 12px;color: ${cssVar.colorTextTertiary};@@ -98,7 +92,7 @@ const styles = createStaticStyles(({ css, cssVar }) => ({}));const FILTER_OPTIONS = [- { labelKey: 'workingPanel.resources.filter.all', value: 'all' },+ { labelKey: 'workingPanel.resources.filter.skills', value: 'skills' },{ labelKey: 'workingPanel.resources.filter.documents', value: 'documents' },{ labelKey: 'workingPanel.resources.filter.web', value: 'web' },] as const satisfies readonly { labelKey: string; value: ResourceFilter }[];@@ -110,11 +104,10 @@ interface DocumentItemProps {document: AgentDocumentListItem;hideDelete?: boolean;mutate: () => Promise<unknown>;- openDocumentId?: string;}const DocumentItem = memo<DocumentItemProps>(- ({ agentId, document, hideDelete = false, mutate, openDocumentId }) => {+ ({ agentId, document, hideDelete = false, mutate }) => {const { t } = useTranslation(['chat', 'common']);const { message, modal } = App.useApp();const [deleting, setDeleting] = useState(false);@@ -127,11 +120,7 @@ const DocumentItem = memo<DocumentItemProps>(const title = document.title || document.filename || '';const description = document.description ?? undefined;const isWeb = document.sourceType === 'web';- const isSkillBundle = isSkillBundleItem(document);- const targetDocumentId = isSkillBundle- ? (openDocumentId ?? document.documentId)- : document.documentId;- const IconComponent: LucideIcon = isWeb ? GlobeIcon : isSkillBundle ? FolderIcon : FileTextIcon;+ const IconComponent: LucideIcon = isWeb ? GlobeIcon : FileTextIcon;const updatedAtLabel = document.updatedAt? t('workingPanel.resources.updatedAt', {ns: 'chat',@@ -140,17 +129,17 @@ const DocumentItem = memo<DocumentItemProps>(: null;const activeDocumentId = pageMatch ? pageMatch.params.docId : portalDocumentId;- const isActive = activeDocumentId === targetDocumentId;+ const isActive = activeDocumentId === document.documentId;const handleOpen = () => {- if (!targetDocumentId) return;+ if (!document.documentId) return;if (pageMatch?.params.aid && pageMatch.params.topicId) {navigate(- `/agent/${pageMatch.params.aid}/${pageMatch.params.topicId}/page/${targetDocumentId}`,+ `/agent/${pageMatch.params.aid}/${pageMatch.params.topicId}/page/${document.documentId}`,);return;}- openDocument(targetDocumentId);+ openDocument(document.documentId);};const handleDelete = (e: MouseEvent) => {@@ -225,15 +214,55 @@ const DocumentItem = memo<DocumentItemProps>(DocumentItem.displayName = 'AgentDocumentsGroupItem';+interface SkillBundleView {+ bundle: AgentDocumentListItem;+ files: string[];+ pathToDocumentId: Map<string, string>;+}++const buildSkillBundleViews = (data: AgentDocumentListItem[]): SkillBundleView[] => {+ const childrenByParent = new Map<string, AgentDocumentListItem[]>();+ for (const doc of data) {+ if (!doc.parentId) continue;+ const list = childrenByParent.get(doc.parentId) ?? [];+ list.push(doc);+ childrenByParent.set(doc.parentId, list);+ }++ return data.filter(isSkillBundleItem).map((bundle) => {+ const files: string[] = [];+ const pathToDocumentId = new Map<string, string>();++ const walk = (parentDocId: string, prefix: string) => {+ const children = childrenByParent.get(parentDocId) ?? [];+ for (const child of children) {+ const name = child.filename || child.title || 'untitled';+ const relPath = prefix ? `${prefix}/${name}` : name;+ if (isFolderItem(child)) {+ walk(child.documentId, relPath);+ } else {+ files.push(relPath);+ pathToDocumentId.set(relPath, child.documentId);+ }+ }+ };+ walk(bundle.documentId, '');++ return { bundle, files, pathToDocumentId };+ });+};+interface AgentDocumentsGroupProps {style?: CSSProperties;- viewMode?: 'list' | 'tree';}-const AgentDocumentsGroup = memo<AgentDocumentsGroupProps>(({ style, viewMode = 'list' }) => {+const AgentDocumentsGroup = memo<AgentDocumentsGroupProps>(({ style }) => {const { t } = useTranslation('chat');const agentId = useAgentStore((s) => s.activeAgentId);- const [filter, setFilter] = useState<ResourceFilter>('all');+ const openDocument = useChatStore((s) => s.openDocument);+ const navigate = useNavigate();+ const pageMatch = useMatch(PAGE_ROUTE_PATTERN);+ const [filter, setFilter] = useState<ResourceFilter>('skills');const {data = [],@@ -244,45 +273,34 @@ const AgentDocumentsGroup = memo<AgentDocumentsGroupProps>(({ style, viewMode =agentDocumentService.getDocuments({ agentId: agentId! }),);- const filteredData = useMemo(() => {- if (filter === 'documents') return data.filter((doc) => doc.sourceType !== 'web');- if (filter === 'web') return data.filter((doc) => doc.sourceType === 'web');- return data;- }, [data, filter]);+ const webData = useMemo(() => data.filter((doc) => doc.sourceType === 'web'), [data]);- const visibleFlatData = useMemo(- () => filteredData.filter((doc) => !isSkillIndexItem(doc)),- [filteredData],+ const documentsData = useMemo(+ () => data.filter((doc) => doc.sourceType !== 'web' && !isManagedSkillItem(doc)),+ [data],);- const skillIndexDocumentIdByBundleDocumentId = useMemo(() => {- const map = new Map<string, string>();- for (const doc of data) {- if (isSkillIndexItem(doc) && doc.parentId) {- map.set(doc.parentId, doc.documentId);- }- }- return map;- }, [data]);-- const getOpenDocumentId = (document: AgentDocumentListItem): string | undefined =>- isSkillBundleItem(document)- ? (skillIndexDocumentIdByBundleDocumentId.get(document.documentId) ?? document.documentId)- : document.documentId;-- const shouldHideDelete = (document: AgentDocumentListItem): boolean =>- isManagedSkillItem(document) && !isOrphanSkillBundleItem(document, data);+ const skillBundleViews = useMemo(() => buildSkillBundleViews(data), [data]);++ const skillItems = useMemo<SkillListItem[]>(+ () =>+ skillBundleViews.map(({ bundle, files }) => ({+ description: bundle.description ?? undefined,+ fileCount: files.length,+ files,+ id: bundle.documentId,+ name: bundle.title || bundle.filename || '',+ })),+ [skillBundleViews],+ );- const treeGroups = useMemo(() => {- const docs = data.filter((doc) => doc.sourceType !== 'web' && !isSkillIndexItem(doc));- const webs = data.filter((doc) => doc.sourceType === 'web');- return (- [- { items: docs, labelKey: 'workingPanel.resources.filter.documents' },- { items: webs, labelKey: 'workingPanel.resources.filter.web' },- ] as const- ).filter((group) => group.items.length > 0);- }, [data]);+ const openDocumentByRoute = (documentId: string) => {+ if (pageMatch?.params.aid && pageMatch.params.topicId) {+ navigate(`/agent/${pageMatch.params.aid}/${pageMatch.params.topicId}/page/${documentId}`);+ return;+ }+ openDocument(documentId);+ };if (!agentId) return null;@@ -302,41 +320,62 @@ const AgentDocumentsGroup = memo<AgentDocumentsGroupProps>(({ style, viewMode =);}- // For filter==='documents' we still render the tree even when empty, so the- // toolbar (new folder / new doc) remains reachable.- if (data.length === 0 && filter !== 'documents') {+ const renderSkills = () => {+ if (skillItems.length === 0) {+ return (+ <Center flex={1} gap={8} paddingBlock={24}>+ <Empty description={t('workingPanel.skills.empty')} icon={SkillsIcon} />+ </Center>+ );+ }return (- <Center flex={1} gap={8} paddingBlock={24}>- <Empty description={t('workingPanel.resources.empty')} icon={FileTextIcon} />- </Center>+ <SkillsList+ items={skillItems}+ onOpenFile={(item, relativePath) => {+ const view = skillBundleViews.find((v) => v.bundle.documentId === item.id);+ const docId = view?.pathToDocumentId.get(relativePath);+ if (docId) openDocumentByRoute(docId);+ }}+ onOpenSkill={(item) => {+ // Open the SKILL.md (skills/index child) when present; fall back to+ // the bundle itself (orphan bundles surface for recovery).+ const view = skillBundleViews.find((v) => v.bundle.documentId === item.id);+ const indexChild = data.find((doc) => doc.parentId === item.id && isSkillIndexItem(doc));+ openDocumentByRoute(indexChild?.documentId ?? view?.bundle.documentId ?? item.id);+ }}+ />);- }+ };++ const renderDocuments = () => (+ // Always render the tree for the Documents tab even when empty, so the+ // toolbar (new folder / new doc) stays reachable.+ <Flexbox flex={1} style={{ minHeight: 0 }}>+ <DocumentExplorerTree+ agentId={agentId}+ data={documentsData}+ mutate={mutate}+ style={{ height: '100%' }}+ />+ </Flexbox>+ );- if (viewMode === 'tree') {+ const renderWeb = () => {+ if (webData.length === 0) {+ return (+ <Center flex={1} gap={8} paddingBlock={24}>+ <Empty description={t('workingPanel.resources.empty')} icon={GlobeIcon} />+ </Center>+ );+ }return (- <Flexbox gap={16}>- {treeGroups.map((group) => (- <Flexbox gap={8} key={group.labelKey}>- <Text className={styles.groupLabel} type={'secondary'}>- {t(group.labelKey)}- </Text>- <Flexbox gap={8}>- {group.items.map((doc) => (- <DocumentItem- agentId={agentId}- document={doc}- hideDelete={shouldHideDelete(doc)}- key={doc.id}- mutate={mutate}- openDocumentId={getOpenDocumentId(doc)}- />- ))}- </Flexbox>- </Flexbox>+ <Flexbox gap={8}>+ {webData.map((doc) => (+ <DocumentItem agentId={agentId} document={doc} key={doc.id} mutate={mutate} />))}</Flexbox>);- }+ };return (<Flexbox gap={12} style={style}>@@ -356,36 +395,9 @@ const AgentDocumentsGroup = memo<AgentDocumentsGroupProps>(({ style, viewMode =);})}</Flexbox>- {filter === 'documents' ? (- <Flexbox flex={1} style={{ minHeight: 0 }}>- <DocumentExplorerTree- agentId={agentId}- data={data}- mutate={mutate}- style={{ height: '100%' }}- />- </Flexbox>- ) : visibleFlatData.length === 0 ? (- <Center flex={1} gap={8} paddingBlock={24}>- <Empty- description={t('workingPanel.resources.empty')}- icon={filter === 'web' ? GlobeIcon : FileTextIcon}- />- </Center>- ) : (- <Flexbox gap={8}>- {visibleFlatData.map((doc) => (- <DocumentItem- agentId={agentId}- document={doc}- hideDelete={shouldHideDelete(doc)}- key={doc.id}- mutate={mutate}- openDocumentId={getOpenDocumentId(doc)}- />- ))}- </Flexbox>- )}+ {filter === 'skills' && renderSkills()}+ {filter === 'documents' && renderDocuments()}+ {filter === 'web' && renderWeb()}</Flexbox>);});diff --git a/src/routes/(main)/agent/features/Conversation/WorkingSidebar/ResourcesSection/SkillsGroup.tsx b/src/routes/(main)/agent/features/Conversation/WorkingSidebar/ResourcesSection/SkillsGroup.tsxindex 088c0aeed20..4a12d37f6a6 100644--- a/src/routes/(main)/agent/features/Conversation/WorkingSidebar/ResourcesSection/SkillsGroup.tsx+++ b/src/routes/(main)/agent/features/Conversation/WorkingSidebar/ResourcesSection/SkillsGroup.tsx@@ -1,61 +1,19 @@import { isDesktop } from '@lobechat/const';import { type ListProjectSkillsResult, type ProjectSkillItem } from '@lobechat/electron-client-ipc';-import { Center, Empty, Flexbox, Icon, Text, Tooltip } from '@lobehub/ui';+import { Center, Empty, Flexbox, Text } from '@lobehub/ui';import { SkillsIcon } from '@lobehub/ui/icons';import { Spin } from 'antd';import { createStaticStyles } from 'antd-style';-import { ChevronRightIcon, FileIcon, FolderIcon } from 'lucide-react';import path from 'pathe';-import { memo, useCallback, useMemo, useState } from 'react';+import { memo, useMemo } from 'react';import { useTranslation } from 'react-i18next';+import SkillsList, { type SkillListItem } from '@/features/AgentDocumentsExplorer/SkillsList';import { useClientDataSWR } from '@/libs/swr';import { localFileService } from '@/services/electron/localFileService';import { useChatStore } from '@/store/chat';const styles = createStaticStyles(({ css, cssVar }) => ({- chevron: css`- flex-shrink: 0;- color: ${cssVar.colorTextTertiary};- transition: transform ${cssVar.motionDurationFast} ${cssVar.motionEaseInOut};- `,- chevronExpanded: css`- transform: rotate(90deg);- `,- childItem: css`- cursor: pointer;-- height: 26px;- padding-inline-end: 8px;- border-radius: 6px;-- font-size: 12px;- color: ${cssVar.colorTextSecondary};-- &:hover {- color: ${cssVar.colorText};- background: ${cssVar.colorFillTertiary};- }- `,- childItemIcon: css`- flex-shrink: 0;- color: ${cssVar.colorTextTertiary};- `,- treeChevronSlot: css`- display: flex;- flex-shrink: 0;- align-items: center;- justify-content: center;-- width: 14px;- height: 14px;- `,- description: css`- max-width: 320px;- font-size: 12px;- line-height: 1.5;- color: ${cssVar.colorTextSecondary};- `,groupCount: css`font-size: 12px;font-variant-numeric: tabular-nums;@@ -65,223 +23,8 @@ const styles = createStaticStyles(({ css, cssVar }) => ({font-size: 12px;font-weight: 500;`,- item: css`- cursor: pointer;-- height: 28px;- padding-inline: 4px 8px;- border-radius: 6px;-- font-size: 13px;- color: ${cssVar.colorTextSecondary};-- &:hover {- color: ${cssVar.colorText};- background: ${cssVar.colorFillTertiary};- }- `,- itemCount: css`- flex-shrink: 0;- font-size: 12px;- font-variant-numeric: tabular-nums;- color: ${cssVar.colorTextTertiary};- `,- itemIcon: css`- flex-shrink: 0;- color: ${cssVar.colorTextTertiary};- `,}));-interface TreeNode {- children: TreeNode[];- isDirectory: boolean;- name: string;- path: string;-}--const buildSkillTree = (paths: string[]): TreeNode[] => {- const root: TreeNode = { children: [], isDirectory: true, name: '', path: '' };-- for (const fullPath of paths) {- const parts = fullPath.split('/').filter(Boolean);- let current = root;- let accumPath = '';-- for (let i = 0; i < parts.length; i++) {- const part = parts[i];- accumPath = accumPath ? `${accumPath}/${part}` : part;- const isDirectory = i < parts.length - 1;-- let child = current.children.find((c) => c.name === part);- if (!child) {- child = { children: [], isDirectory, name: part, path: accumPath };- current.children.push(child);- }- current = child;- }- }-- const sortNode = (node: TreeNode) => {- node.children.sort((a, b) => {- if (a.isDirectory !== b.isDirectory) return a.isDirectory ? -1 : 1;- return a.name.localeCompare(b.name);- });- for (const child of node.children) sortNode(child);- };- sortNode(root);-- return root.children;-};--const TREE_BASE_INSET = 24;-const TREE_DEPTH_INDENT = 14;--interface TreeRowProps {- depth: number;- expanded: Set<string>;- node: TreeNode;- onOpenFile: (relativePath: string) => void;- onToggleFolder: (folderPath: string) => void;-}--const TreeRow = memo<TreeRowProps>(({ depth, expanded, node, onOpenFile, onToggleFolder }) => {- const isOpen = expanded.has(node.path);- const paddingInlineStart = TREE_BASE_INSET + depth * TREE_DEPTH_INDENT;-- if (node.isDirectory) {- return (- <>- <Flexbox- horizontal- align={'center'}- className={styles.childItem}- gap={6}- style={{ paddingInlineStart }}- onClick={() => onToggleFolder(node.path)}- >- <span className={styles.treeChevronSlot}>- <Icon- className={`${styles.chevron} ${isOpen ? styles.chevronExpanded : ''}`}- icon={ChevronRightIcon}- size={12}- />- </span>- <Icon className={styles.childItemIcon} icon={FolderIcon} size={12} />- <Text ellipsis style={{ flex: 1, fontSize: 12, minWidth: 0 }}>- {node.name}- </Text>- </Flexbox>- {isOpen &&- node.children.map((child) => (- <TreeRow- depth={depth + 1}- expanded={expanded}- key={child.path}- node={child}- onOpenFile={onOpenFile}- onToggleFolder={onToggleFolder}- />- ))}- </>- );- }-- return (- <Flexbox- horizontal- align={'center'}- className={styles.childItem}- gap={6}- style={{ paddingInlineStart }}- title={node.path}- onClick={() => onOpenFile(node.path)}- >- <span className={styles.treeChevronSlot} />- <Icon className={styles.childItemIcon} icon={FileIcon} size={12} />- <Text ellipsis style={{ flex: 1, fontSize: 12, minWidth: 0 }}>- {node.name}- </Text>- </Flexbox>- );-});--TreeRow.displayName = 'SkillTreeRow';--interface SkillRowProps {- expanded: boolean;- onOpenFile: (relativePath: string) => void;- onToggle: () => void;- skill: ProjectSkillItem;- workingDirectory: string;-}--const SkillRow = memo<SkillRowProps>(- ({ expanded, onOpenFile, onToggle, skill, workingDirectory }) => {- const openLocalFile = useChatStore((s) => s.openLocalFile);- const handleOpenSkill = () => openLocalFile({ filePath: skill.path, workingDirectory });- const tree = useMemo(() => buildSkillTree(skill.files), [skill.files]);- const [expandedFolders, setExpandedFolders] = useState<Set<string>>(() => new Set());-- const toggleFolder = useCallback((folderPath: string) => {- setExpandedFolders((prev) => {- const next = new Set(prev);- if (next.has(folderPath)) next.delete(folderPath);- else next.add(folderPath);- return next;- });- }, []);-- return (- <>- <Tooltip- placement={'left'}- title={- skill.description ? (- <span className={styles.description}>{skill.description}</span>- ) : undefined- }- >- <Flexbox horizontal align={'center'} className={styles.item} gap={6}>- <Flexbox- align={'center'}- justify={'center'}- style={{ cursor: 'pointer', flexShrink: 0, height: 20, width: 20 }}- onClick={(e) => {- e.stopPropagation();- onToggle();- }}- >- <Icon- className={`${styles.chevron} ${expanded ? styles.chevronExpanded : ''}`}- icon={ChevronRightIcon}- size={14}- />- </Flexbox>- <Icon className={styles.itemIcon} icon={SkillsIcon} size={14} />- <Text ellipsis style={{ flex: 1, minWidth: 0 }} onClick={handleOpenSkill}>- {skill.name}- </Text>- <span className={styles.itemCount}>{skill.fileCount}</span>- </Flexbox>- </Tooltip>- {expanded &&- tree.map((node) => (- <TreeRow- depth={0}- expanded={expandedFolders}- key={node.path}- node={node}- onOpenFile={onOpenFile}- onToggleFolder={toggleFolder}- />- ))}- </>- );- },-);--SkillRow.displayName = 'SkillRow';-interface SkillsGroupProps {workingDirectory: string;}@@ -289,19 +32,6 @@ interface SkillsGroupProps {const SkillsGroup = memo<SkillsGroupProps>(({ workingDirectory }) => {const { t } = useTranslation('chat');const openLocalFile = useChatStore((s) => s.openLocalFile);- const [expanded, setExpanded] = useState<Set<string>>(() => new Set());-- const toggle = useCallback((skillDir: string) => {- setExpanded((prev) => {- const next = new Set(prev);- if (next.has(skillDir)) {- next.delete(skillDir);- } else {- next.add(skillDir);- }- return next;- });- }, []);const enabled = isDesktop && !!workingDirectory;const { data, error, isLoading } = useClientDataSWR<ListProjectSkillsResult>(@@ -310,15 +40,34 @@ const SkillsGroup = memo<SkillsGroupProps>(({ workingDirectory }) => {{ revalidateOnFocus: false, shouldRetryOnError: false },);- if (!enabled) return null;-- const totalCount = data?.skills.length ?? 0;// listProjectSkills approves `data.root` for preview. Hand that exact value// back to openLocalFile so LocalFileProtocolManager.createPreviewUrl's// approved-root check matches; fall back to the requested workingDirectory// while the SWR fetch is in flight.const previewWorkspaceRoot = data?.root || workingDirectory;+ const items = useMemo<SkillListItem[]>(+ () =>+ (data?.skills ?? []).map((skill) => ({+ description: skill.description,+ fileCount: skill.fileCount,+ files: skill.files,+ id: skill.skillDir,+ name: skill.name,+ })),+ [data?.skills],+ );++ const skillByDir = useMemo(() => {+ const map = new Map<string, ProjectSkillItem>();+ for (const skill of data?.skills ?? []) map.set(skill.skillDir, skill);+ return map;+ }, [data?.skills]);++ if (!enabled) return null;++ const totalCount = data?.skills.length ?? 0;+return (<Flexbox gap={4}><Flexbox horizontal align={'center'} gap={6} paddingInline={4}>@@ -336,23 +85,22 @@ const SkillsGroup = memo<SkillsGroupProps>(({ workingDirectory }) => {<Empty description={t('workingPanel.skills.empty')} icon={SkillsIcon} /></Center>) : (- <Flexbox gap={2}>- {data.skills.map((skill) => (- <SkillRow- expanded={expanded.has(skill.skillDir)}- key={skill.skillDir}- skill={skill}- workingDirectory={previewWorkspaceRoot}- onToggle={() => toggle(skill.skillDir)}- onOpenFile={(relativePath) =>- openLocalFile({- filePath: path.join(skill.skillDir, relativePath),- workingDirectory: previewWorkspaceRoot,- })- }- />- ))}- </Flexbox>+ <SkillsList+ items={items}+ onOpenFile={(item, relativePath) => {+ const skill = skillByDir.get(item.id);+ if (!skill) return;+ openLocalFile({+ filePath: path.join(skill.skillDir, relativePath),+ workingDirectory: previewWorkspaceRoot,+ });+ }}+ onOpenSkill={(item) => {+ const skill = skillByDir.get(item.id);+ if (!skill) return;+ openLocalFile({ filePath: skill.path, workingDirectory: previewWorkspaceRoot });+ }}+ />)}</Flexbox>);diff --git a/src/routes/(main)/agent/features/Conversation/WorkingSidebar/ResourcesSection/index.tsx b/src/routes/(main)/agent/features/Conversation/WorkingSidebar/ResourcesSection/index.tsxindex fdb87e4c63d..bf6db155195 100644--- a/src/routes/(main)/agent/features/Conversation/WorkingSidebar/ResourcesSection/index.tsx+++ b/src/routes/(main)/agent/features/Conversation/WorkingSidebar/ResourcesSection/index.tsx@@ -9,8 +9,6 @@ import { topicSelectors } from '@/store/chat/selectors';import AgentDocumentsGroup from './AgentDocumentsGroup';import SkillsGroup from './SkillsGroup';-export type ResourceViewMode = 'list' | 'tree';-const ResourcesSection = memo(() => {const isHetero = useAgentStore(agentSelectors.isCurrentAgentHeterogeneous);const activeAgentId = useAgentStore((s) => s.activeAgentId);@@ -30,7 +28,7 @@ const ResourcesSection = memo(() => {style={{ minHeight: 0 }}>{isHetero && workingDirectory && <SkillsGroup workingDirectory={workingDirectory} />}- {!isHetero && <AgentDocumentsGroup style={{ flex: 1, minHeight: 0 }} viewMode={'list'} />}+ {!isHetero && <AgentDocumentsGroup style={{ flex: 1, minHeight: 0 }} />}</Flexbox>);});diff --git a/src/routes/(main)/agent/features/Conversation/WorkingSidebar/index.test.tsx b/src/routes/(main)/agent/features/Conversation/WorkingSidebar/index.test.tsxindex 5ff2105b526..942da8588af 100644--- a/src/routes/(main)/agent/features/Conversation/WorkingSidebar/index.test.tsx+++ b/src/routes/(main)/agent/features/Conversation/WorkingSidebar/index.test.tsx@@ -143,12 +143,18 @@ vi.mock('react-i18next', () => ({({'workingPanel.resources.empty': 'No agent documents yet','workingPanel.review.title': 'Review',+ 'workingPanel.skills.empty': 'No skills found','workingPanel.space': 'Space',}) as Record<string, string>)[key] || key,}),}));+vi.mock('react-router-dom', () => ({+ useMatch: () => null,+ useNavigate: () => vi.fn(),+}));+vi.mock('@/store/agent', () => ({useAgentStore: (selector: (state: Record<string, unknown>) => unknown) =>selector?.(mocks.agentStoreState),@@ -225,7 +231,8 @@ describe('AgentWorkingSidebar', () => {expect(screen.getAllByText('Space').length).toBeGreaterThan(0);const resources = screen.getByTestId('workspace-resources');- expect(resources).toHaveTextContent('No agent documents yet');+ // Default tab is Skills; empty data shows the skills empty state.+ expect(resources).toHaveTextContent('No skills found');});it('mounts a right panel wrapper', () => {