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(skills): add view/rename/delete row actions in working sidebar (#15864)

Arvin Xu4b72bcfe9992
diff --git a/locales/en-US/chat.json b/locales/en-US/chat.json
index f14bdd8ea56..31b673d2354 100644
--- a/locales/en-US/chat.json
+++ b/locales/en-US/chat.json
@@ -1096,7 +1096,21 @@
"workingPanel.review.viewMode.unified": "Switch to unified view",
"workingPanel.review.wordWrap.disable": "Disable word wrap",
"workingPanel.review.wordWrap.enable": "Enable word wrap",
+ "workingPanel.skills.actions.comingSoon": "Coming soon",
+ "workingPanel.skills.actions.delete": "Delete",
+ "workingPanel.skills.actions.rename": "Rename",
+ "workingPanel.skills.actions.view": "View",
+ "workingPanel.skills.delete.agentConfirm": "Remove the skill “{{name}}” from this agent? This cannot be undone.",
+ "workingPanel.skills.delete.error": "Failed to delete skill",
+ "workingPanel.skills.delete.success": "Skill deleted",
+ "workingPanel.skills.delete.title": "Delete skill?",
+ "workingPanel.skills.delete.userConfirm": "Uninstall the skill “{{name}}”? This cannot be undone.",
+ "workingPanel.skills.detail.title": "Skill details",
"workingPanel.skills.empty": "No skills available",
+ "workingPanel.skills.rename.action": "Rename",
+ "workingPanel.skills.rename.error": "Failed to rename skill",
+ "workingPanel.skills.rename.placeholder": "Skill name",
+ "workingPanel.skills.rename.title": "Rename skill",
"workingPanel.skills.section.agent": "Agent skills",
"workingPanel.skills.section.project": "Project skills",
"workingPanel.skills.section.user": "User skills",
diff --git a/locales/zh-CN/chat.json b/locales/zh-CN/chat.json
index c688a658e4c..65d853e183a 100644
--- a/locales/zh-CN/chat.json
+++ b/locales/zh-CN/chat.json
@@ -1096,7 +1096,21 @@
"workingPanel.review.viewMode.unified": "切换到合并视图",
"workingPanel.review.wordWrap.disable": "关闭自动换行",
"workingPanel.review.wordWrap.enable": "启用自动换行",
+ "workingPanel.skills.actions.comingSoon": "即将支持",
+ "workingPanel.skills.actions.delete": "删除",
+ "workingPanel.skills.actions.rename": "重命名",
+ "workingPanel.skills.actions.view": "查看",
+ "workingPanel.skills.delete.agentConfirm": "确定从当前智能体移除技能「{{name}}」?此操作不可撤销。",
+ "workingPanel.skills.delete.error": "删除技能失败",
+ "workingPanel.skills.delete.success": "技能已删除",
+ "workingPanel.skills.delete.title": "删除技能?",
+ "workingPanel.skills.delete.userConfirm": "确定卸载技能「{{name}}」?此操作不可撤销。",
+ "workingPanel.skills.detail.title": "技能详情",
"workingPanel.skills.empty": "暂无可用技能",
+ "workingPanel.skills.rename.action": "重命名",
+ "workingPanel.skills.rename.error": "重命名技能失败",
+ "workingPanel.skills.rename.placeholder": "技能名称",
+ "workingPanel.skills.rename.title": "重命名技能",
"workingPanel.skills.section.agent": "智能体技能",
"workingPanel.skills.section.project": "项目技能",
"workingPanel.skills.section.user": "用户技能",
diff --git a/packages/locales/src/default/chat.ts b/packages/locales/src/default/chat.ts
index 4c3ce004780..3ce43e107e9 100644
--- a/packages/locales/src/default/chat.ts
+++ b/packages/locales/src/default/chat.ts
@@ -1133,7 +1133,23 @@ export default {
'workingPanel.localFile.preview.render': 'Preview',
'workingPanel.localFile.preview.source': 'Source',
'workingPanel.localFile.truncated': 'File preview truncated to {{limit}} characters',
+ 'workingPanel.skills.actions.comingSoon': 'Coming soon',
+ 'workingPanel.skills.actions.delete': 'Delete',
+ 'workingPanel.skills.actions.rename': 'Rename',
+ 'workingPanel.skills.actions.view': 'View',
+ 'workingPanel.skills.delete.agentConfirm':
+ 'Remove the skill “{{name}}” from this agent? This cannot be undone.',
+ 'workingPanel.skills.delete.error': 'Failed to delete skill',
+ 'workingPanel.skills.delete.success': 'Skill deleted',
+ 'workingPanel.skills.delete.title': 'Delete skill?',
+ 'workingPanel.skills.delete.userConfirm':
+ 'Uninstall the skill “{{name}}”? This cannot be undone.',
+ 'workingPanel.skills.detail.title': 'Skill details',
'workingPanel.skills.empty': 'No skills available',
+ 'workingPanel.skills.rename.action': 'Rename',
+ 'workingPanel.skills.rename.error': 'Failed to rename skill',
+ 'workingPanel.skills.rename.placeholder': 'Skill name',
+ 'workingPanel.skills.rename.title': 'Rename skill',
'workingPanel.skills.section.agent': 'Agent skills',
'workingPanel.skills.section.project': 'Project skills',
'workingPanel.skills.section.user': 'User skills',
diff --git a/src/features/SkillsList/RenameSkillModal.tsx b/src/features/SkillsList/RenameSkillModal.tsx
new file mode 100644
index 00000000000..8e4e9318c6f
--- /dev/null
+++ b/src/features/SkillsList/RenameSkillModal.tsx
@@ -0,0 +1,103 @@
+'use client';
+
+import { Button, Flexbox, Input, Text } from '@lobehub/ui';
+import { createModal, type ModalInstance, useModalContext } from '@lobehub/ui/base-ui';
+import { type InputRef } from 'antd';
+import { cssVar } from 'antd-style';
+import { t } from 'i18next';
+import { memo, useCallback, useEffect, useRef, useState } from 'react';
+import { useTranslation } from 'react-i18next';
+
+interface RenameSkillContentProps {
+ /** The skill's current name — prefilled and selected for quick editing. */
+ currentName: string;
+ /**
+ * Rename the skill. Return an error message to show inline and keep the modal
+ * open; return undefined on success (the modal closes).
+ */
+ onSubmit: (name: string) => Promise<string | undefined>;
+}
+
+const RenameSkillContent = memo<RenameSkillContentProps>(({ currentName, onSubmit }) => {
+ const { t: tChat } = useTranslation('chat');
+ const { t: tCommon } = useTranslation('common');
+ const { close } = useModalContext();
+ const [value, setValue] = useState(currentName);
+ const [loading, setLoading] = useState(false);
+ const [error, setError] = useState<string>();
+ const inputRef = useRef<InputRef>(null);
+
+ useEffect(() => {
+ // Focus + select the whole name so the user can immediately retype.
+ queueMicrotask(() => inputRef.current?.select());
+ }, []);
+
+ const handleSubmit = useCallback(async () => {
+ if (loading) return;
+ const name = value.trim();
+ if (!name || name === currentName) return;
+ setLoading(true);
+ try {
+ const message = await onSubmit(name);
+ if (message) {
+ setError(message);
+ return;
+ }
+ close();
+ } finally {
+ setLoading(false);
+ }
+ }, [close, currentName, loading, onSubmit, value]);
+
+ const trimmed = value.trim();
+ return (
+ <Flexbox gap={16}>
+ <Flexbox gap={6}>
+ <Input
+ placeholder={tChat('workingPanel.skills.rename.placeholder')}
+ ref={inputRef}
+ value={value}
+ onPressEnter={handleSubmit}
+ onChange={(e) => {
+ setValue(e.target.value);
+ setError(undefined);
+ }}
+ />
+ {error ? <Text style={{ color: cssVar.colorError, fontSize: 12 }}>{error}</Text> : null}
+ </Flexbox>
+ <Flexbox horizontal gap={8} justify={'flex-end'}>
+ <Button disabled={loading} onClick={close}>
+ {tCommon('cancel')}
+ </Button>
+ <Button
+ disabled={!trimmed || trimmed === currentName}
+ loading={loading}
+ type={'primary'}
+ onClick={handleSubmit}
+ >
+ {tChat('workingPanel.skills.rename.action')}
+ </Button>
+ </Flexbox>
+ </Flexbox>
+ );
+});
+
+RenameSkillContent.displayName = 'RenameSkillContent';
+
+/**
+ * Skill-name entry for renaming a skill. Prefills the current name and submits
+ * the new one. Shared by the agent-skill and user-skill rows in the working
+ * sidebar (both back onto a rename service); mirrors the branch rename modal.
+ */
+export const openRenameSkillModal = (options: {
+ currentName: string;
+ onSubmit: (name: string) => Promise<string | undefined>;
+}): ModalInstance =>
+ createModal({
+ content: <RenameSkillContent currentName={options.currentName} onSubmit={options.onSubmit} />,
+ footer: null,
+ maskClosable: true,
+ styles: { header: { borderBottom: 'none' } },
+ title: t('workingPanel.skills.rename.title', { ns: 'chat' }),
+ width: 'min(90vw, 480px)',
+ });
diff --git a/src/features/SkillsList/SkillsList.tsx b/src/features/SkillsList/SkillsList.tsx
index 626111f9782..4105775c7d7 100644
--- a/src/features/SkillsList/SkillsList.tsx
+++ b/src/features/SkillsList/SkillsList.tsx
@@ -1,8 +1,15 @@
import { EMPTY_ARRAY } from '@lobechat/const';
-import { Flexbox, Icon, Text, Tooltip } from '@lobehub/ui';
+import {
+ ContextMenuTrigger,
+ Flexbox,
+ type GenericItemType,
+ 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 { createStaticStyles, cx } from 'antd-style';
+import { ChevronRightIcon, FileIcon, FolderIcon, type LucideIcon } from 'lucide-react';
import type React from 'react';
import { memo, useCallback, useMemo, useState } from 'react';
@@ -22,7 +29,32 @@ export interface SkillListItem {
name: string;
}
+/**
+ * A per-row action (view / rename / delete …). The same descriptor drives both
+ * the hover-revealed icon button on the right of the row and the right-click
+ * context menu, so callers wire each capability once. Disabled actions render
+ * greyed (used for not-yet-supported operations, e.g. mutating filesystem
+ * project skills).
+ */
+export interface SkillRowAction {
+ danger?: boolean;
+ disabled?: boolean;
+ icon: LucideIcon;
+ key: string;
+ label: string;
+ onClick: (item: SkillListItem) => void;
+ /** Hover-icon tooltip; falls back to `label`. Use for "coming soon" hints. */
+ tooltip?: string;
+}
+
interface SkillsListProps {
+ /**
+ * Per-row actions. When this returns a non-empty array the row gains a
+ * hover-revealed action cluster (right side, swaps with the file count) and a
+ * right-click context menu sharing the same actions. Return `[]`/omit for
+ * read-only rows (no menu, native right-click preserved).
+ */
+ getRowActions?: (item: SkillListItem) => SkillRowAction[];
items: SkillListItem[];
onOpenFile?: (item: SkillListItem, relativePath: string) => void;
onOpenSkill?: (item: SkillListItem) => void;
@@ -82,6 +114,15 @@ const styles = createStaticStyles(({ css, cssVar }) => ({
color: ${cssVar.colorText};
background: ${cssVar.colorFillTertiary};
}
+
+ /* Swap the file count for the row actions while hovering the row. */
+ &:hover .skill-row-actions {
+ display: flex;
+ }
+
+ &:hover .skill-row-count {
+ display: none;
+ }
`,
itemCount: css`
flex-shrink: 0;
@@ -89,6 +130,47 @@ const styles = createStaticStyles(({ css, cssVar }) => ({
font-variant-numeric: tabular-nums;
color: ${cssVar.colorTextTertiary};
`,
+ rowAction: css`
+ cursor: pointer;
+
+ display: flex;
+ align-items: center;
+ justify-content: center;
+
+ width: 20px;
+ height: 20px;
+ border-radius: 4px;
+
+ color: ${cssVar.colorTextTertiary};
+
+ transition: all 0.2s;
+
+ &:hover {
+ color: ${cssVar.colorText};
+ background: ${cssVar.colorFillSecondary};
+ }
+ `,
+ rowActionDanger: css`
+ &:hover {
+ color: ${cssVar.colorError};
+ background: ${cssVar.colorErrorBg};
+ }
+ `,
+ rowActionDisabled: css`
+ cursor: not-allowed;
+ color: ${cssVar.colorTextQuaternary};
+
+ &:hover {
+ color: ${cssVar.colorTextQuaternary};
+ background: transparent;
+ }
+ `,
+ rowActions: css`
+ display: none;
+ flex: none;
+ gap: 2px;
+ align-items: center;
+ `,
itemIcon: css`
flex-shrink: 0;
color: ${cssVar.colorTextTertiary};
@@ -220,6 +302,7 @@ const TreeRow = memo<TreeRowProps>(({ depth, expanded, node, onOpenFile, onToggl
TreeRow.displayName = 'SkillsListTreeRow';
interface SkillRowProps {
+ actions: SkillRowAction[];
expanded: boolean;
item: SkillListItem;
onDragStart?: (event: React.DragEvent) => void;
@@ -230,9 +313,19 @@ interface SkillRowProps {
}
const SkillRow = memo<SkillRowProps>(
- ({ expanded, item, onDragStart, onOpenFile, onOpenSkill, onToggle, reserveChevronSlot }) => {
+ ({
+ actions,
+ expanded,
+ item,
+ onDragStart,
+ onOpenFile,
+ onOpenSkill,
+ onToggle,
+ reserveChevronSlot,
+ }) => {
const files = item.files ?? EMPTY_ARRAY;
const hasFiles = files.length > 0;
+ const hasActions = actions.length > 0;
const tree = useMemo(() => buildSkillTree(files), [files]);
const [expandedFolders, setExpandedFolders] = useState<Set<string>>(() => new Set());
@@ -245,52 +338,100 @@ const SkillRow = memo<SkillRowProps>(
});
}, []);
- return (
- <>
- <Tooltip
- placement={'left'}
- title={
- item.description ? (
- <span className={styles.description}>{item.description}</span>
- ) : undefined
- }
- >
+ const contextMenuItems = useCallback(
+ (): GenericItemType[] =>
+ actions.map((action) => ({
+ danger: action.danger,
+ disabled: action.disabled,
+ icon: <Icon icon={action.icon} />,
+ key: action.key,
+ label: action.label,
+ onClick: () => action.onClick(item),
+ })),
+ [actions, item],
+ );
+
+ // The description Tooltip wraps just the name (a ref-forwarding leaf) and the
+ // ContextMenuTrigger wraps just the row Flexbox — both cloning wrappers get
+ // a clean DOM-forwarding child. Nesting them (Tooltip around the trigger, or
+ // vice versa) would drop `onContextMenu` / the ref on the way through.
+ const nameNode = (
+ <Text ellipsis style={{ color: 'inherit', flex: 1, minWidth: 0 }} onClick={onOpenSkill}>
+ {item.name}
+ </Text>
+ );
+
+ const row = (
+ <Flexbox
+ horizontal
+ align={'center'}
+ className={styles.item}
+ draggable={!!onDragStart}
+ gap={6}
+ onDragStart={onDragStart}
+ >
+ {hasFiles ? (
<Flexbox
- horizontal
align={'center'}
- className={styles.item}
- draggable={!!onDragStart}
- gap={6}
- onDragStart={onDragStart}
+ justify={'center'}
+ style={{ cursor: 'pointer', flexShrink: 0, height: 20, width: 20 }}
+ onClick={(e) => {
+ e.stopPropagation();
+ onToggle();
+ }}
>
- {hasFiles ? (
- <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>
- ) : reserveChevronSlot ? (
- <span style={{ flexShrink: 0, height: 20, width: 20 }} />
- ) : null}
- <Icon className={styles.itemIcon} icon={SkillsIcon} size={14} />
- <Text ellipsis style={{ color: 'inherit', flex: 1, minWidth: 0 }} onClick={onOpenSkill}>
- {item.name}
- </Text>
- {typeof item.fileCount === 'number' && item.fileCount > 0 && (
- <span className={styles.itemCount}>{item.fileCount}</span>
- )}
+ <Icon
+ className={`${styles.chevron} ${expanded ? styles.chevronExpanded : ''}`}
+ icon={ChevronRightIcon}
+ size={14}
+ />
</Flexbox>
- </Tooltip>
+ ) : reserveChevronSlot ? (
+ <span style={{ flexShrink: 0, height: 20, width: 20 }} />
+ ) : null}
+ <Icon className={styles.itemIcon} icon={SkillsIcon} size={14} />
+ {item.description ? (
+ <Tooltip
+ placement={'left'}
+ title={<span className={styles.description}>{item.description}</span>}
+ >
+ {nameNode}
+ </Tooltip>
+ ) : (
+ nameNode
+ )}
+ {typeof item.fileCount === 'number' && item.fileCount > 0 && (
+ <span className={cx('skill-row-count', styles.itemCount)}>{item.fileCount}</span>
+ )}
+ {hasActions && (
+ <div className={cx('skill-row-actions', styles.rowActions)} draggable={false}>
+ {actions.map((action) => (
+ <Tooltip key={action.key} title={action.tooltip ?? action.label}>
+ <div
+ role={'button'}
+ className={cx(
+ styles.rowAction,
+ action.danger && !action.disabled && styles.rowActionDanger,
+ action.disabled && styles.rowActionDisabled,
+ )}
+ onClick={(e) => {
+ e.stopPropagation();
+ if (action.disabled) return;
+ action.onClick(item);
+ }}
+ >
+ <Icon icon={action.icon} size={13} />
+ </div>
+ </Tooltip>
+ ))}
+ </div>
+ )}
+ </Flexbox>
+ );
+
+ return (
+ <>
+ {hasActions ? <ContextMenuTrigger items={contextMenuItems}>{row}</ContextMenuTrigger> : row}
{expanded &&
hasFiles &&
onOpenFile &&
@@ -311,40 +452,43 @@ const SkillRow = memo<SkillRowProps>(
SkillRow.displayName = 'SkillsListSkillRow';
-const SkillsList = memo<SkillsListProps>(({ items, onOpenFile, onOpenSkill, onSkillDragStart }) => {
- const [expanded, setExpanded] = useState<Set<string>>(() => new Set());
+const SkillsList = memo<SkillsListProps>(
+ ({ getRowActions, items, onOpenFile, onOpenSkill, onSkillDragStart }) => {
+ 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;
- });
- }, []);
+ 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;
+ });
+ }, []);
- const reserveChevronSlot = useMemo(
- () => items.some((item) => (item.files?.length ?? 0) > 0),
- [items],
- );
+ const reserveChevronSlot = useMemo(
+ () => items.some((item) => (item.files?.length ?? 0) > 0),
+ [items],
+ );
- return (
- <Flexbox gap={2}>
- {items.map((item) => (
- <SkillRow
- expanded={expanded.has(item.id)}
- item={item}
- key={item.id}
- reserveChevronSlot={reserveChevronSlot}
- onDragStart={onSkillDragStart ? (event) => onSkillDragStart(item, event) : undefined}
- onOpenFile={onOpenFile ? (relativePath) => onOpenFile(item, relativePath) : undefined}
- onOpenSkill={onOpenSkill ? () => onOpenSkill(item) : undefined}
- onToggle={() => toggle(item.id)}
- />
- ))}
- </Flexbox>
- );
-});
+ return (
+ <Flexbox gap={2}>
+ {items.map((item) => (
+ <SkillRow
+ actions={getRowActions?.(item) ?? EMPTY_ARRAY}
+ expanded={expanded.has(item.id)}
+ item={item}
+ key={item.id}
+ reserveChevronSlot={reserveChevronSlot}
+ onDragStart={onSkillDragStart ? (event) => onSkillDragStart(item, event) : undefined}
+ onOpenFile={onOpenFile ? (relativePath) => onOpenFile(item, relativePath) : undefined}
+ onOpenSkill={onOpenSkill ? () => onOpenSkill(item) : undefined}
+ onToggle={() => toggle(item.id)}
+ />
+ ))}
+ </Flexbox>
+ );
+ },
+);
SkillsList.displayName = 'SkillsList';
diff --git a/src/features/SkillsList/index.ts b/src/features/SkillsList/index.ts
index 7c167e56e2c..05d46434fc9 100644
--- a/src/features/SkillsList/index.ts
+++ b/src/features/SkillsList/index.ts
@@ -1,5 +1,6 @@
+export { openRenameSkillModal } from './RenameSkillModal';
export type { SkillSectionHeader, SkillSectionProps } from './SkillSection';
export { default as SkillSection } from './SkillSection';
-export type { SkillListItem } from './SkillsList';
+export type { SkillListItem, SkillRowAction } from './SkillsList';
export { default as SkillsList } from './SkillsList';
export { useProjectSkills, type UseProjectSkillsResult } from './useProjectSkills';
diff --git a/src/features/SkillsList/useProjectSkills.ts b/src/features/SkillsList/useProjectSkills.ts
index 1ea16f8637e..6fbebf490ea 100644
--- a/src/features/SkillsList/useProjectSkills.ts
+++ b/src/features/SkillsList/useProjectSkills.ts
@@ -1,13 +1,22 @@
import { type ListProjectSkillsResult, type ProjectSkillItem } from '@lobechat/electron-client-ipc';
+import { EyeIcon, PencilIcon, Trash2Icon } from 'lucide-react';
import path from 'pathe';
import { useMemo } from 'react';
+import { useTranslation } from 'react-i18next';
import { useFetchProjectSkills } from '@/hooks/useFetchProjectSkills';
import { useChatStore } from '@/store/chat';
-import type { SkillListItem } from './SkillsList';
+import type { SkillListItem, SkillRowAction } from './SkillsList';
export interface UseProjectSkillsResult {
+ /**
+ * Per-row actions for project skills: "view" opens the SKILL.md (local only —
+ * a remote device's filesystem isn't reachable by the local viewer), while
+ * rename / delete are stubbed (disabled) until the filesystem-mutation IPC
+ * lands.
+ */
+ getRowActions: (item: SkillListItem) => SkillRowAction[];
isLoading: boolean;
items: SkillListItem[];
onOpenFile: (item: SkillListItem, relativePath: string) => void;
@@ -32,6 +41,7 @@ export const useProjectSkills = (
workingDirectory: string | undefined,
deviceId?: string,
): UseProjectSkillsResult => {
+ const { t } = useTranslation('chat');
const openLocalFile = useChatStore((s) => s.openLocalFile);
const isRemote = !!deviceId;
@@ -80,5 +90,37 @@ export const useProjectSkills = (
openLocalFile({ filePath: skill.path, workingDirectory: previewRoot });
};
- return { isLoading, items, onOpenFile, onOpenSkill, raw: data };
+ const getRowActions = (_item: SkillListItem): SkillRowAction[] => {
+ const comingSoon = t('workingPanel.skills.actions.comingSoon');
+ return [
+ {
+ // Remote devices list skills but can't preview them (matches Files tab).
+ disabled: isRemote,
+ icon: EyeIcon,
+ key: 'view',
+ label: t('workingPanel.skills.actions.view'),
+ onClick: onOpenSkill,
+ },
+ {
+ // Renaming a filesystem skill needs an IPC/RPC that doesn't exist yet.
+ disabled: true,
+ icon: PencilIcon,
+ key: 'rename',
+ label: t('workingPanel.skills.actions.rename'),
+ onClick: () => {},
+ tooltip: comingSoon,
+ },
+ {
+ danger: true,
+ disabled: true,
+ icon: Trash2Icon,
+ key: 'delete',
+ label: t('workingPanel.skills.actions.delete'),
+ onClick: () => {},
+ tooltip: comingSoon,
+ },
+ ];
+ };
+
+ return { getRowActions, isLoading, items, onOpenFile, onOpenSkill, raw: data };
};
diff --git a/src/routes/(main)/agent/features/Conversation/WorkingSidebar/ResourcesSection/AgentDocumentsGroup.tsx b/src/routes/(main)/agent/features/Conversation/WorkingSidebar/ResourcesSection/AgentDocumentsGroup.tsx
index 2109a665dbe..a4517dd3f27 100644
--- a/src/routes/(main)/agent/features/Conversation/WorkingSidebar/ResourcesSection/AgentDocumentsGroup.tsx
+++ b/src/routes/(main)/agent/features/Conversation/WorkingSidebar/ResourcesSection/AgentDocumentsGroup.tsx
@@ -11,7 +11,7 @@ import { createStaticStyles, cx } from 'antd-style';
import dayjs from 'dayjs';
import relativeTime from 'dayjs/plugin/relativeTime';
import type { LucideIcon } from 'lucide-react';
-import { FileTextIcon, GlobeIcon, Trash2Icon } from 'lucide-react';
+import { EyeIcon, FileTextIcon, GlobeIcon, PencilIcon, Trash2Icon } from 'lucide-react';
import type { CSSProperties, MouseEvent } from 'react';
import { memo, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
@@ -20,7 +20,9 @@ import NeuralNetworkLoading from '@/components/NeuralNetworkLoading';
import { DocumentExplorerTree } from '@/features/AgentDocumentsExplorer';
import { startSkillDrag } from '@/features/ChatInput/InputEditor/ActionTag/skillDragData';
import {
+ openRenameSkillModal,
type SkillListItem,
+ type SkillRowAction,
SkillSection,
SkillsList,
useProjectSkills,
@@ -261,6 +263,8 @@ interface AgentDocumentsGroupProps {
const AgentDocumentsGroup = memo<AgentDocumentsGroupProps>(
({ deviceId, style, workingDirectory }) => {
const { t } = useTranslation('chat');
+ const { t: tCommon } = useTranslation('common');
+ const { message } = App.useApp();
const agentId = useAgentStore((s) => s.activeAgentId);
const isLocalEnabled = useAgentStore((s) =>
agentId ? chatConfigByIdSelectors.isLocalSystemEnabledById(agentId)(s) : false,
@@ -331,9 +335,92 @@ const AgentDocumentsGroup = memo<AgentDocumentsGroupProps>(
);
}
+ // Open the SKILL.md (skills/index child) when present; fall back to the
+ // bundle itself (orphan bundles surface for recovery).
+ const openAgentSkill = (item: SkillListItem) => {
+ const view = skillBundleViews.find((v) => v.bundle.documentId === item.id);
+ const indexChild = data.find((doc) => doc.parentId === item.id && doc.isSkillIndex);
+ const targetDocId = indexChild?.documentId ?? view?.bundle.documentId ?? item.id;
+ const targetRow = data.find((d) => d.documentId === targetDocId);
+ openDocument(targetDocId, targetRow?.id);
+ };
+
+ // Agent skills are document bundles, so view / rename / delete map onto the
+ // agent-document service (`item.id` is the bundle's documentId; the service
+ // keys off the row id carried on the bundle).
+ const getAgentSkillActions = (item: SkillListItem): SkillRowAction[] => {
+ const view = skillBundleViews.find((v) => v.bundle.documentId === item.id);
+ const rowId = view?.bundle.id;
+ return [
+ {
+ icon: EyeIcon,
+ key: 'view',
+ label: t('workingPanel.skills.actions.view'),
+ onClick: openAgentSkill,
+ },
+ {
+ disabled: !rowId,
+ icon: PencilIcon,
+ key: 'rename',
+ label: t('workingPanel.skills.actions.rename'),
+ onClick: () => {
+ if (!rowId) return;
+ openRenameSkillModal({
+ currentName: item.name,
+ onSubmit: async (newName) => {
+ try {
+ await agentDocumentService.renameDocument({
+ agentId: agentId!,
+ id: rowId,
+ newTitle: newName,
+ });
+ await mutate();
+ return undefined;
+ } catch (error) {
+ return error instanceof Error
+ ? error.message
+ : t('workingPanel.skills.rename.error');
+ }
+ },
+ });
+ },
+ },
+ {
+ danger: true,
+ disabled: !rowId,
+ icon: Trash2Icon,
+ key: 'delete',
+ label: t('workingPanel.skills.actions.delete'),
+ onClick: () => {
+ if (!rowId) return;
+ confirmModal({
+ cancelText: tCommon('cancel'),
+ content: t('workingPanel.skills.delete.agentConfirm', { name: item.name }),
+ okButtonProps: { danger: true },
+ okText: tCommon('delete'),
+ onOk: async () => {
+ try {
+ await agentDocumentService.removeDocument({ agentId: agentId!, id: rowId });
+ await mutate();
+ message.success(t('workingPanel.skills.delete.success'));
+ } catch (error) {
+ message.error(
+ error instanceof Error ? error.message : t('workingPanel.skills.delete.error'),
+ );
+ }
+ },
+ title: t('workingPanel.skills.delete.title'),
+ });
+ },
+ },
+ ];
+ };
+
const renderAgentSkillsList = () => (
<SkillsList
+ getRowActions={getAgentSkillActions}
items={skillItems}
+ onOpenSkill={openAgentSkill}
onOpenFile={(item, relativePath) => {
const view = skillBundleViews.find((v) => v.bundle.documentId === item.id);
const docId = view?.pathToDocumentId.get(relativePath);
@@ -341,15 +428,6 @@ const AgentDocumentsGroup = memo<AgentDocumentsGroupProps>(
const row = data.find((d) => d.documentId === docId);
openDocument(docId, row?.id);
}}
- 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 && doc.isSkillIndex);
- const targetDocId = indexChild?.documentId ?? view?.bundle.documentId ?? item.id;
- const targetRow = data.find((d) => d.documentId === targetDocId);
- openDocument(targetDocId, targetRow?.id);
- }}
onSkillDragStart={(item, event) => {
// The runtime resolves these via the `agent-skills:<filename>`
// identifier (built from the shared const helper so the prefix stays
diff --git a/src/routes/(main)/agent/features/Conversation/WorkingSidebar/ResourcesSection/ProjectLevelSkills.tsx b/src/routes/(main)/agent/features/Conversation/WorkingSidebar/ResourcesSection/ProjectLevelSkills.tsx
index ded068c3666..9a1f9258f72 100644
--- a/src/routes/(main)/agent/features/Conversation/WorkingSidebar/ResourcesSection/ProjectLevelSkills.tsx
+++ b/src/routes/(main)/agent/features/Conversation/WorkingSidebar/ResourcesSection/ProjectLevelSkills.tsx
@@ -18,12 +18,16 @@ interface ProjectLevelSkillsProps {
const ProjectLevelSkills = memo<ProjectLevelSkillsProps>(
({ deviceId, hideHeader, workingDirectory }) => {
const { t } = useTranslation('chat');
- const { items, onOpenFile, onOpenSkill } = useProjectSkills(workingDirectory, deviceId);
+ const { getRowActions, items, onOpenFile, onOpenSkill } = useProjectSkills(
+ workingDirectory,
+ deviceId,
+ );
if (items.length === 0) return null;
const list = (
<SkillsList
+ getRowActions={getRowActions}
items={items}
onOpenFile={onOpenFile}
onOpenSkill={onOpenSkill}
diff --git a/src/routes/(main)/agent/features/Conversation/WorkingSidebar/ResourcesSection/SkillsGroup.tsx b/src/routes/(main)/agent/features/Conversation/WorkingSidebar/ResourcesSection/SkillsGroup.tsx
index 7b2a3451aff..c6b31e40cfd 100644
--- a/src/routes/(main)/agent/features/Conversation/WorkingSidebar/ResourcesSection/SkillsGroup.tsx
+++ b/src/routes/(main)/agent/features/Conversation/WorkingSidebar/ResourcesSection/SkillsGroup.tsx
@@ -16,7 +16,7 @@ const SkillsGroup = memo<SkillsGroupProps>(({ deviceId, workingDirectory }) => {
// Local desktop reads over IPC; a bound device reads over RPC. Either path
// makes the skills list reachable even when this client isn't the desktop.
const enabled = (isDesktop || !!deviceId) && !!workingDirectory;
- const { isLoading, items, onOpenFile, onOpenSkill } = useProjectSkills(
+ const { getRowActions, isLoading, items, onOpenFile, onOpenSkill } = useProjectSkills(
enabled ? workingDirectory : undefined,
deviceId,
);
@@ -35,6 +35,7 @@ const SkillsGroup = memo<SkillsGroupProps>(({ deviceId, workingDirectory }) => {
}}
>
<SkillsList
+ getRowActions={getRowActions}
items={items}
onOpenFile={onOpenFile}
onOpenSkill={onOpenSkill}
diff --git a/src/routes/(main)/agent/features/Conversation/WorkingSidebar/ResourcesSection/UserLevelSkills.tsx b/src/routes/(main)/agent/features/Conversation/WorkingSidebar/ResourcesSection/UserLevelSkills.tsx
index be5ea6e0291..aa1ce1faba4 100644
--- a/src/routes/(main)/agent/features/Conversation/WorkingSidebar/ResourcesSection/UserLevelSkills.tsx
+++ b/src/routes/(main)/agent/features/Conversation/WorkingSidebar/ResourcesSection/UserLevelSkills.tsx
@@ -1,12 +1,25 @@
+import { Modal } from '@lobehub/ui';
+import { confirmModal } from '@lobehub/ui/base-ui';
+import { App } from 'antd';
import isEqual from 'fast-deep-equal';
-import { memo, useMemo } from 'react';
+import { EyeIcon, PencilIcon, Trash2Icon } from 'lucide-react';
+import { lazy, memo, Suspense, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { startSkillDrag } from '@/features/ChatInput/InputEditor/ActionTag/skillDragData';
-import { type SkillListItem, SkillSection, SkillsList } from '@/features/SkillsList';
+import {
+ openRenameSkillModal,
+ type SkillListItem,
+ type SkillRowAction,
+ SkillSection,
+ SkillsList,
+} from '@/features/SkillsList';
+import { usePermission } from '@/hooks/usePermission';
import { useToolStore } from '@/store/tool';
import { agentSkillsSelectors } from '@/store/tool/selectors';
+const AgentSkillDetail = lazy(() => import('@/features/AgentSkillDetail'));
+
/**
* Reads user-installed skills (entries in the `agent_skill` table — market
* imports plus user-created customs) into the `SkillsList` row shape. Builtin
@@ -46,13 +59,96 @@ interface UserLevelSkillsProps {
const UserLevelSkills = memo<UserLevelSkillsProps>(({ hideHeader }) => {
const { t } = useTranslation('chat');
+ const { t: tCommon } = useTranslation('common');
+ const { message } = App.useApp();
const items = useUserSkills();
+ // The row shape keys off `identifier`, but the store mutations key off the DB
+ // id — resolve one from the other through the raw skill list.
+ const agentSkills = useToolStore(agentSkillsSelectors.getAgentSkills, isEqual);
+ const updateAgentSkill = useToolStore((s) => s.updateAgentSkill);
+ const deleteAgentSkill = useToolStore((s) => s.deleteAgentSkill);
+ const { allowed: canEdit } = usePermission('edit_own_content');
+ const [detailSkillId, setDetailSkillId] = useState<string>();
+
+ const getRowActions = (item: SkillListItem): SkillRowAction[] => {
+ const skill = agentSkills.find((s) => s.identifier === item.id);
+ if (!skill) return [];
+
+ const actions: SkillRowAction[] = [
+ {
+ icon: EyeIcon,
+ key: 'view',
+ label: t('workingPanel.skills.actions.view'),
+ onClick: () => setDetailSkillId(skill.id),
+ },
+ ];
+
+ // Only user-authored skills carry an editable name; market imports are
+ // pinned to their source manifest.
+ if (skill.source === 'user') {
+ actions.push({
+ disabled: !canEdit,
+ icon: PencilIcon,
+ key: 'rename',
+ label: t('workingPanel.skills.actions.rename'),
+ onClick: () => {
+ openRenameSkillModal({
+ currentName: skill.name,
+ onSubmit: async (newName) => {
+ try {
+ await updateAgentSkill({ id: skill.id, name: newName });
+ return undefined;
+ } catch (error) {
+ return error instanceof Error
+ ? error.message
+ : t('workingPanel.skills.rename.error');
+ }
+ },
+ });
+ },
+ });
+ }
+
+ actions.push({
+ danger: true,
+ disabled: !canEdit,
+ icon: Trash2Icon,
+ key: 'delete',
+ label: t('workingPanel.skills.actions.delete'),
+ onClick: () => {
+ confirmModal({
+ cancelText: tCommon('cancel'),
+ content: t('workingPanel.skills.delete.userConfirm', { name: skill.name }),
+ okButtonProps: { danger: true },
+ okText: tCommon('delete'),
+ onOk: async () => {
+ try {
+ await deleteAgentSkill(skill.id);
+ message.success(t('workingPanel.skills.delete.success'));
+ } catch (error) {
+ message.error(
+ error instanceof Error ? error.message : t('workingPanel.skills.delete.error'),
+ );
+ }
+ },
+ title: t('workingPanel.skills.delete.title'),
+ });
+ },
+ });
+
+ return actions;
+ };
if (items.length === 0) return null;
const list = (
<SkillsList
+ getRowActions={getRowActions}
items={items}
+ onOpenSkill={(item) => {
+ const skill = agentSkills.find((s) => s.identifier === item.id);
+ if (skill) setDetailSkillId(skill.id);
+ }}
onSkillDragStart={(item, event) => {
startSkillDrag(event, {
category: 'skill',
@@ -63,17 +159,42 @@ const UserLevelSkills = memo<UserLevelSkillsProps>(({ hideHeader }) => {
/>
);
- if (hideHeader) return list;
+ const detailModal = (
+ <Modal
+ destroyOnHidden
+ footer={null}
+ open={!!detailSkillId}
+ styles={{ body: { height: 'calc(100dvh - 200px)', overflow: 'hidden', padding: 0 } }}
+ title={t('workingPanel.skills.detail.title')}
+ width={960}
+ onCancel={() => setDetailSkillId(undefined)}
+ >
+ <Suspense fallback={<div style={{ height: '100%' }} />}>
+ {detailSkillId && <AgentSkillDetail skillId={detailSkillId} />}
+ </Suspense>
+ </Modal>
+ );
+
+ if (hideHeader)
+ return (
+ <>
+ {list}
+ {detailModal}
+ </>
+ );
return (
- <SkillSection
- sectionHeader={{
- count: items.length,
- title: t('workingPanel.skills.section.user'),
- }}
- >
- {list}
- </SkillSection>
+ <>
+ <SkillSection
+ sectionHeader={{
+ count: items.length,
+ title: t('workingPanel.skills.section.user'),
+ }}
+ >
+ {list}
+ </SkillSection>
+ {detailModal}
+ </>
);
});