Skip to content

A cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode,DeepSeek Harness and more. Only official website: ccswitch.io

refactor(skills): unify flat layout, toolbar, and header refresh across Skills tabs (#10050)

Allen Xu5637b12ec316
diff --git a/src/components/skills/SkillsPage.tsx b/src/components/skills/SkillsPage.tsx
index 872522ee6..1523c57e6 100644
--- a/src/components/skills/SkillsPage.tsx
+++ b/src/components/skills/SkillsPage.tsx
@@ -1,4 +1,4 @@
-import React, { useEffect, useMemo, useRef, useState } from "react";
+import { useEffect, useMemo, useRef, useState } from "react";
import { useVirtualizer } from "@tanstack/react-virtual";
import { useTranslation } from "react-i18next";
import {
@@ -6,15 +6,15 @@ import {
ChevronRight,
Download,
ExternalLink,
+ ListFilter,
Loader2,
- RefreshCw,
+ X,
} from "lucide-react";
import { toast } from "@/lib/toast";
import { settingsApi } from "@/lib/api";
import { Button } from "@/components/ui/button";
import { HelpTip } from "@/components/ui/help-tip";
import { Notice } from "@/components/ui/notice";
-import { SegmentedControl } from "@/components/ui/segmented-control";
import { HoverTip } from "@/components/ui/hover-tip";
import {
Popover,
@@ -122,12 +122,15 @@ export function useSkillRepoActions() {
return { addRepo, removeRepo, setRepoEnabled };
}
+export interface SkillsShRefreshHandle {
+ canRefresh: boolean;
+ refreshing: boolean;
+ refresh: () => void;
+}
+
interface SkillsPageProps {
- /**
- * 「已安装 / 发现」页签(由外层渲染,两段共用一条页签行);
- * 传入的内容放在页签行右侧(安装到、搜索)。
- */
- renderViewTabs: (trailing: React.ReactNode) => React.ReactNode;
+ /** 平铺一级页签传入的来源:仓库 或 skills.sh */
+ source: SkillsPageSource;
visibleAppIds: AppId[];
installTargets: AppId[];
onInstallTargetsChange: (apps: AppId[]) => void;
@@ -135,10 +138,14 @@ interface SkillsPageProps {
/** 「已安装 · 3 个应用 ›」:切到已安装段并定位到那一行 */
onShowInstalled: (skillId: string) => void;
onOpenRepoManager: () => void;
+ /** 没配置仓库时在空状态提供切到 skills.sh 的入口 */
+ onOpenSkillsSh?: () => void;
/** 安装后有应用没能启用:交给已安装段标 ⚠ */
onEnableFailures: (
failures: Array<{ id: string; app: AppId; error: unknown }>,
) => void;
+ /** 把 skills.sh 的刷新状态同步给外层页头统一的刷新按钮 */
+ onSkillsShRefreshChange?: (handle: SkillsShRefreshHandle) => void;
initialQuery?: string;
}
@@ -194,30 +201,31 @@ function formatInstalls(count: number, locale: string): string {
}
/**
- * Skills 的「发现」段:仓库 / skills.sh 两个来源,结果是行列表;显式「安装到」哪些应用。
+ * Skills 的「仓库」与「skills.sh」平铺页:统一工具栏(左搜索 + 筛选 + 计数,右安装到)+ 纯平铺列表。
*/
export function SkillsPage({
- renderViewTabs,
+ source,
visibleAppIds,
installTargets,
onInstallTargetsChange,
installTo,
onShowInstalled,
onOpenRepoManager,
+ onOpenSkillsSh,
onEnableFailures,
+ onSkillsShRefreshChange,
initialQuery = "",
}: SkillsPageProps) {
const { t, i18n } = useTranslation();
- const [source, setSource] = useState<SkillsPageSource>("repos");
const [query, setQuery] = useState(initialQuery);
const [statusFilter, setStatusFilter] = useState<"all" | "uninstalled">(
"all",
);
const [skillsShQuery, setSkillsShQuery] = useState("");
const [skillsShOffset, setSkillsShOffset] = useState(0);
- const [accumulated, setAccumulated] = useState<SkillsShDiscoverableSkill[]>(
- [],
- );
+ const [skillsShPages, setSkillsShPages] = useState<
+ Map<number, SkillsShDiscoverableSkill[]>
+ >(() => new Map());
const [installing, setInstalling] = useState<Set<string>>(new Set());
const [failed, setFailed] = useState<Record<string, string>>({});
@@ -242,48 +250,92 @@ export function SkillsPage({
isFetching: fetchingSkillsSh,
isPlaceholderData: placeholderSkillsSh,
isError: skillsShError,
+ dataUpdatedAt: skillsShUpdatedAt,
refetch: refetchSkillsSh,
} = useSearchSkillsSh(skillsShQuery, SKILLSSH_PAGE_SIZE, skillsShOffset);
const installMutation = useInstallSkill();
const { setRepoEnabled } = useSkillRepoActions();
+ // 按 offset 存每一页:同一页后台重拉(窗口聚焦/重连)时原地替换,不重复追加;
+ // 带上 skillsShUpdatedAt 确保返回相同数据时也同步更新。
useEffect(() => {
if (skillsShResult && !placeholderSkillsSh) {
- setAccumulated((prev) =>
- skillsShOffset === 0
- ? skillsShResult.skills
- : [...prev, ...skillsShResult.skills],
- );
+ setSkillsShPages((prev) => {
+ const next = skillsShOffset === 0 ? new Map() : new Map(prev);
+ next.set(skillsShOffset, skillsShResult.skills);
+ return next;
+ });
+ }
+ }, [skillsShResult, skillsShOffset, placeholderSkillsSh, skillsShUpdatedAt]);
+
+ const accumulated = useMemo(() => {
+ const seen = new Set<string>();
+ const merged: SkillsShDiscoverableSkill[] = [];
+ const offsets = [...skillsShPages.keys()].sort((a, b) => a - b);
+ for (const offset of offsets) {
+ for (const item of skillsShPages.get(offset) ?? []) {
+ if (seen.has(item.key)) continue;
+ seen.add(item.key);
+ merged.push(item);
+ }
}
- }, [skillsShResult, skillsShOffset, placeholderSkillsSh]);
+ return merged;
+ }, [skillsShPages]);
- // 没配置任何仓库时直接看 skills.sh;仓库读出来是空的仍留在仓库,方便重试
- const effectiveSource: SkillsPageSource =
- source === "repos" && !loadingRepos && repos.length === 0
- ? "skillssh"
- : source;
- const isSkillsSh = effectiveSource === "skillssh";
+ const isSkillsSh = source === "skillssh";
const enabledRepos = repos.filter((repo) => repo.enabled);
+ const refetchPageZeroRef = useRef(false);
+
+ useEffect(() => {
+ if (skillsShOffset === 0 && refetchPageZeroRef.current) {
+ refetchPageZeroRef.current = false;
+ void refetchSkillsSh();
+ }
+ }, [skillsShOffset, refetchSkillsSh]);
const submitSkillsSh = () => {
const trimmed = query.trim();
if (trimmed.length < 2) return;
if (trimmed === skillsShQuery && skillsShOffset === 0) return;
setSkillsShOffset(0);
- setAccumulated([]);
+ setSkillsShPages(new Map());
setSkillsShQuery(trimmed);
};
// 第一页失败时 query key 没变,光把 offset 设回 0 什么都不会发生,要显式重新请求
const retrySkillsSh = () => {
- setAccumulated([]);
+ setSkillsShPages(new Map());
if (skillsShOffset === 0) {
void refetchSkillsSh();
} else {
+ refetchPageZeroRef.current = true;
setSkillsShOffset(0);
}
};
+ // 页头刷新:不先清空已展示的列表;翻过页时回到第一页并强制重拉(不吃 5 分钟缓存)
+ const refreshSkillsSh = () => {
+ if (skillsShQuery.length < 2) return;
+ if (skillsShOffset === 0) {
+ void refetchSkillsSh();
+ } else {
+ refetchPageZeroRef.current = true;
+ setSkillsShOffset(0);
+ }
+ };
+
+ const refreshSkillsShRef = useRef(refreshSkillsSh);
+ refreshSkillsShRef.current = refreshSkillsSh;
+
+ useEffect(() => {
+ if (!isSkillsSh || !onSkillsShRefreshChange) return;
+ onSkillsShRefreshChange({
+ canRefresh: skillsShQuery.length >= 2,
+ refreshing: fetchingSkillsSh,
+ refresh: () => refreshSkillsShRef.current(),
+ });
+ }, [isSkillsSh, skillsShQuery, fetchingSkillsSh, onSkillsShRefreshChange]);
+
// ─── 已安装 / 目录名占用 ────────────────────────────────────────────
const installedByKey = useMemo(() => {
const map = new Map<string, InstalledSkill>();
@@ -498,6 +550,17 @@ export function SkillsPage({
onClick: onOpenRepoManager,
},
];
+ } else if (!loadingRepos && repos.length === 0) {
+ title = t("skills.repo.empty");
+ buttons = [
+ {
+ label: t("skillsPage.discover.manageRepos"),
+ onClick: onOpenRepoManager,
+ },
+ ...(onOpenSkillsSh
+ ? [{ label: "skills.sh", onClick: onOpenSkillsSh }]
+ : []),
+ ];
} else if (repoRows.length === 0) {
// 后端逐仓库报告了失败:如实写哪些没读到、为什么;否则是读到了但里面没有 Skill
title =
@@ -565,59 +628,108 @@ export function SkillsPage({
);
};
+ const hasActiveFilter =
+ !isSkillsSh &&
+ (statusFilter === "uninstalled" || enabledRepos.length < repos.length);
+
+ const formatSkillCount = (count: number) =>
+ count === 1
+ ? t("skillsPage.countOne", { count })
+ : t("skillsPage.count", { count });
+
return (
<div className="flex min-h-0 flex-1 flex-col">
- {/* 页签行在外层(UnifiedSkillsPanel),这里只把右侧控件交出去 */}
- {renderViewTabs(
- // 和「已安装」同一套:搜索框 + 去远端拉最新的文字按钮
- <div className="flex min-w-0 items-center gap-2">
- <MatrixSearch
- className="w-[280px] min-w-[160px] shrink"
- inputId="sk-discover-search"
- value={query}
- onValueChange={setQuery}
- onEnter={isSkillsSh ? submitSkillsSh : undefined}
- placeholder={
- isSkillsSh
- ? t("skillsPage.discover.skillsShPlaceholder")
- : t("skillsPage.discover.searchPlaceholder")
- }
- ariaLabel={
- isSkillsSh
- ? t("skillsPage.discover.skillsShAria")
- : t("skillsPage.discover.searchAria")
- }
- status={
- normalizedQuery && !isSkillsSh
- ? t("appMatrix.found", { count: visibleRows.length })
- : ""
- }
- />
- {!isSkillsSh && (
- <Button
- type="button"
- variant="quiet"
- size="regular"
- className="shrink-0"
- disabled={fetchingDiscoverable}
- onClick={reload}
- >
- <RefreshCw
- className={cn(
- "h-4 w-4",
- fetchingDiscoverable && "animate-spin",
- )}
- strokeWidth={2}
- />
- {t("skillsPage.discover.reload")}
- </Button>
+ {/* 统一平铺工具栏(min-h-14 可换行,对齐 MCP / Plugins / 已安装):左搜索 + 筛选 + 计数,右安装到 */}
+ <div className="flex min-h-14 shrink-0 flex-wrap items-center gap-x-3 gap-y-2 px-6 py-2">
+ <MatrixSearch
+ className="w-[320px] min-w-[180px] shrink"
+ inputId={`sk-${source}-search`}
+ value={query}
+ onValueChange={setQuery}
+ onEnter={isSkillsSh ? submitSkillsSh : undefined}
+ placeholder={
+ isSkillsSh
+ ? t("skillsPage.discover.skillsShPlaceholder")
+ : t("skillsPage.discover.searchPlaceholder")
+ }
+ ariaLabel={
+ isSkillsSh
+ ? t("skillsPage.discover.skillsShAria")
+ : t("skillsPage.discover.searchAria")
+ }
+ status={
+ normalizedQuery && !isSkillsSh
+ ? t("appMatrix.found", { count: visibleRows.length })
+ : ""
+ }
+ />
+ {!isSkillsSh && (
+ <>
+ <ReposFilterPopover
+ repos={repos}
+ discoverable={discoverable ?? []}
+ failures={repoFailures}
+ onlyUninstalled={statusFilter === "uninstalled"}
+ active={hasActiveFilter}
+ onOnlyUninstalledChange={(checked) =>
+ setStatusFilter(checked ? "uninstalled" : "all")
+ }
+ onToggleRepo={setRepoEnabled}
+ onManage={onOpenRepoManager}
+ />
+ {statusFilter === "uninstalled" && (
+ <span className="inline-flex h-6 shrink-0 items-center gap-1 rounded-control bg-subtle px-2 text-caption text-fg-1">
+ <span>{t("skillsPage.discover.onlyUninstalled")}</span>
+ <button
+ type="button"
+ aria-label={t("skillsPage.clearFilters")}
+ onClick={() => setStatusFilter("all")}
+ className="rounded-sm text-fg-3 transition-colors hover:text-fg-1"
+ >
+ <X className="h-3 w-3" strokeWidth={2} />
+ </button>
+ </span>
+ )}
+ {repos.length > 0 && enabledRepos.length < repos.length && (
+ <span className="inline-flex h-6 shrink-0 items-center rounded-control bg-subtle px-2 text-caption tabular-nums text-fg-1">
+ {t("skillsPage.repos.buttonSome", {
+ count: enabledRepos.length,
+ total: repos.length,
+ })}
+ </span>
+ )}
+ </>
+ )}
+ {!loadingList &&
+ (isSkillsSh ? accumulated.length > 0 : repoRows.length > 0) && (
+ <span className="shrink-0 whitespace-nowrap text-caption tabular-nums text-fg-2">
+ {isSkillsSh
+ ? formatSkillCount(
+ skillsShResult?.totalCount ?? accumulated.length,
+ )
+ : visibleRows.length === repoRows.length
+ ? formatSkillCount(repoRows.length)
+ : t("skillsPage.countFiltered", {
+ shown: visibleRows.length,
+ count: repoRows.length,
+ })}
+ </span>
)}
- </div>,
- )}
+ <div className="flex-1" />
+ <InstallToPopover
+ label={installToLabel}
+ fullLabel={t("skillsPage.installTo.button", {
+ apps: names(installTargets),
+ })}
+ visibleAppIds={visibleAppIds}
+ targets={installTargets}
+ onChange={onInstallTargetsChange}
+ />
+ </div>
{/* 部分仓库没读到:列表照常显示读到的,横幅如实说哪些没读到。全部没读到时由空状态说明。 */}
{!isSkillsSh && repoFailures.length > 0 && repoRows.length > 0 && (
- <div className="px-6 pt-3">
+ <div className="px-6 pb-3">
<Notice
tone="warning"
title={t("skillsPage.repoFail.title", {
@@ -641,63 +753,8 @@ export function SkillsPage({
</div>
)}
- <div className="flex min-h-0 flex-1 flex-col px-6 pb-5 pt-3">
+ <div className="flex min-h-0 flex-1 flex-col px-6 pb-5">
<div className="flex min-h-0 flex-col overflow-hidden rounded-panel border border-border bg-surface">
- {/* 表头和「已安装」对齐:左边筛选,右边装到哪些应用(对应已安装的应用列) */}
- <div className="flex h-11 shrink-0 items-center gap-2 border-b border-border bg-subtle px-2">
- <SegmentedControl<SkillsPageSource>
- aria-label={t("skillsPage.discover.sourceAria")}
- size="sm"
- value={effectiveSource}
- onValueChange={setSource}
- items={[
- {
- value: "repos",
- label: t("skillsPage.discover.sourceRepos", {
- count: enabledRepos.length,
- }),
- },
- {
- value: "skillssh",
- label: "skills.sh",
- },
- ]}
- />
- {!isSkillsSh && (
- <>
- <RepoPopover
- repos={repos}
- discoverable={discoverable ?? []}
- failures={repoFailures}
- onToggle={setRepoEnabled}
- onManage={onOpenRepoManager}
- />
- <label className="flex h-7 shrink-0 cursor-pointer items-center gap-2 rounded-control px-2 text-body text-fg-2 transition-colors hover:bg-subtle hover:text-fg-1">
- <input
- type="checkbox"
- className={CHECKBOX_CLASS}
- checked={statusFilter === "uninstalled"}
- onChange={(event) =>
- setStatusFilter(
- event.target.checked ? "uninstalled" : "all",
- )
- }
- />
- {t("skillsPage.discover.onlyUninstalled")}
- </label>
- </>
- )}
- <div className="flex-1" />
- <InstallToPopover
- label={installToLabel}
- fullLabel={t("skillsPage.installTo.button", {
- apps: names(installTargets),
- })}
- visibleAppIds={visibleAppIds}
- targets={installTargets}
- onChange={onInstallTargetsChange}
- />
- </div>
<div
ref={listScrollRef}
className="min-h-0 overflow-auto scroll-stable"
@@ -992,18 +1049,24 @@ function InstallToPopover({
);
}
-// ─── 「仓库」弹层:勾掉即停用 ────────────────────────────────────────────
-function RepoPopover({
+// ─── 「仓库」页统一筛选弹层:仅未安装 + 仓库开关 + 管理仓库 ──────────────
+function ReposFilterPopover({
repos,
discoverable,
failures,
- onToggle,
+ onlyUninstalled,
+ active,
+ onOnlyUninstalledChange,
+ onToggleRepo,
onManage,
}: {
repos: SkillRepo[];
discoverable: DiscoverableSkill[];
failures: SkillRepoFailure[];
- onToggle: (repo: SkillRepo, enabled: boolean) => Promise<void>;
+ onlyUninstalled: boolean;
+ active: boolean;
+ onOnlyUninstalledChange: (checked: boolean) => void;
+ onToggleRepo: (repo: SkillRepo, enabled: boolean) => Promise<void>;
onManage: () => void;
}) {
const { t } = useTranslation();
@@ -1011,14 +1074,6 @@ function RepoPopover({
failures.map((failure) => [repoFailureKey(failure), failure]),
);
const [open, setOpen] = useState(false);
- const enabled = repos.filter((repo) => repo.enabled).length;
- const label =
- enabled === repos.length
- ? t("skillsPage.repos.buttonAll")
- : t("skillsPage.repos.buttonSome", {
- count: enabled,
- total: repos.length,
- });
return (
<Popover open={open} onOpenChange={setOpen}>
<PopoverTrigger asChild>
@@ -1026,10 +1081,13 @@ function RepoPopover({
type="button"
variant="quiet"
size="compact"
- className="pe-1.5 ps-2.5 text-fg-2"
+ className={cn(
+ "shrink-0 px-2.5",
+ active ? "bg-subtle text-fg-1" : "text-fg-2",
+ )}
>
- {label}
- <ChevronDown className="h-3.5 w-3.5" strokeWidth={2} />
+ <ListFilter className="h-3.5 w-3.5" strokeWidth={2} />
+ {t("skillsPage.filter.button")}
</Button>
</PopoverTrigger>
<PopoverContent
@@ -1039,50 +1097,69 @@ function RepoPopover({
aria-label={t("skillsPage.repos.popoverAria")}
className={cn(POPOVER_CLASS, "flex w-[300px] flex-col")}
>
- <div className="flex max-h-[280px] flex-col overflow-y-auto">
- {repos.map((repo) => {
- const id = `${repo.owner}/${repo.name}`;
- const failure = repo.enabled
- ? failureByRepo.get(repoFailureKey(repo))
- : undefined;
- return (
- <label
- key={id}
- className="flex min-h-8 cursor-pointer items-center gap-2 rounded-control px-2 py-1 transition-colors hover:bg-subtle"
- >
- <input
- type="checkbox"
- className={CHECKBOX_CLASS}
- checked={repo.enabled}
- aria-label={t("skillsPage.repos.enableAria", { repo: id })}
- onChange={(event) =>
- void onToggle(repo, event.target.checked)
- }
- />
- <span className="min-w-0 flex-1 truncate font-mono text-caption">
- {id}
- </span>
- <span className="shrink-0 text-caption text-fg-3">
- {displayRepoBranch(discoverable, repo)}
- </span>
- {failure ? (
- <span
- className="shrink-0 text-right text-caption text-warning-text"
- title={skillErrorReason(failure.error, t)}
+ <label className="flex min-h-8 cursor-pointer items-center gap-2 rounded-control px-2 py-1 text-body transition-colors hover:bg-subtle">
+ <input
+ type="checkbox"
+ className={CHECKBOX_CLASS}
+ checked={onlyUninstalled}
+ onChange={(event) => onOnlyUninstalledChange(event.target.checked)}
+ />
+ {t("skillsPage.discover.onlyUninstalled")}
+ </label>
+ {repos.length > 0 && (
+ <>
+ <div aria-hidden="true" className="mx-1.5 my-1 h-px bg-border" />
+ <div className="px-2 py-1 text-caption font-medium text-fg-3">
+ {t("skillsPage.filter.sourceHeading")}
+ </div>
+ <div className="flex max-h-[240px] flex-col overflow-y-auto">
+ {repos.map((repo) => {
+ const id = `${repo.owner}/${repo.name}`;
+ const failure = repo.enabled
+ ? failureByRepo.get(repoFailureKey(repo))
+ : undefined;
+ return (
+ <label
+ key={id}
+ className="flex min-h-8 cursor-pointer items-center gap-2 rounded-control px-2 py-1 transition-colors hover:bg-subtle"
>
- {t("skillsPage.repos.readFailed")}
- </span>
- ) : (
- <span className="w-12 shrink-0 text-right text-caption tabular-nums text-fg-2">
- {repo.enabled
- ? countRepoSkills(discoverable, repo)
- : t("skillsPage.repos.disabledShort")}
- </span>
- )}
- </label>
- );
- })}
- </div>
+ <input
+ type="checkbox"
+ className={CHECKBOX_CLASS}
+ checked={repo.enabled}
+ aria-label={t("skillsPage.repos.enableAria", {
+ repo: id,
+ })}
+ onChange={(event) =>
+ void onToggleRepo(repo, event.target.checked)
+ }
+ />
+ <span className="min-w-0 flex-1 truncate font-mono text-caption">
+ {id}
+ </span>
+ <span className="shrink-0 text-caption text-fg-3">
+ {displayRepoBranch(discoverable, repo)}
+ </span>
+ {failure ? (
+ <span
+ className="shrink-0 text-right text-caption text-warning-text"
+ title={skillErrorReason(failure.error, t)}
+ >
+ {t("skillsPage.repos.readFailed")}
+ </span>
+ ) : (
+ <span className="w-12 shrink-0 text-right text-caption tabular-nums text-fg-2">
+ {repo.enabled
+ ? countRepoSkills(discoverable, repo)
+ : t("skillsPage.repos.disabledShort")}
+ </span>
+ )}
+ </label>
+ );
+ })}
+ </div>
+ </>
+ )}
<div aria-hidden="true" className="mx-1.5 my-1 h-px bg-border" />
<button
type="button"
diff --git a/src/components/skills/UnifiedSkillsPanel.tsx b/src/components/skills/UnifiedSkillsPanel.tsx
index 88ec305f1..f78f28baa 100644
--- a/src/components/skills/UnifiedSkillsPanel.tsx
+++ b/src/components/skills/UnifiedSkillsPanel.tsx
@@ -1,15 +1,22 @@
-import { createPortal } from "react-dom";
-import React, { useEffect, useMemo, useRef, useState } from "react";
+import React, {
+ useCallback,
+ useEffect,
+ useMemo,
+ useRef,
+ useState,
+} from "react";
import { useDelayedFlag } from "@/hooks/useDelayedFlag";
import { useTranslation } from "react-i18next";
import {
ArrowUpCircle,
Check,
ChevronDown,
+ ListFilter,
Loader2,
MoreHorizontal,
Plus,
RefreshCw,
+ X,
} from "lucide-react";
import { toast } from "@/lib/toast";
import { Button } from "@/components/ui/button";
@@ -20,6 +27,7 @@ import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
+ DropdownMenuLabel,
DropdownMenuSeparator,
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";
@@ -41,7 +49,10 @@ import {
useImportSkillsFromApps,
useInstallSkillsFromZip,
useInstalledSkills,
+ useIsFetchingDiscoverableSkills,
+ useRefreshDiscoverableSkills,
useRefreshLocalSkillMetadata,
+ useRefreshSkillRepos,
useRestoreSkillBackup,
useScanUnmanagedSkills,
useSkillBackups,
@@ -69,7 +80,11 @@ import {
} from "@/components/mcp/AppMatrix";
import { V7ConfirmDialog } from "@/components/mcp/formBits";
import { useVisibleAppIds } from "@/components/mcp/useVisibleAppIds";
-import { SkillsPage, useSkillRepoActions } from "./SkillsPage";
+import {
+ SkillsPage,
+ type SkillsShRefreshHandle,
+ useSkillRepoActions,
+} from "./SkillsPage";
import { RepoManagerPanel } from "./RepoManagerPanel";
import { SkillImportDialog } from "./SkillImportDialog";
import { SkillRestoreDialog } from "./SkillRestoreDialog";
@@ -89,7 +104,7 @@ const APP_COLUMN_WIDTH = 36;
const matrixMinWidth = (appCount: number) =>
8 + 24 + 8 + NAME_MIN_WIDTH + appCount * APP_COLUMN_WIDTH + 40 + 8;
-type SkillsView = "installed" | "discover";
+type SkillsView = "installed" | "repos" | "skillssh";
type StatusFilter = "all" | "updates" | "none" | `app:${AppId}`;
interface WriteFailure {
@@ -104,8 +119,8 @@ type ConfirmState =
| { kind: "deleteBackup"; backup: SkillBackupEntry };
interface UnifiedSkillsPanelProps {
- /** 从旧的 skillsDiscovery 视图进来时直接打开「发现」段 */
- initialView?: SkillsView;
+ /** 从旧的 skillsDiscovery 视图进来时直接打开「仓库」页签 */
+ initialView?: SkillsView | "discover";
onInteractionBlockedChange?: (blocked: boolean) => void;
onNavigationBlockedChange?: (blocked: boolean) => void;
}
@@ -138,15 +153,37 @@ const UnifiedSkillsPanel: React.FC<UnifiedSkillsPanelProps> = ({
const appIds = useVisibleAppIds(APP_IDS_WITH.skills);
const { targets, setTargets, installTo } = useSkillInstallTargets(appIds);
- const [view, setView] = useState<SkillsView>(initialView);
- // 「发现」段第一次打开后就一直挂着(隐藏而不卸载),来回切不再重新加载仓库列表
- const [discoverMounted, setDiscoverMounted] = useState(
- initialView === "discover",
+ const resolvedInitialView: SkillsView =
+ initialView === "discover" ? "repos" : initialView;
+ const [view, setView] = useState<SkillsView>(resolvedInitialView);
+ // 「仓库 / skills.sh」第一次打开后就一直挂着(隐藏而不卸载),来回切不再重新加载
+ const [reposMounted, setReposMounted] = useState(
+ resolvedInitialView === "repos",
+ );
+ const [skillsShMounted, setSkillsShMounted] = useState(
+ resolvedInitialView === "skillssh",
);
useEffect(() => {
- if (view === "discover") setDiscoverMounted(true);
+ if (view === "repos") setReposMounted(true);
+ if (view === "skillssh") setSkillsShMounted(true);
}, [view]);
const [discoverQuery, setDiscoverQuery] = useState("");
+ const [skillsShRefresh, setSkillsShRefresh] = useState<SkillsShRefreshHandle>(
+ {
+ canRefresh: false,
+ refreshing: false,
+ refresh: () => undefined,
+ },
+ );
+ const handleSkillsShRefreshChange = useCallback(
+ (handle: SkillsShRefreshHandle) => {
+ setSkillsShRefresh(handle);
+ },
+ [],
+ );
+ const fetchingDiscoverable = useIsFetchingDiscoverableSkills();
+ const refreshDiscoverable = useRefreshDiscoverableSkills();
+ const refreshSkillRepos = useRefreshSkillRepos();
const [searchQuery, setSearchQuery] = useState("");
const [statusFilter, setStatusFilter] = useState<StatusFilter>("all");
const [sourceFilter, setSourceFilter] = useState("all");
@@ -394,9 +431,9 @@ const UnifiedSkillsPanel: React.FC<UnifiedSkillsPanelProps> = ({
row?.focus?.({ preventScroll: true });
}, [highlightId, view]);
- // 在「发现」段按 Escape 回到「已安装」
+ // 在「仓库 / skills.sh」段按 Escape 回到「已安装」
useEffect(() => {
- if (view !== "discover") return;
+ if (view === "installed") return;
const onKey = (event: KeyboardEvent) => {
if (event.key !== "Escape" || event.defaultPrevented) return;
if (document.body.style.overflow === "hidden") return;
@@ -932,7 +969,73 @@ const UnifiedSkillsPanel: React.FC<UnifiedSkillsPanelProps> = ({
const loadOk = !isLoading && !isError;
const selectionActive = selected.size > 0;
- // 可更新的数量只在工具栏的「全部更新(N 个)」上说一次;要只看可更新的,用状态筛选
+ // 统一页头刷新 / 检查更新按钮(对齐 PluginsPage)
+ const headerRefresh =
+ view === "installed" ? (
+ <HoverTip
+ content={
+ lastCheckedText
+ ? t("skillsPage.lastChecked", { when: lastCheckedText })
+ : undefined
+ }
+ >
+ <Button
+ type="button"
+ variant="quiet"
+ size="regular"
+ className="shrink-0"
+ disabled={controlsDisabled || nInstalled === 0}
+ onClick={() => void handleCheckUpdates()}
+ >
+ {isCheckingUpdates ? (
+ <Loader2 className="h-4 w-4 animate-spin" />
+ ) : (
+ <RefreshCw className="h-4 w-4" strokeWidth={2} />
+ )}
+ {isCheckingUpdates
+ ? t("skills.checkingUpdates")
+ : t("skills.checkUpdates")}
+ </Button>
+ </HoverTip>
+ ) : view === "repos" ? (
+ <Button
+ type="button"
+ variant="quiet"
+ size="regular"
+ className="shrink-0"
+ disabled={fetchingDiscoverable}
+ onClick={() => {
+ void refreshDiscoverable();
+ void refreshSkillRepos();
+ }}
+ >
+ <RefreshCw
+ className={cn("h-4 w-4", fetchingDiscoverable && "animate-spin")}
+ strokeWidth={2}
+ />
+ {t("skillsPage.discover.reload")}
+ </Button>
+ ) : (
+ <Button
+ type="button"
+ variant="quiet"
+ size="regular"
+ className="shrink-0"
+ disabled={!skillsShRefresh.canRefresh || skillsShRefresh.refreshing}
+ onClick={skillsShRefresh.refresh}
+ >
+ <RefreshCw
+ className={cn(
+ "h-4 w-4",
+ skillsShRefresh.refreshing && "animate-spin",
+ )}
+ strokeWidth={2}
+ />
+ {t("common.refresh")}
+ </Button>
+ );
+
+ // 可更新的数量只在工具栏的「全部更新(N 个)」上说一次;要只看可更新的,用筛选菜单
const header = (
<AppPageHeader
icon={<SkillsIcon size={20} />}
@@ -944,6 +1047,7 @@ const UnifiedSkillsPanel: React.FC<UnifiedSkillsPanelProps> = ({
}
actions={
<>
+ {headerRefresh}
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button
@@ -959,7 +1063,7 @@ const UnifiedSkillsPanel: React.FC<UnifiedSkillsPanelProps> = ({
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end" className="min-w-[220px]">
- <DropdownMenuItem onSelect={() => setView("discover")}>
+ <DropdownMenuItem onSelect={() => setView("repos")}>
{t("skillsPage.addMenu.discover")}
</DropdownMenuItem>
<DropdownMenuItem onSelect={() => void handleInstallFromZip()}>
@@ -986,12 +1090,6 @@ const UnifiedSkillsPanel: React.FC<UnifiedSkillsPanelProps> = ({
</DropdownMenuTrigger>
</HoverTip>
<DropdownMenuContent align="end" className="min-w-[200px]">
- <DropdownMenuItem
- disabled={controlsDisabled || nInstalled === 0}
- onSelect={() => void handleCheckUpdates()}
- >
- {t("skills.checkUpdates")}
- </DropdownMenuItem>
<DropdownMenuItem
disabled={controlsDisabled}
onSelect={() => void handleOpenRestoreFromBackup()}
@@ -1020,14 +1118,7 @@ const UnifiedSkillsPanel: React.FC<UnifiedSkillsPanelProps> = ({
/>
);
- // 「已安装 / 发现」换的是整块内容:页面级导航,用下划线页签(不是分段控件)。
- // 页签行只渲染一份(两段共用,下划线才滑得过去);各段右侧的控件用 portal 放进 trailing 槽。
- const [tabsTrailingSlot, setTabsTrailingSlot] =
- useState<HTMLDivElement | null>(null);
- const viewTabsTrailing = (owner: SkillsView, trailing: React.ReactNode) =>
- view === owner && tabsTrailingSlot
- ? createPortal(trailing, tabsTrailingSlot)
- : null;
+ // 平铺 3 个一级页签(已安装 / 仓库 / skills.sh),与 Plugins 页一致,页签行不再塞搜索框
const viewTabs = (
<PageTabs<SkillsView>
aria-label={t("skillsPage.viewAria")}
@@ -1035,7 +1126,7 @@ const UnifiedSkillsPanel: React.FC<UnifiedSkillsPanelProps> = ({
className="h-11"
value={view}
onValueChange={(next) => {
- if (next === "discover" && navigationBlocked) return;
+ if (next !== "installed" && navigationBlocked) return;
setView(next);
}}
items={[
@@ -1046,11 +1137,14 @@ const UnifiedSkillsPanel: React.FC<UnifiedSkillsPanelProps> = ({
: t("skillsPage.viewInstalled"),
},
{
- value: "discover",
- label: t("skillsPage.viewDiscover"),
+ value: "repos",
+ label: t("skillsPage.viewRepos"),
+ },
+ {
+ value: "skillssh",
+ label: "skills.sh",
},
]}
- trailing={<div ref={setTabsTrailingSlot} className="flex items-center" />}
/>
);
@@ -1105,7 +1199,7 @@ const UnifiedSkillsPanel: React.FC<UnifiedSkillsPanelProps> = ({
type="button"
variant="neutral"
size="regular"
- onClick={() => setView("discover")}
+ onClick={() => setView("repos")}
>
{t("skillsPage.goDiscover")}
</Button>
@@ -1250,7 +1344,7 @@ const UnifiedSkillsPanel: React.FC<UnifiedSkillsPanelProps> = ({
onClick={() => {
setDiscoverQuery(searchQuery.trim());
setSearchQuery("");
- setView("discover");
+ setView("repos");
}}
>
{t("skillsPage.searchInDiscover", {
@@ -1352,20 +1446,38 @@ const UnifiedSkillsPanel: React.FC<UnifiedSkillsPanelProps> = ({
{header}
<div id="main-content" className="flex min-h-0 flex-1 flex-col">
<div className="shrink-0 px-6 pt-1">{viewTabs}</div>
- {/* 两段打开过就一直挂着,切回来不重新加载;不在看的那段只是隐藏 */}
- {discoverMounted && (
+ {/* 仓库与 skills.sh 打开过就一直挂着,切回来不重新加载;不在看的那段只是隐藏 */}
+ {reposMounted && (
<div
className={cn(
"min-h-0 flex-1 flex-col",
- view === "discover" ? "flex" : "hidden",
+ view === "repos" ? "flex" : "hidden",
)}
>
<SkillsPage
- key={discoverQuery}
+ key={`repos:${discoverQuery}`}
+ source="repos"
initialQuery={discoverQuery}
- renderViewTabs={(trailing) =>
- viewTabsTrailing("discover", trailing)
- }
+ visibleAppIds={appIds}
+ installTargets={targets}
+ onInstallTargetsChange={setTargets}
+ installTo={installTo}
+ onShowInstalled={showInstalled}
+ onOpenRepoManager={() => setRepoManagerOpen(true)}
+ onOpenSkillsSh={() => setView("skillssh")}
+ onEnableFailures={recordEnableFailures}
+ />
+ </div>
+ )}
+ {skillsShMounted && (
+ <div
+ className={cn(
+ "min-h-0 flex-1 flex-col",
+ view === "skillssh" ? "flex" : "hidden",
+ )}
+ >
+ <SkillsPage
+ source="skillssh"
visibleAppIds={appIds}
installTargets={targets}
onInstallTargetsChange={setTargets}
@@ -1373,6 +1485,7 @@ const UnifiedSkillsPanel: React.FC<UnifiedSkillsPanelProps> = ({
onShowInstalled={showInstalled}
onOpenRepoManager={() => setRepoManagerOpen(true)}
onEnableFailures={recordEnableFailures}
+ onSkillsShRefreshChange={handleSkillsShRefreshChange}
/>
</div>
)}
@@ -1382,11 +1495,13 @@ const UnifiedSkillsPanel: React.FC<UnifiedSkillsPanelProps> = ({
view === "installed" ? "flex" : "hidden",
)}
>
- {viewTabsTrailing(
- "installed",
- showInstalledToolbar ? (
+ {/* 统一单行平铺工具栏(min-h-14 可换行,对齐 MCP / Plugins / 仓库):
+ 左边搜索、筛选、激活标签和计数常驻(多选时也保留,支持连续搜索勾选);
+ 右边优先显示更新进度,其次批量操作,否则有更新时显示「全部更新」 */}
+ {showInstalledToolbar && (
+ <div className="flex min-h-14 shrink-0 flex-wrap items-center gap-x-3 gap-y-2 px-6 py-2">
<MatrixSearch
- className="w-[280px] min-w-[160px] shrink"
+ className="w-[320px] min-w-[180px] shrink"
value={searchQuery}
onValueChange={setSearchQuery}
placeholder={t("skillsPage.searchPlaceholder")}
@@ -1399,52 +1514,76 @@ const UnifiedSkillsPanel: React.FC<UnifiedSkillsPanelProps> = ({
: ""
}
/>
- ) : null,
- )}
-
- {/* 页签下面一行,和「发现」段同高:左边筛选一直在,右边是更新入口;勾选了行就换成批量操作。
- 窄窗口 + 大缩放时两边放不下就把右边整组折到下一行,不叠在一起 */}
- {showInstalledToolbar && (
- <div className="flex min-h-12 shrink-0 flex-wrap items-center gap-x-2 gap-y-1 px-6 py-2">
- <div className="-ms-2.5 flex min-w-0 items-center gap-0.5">
- <FilterMenu
- label={statusLabel(statusFilter)}
- active={statusFilter !== "all"}
- items={(["all", "updates", "none"] as StatusFilter[]).map(
- (value) => ({
- key: value,
- label: statusLabel(value),
- checked: statusFilter === value,
- onSelect: () => setStatusFilter(value),
- }),
- )}
- />
- <FilterMenu
- label={t("skillsPage.filter.sourceButton", {
- source:
- sourceFilter === "all"
- ? t("skillsPage.filter.all")
- : sourceLabel(sourceFilter),
- })}
- active={sourceFilter !== "all"}
- items={[
- {
- key: "all",
- label: t("skillsPage.filter.all"),
- checked: sourceFilter === "all",
- onSelect: () => setSourceFilter("all"),
- },
- ...sourceOptions.map(([key, count]) => ({
- key,
- label: sourceLabel(key),
- mono: key !== "local",
- count,
- checked: sourceFilter === key,
- onSelect: () => setSourceFilter(key),
- })),
- ]}
- />
- </div>
+ <InstalledFilterMenu
+ active={filtersActive}
+ statusItems={(["all", "updates", "none"] as StatusFilter[]).map(
+ (value) => ({
+ key: value,
+ label: statusLabel(value),
+ checked: statusFilter === value,
+ onSelect: () => setStatusFilter(value),
+ }),
+ )}
+ sourceItems={[
+ {
+ key: "all",
+ label: t("skillsPage.filter.all"),
+ checked: sourceFilter === "all",
+ onSelect: () => setSourceFilter("all"),
+ },
+ ...sourceOptions.map(([key, count]) => ({
+ key,
+ label: sourceLabel(key),
+ mono: key !== "local",
+ count,
+ checked: sourceFilter === key,
+ onSelect: () => setSourceFilter(key),
+ })),
+ ]}
+ />
+ {statusFilter !== "all" && (
+ <span className="inline-flex h-6 shrink-0 items-center gap-1 rounded-control bg-subtle px-2 text-caption text-fg-1">
+ <span>{statusLabel(statusFilter)}</span>
+ <button
+ type="button"
+ aria-label={t("skillsPage.clearFilters")}
+ onClick={() => setStatusFilter("all")}
+ className="rounded-sm text-fg-3 transition-colors hover:text-fg-1"
+ >
+ <X className="h-3 w-3" strokeWidth={2} />
+ </button>
+ </span>
+ )}
+ {sourceFilter !== "all" && (
+ <span className="inline-flex h-6 shrink-0 items-center gap-1 rounded-control bg-subtle px-2 text-caption text-fg-1">
+ <span
+ className={cn(
+ "max-w-[140px] truncate",
+ sourceFilter !== "local" && "font-mono",
+ )}
+ >
+ {sourceLabel(sourceFilter)}
+ </span>
+ <button
+ type="button"
+ aria-label={t("skillsPage.clearFilters")}
+ onClick={() => setSourceFilter("all")}
+ className="rounded-sm text-fg-3 transition-colors hover:text-fg-1"
+ >
+ <X className="h-3 w-3" strokeWidth={2} />
+ </button>
+ </span>
+ )}
+ <span className="shrink-0 whitespace-nowrap text-caption tabular-nums text-fg-2">
+ {filteredSkills.length === nInstalled
+ ? nInstalled === 1
+ ? t("skillsPage.countOne", { count: nInstalled })
+ : t("skillsPage.count", { count: nInstalled })
+ : t("skillsPage.countFiltered", {
+ shown: filteredSkills.length,
+ count: nInstalled,
+ })}
+ </span>
<div className="flex-1" />
{updateProgress ? (
<Button
@@ -1465,10 +1604,9 @@ const UnifiedSkillsPanel: React.FC<UnifiedSkillsPanelProps> = ({
</Button>
) : selectionActive ? (
<div className="flex shrink-0 flex-wrap items-center gap-0.5">
- <span className="shrink-0 whitespace-nowrap pe-1.5 text-body font-medium tabular-nums">
+ <span className="shrink-0 whitespace-nowrap pe-2 text-body font-medium tabular-nums">
{t("skillsPage.bulk.selected", { count: selected.size })}
</span>
- {/* 列头的批量只按筛选范围走;挑着勾的几行要一次启用到 / 停用某个应用,走这里 */}
<AppMenuButton
label={t("skillsPage.bulk.enableTo")}
ariaLabel={t("skillsPage.bulk.enableToAria", {
@@ -1522,56 +1660,25 @@ const UnifiedSkillsPanel: React.FC<UnifiedSkillsPanelProps> = ({
type="button"
variant="quiet"
size="compact"
- className="px-2 text-fg-2"
+ className="shrink-0 px-2 text-fg-2"
onClick={() => setSelected(new Set())}
>
{t("common.cancel")}
</Button>
</div>
- ) : (
- <HoverTip
- content={
- lastCheckedText
- ? t("skillsPage.lastChecked", {
- when: lastCheckedText,
- })
- : undefined
- }
+ ) : nUpdates > 0 && !isCheckingUpdates ? (
+ <Button
+ type="button"
+ variant="neutral"
+ size="regular"
+ className="shrink-0"
+ disabled={controlsDisabled}
+ onClick={() => setConfirm({ kind: "updateAll" })}
>
- {/* 已知有更新时这颗按钮就是「全部更新」;想重新检查走「⋯」菜单 */}
- {nUpdates > 0 && !isCheckingUpdates ? (
- <Button
- type="button"
- variant="neutral"
- size="regular"
- className="shrink-0"
- disabled={controlsDisabled}
- onClick={() => setConfirm({ kind: "updateAll" })}
- >
- <ArrowUpCircle className="h-4 w-4" strokeWidth={2} />
- {t("skillsPage.updateAllCount", { count: nUpdates })}
- </Button>
- ) : (
- <Button
- type="button"
- variant="quiet"
- size="regular"
- className="shrink-0"
- disabled={controlsDisabled}
- onClick={() => void handleCheckUpdates()}
- >
- {isCheckingUpdates ? (
- <Loader2 className="h-4 w-4 animate-spin" />
- ) : (
- <RefreshCw className="h-4 w-4" strokeWidth={2} />
- )}
- {isCheckingUpdates
- ? t("skills.checkingUpdates")
- : t("skills.checkUpdates")}
- </Button>
- )}
- </HoverTip>
- )}
+ <ArrowUpCircle className="h-4 w-4" strokeWidth={2} />
+ {t("skillsPage.updateAllCount", { count: nUpdates })}
+ </Button>
+ ) : null}
</div>
)}
@@ -2018,23 +2125,46 @@ function InstalledRow({
);
}
-// ─── 列头左侧的筛选按钮 ──────────────────────────────────────────────────
-function FilterMenu({
- label,
+// ─── 统一筛选菜单(合并状态与来源,平时保持工具栏安静) ──────────────────
+interface FilterOption {
+ key: string;
+ label: string;
+ checked: boolean;
+ onSelect: () => void;
+ count?: number;
+ mono?: boolean;
+}
+
+function InstalledFilterMenu({
active,
- items,
+ statusItems,
+ sourceItems,
}: {
- label: string;
active: boolean;
- items: Array<{
- key: string;
- label: string;
- checked: boolean;
- onSelect: () => void;
- count?: number;
- mono?: boolean;
- }>;
+ statusItems: FilterOption[];
+ sourceItems: FilterOption[];
}) {
+ const { t } = useTranslation();
+ const renderItem = (item: FilterOption) => (
+ <DropdownMenuItem key={item.key} onSelect={item.onSelect}>
+ <span className="flex w-4 shrink-0 justify-center">
+ {item.checked && <Check className="h-3.5 w-3.5" strokeWidth={2} />}
+ </span>
+ <span
+ className={cn(
+ "min-w-0 flex-1 truncate",
+ item.mono && "font-mono text-caption",
+ )}
+ >
+ {item.label}
+ </span>
+ {item.count !== undefined && (
+ <span className="shrink-0 text-caption tabular-nums text-fg-3">
+ {item.count}
+ </span>
+ )}
+ </DropdownMenuItem>
+ );
return (
<DropdownMenu>
<DropdownMenuTrigger asChild>
@@ -2043,40 +2173,27 @@ function FilterMenu({
variant="quiet"
size="compact"
className={cn(
- "shrink-0 pe-1.5 ps-2.5",
- active ? "text-fg-1" : "text-fg-2",
+ "shrink-0 px-2.5",
+ active ? "bg-subtle text-fg-1" : "text-fg-2",
)}
>
- <span className="max-w-[180px] truncate">{label}</span>
- <ChevronDown className="h-3.5 w-3.5" strokeWidth={2} />
+ <ListFilter className="h-3.5 w-3.5" strokeWidth={2} />
+ {t("skillsPage.filter.button")}
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent
align="start"
- className="min-w-[210px] max-w-[280px]"
+ className="min-w-[220px] max-w-[280px]"
>
- {items.map((item) => (
- <DropdownMenuItem key={item.key} onSelect={item.onSelect}>
- <span className="flex w-4 shrink-0 justify-center">
- {item.checked && (
- <Check className="h-3.5 w-3.5" strokeWidth={2} />
- )}
- </span>
- <span
- className={cn(
- "min-w-0 flex-1 truncate",
- item.mono && "font-mono text-caption",
- )}
- >
- {item.label}
- </span>
- {item.count !== undefined && (
- <span className="shrink-0 text-caption tabular-nums text-fg-3">
- {item.count}
- </span>
- )}
- </DropdownMenuItem>
- ))}
+ <DropdownMenuLabel className="text-caption font-medium text-fg-3">
+ {t("skillsPage.filter.statusHeading")}
+ </DropdownMenuLabel>
+ {statusItems.map(renderItem)}
+ <DropdownMenuSeparator />
+ <DropdownMenuLabel className="text-caption font-medium text-fg-3">
+ {t("skillsPage.filter.sourceHeading")}
+ </DropdownMenuLabel>
+ {sourceItems.map(renderItem)}
</DropdownMenuContent>
</DropdownMenu>
);
diff --git a/src/hooks/useSkills.ts b/src/hooks/useSkills.ts
index 7a0341522..06b71913d 100644
--- a/src/hooks/useSkills.ts
+++ b/src/hooks/useSkills.ts
@@ -1,5 +1,6 @@
import { useCallback } from "react";
import {
+ useIsFetching,
useIsMutating,
useMutation,
useQuery,
@@ -157,6 +158,13 @@ export function useDiscoverableSkills() {
return useDiscoverableQuery(selectDiscoveredSkills);
}
+/**
+ * 订阅发现查询的加载态,不挂载查询本身(避免停在「已安装」时触发首次拉仓库)。
+ */
+export function useIsFetchingDiscoverableSkills() {
+ return useIsFetching({ queryKey: DISCOVERABLE_QUERY_KEY, exact: true }) > 0;
+}
+
/**
* 手动刷新发现列表:绕过缓存 TTL,后端仍按 commit SHA 跳过未变化的归档。
*/
@@ -171,6 +179,21 @@ export function useRefreshDiscoverableSkills() {
}, [queryClient]);
}
+/**
+ * 手动刷新仓库列表缓存,不挂载 useSkillRepos 查询本身。
+ */
+export function useRefreshSkillRepos() {
+ const queryClient = useQueryClient();
+ return useCallback(
+ () =>
+ queryClient.refetchQueries({
+ queryKey: ["skills", "repos"],
+ exact: true,
+ }),
+ [queryClient],
+ );
+}
+
/**
* 只改发现缓存里一个仓库的部分(next 不传就是删掉这个仓库)。
* 先取消进行中的整体发现:它读的是改动前的仓库表,晚到会把这次改动盖掉。
diff --git a/src/i18n/locales/de.json b/src/i18n/locales/de.json
index d42383c59..9c804d680 100644
--- a/src/i18n/locales/de.json
+++ b/src/i18n/locales/de.json
@@ -5013,7 +5013,10 @@
"viewAria": "Skills-Ansicht",
"viewInstalled": "Installiert",
"viewInstalledCount": "Installiert {{count}}",
- "viewDiscover": "Entdecken",
+ "viewRepos": "Repositories",
+ "countOne": "{{count}} Skill",
+ "count": "{{count}} Skills",
+ "countFiltered": "{{shown}} von {{count}}",
"searchPlaceholder": "Name, Ordner, Beschreibung oder Repo suchen",
"lastChecked": "Zuletzt geprüft: {{when}}",
"justNow": "gerade eben",
@@ -5024,11 +5027,13 @@
"close": "Schließen"
},
"filter": {
+ "button": "Filter",
+ "statusHeading": "Status",
+ "sourceHeading": "Quelle",
"all": "Alle",
"updates": "Mit Updates",
"none": "Nirgends aktiviert",
- "inApp": "In {{app}} aktiviert",
- "sourceButton": "Quelle: {{source}}"
+ "inApp": "In {{app}} aktiviert"
},
"source": {
"local": "Lokal"
@@ -5104,8 +5109,6 @@
"skillsShAria": "skills.sh durchsuchen",
"skillsShHint": "Geben Sie oben mindestens 2 Zeichen ein und drücken Sie die Eingabetaste, um skills.sh zu durchsuchen.",
"skillsShNone": "Auf skills.sh wurde nichts zu „{{query}}“ gefunden",
- "sourceAria": "Quelle für „Entdecken“",
- "sourceRepos": "Repos · {{count}}",
"reload": "Repos aktualisieren",
"listLabel": "Installierbare Skills",
"installed": "Installiert",
@@ -5125,7 +5128,6 @@
"onlyUninstalled": "Nur nicht installierte"
},
"repos": {
- "buttonAll": "Quelle: alle",
"buttonSome": "Quelle: {{count}} von {{total}}",
"popoverAria": "Von „Entdecken“ verwendete Repositories",
"enableAria": "{{repo}} in „Entdecken“ verwenden",
diff --git a/src/i18n/locales/en.json b/src/i18n/locales/en.json
index 64230ffe9..1819e9d37 100644
--- a/src/i18n/locales/en.json
+++ b/src/i18n/locales/en.json
@@ -5013,7 +5013,10 @@
"viewAria": "Skills view",
"viewInstalled": "Installed",
"viewInstalledCount": "Installed {{count}}",
- "viewDiscover": "Discover",
+ "viewRepos": "Repositories",
+ "countOne": "{{count}} Skill",
+ "count": "{{count}} Skills",
+ "countFiltered": "{{shown}} of {{count}}",
"searchPlaceholder": "Search name, folder, description or repo",
"lastChecked": "Last checked: {{when}}",
"justNow": "just now",
@@ -5024,11 +5027,13 @@
"close": "Dismiss"
},
"filter": {
+ "button": "Filter",
+ "statusHeading": "Status",
+ "sourceHeading": "Source",
"all": "All",
"updates": "Has updates",
"none": "Not enabled anywhere",
- "inApp": "Enabled in {{app}}",
- "sourceButton": "Source: {{source}}"
+ "inApp": "Enabled in {{app}}"
},
"source": {
"local": "Local"
@@ -5104,8 +5109,6 @@
"skillsShAria": "Search skills.sh",
"skillsShHint": "Type at least 2 characters above and press Enter to search skills.sh.",
"skillsShNone": "Nothing found on skills.sh for “{{query}}”",
- "sourceAria": "Discover source",
- "sourceRepos": "Repos · {{count}}",
"reload": "Refresh repos",
"listLabel": "Skills you can install",
"installed": "Installed",
@@ -5125,7 +5128,6 @@
"onlyUninstalled": "Not installed only"
},
"repos": {
- "buttonAll": "Source: all",
"buttonSome": "Source: {{count}} of {{total}}",
"popoverAria": "Repositories used by Discover",
"enableAria": "Use {{repo}} in Discover",
diff --git a/src/i18n/locales/ja.json b/src/i18n/locales/ja.json
index ac0b6010e..de501c1b4 100644
--- a/src/i18n/locales/ja.json
+++ b/src/i18n/locales/ja.json
@@ -5013,7 +5013,10 @@
"viewAria": "Skills の表示",
"viewInstalled": "インストール済み",
"viewInstalledCount": "インストール済み {{count}}",
- "viewDiscover": "見つける",
+ "viewRepos": "リポジトリ",
+ "countOne": "{{count}} 件の Skill",
+ "count": "{{count}} 件の Skill",
+ "countFiltered": "{{shown}} / {{count}}",
"searchPlaceholder": "名前・フォルダー・説明・リポジトリを検索",
"lastChecked": "前回の確認:{{when}}",
"justNow": "たった今",
@@ -5024,11 +5027,13 @@
"close": "閉じる"
},
"filter": {
+ "button": "フィルター",
+ "statusHeading": "状態",
+ "sourceHeading": "ソース",
"all": "すべて",
"updates": "更新あり",
"none": "どのアプリでも無効",
- "inApp": "{{app}} で有効",
- "sourceButton": "ソース:{{source}}"
+ "inApp": "{{app}} で有効"
},
"source": {
"local": "ローカル"
@@ -5104,8 +5109,6 @@
"skillsShAria": "skills.sh で検索",
"skillsShHint": "上に 2 文字以上入力し、Enter で skills.sh を検索します。",
"skillsShNone": "skills.sh で「{{query}}」は見つかりませんでした",
- "sourceAria": "探す場所",
- "sourceRepos": "リポジトリ · {{count}}",
"reload": "リポジトリを更新",
"listLabel": "インストールできる Skill",
"installed": "インストール済み",
@@ -5125,7 +5128,6 @@
"onlyUninstalled": "未インストールのみ"
},
"repos": {
- "buttonAll": "ソース:すべて",
"buttonSome": "ソース:{{total}} 件中 {{count}}",
"popoverAria": "「見つける」で使うリポジトリ",
"enableAria": "「見つける」で {{repo}} を使う",
diff --git a/src/i18n/locales/ko.json b/src/i18n/locales/ko.json
index a2c0c8b7d..6ee72a328 100644
--- a/src/i18n/locales/ko.json
+++ b/src/i18n/locales/ko.json
@@ -5013,7 +5013,10 @@
"viewAria": "스킬 보기",
"viewInstalled": "설치됨",
"viewInstalledCount": "{{count}}개 설치됨",
- "viewDiscover": "탐색",
+ "viewRepos": "저장소",
+ "countOne": "{{count}}개 Skill",
+ "count": "{{count}}개 Skill",
+ "countFiltered": "{{shown}} / {{count}}",
"searchPlaceholder": "이름, 폴더, 설명 또는 저장소 검색",
"lastChecked": "마지막 확인: {{when}}",
"justNow": "방금",
@@ -5024,11 +5027,13 @@
"close": "닫기"
},
"filter": {
+ "button": "필터",
+ "statusHeading": "상태",
+ "sourceHeading": "소스",
"all": "모두",
"updates": "업데이트 있음",
"none": "활성화된 앱 없음",
- "inApp": "{{app}}에서 활성화됨",
- "sourceButton": "출처: {{source}}"
+ "inApp": "{{app}}에서 활성화됨"
},
"source": {
"local": "로컬"
@@ -5104,8 +5109,6 @@
"skillsShAria": "skills.sh 검색",
"skillsShHint": "위에 2자 이상 입력하고 Enter를 눌러 skills.sh를 검색하세요.",
"skillsShNone": "skills.sh에서 “{{query}}”에 대한 결과가 없습니다",
- "sourceAria": "탐색 출처",
- "sourceRepos": "저장소 · {{count}}개",
"reload": "저장소 새로 고침",
"listLabel": "설치 가능한 스킬",
"installed": "설치됨",
@@ -5125,7 +5128,6 @@
"onlyUninstalled": "미설치 항목만"
},
"repos": {
- "buttonAll": "출처: 전체",
"buttonSome": "출처: {{total}}개 중 {{count}}개",
"popoverAria": "탐색에 사용하는 저장소",
"enableAria": "탐색에서 {{repo}} 사용",
diff --git a/src/i18n/locales/ru.json b/src/i18n/locales/ru.json
index 998846905..84f2dea02 100644
--- a/src/i18n/locales/ru.json
+++ b/src/i18n/locales/ru.json
@@ -5011,7 +5011,10 @@
"viewAria": "Вид навыков",
"viewInstalled": "Установленные",
"viewInstalledCount": "Установленные {{count}}",
- "viewDiscover": "Обзор",
+ "viewRepos": "Репозитории",
+ "countOne": "Навыков: {{count}}",
+ "count": "Навыков: {{count}}",
+ "countFiltered": "{{shown}} из {{count}}",
"searchPlaceholder": "Поиск по имени, каталогу, описанию или репозиторию",
"lastChecked": "Последняя проверка: {{when}}",
"justNow": "только что",
@@ -5022,11 +5025,13 @@
"close": "Скрыть"
},
"filter": {
+ "button": "Фильтр",
+ "statusHeading": "Статус",
+ "sourceHeading": "Источник",
"all": "Все",
"updates": "Есть обновления",
"none": "Нигде не включены",
- "inApp": "Включены в {{app}}",
- "sourceButton": "Источник: {{source}}"
+ "inApp": "Включены в {{app}}"
},
"source": {
"local": "Локальные"
@@ -5102,8 +5107,6 @@
"skillsShAria": "Поиск по skills.sh",
"skillsShHint": "Введите выше минимум 2 символа и нажмите Enter, чтобы искать по skills.sh.",
"skillsShNone": "На skills.sh ничего не найдено по запросу «{{query}}»",
- "sourceAria": "Источник обзора",
- "sourceRepos": "Репозитории · {{count}}",
"reload": "Обновить репозитории",
"listLabel": "Навыки, доступные для установки",
"installed": "Установлен",
@@ -5123,7 +5126,6 @@
"onlyUninstalled": "Только неустановленные"
},
"repos": {
- "buttonAll": "Источник: все",
"buttonSome": "Источник: {{count}} из {{total}}",
"popoverAria": "Репозитории, используемые в обзоре",
"enableAria": "Использовать {{repo}} в обзоре",
diff --git a/src/i18n/locales/tr.json b/src/i18n/locales/tr.json
index b74e618ad..d848d8a8c 100644
--- a/src/i18n/locales/tr.json
+++ b/src/i18n/locales/tr.json
@@ -4942,7 +4942,10 @@
"viewAria": "Beceri görünümü",
"viewInstalled": "Yüklendi",
"viewInstalledCount": "{{count}} kuruldu",
- "viewDiscover": "Keşfet",
+ "viewRepos": "Depolar",
+ "countOne": "{{count}} Beceri",
+ "count": "{{count}} Beceri",
+ "countFiltered": "{{shown}} / {{count}}",
"searchPlaceholder": "Ad, klasör, açıklama veya repoyu arayın",
"lastChecked": "Son kontrol: {{when}}",
"justNow": "şimdi",
@@ -4953,11 +4956,13 @@
"close": "Reddet"
},
"filter": {
+ "button": "Filtrele",
+ "statusHeading": "Durum",
+ "sourceHeading": "Kaynak",
"all": "Tümü",
"updates": "Güncellemeler var",
"none": "Hiçbir yerde etkinleştirilmedi",
- "inApp": "{{app}}'de etkinleştirildi",
- "sourceButton": "Kaynak: {{source}}"
+ "inApp": "{{app}}'de etkinleştirildi"
},
"source": {
"local": "Yerel"
@@ -5033,8 +5038,6 @@
"skillsShAria": "Skills.sh'de arama yapın",
"skillsShHint": "Skills.sh'yi aramak için yukarıya en az 2 karakter yazın ve Enter tuşuna basın.",
"skillsShNone": "skills.sh'de “{{query}}” için hiçbir şey bulunamadı",
- "sourceAria": "Kaynağı keşfedin",
- "sourceRepos": "Depolar · {{count}}",
"reload": "Depoları yenile",
"listLabel": "Yükleyebileceğiniz beceriler",
"installed": "Yüklendi",
@@ -5054,7 +5057,6 @@
"onlyUninstalled": "Yalnızca yüklü değil"
},
"repos": {
- "buttonAll": "Kaynak: hepsi",
"buttonSome": "Kaynak: {{count}} / {{total}}",
"popoverAria": "Discover tarafından kullanılan depolar",
"enableAria": "Keşfet'te {{repo}}'yi kullanın",
diff --git a/src/i18n/locales/zh-TW.json b/src/i18n/locales/zh-TW.json
index 3197f0523..d458bcf7e 100644
--- a/src/i18n/locales/zh-TW.json
+++ b/src/i18n/locales/zh-TW.json
@@ -5013,7 +5013,10 @@
"viewAria": "Skills 檢視",
"viewInstalled": "已安裝",
"viewInstalledCount": "已安裝 {{count}}",
- "viewDiscover": "探索",
+ "viewRepos": "倉庫",
+ "countOne": "{{count}} 個 Skill",
+ "count": "{{count}} 個 Skill",
+ "countFiltered": "{{shown}} / {{count}}",
"searchPlaceholder": "搜尋名稱、目錄、描述或倉庫",
"lastChecked": "上次檢查:{{when}}",
"justNow": "剛剛",
@@ -5024,11 +5027,13 @@
"close": "關閉提示"
},
"filter": {
+ "button": "篩選",
+ "statusHeading": "狀態",
+ "sourceHeading": "來源",
"all": "全部",
"updates": "可更新",
"none": "未在任何應用啟用",
- "inApp": "在 {{app}} 啟用",
- "sourceButton": "來源:{{source}}"
+ "inApp": "在 {{app}} 啟用"
},
"source": {
"local": "本機"
@@ -5104,8 +5109,6 @@
"skillsShAria": "在 skills.sh 搜尋",
"skillsShHint": "在上面輸入至少 2 個字,按 Enter 搜尋 skills.sh。",
"skillsShNone": "skills.sh 上沒有找到「{{query}}」",
- "sourceAria": "探索來源",
- "sourceRepos": "倉庫 · {{count}}",
"reload": "重新整理倉庫",
"listLabel": "可安裝的 Skill",
"installed": "已安裝",
@@ -5125,7 +5128,6 @@
"onlyUninstalled": "只看未安裝"
},
"repos": {
- "buttonAll": "來源:全部",
"buttonSome": "來源:{{count}} / {{total}}",
"popoverAria": "參與探索的倉庫",
"enableAria": "在探索裡使用 {{repo}}",
diff --git a/src/i18n/locales/zh.json b/src/i18n/locales/zh.json
index b5ff42851..5570a76cf 100644
--- a/src/i18n/locales/zh.json
+++ b/src/i18n/locales/zh.json
@@ -5013,7 +5013,10 @@
"viewAria": "Skills 视图",
"viewInstalled": "已安装",
"viewInstalledCount": "已安装 {{count}}",
- "viewDiscover": "发现",
+ "viewRepos": "仓库",
+ "countOne": "{{count}} 个 Skill",
+ "count": "{{count}} 个 Skill",
+ "countFiltered": "{{shown}} / {{count}}",
"searchPlaceholder": "搜索名称、目录、描述或仓库",
"lastChecked": "上次检查:{{when}}",
"justNow": "刚刚",
@@ -5024,11 +5027,13 @@
"close": "关闭提示"
},
"filter": {
+ "button": "筛选",
+ "statusHeading": "状态",
+ "sourceHeading": "来源",
"all": "全部",
"updates": "可更新",
"none": "未在任何应用启用",
- "inApp": "在 {{app}} 启用",
- "sourceButton": "来源:{{source}}"
+ "inApp": "在 {{app}} 启用"
},
"source": {
"local": "本地"
@@ -5104,8 +5109,6 @@
"skillsShAria": "在 skills.sh 搜索",
"skillsShHint": "在上面输入至少 2 个字,按回车搜索 skills.sh。",
"skillsShNone": "skills.sh 上没有找到“{{query}}”",
- "sourceAria": "发现来源",
- "sourceRepos": "仓库 · {{count}}",
"reload": "刷新仓库",
"listLabel": "可安装的 Skill",
"installed": "已安装",
@@ -5125,7 +5128,6 @@
"onlyUninstalled": "只看未安装"
},
"repos": {
- "buttonAll": "来源:全部",
"buttonSome": "来源:{{count}} / {{total}}",
"popoverAria": "参与发现的仓库",
"enableAria": "在发现里使用 {{repo}}",
diff --git a/tests/components/SkillsPageInstall.test.tsx b/tests/components/SkillsPageInstall.test.tsx
index 039676fa4..229c42f7e 100644
--- a/tests/components/SkillsPageInstall.test.tsx
+++ b/tests/components/SkillsPageInstall.test.tsx
@@ -33,6 +33,7 @@ const searchCache = new Map<
isFetching: boolean;
isPlaceholderData?: boolean;
isError?: boolean;
+ dataUpdatedAt?: number;
refetch?: () => void;
}
>();
@@ -45,6 +46,7 @@ const setSearchResult = (
isLoading: boolean;
isFetching: boolean;
isError: boolean;
+ dataUpdatedAt: number;
refetch: () => void;
}> = {},
) => {
@@ -52,6 +54,7 @@ const setSearchResult = (
data: result,
isLoading: false,
isFetching: false,
+ dataUpdatedAt: 1,
...state,
});
};
@@ -142,7 +145,7 @@ function renderPage(
const onShowInstalled = vi.fn();
render(
<SkillsPage
- renderViewTabs={(trailing) => trailing}
+ source={m.repos.length > 0 ? "repos" : "skillssh"}
visibleAppIds={["claude", "codex", "pi"]}
installTargets={["codex", "claude"]}
onInstallTargetsChange={vi.fn()}
@@ -248,10 +251,7 @@ describe("SkillsPage (Discover)", () => {
it("stays on repositories when they return no skills, so a retry is possible", () => {
m.repos = [makeRepo()];
- renderPage();
- expect(
- screen.getByRole("button", { name: "skillsPage.discover.sourceRepos" }),
- ).toHaveAttribute("aria-pressed", "true");
+ renderPage({ source: "repos" });
expect(
screen.getByText("skillsPage.discover.noneRead"),
).toBeInTheDocument();
@@ -272,7 +272,7 @@ describe("SkillsPage (Discover)", () => {
}),
},
];
- renderPage();
+ renderPage({ source: "repos" });
// 读到的照常列出,横幅说哪些没读到
expect(screen.getByText("repo-skill")).toBeInTheDocument();
@@ -283,9 +283,9 @@ describe("SkillsPage (Discover)", () => {
await userEvent.click(screen.getByRole("button", { name: "common.retry" }));
expect(m.refetchDiscoverable).toHaveBeenCalled();
- // 仓库弹层里那一行写「读取失败」
+ // 筛选弹层里的仓库行写「读取失败」
await userEvent.click(
- screen.getByRole("button", { name: /skillsPage.repos.buttonAll/ }),
+ screen.getByRole("button", { name: "skillsPage.filter.button" }),
);
expect(
await screen.findByText("skillsPage.repos.readFailed"),
@@ -347,12 +347,12 @@ describe("SkillsPage (Discover)", () => {
expect(onShowInstalled).toHaveBeenCalledWith("owner-a/repo-a:repo-skill");
expect(screen.queryByText("skills.uninstall")).not.toBeInTheDocument();
- // 「只看未安装」是页内筛选:复选框,不是第二层分段控件
- expect(
- screen.queryByRole("button", { name: "skills.filter.uninstalled" }),
- ).not.toBeInTheDocument();
+ // 「只看未安装」收在统一筛选弹层里
+ await userEvent.click(
+ screen.getByRole("button", { name: "skillsPage.filter.button" }),
+ );
await userEvent.click(
- screen.getByRole("checkbox", {
+ await screen.findByRole("checkbox", {
name: "skillsPage.discover.onlyUninstalled",
}),
);
@@ -439,7 +439,7 @@ describe("SkillsPage (Discover)", () => {
m.discoverable = [makeDiscoverable()];
renderPage();
await userEvent.click(
- screen.getByRole("button", { name: /skillsPage.repos.buttonAll/ }),
+ screen.getByRole("button", { name: "skillsPage.filter.button" }),
);
const boxes = await screen.findAllByRole("checkbox", {
name: "skillsPage.repos.enableAria",
@@ -454,4 +454,133 @@ describe("SkillsPage (Discover)", () => {
}),
);
});
+
+ it("shows empty repositories state with skills.sh shortcut when zero repos are configured", async () => {
+ const onOpenSkillsSh = vi.fn();
+ renderPage({ source: "repos", onOpenSkillsSh });
+ expect(screen.getByText("skills.repo.empty")).toBeInTheDocument();
+ expect(
+ screen.queryByText("skillsPage.discover.noneRead"),
+ ).not.toBeInTheDocument();
+ await userEvent.click(screen.getByRole("button", { name: "skills.sh" }));
+ expect(onOpenSkillsSh).toHaveBeenCalledTimes(1);
+ });
+
+ it("keeps skills.sh results when Refresh returns identical data and forces page-0 refetch after Load more", async () => {
+ const refetchPage0 = vi.fn();
+ const refetchPage1 = vi.fn();
+ setSearchResult(
+ "react",
+ 0,
+ {
+ skills: [makeSkillsSh({ key: "p0", name: "Page 0 Skill" })],
+ totalCount: 25,
+ query: "react",
+ },
+ { refetch: refetchPage0 },
+ );
+ setSearchResult(
+ "react",
+ 20,
+ {
+ skills: [makeSkillsSh({ key: "p1", name: "Page 1 Skill" })],
+ totalCount: 25,
+ query: "react",
+ },
+ { refetch: refetchPage1 },
+ );
+
+ let handle: {
+ canRefresh: boolean;
+ refreshing: boolean;
+ refresh: () => void;
+ } = { canRefresh: false, refreshing: false, refresh: () => undefined };
+ renderPage({
+ source: "skillssh",
+ onSkillsShRefreshChange: (next) => {
+ handle = next;
+ },
+ });
+
+ await userEvent.type(
+ screen.getByRole("textbox", { name: "skillsPage.discover.skillsShAria" }),
+ "react{Enter}",
+ );
+ await screen.findByText("Page 0 Skill");
+ expect(handle.canRefresh).toBe(true);
+
+ // Refresh on page 0: refetches without wiping results even if data reference is unchanged
+ handle.refresh();
+ expect(refetchPage0).toHaveBeenCalledTimes(1);
+ expect(screen.getByText("Page 0 Skill")).toBeInTheDocument();
+
+ // Load more -> page 1
+ await userEvent.click(
+ screen.getByRole("button", { name: "skills.skillssh.loadMore" }),
+ );
+ await screen.findByText("Page 1 Skill");
+
+ // Refresh after Load more: drops back to page 0 and forces a fresh refetch
+ handle.refresh();
+ await waitFor(() => expect(refetchPage0).toHaveBeenCalledTimes(2));
+ expect(screen.getByText("Page 0 Skill")).toBeInTheDocument();
+ });
+
+ it("does not duplicate page 2 rows on a same-page background refetch after Load more", async () => {
+ const page0 = {
+ skills: [makeSkillsSh({ key: "p0", name: "Page 0 Skill" })],
+ totalCount: 3,
+ query: "bg",
+ };
+ const page1 = {
+ skills: [makeSkillsSh({ key: "p1", name: "Page 1 Skill" })],
+ totalCount: 3,
+ query: "bg",
+ };
+ setSearchResult("bg", 0, page0, { dataUpdatedAt: 100 });
+ setSearchResult("bg", 20, page1, { dataUpdatedAt: 100 });
+
+ const installTo = vi.fn(
+ async (install: (first: AppId) => Promise<Array<{ id: string }>>) => ({
+ installed: await install("codex"),
+ failures: [],
+ }),
+ );
+ const props: React.ComponentProps<typeof SkillsPage> = {
+ source: "skillssh",
+ visibleAppIds: ["claude", "codex", "pi"],
+ installTargets: ["codex", "claude"],
+ onInstallTargetsChange: vi.fn(),
+ installTo: installTo as never,
+ onShowInstalled: vi.fn(),
+ onOpenRepoManager: vi.fn(),
+ onEnableFailures: vi.fn(),
+ };
+ const { rerender } = render(<SkillsPage {...props} />);
+
+ await userEvent.type(
+ screen.getByRole("textbox", { name: "skillsPage.discover.skillsShAria" }),
+ "bg{Enter}",
+ );
+ await screen.findByText("Page 0 Skill");
+
+ await userEvent.click(
+ screen.getByRole("button", { name: "skills.skillssh.loadMore" }),
+ );
+ await screen.findByText("Page 1 Skill");
+ expect(screen.getAllByText("Page 1 Skill")).toHaveLength(1);
+ expect(
+ screen.getByRole("button", { name: "skills.skillssh.loadMore" }),
+ ).toBeInTheDocument();
+
+ // Simulate TanStack Query background refetch of page 1 (same data, newer dataUpdatedAt)
+ setSearchResult("bg", 20, page1, { dataUpdatedAt: 200 });
+ rerender(<SkillsPage {...props} />);
+
+ expect(screen.getAllByText("Page 1 Skill")).toHaveLength(1);
+ expect(screen.getAllByRole("listitem")).toHaveLength(2);
+ expect(
+ screen.getByRole("button", { name: "skills.skillssh.loadMore" }),
+ ).toBeInTheDocument();
+ });
});
diff --git a/tests/components/UnifiedSkillsPanel.test.tsx b/tests/components/UnifiedSkillsPanel.test.tsx
index 44cbc36c8..f2ae0cf53 100644
--- a/tests/components/UnifiedSkillsPanel.test.tsx
+++ b/tests/components/UnifiedSkillsPanel.test.tsx
@@ -15,6 +15,8 @@ import type {
import { waitForOverlayTransition } from "../utils/overlayTransition";
const m = vi.hoisted(() => ({
+ discoverableMounted: vi.fn(),
+ reposMounted: vi.fn(),
scanUnmanaged: vi.fn(),
toggle: vi.fn(),
bulkToggle: vi.fn(),
@@ -116,10 +118,18 @@ vi.mock("@/hooks/useSkills", () => ({
}),
useResyncSkillsToApps: () => ({ mutateAsync: m.resync, isPending: false }),
useIsResyncingSkills: () => false,
- useDiscoverableSkills: () => ({ data: [], refetch: vi.fn() }),
+ useDiscoverableSkills: () => {
+ m.discoverableMounted();
+ return { data: [], refetch: vi.fn() };
+ },
+ useIsFetchingDiscoverableSkills: () => false,
useRefreshDiscoverableSkills: () => vi.fn(),
+ useRefreshSkillRepos: () => vi.fn(),
useDiscoverableSkillsFailures: () => ({ data: [] }),
- useSkillRepos: () => ({ data: [], refetch: vi.fn() }),
+ useSkillRepos: () => {
+ m.reposMounted();
+ return { data: [], refetch: vi.fn() };
+ },
useSkillRepoTokens: () => ({ data: { hosts: [], secureStorage: true } }),
useSkillRepoTokenActions: () => ({
setToken: vi.fn(),
@@ -177,6 +187,8 @@ async function openMenu(trigger: string, item: string) {
describe("UnifiedSkillsPanel", () => {
beforeEach(() => {
+ m.discoverableMounted.mockReset();
+ m.reposMounted.mockReset();
m.installed = [];
m.backups = [];
m.updates = [];
@@ -220,6 +232,13 @@ describe("UnifiedSkillsPanel", () => {
}
});
+ it("does not mount discoverable or repo queries while staying on Installed", () => {
+ m.installed = [makeSkill()];
+ renderPanel();
+ expect(m.discoverableMounted).not.toHaveBeenCalled();
+ expect(m.reposMounted).not.toHaveBeenCalled();
+ });
+
it("always shows the Pi column and toggles it like the other apps", async () => {
m.installed = [makeSkill({ apps: { claude: true, pi: true } })];
renderPanel();
@@ -602,29 +621,36 @@ describe("UnifiedSkillsPanel", () => {
// 可更新的数量只说一次(工具栏按钮);行上的「可更新」就是这一行的更新按钮
expect(screen.getAllByText("skills.updateAvailable")).toHaveLength(1);
expect(screen.getAllByRole("listitem")).toHaveLength(2);
- // 已知有更新时「检查更新」直接变成「全部更新」,不用先筛选
+ // 已知有更新时工具栏出现「全部更新」,页头仍保留统一的「检查更新」
expect(
screen.getAllByRole("button", { name: "skillsPage.updateAllCount" }),
).toHaveLength(1);
expect(
- screen.queryByRole("button", { name: "skills.checkUpdates" }),
- ).not.toBeInTheDocument();
+ screen.getByRole("button", { name: "skills.checkUpdates" }),
+ ).toBeInTheDocument();
- await openMenu("skillsPage.filter.all", "skillsPage.filter.updates");
+ await openMenu("skillsPage.filter.button", "skillsPage.filter.updates");
expect(screen.getAllByRole("listitem")).toHaveLength(1);
- // 筛选按钮在工具栏,选中行时也一直看得见
+ // 搜索框、筛选按钮与激活标签在多选时都保持可见,支持连续搜索勾选
await userEvent.click(
screen.getByRole("checkbox", { name: "skillsPage.selectAria" }),
);
expect(screen.getByText("skillsPage.bulk.selected")).toBeInTheDocument();
expect(
- screen.getByRole("button", { name: "skillsPage.filter.updates" }),
+ screen.getByRole("button", { name: "skillsPage.filter.button" }),
+ ).toBeInTheDocument();
+ expect(screen.getByText("skillsPage.filter.updates")).toBeInTheDocument();
+ expect(
+ screen.getByRole("textbox", { name: "skills.installedSearchAriaLabel" }),
).toBeInTheDocument();
await userEvent.click(
screen.getByRole("button", { name: "common.cancel" }),
);
+ expect(screen.getByText("skillsPage.filter.updates")).toBeInTheDocument();
- await openMenu("skillsPage.filter.updates", "skillsPage.filter.all");
+ await userEvent.click(
+ screen.getByRole("button", { name: "skillsPage.clearFilters" }),
+ );
expect(screen.getAllByRole("listitem")).toHaveLength(2);
await userEvent.click(