JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.
Python
feat(skill): Adapt the style of the skill page for dark mode and add a disable button on the skill page
openJiuwen-bot1d68ab808c9d
diff --git a/jiuwenswarm/channels/web/frontend/src/components/SkillPanel/index.tsx b/jiuwenswarm/channels/web/frontend/src/components/SkillPanel/index.tsxindex 909e695f2c..091a7834b2 100644--- a/jiuwenswarm/channels/web/frontend/src/components/SkillPanel/index.tsx+++ b/jiuwenswarm/channels/web/frontend/src/components/SkillPanel/index.tsx@@ -12,6 +12,7 @@ import { ClawHubSearchModal } from "../../features/ClawHubSearchModal";import { TeamSkillsHubModal } from "../../features/TeamSkillsHubModal";import { SkillEvolutionModal } from "../../features/SkillEvolutionModal";import { normalizeSkillNetUrl } from "../../utils/skillNetUrl";+import { Switch } from "../Switch";/** 刷新会 git pull marketplace,略放宽;普通进页单次 RPC 一般很快。 */const SKILLS_FETCH_TIMEOUT_REFRESH_MS = 60_000;@@ -34,6 +35,8 @@ type SkillItem = {is_builtin_source?: boolean;/** 本地技能目录是否存在 evolutions.json */has_evolutions?: boolean;+ /** 是否启用 */+ enabled?: boolean;};type InstalledPluginItem = {@@ -100,6 +103,7 @@ function normalizeSkillItem<T extends SkillItem>(raw: T): T {export function SkillPanel({ sessionId, onNavigateToConfig }: SkillPanelProps) {const { t } = useTranslation();const [activeTab, setActiveTab] = useState<"my" | "marketplace">("my");+ const [mySkillsSubTab, setMySkillsSubTab] = useState<"all" | "installed" | "pending" | "disabled">("all");const [marketplaceSubTab, setMarketplaceSubTab] = useState<"builtin" | "swarmskills" | "online">("builtin");const [onlineSource, setOnlineSource] = useState<"skillnet" | "clawhub">("skillnet");const [searchTrigger, setSearchTrigger] = useState(0);@@ -198,7 +202,12 @@ export function SkillPanel({ sessionId, onNavigateToConfig }: SkillPanelProps) {const filteredSkills = useMemo(() => {let result = skills;if (activeTab === "my") {- result = result.filter((skill) => installedSkillMap.has(skill.name) || skill.source === "local");+ result = result.filter((skill) =>+ installedSkillMap.has(skill.name) ||+ skill.source === "local" ||+ skill.is_builtin === true ||+ skill.is_builtin_source === true+ );}const keyword = search.trim().toLowerCase();if (!keyword) return result;@@ -216,12 +225,8 @@ export function SkillPanel({ sessionId, onNavigateToConfig }: SkillPanelProps) {}, [skills, search, activeTab, installedSkillMap]);const visibleSkills = useMemo(() => {- // 只显示已安装的技能(需手动安装后才会显示)- // 本地/项目技能(source=local/project)不在 plugins 中,但已在 skills 目录下,属于已安装- const installed = filteredSkills.filter((skill) =>- installedSkillMap.has(skill.name) || skill.source === "local" || skill.source === "project"- );- return [...installed].sort((a, b) => {+ // 显示所有技能+ return [...filteredSkills].sort((a, b) => {const aSkillNet = a.source === "skillnet" ? 1 : 0;const bSkillNet = b.source === "skillnet" ? 1 : 0;if (aSkillNet !== bSkillNet) {@@ -229,7 +234,7 @@ export function SkillPanel({ sessionId, onNavigateToConfig }: SkillPanelProps) {}return a.name.localeCompare(b.name);});- }, [filteredSkills, installedSkillMap]);+ }, [filteredSkills]);const builtinSkills = useMemo(() => {let filtered = skills.filter((skill) => skill.is_builtin === true);@@ -525,7 +530,7 @@ export function SkillPanel({ sessionId, onNavigateToConfig }: SkillPanelProps) {event.stopPropagation();handleInstall(skill.name);}}- className="w-[76px] h-[28px] rounded-[24px] text-sm text-[#191919] border border-[#191919] hover:bg-secondary/50 transition-colors whitespace-nowrap"+ className="skill-action-btn"disabled={isLoading}>{isLoading ? t('skills.actions.installing') : t('skills.actions.install')}@@ -542,7 +547,7 @@ export function SkillPanel({ sessionId, onNavigateToConfig }: SkillPanelProps) {event.stopPropagation();handleUninstall(skill.name);}}- className="w-[76px] h-[28px] rounded-[24px] text-sm text-[#191919] border border-[#191919] hover:bg-secondary/50 transition-colors whitespace-nowrap"+ className="skill-action-btn"disabled={isLoading}>{t('skills.actions.uninstall')}@@ -560,7 +565,7 @@ export function SkillPanel({ sessionId, onNavigateToConfig }: SkillPanelProps) {event.stopPropagation();handleUninstall(pluginName);}}- className="w-[76px] h-[28px] rounded-[24px] text-sm text-[#191919] border border-[#191919] hover:bg-secondary/50 transition-colors whitespace-nowrap"+ className="skill-action-btn"disabled={isLoading}>{t('skills.actions.uninstall')}@@ -577,7 +582,7 @@ export function SkillPanel({ sessionId, onNavigateToConfig }: SkillPanelProps) {event.stopPropagation();handleInstall(skill.name);}}- className="w-[76px] h-[28px] rounded-[24px] text-sm text-[#191919] border border-[#191919] hover:bg-secondary/50 transition-colors whitespace-nowrap"+ className="skill-action-btn"disabled={isLoading}>{isLoading ? t('skills.actions.installing') : t('skills.actions.install')}@@ -596,7 +601,7 @@ export function SkillPanel({ sessionId, onNavigateToConfig }: SkillPanelProps) {event.stopPropagation();handleUninstall(skill.name);}}- className="w-[76px] h-[28px] rounded-[24px] text-sm text-[#191919] border border-[#191919] hover:bg-secondary/50 transition-colors whitespace-nowrap"+ className="skill-action-btn"disabled={isLoading}>{t('skills.actions.uninstall')}@@ -619,13 +624,71 @@ export function SkillPanel({ sessionId, onNavigateToConfig }: SkillPanelProps) {if (installedSkillMap.has(skill.name)) return t('skills.status.installed');if (skill.source === "local") return t('skills.status.installed');if (skill.is_builtin) {- // 未安装的内置技能return t('skills.status.notInstalled');}if (skill.source !== "project") return t('skills.status.notInstalled');return t('skills.status.builtIn');};+ const isSkillInstalled = (skill: SkillItem): boolean => {+ return installedSkillMap.has(skill.name) || skill.source === "local" || skill.source === "project";+ };++ const getMySkillsFiltered = useCallback(() => {+ let filtered = visibleSkills;+ switch (mySkillsSubTab) {+ case "installed":+ filtered = visibleSkills.filter(s => isSkillInstalled(s) && s.enabled !== false);+ break;+ case "pending":+ filtered = visibleSkills.filter(s => !isSkillInstalled(s) && s.enabled !== false);+ break;+ case "disabled":+ filtered = visibleSkills.filter(s => s.enabled === false);+ break;+ default:+ break;+ }+ return filtered;+ }, [visibleSkills, mySkillsSubTab, installedSkillMap]);++ const toggleSkillDisabled = async (skillName: string) => {+ const skill = skills.find(s => s.name === skillName);+ const newEnabled = skill?.enabled === false ? true : false;++ const toggleKey = `toggle:${skillName}`;+ setActionTarget(toggleKey);++ try {+ const result = await webRequest<{+ success: boolean;+ name: string;+ enabled: boolean;+ detail?: string;+ }>(+ "skills.toggle",+ withSession({ name: skillName, enabled: newEnabled })+ );++ if (!result.success) {+ throw new Error(result.detail || 'Failed to toggle skill');+ }++ setSkills((prev) =>+ prev.map(s =>+ s.name === skillName ? { ...s, enabled: newEnabled } : s+ )+ );++ showMessage('success', t(newEnabled ? 'skills.setEnabledSuccess' : 'skills.setDisabledSuccess', { name: skillName }));+ } catch (error) {+ console.error('Failed to toggle skill enabled:', error);+ showMessage('error', t('skills.setEnabledError'));+ } finally {+ setActionTarget(null);+ }+ };+const renderEvolutionButton = (skill: SkillItem) => {const disabled = !skill.has_evolutions;if (disabled) {@@ -721,10 +784,9 @@ export function SkillPanel({ sessionId, onNavigateToConfig }: SkillPanelProps) {onClick={() => setActiveTab("my")}className={`px-4 text-sm font-medium transition-colors ${activeTab === "my"- ? "rounded-[8px]"+ ? "rounded-[8px] bg-secondary h-8 text-text": "text-text-muted hover:text-text"}`}- style={activeTab === "my" ? { backgroundColor: "#EAEAEB", height: "32px", color: "#191919" } : undefined}>{t('skills.tabs.mySkills')}</button>@@ -732,10 +794,9 @@ export function SkillPanel({ sessionId, onNavigateToConfig }: SkillPanelProps) {onClick={() => setActiveTab("marketplace")}className={`px-4 text-sm font-medium transition-colors ${activeTab === "marketplace"- ? "rounded-[8px]"+ ? "rounded-[8px] bg-secondary h-8 text-text": "text-text-muted hover:text-text"}`}- style={activeTab === "marketplace" ? { backgroundColor: "#EAEAEB", height: "32px", color: "#191919" } : undefined}>{t('skills.tabs.marketplace')}</button>@@ -782,10 +843,9 @@ export function SkillPanel({ sessionId, onNavigateToConfig }: SkillPanelProps) {}}className={`px-4 text-sm font-medium transition-colors ${marketplaceSubTab === "builtin"- ? "rounded-[8px]"+ ? "rounded-[8px] bg-secondary h-8 text-text": "text-text-muted hover:text-text"}`}- style={marketplaceSubTab === "builtin" ? { backgroundColor: "#EAEAEB", height: "32px", color: "#191919" } : undefined}>{t('skills.marketplaceTabs.builtin')}</button>@@ -797,10 +857,9 @@ export function SkillPanel({ sessionId, onNavigateToConfig }: SkillPanelProps) {}}className={`px-4 text-sm font-medium transition-colors ${marketplaceSubTab === "swarmskills"- ? "rounded-[8px]"+ ? "rounded-[8px] bg-secondary h-8 text-text": "text-text-muted hover:text-text"}`}- style={marketplaceSubTab === "swarmskills" ? { backgroundColor: "#EAEAEB", height: "32px", color: "#191919" } : undefined}>{t('skills.swarmskills.title')}</button>@@ -812,10 +871,9 @@ export function SkillPanel({ sessionId, onNavigateToConfig }: SkillPanelProps) {}}className={`px-4 text-sm font-medium transition-colors ${marketplaceSubTab === "online"- ? "rounded-[8px]"+ ? "rounded-[8px] bg-secondary h-8 text-text": "text-text-muted hover:text-text"}`}- style={marketplaceSubTab === "online" ? { backgroundColor: "#EAEAEB", height: "32px", color: "#191919" } : undefined}>{t('skills.onlineSearch.title')}</button>@@ -1054,6 +1112,48 @@ export function SkillPanel({ sessionId, onNavigateToConfig }: SkillPanelProps) {) : (<div className="mt-4 flex flex-col flex-1 min-h-0"><div className="flex items-center gap-3 flex-shrink-0">+ <div className="flex items-center gap-2">+ <button+ onClick={() => setMySkillsSubTab("all")}+ className={`px-4 text-sm font-medium transition-colors ${+ mySkillsSubTab === "all"+ ? "rounded-[8px] bg-secondary h-8 text-text"+ : "text-text-muted hover:text-text"+ }`}+ >+ {t('skills.mySkillsTabs.all')}+ </button>+ <button+ onClick={() => setMySkillsSubTab("installed")}+ className={`px-4 text-sm font-medium transition-colors ${+ mySkillsSubTab === "installed"+ ? "rounded-[8px] bg-secondary h-8 text-text"+ : "text-text-muted hover:text-text"+ }`}+ >+ {t('skills.mySkillsTabs.installed')}+ </button>+ <button+ onClick={() => setMySkillsSubTab("pending")}+ className={`px-4 text-sm font-medium transition-colors ${+ mySkillsSubTab === "pending"+ ? "rounded-[8px] bg-secondary h-8 text-text"+ : "text-text-muted hover:text-text"+ }`}+ >+ {t('skills.mySkillsTabs.pending')}+ </button>+ <button+ onClick={() => setMySkillsSubTab("disabled")}+ className={`px-4 text-sm font-medium transition-colors ${+ mySkillsSubTab === "disabled"+ ? "rounded-[8px] bg-secondary h-8 text-text"+ : "text-text-muted hover:text-text"+ }`}+ >+ {t('skills.mySkillsTabs.disabled')}+ </button>+ </div><div className="flex-1 min-w-0"><inputvalue={search}@@ -1063,7 +1163,7 @@ export function SkillPanel({ sessionId, onNavigateToConfig }: SkillPanelProps) {/></div><div className="text-xs text-text-muted flex-shrink-0">- {t('skills.totalCount', { count: visibleSkills.length })}+ {t('skills.totalCount', { count: getMySkillsFiltered().length })}</div></div>@@ -1076,12 +1176,19 @@ export function SkillPanel({ sessionId, onNavigateToConfig }: SkillPanelProps) {{t('skills.listError')}</div>)}- {listState === "success" && visibleSkills.length === 0 && (- <div className="text-sm text-text-muted">{t('skills.noMatches')}</div>+ {listState === "success" && getMySkillsFiltered().length === 0 && (+ <div className="text-sm text-text-muted">+ {mySkillsSubTab === "disabled" ? t('skills.noDisabledSkills') :+ mySkillsSubTab === "installed" ? t('skills.noInstalledSkills') :+ mySkillsSubTab === "pending" ? t('skills.noPendingSkills') :+ t('skills.noMatches')}+ </div>)}{listState === "success" &&- visibleSkills.map((skill) => {+ getMySkillsFiltered().map((skill) => {const avatar = getSkillAvatar(skill.name);+ const isDisabled = skill.enabled === false;+ const isToggling = actionTarget === `toggle:${skill.name}`;return (<buttonkey={skill.name}@@ -1115,6 +1222,15 @@ export function SkillPanel({ sessionId, onNavigateToConfig }: SkillPanelProps) {<div className="flex flex-col items-end gap-2 flex-shrink-0">{renderActionButton(skill)}{renderEvolutionButton(skill)}+ <div className="flex items-center gap-2">+ <span className="text-xs text-text-muted">{isToggling ? (isDisabled ? t('skills.actions.enabling') : t('skills.actions.disabling')) : (isDisabled ? t('skills.mySkillsTabs.disabled') : t('skills.enable'))}</span>+ <Switch+ checked={!isDisabled}+ onChange={() => toggleSkillDisabled(skill.name)}+ title={isDisabled ? t('skills.mySkillsTabs.all') : t('skills.mySkillsTabs.disabled')}+ disabled={isToggling}+ />+ </div></div></div>) : (@@ -1144,6 +1260,15 @@ export function SkillPanel({ sessionId, onNavigateToConfig }: SkillPanelProps) {<div className="flex gap-1.5 flex-1">{renderEvolutionButton(skill)}</div>+ <div className="flex items-center gap-2">+ <span className="text-xs text-text-muted">{isToggling ? (isDisabled ? t('skills.actions.enabling') : t('skills.actions.disabling')) : (isDisabled ? t('skills.mySkillsTabs.disabled') : t('skills.enable'))}</span>+ <Switch+ checked={!isDisabled}+ onChange={() => toggleSkillDisabled(skill.name)}+ title={isDisabled ? t('skills.mySkillsTabs.all') : t('skills.mySkillsTabs.disabled')}+ disabled={isToggling}+ />+ </div><div className="flex-shrink-0 ml-auto">{renderActionButton(skill)}</div>diff --git a/jiuwenswarm/channels/web/frontend/src/components/Switch/index.tsx b/jiuwenswarm/channels/web/frontend/src/components/Switch/index.tsxnew file mode 100644index 0000000000..6dbee643f9--- /dev/null+++ b/jiuwenswarm/channels/web/frontend/src/components/Switch/index.tsx@@ -0,0 +1,41 @@+interface SwitchProps {+ checked: boolean;+ onChange: (checked: boolean) => void;+ disabled?: boolean;+ title?: string;+}++export function Switch({ checked, onChange, disabled = false, title }: SwitchProps) {+ const handleClick = (e: React.MouseEvent) => {+ e.stopPropagation();+ onChange(!checked);+ };++ return (+ <button+ type="button"+ role="switch"+ aria-checked={checked}+ disabled={disabled}+ onClick={handleClick}+ title={title}+ className={`+ relative inline-flex h-5 w-9 flex-shrink-0 cursor-pointer rounded-full+ border-2 transition-colors duration-200 ease-in-out+ focus:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2+ ${checked+ ? 'bg-accent border-accent'+ : 'bg-gray-200 dark:bg-gray-600 border-gray-300 dark:border-gray-500'}+ ${disabled ? 'opacity-50 cursor-not-allowed' : ''}+ `}+ >+ <span+ className={`+ pointer-events-none inline-block h-4 w-4 transform rounded-full bg-white shadow+ transition duration-200 ease-in-out+ ${checked ? 'translate-x-4' : 'translate-x-0.5'}+ `}+ />+ </button>+ );+}diff --git a/jiuwenswarm/channels/web/frontend/src/i18n/locales/en.json b/jiuwenswarm/channels/web/frontend/src/i18n/locales/en.jsonindex bca45bdf70..9e7162544f 100644--- a/jiuwenswarm/channels/web/frontend/src/i18n/locales/en.json+++ b/jiuwenswarm/channels/web/frontend/src/i18n/locales/en.json@@ -819,6 +819,19 @@"mySkills": "My Skills","marketplace": "Marketplace"},+ "mySkillsTabs": {+ "all": "All",+ "installed": "Installed",+ "pending": "Pending",+ "disabled": "Disabled"+ },+ "enable": "Enable",+ "noDisabledSkills": "No disabled skills",+ "noInstalledSkills": "No installed skills",+ "noPendingSkills": "No pending skills",+ "setEnabledError": "Failed to set skill enabled status",+ "setEnabledSuccess": "Skill {name} enabled",+ "setDisabledSuccess": "Skill {name} disabled","marketplaceTabs": {"builtin": "Built-in"},@@ -836,7 +849,9 @@"importLocal": "Import Local Skill","sourceManager": "Source Manager","backToList": "Back to List",- "viewEvolution": "View Skill Experience"+ "viewEvolution": "View Skill Experience",+ "enabling": "Enabling...",+ "disabling": "Disabling..."},"builtIn": "Built-in","status": {diff --git a/jiuwenswarm/channels/web/frontend/src/i18n/locales/zh.json b/jiuwenswarm/channels/web/frontend/src/i18n/locales/zh.jsonindex d4096928e7..78de0c5493 100644--- a/jiuwenswarm/channels/web/frontend/src/i18n/locales/zh.json+++ b/jiuwenswarm/channels/web/frontend/src/i18n/locales/zh.json@@ -818,6 +818,19 @@"mySkills": "我的技能","marketplace": "技能广场"},+ "mySkillsTabs": {+ "all": "全部",+ "installed": "已安装",+ "pending": "待安装",+ "disabled": "禁用"+ },+ "enable": "启用",+ "noDisabledSkills": "暂无禁用的技能",+ "noInstalledSkills": "暂无已安装的技能",+ "noPendingSkills": "暂无待安装的技能",+ "setEnabledError": "设置技能启用状态失败",+ "setEnabledSuccess": "已启用技能 {name}",+ "setDisabledSuccess": "已禁用技能 {name}","marketplaceTabs": {"builtin": "预置"},@@ -835,7 +848,9 @@"importLocal": "导入本地技能","sourceManager": "源管理","backToList": "返回列表",- "viewEvolution": "查看技能经验"+ "viewEvolution": "查看技能经验",+ "enabling": "启用中...",+ "disabling": "禁用中..."},"builtIn": "内置","status": {diff --git a/jiuwenswarm/channels/web/frontend/src/index.css b/jiuwenswarm/channels/web/frontend/src/index.cssindex 20428d1219..37d30a0835 100644--- a/jiuwenswarm/channels/web/frontend/src/index.css+++ b/jiuwenswarm/channels/web/frontend/src/index.css@@ -1566,6 +1566,33 @@ select {margin-left: 2px;vertical-align: text-bottom;}++ /* Skill action button - white/black in light mode, gray/white in dark mode */+ .skill-action-btn {+ width: 76px;+ height: 28px;+ border-radius: 24px;+ font-size: var(--font-size-sm);+ border: 1px solid #000000;+ background: #ffffff;+ color: #000000;+ transition: background var(--duration-fast) ease, border-color var(--duration-fast) ease;+ white-space: nowrap;+ }++ .skill-action-btn:hover {+ background: #f0f0f0;+ }++ :root:not([data-theme="light"]) .skill-action-btn {+ border-color: #4b5563;+ background: #374151;+ color: #ffffff;+ }++ :root:not([data-theme="light"]) .skill-action-btn:hover {+ background: #4b5563;+ }}/* ===========================================