Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(desktop): 优化插件列表布局与操作体验 (#1759)
nanaco28c53fef44d3
diff --git a/apps/desktop/src/renderer/features/plugin/GhostPluginDetailView.tsx b/apps/desktop/src/renderer/features/plugin/GhostPluginDetailView.tsxindex b467b380cb..ebed5d4767 100644--- a/apps/desktop/src/renderer/features/plugin/GhostPluginDetailView.tsx+++ b/apps/desktop/src/renderer/features/plugin/GhostPluginDetailView.tsx@@ -165,8 +165,7 @@ export function GhostPluginDetailView({const primaryEnabled =enabled && (primaryAction === 'panel' || (primaryAction === 'command' && detail.canUse));const cindyCapabilities = detail.cindyCapabilities;- const hasConfiguration =- detail.hasSettingsUi || cindyCapabilities.length > 0 || detail.hasErrand;+ const hasConfiguration = detail.hasSettingsUi || cindyCapabilities.length > 0 || detail.hasErrand;const summary = ghostPluginSummary(detail.description, detail.id);/*** 「从 .cindy 文件更新」是否可用。官方保留前缀(cindy- / filo- / xd-)在**非 dev@@ -180,6 +179,7 @@ export function GhostPluginDetailView({* 普通第三方插件不受影响。*/const localUpdateAvailable = import.meta.env.DEV || !isOfficialGhostId(detail.id);+ const hasAdditionalActions = localUpdateAvailable || onExport !== undefined;useLayoutEffect(() => {setDescriptionExpanded(false);@@ -368,7 +368,9 @@ export function GhostPluginDetailView({{t('settings.ghosts.detail.exportPackage')}</DropdownMenuItem>) : null}- <DropdownMenuSeparator className="mx-2 my-1 h-px bg-[var(--border-default)]" />+ {hasAdditionalActions ? (+ <DropdownMenuSeparator className="mx-2 my-1 h-px bg-[var(--border-default)]" />+ ) : null}<DropdownMenuItemonSelect={onUninstall}className="h-10 gap-2.5 rounded-lg px-3 text-13 text-[var(--error-fg)] focus:bg-[var(--error-bg)] focus:text-[var(--error-fg-strong)]"@@ -480,11 +482,7 @@ export function OauthScopeStaleBadge() {role="status"className="inline-flex w-fit max-w-full items-center gap-1.5 rounded-full bg-[var(--warning-bg-soft)] px-3 py-1.5 text-12 leading-5 text-[var(--text-secondary)]">- <AlertTriangle- size={13}- className="shrink-0 text-[var(--warning-fg)]"- aria-hidden="true"- />+ <AlertTriangle size={13} className="shrink-0 text-[var(--warning-fg)]" aria-hidden="true" /><span>{t('settings.ghosts.detail.oauthScopeStale')}</span></div>);diff --git a/apps/desktop/src/renderer/features/plugin/GhostPluginPage.tsx b/apps/desktop/src/renderer/features/plugin/GhostPluginPage.tsxindex 87ba7be792..dba29f54b0 100644--- a/apps/desktop/src/renderer/features/plugin/GhostPluginPage.tsx+++ b/apps/desktop/src/renderer/features/plugin/GhostPluginPage.tsx@@ -9,6 +9,7 @@import {useCallback,useEffect,+ useId,useMemo,useRef,useState,@@ -101,6 +102,7 @@ import {import { formatSetupGateDescription } from './lib/ghostSetupGateModel';import {PLUGIN_MANAGEMENT_CARD_GRID_CLASS,+ PLUGIN_INSTALLED_CARD_GRID_CLASS,PluginManagementLayout,PluginManagementPage,} from './PluginManagementLayout';@@ -139,6 +141,171 @@ const RECOMMENDED_FILTERS: readonly PluginPresentationFilter[] = ['custom',];+/** 已安装区默认只展开一屏内的前 8 个,其余通过显式操作渐进展示。 */+const MAX_VISIBLE_INSTALLED_PLUGINS = 8;+/** 折叠入口只预览前三个隐藏插件,避免头像堆叠反过来抢占操作文案。 */+const MAX_COLLAPSED_INSTALLED_PLUGIN_PREVIEWS = 3;++/** Keeps the installed-section disclosure rule deterministic and directly testable. */+function visibleInstalledPluginItems<T>(items: readonly T[]): T[] {+ return items.slice(0, MAX_VISIBLE_INSTALLED_PLUGINS);+}++function collapsedInstalledPluginPreviewItems<T>(items: readonly T[]): T[] {+ return items.slice(0, MAX_COLLAPSED_INSTALLED_PLUGIN_PREVIEWS);+}++function reconcileInstalledPluginOrderSnapshot(+ snapshot: readonly string[],+ previousIds: readonly string[],+ nextIds: readonly string[],+): string[] {+ const previousSet = new Set(previousIds);+ const nextSet = new Set(nextIds);+ const addedIds = nextIds.filter((id) => !previousSet.has(id));+ const addedSet = new Set(addedIds);+ const retainedIds = snapshot.filter((id) => nextSet.has(id) && !addedSet.has(id));+ const retainedSet = new Set(retainedIds);+ const untrackedIds = nextIds.filter((id) => !addedSet.has(id) && !retainedSet.has(id));+ return [...addedIds, ...retainedIds, ...untrackedIds];+}++function initializeInstalledPluginOrderSnapshot(+ marketSortedIds: readonly string[],+ preSnapshotIds: readonly string[],+ currentIds: readonly string[],+): string[] {+ return reconcileInstalledPluginOrderSnapshot(marketSortedIds, preSnapshotIds, currentIds);+}++function shouldInitializeInstalledPluginOrderSnapshot(+ hasOrderSnapshot: boolean,+ orderSnapshotHasAvailableMarket: boolean,+ marketSnapshot: PluginMarketSnapshot | null,+): boolean {+ if (marketSnapshot === null) return false;+ if (!hasOrderSnapshot) return true;+ return !orderSnapshotHasAvailableMarket && marketSnapshot.unavailableReason === null;+}++function surfaceNewlyUpdatableInstalledPlugins(+ orderSnapshot: readonly string[],+ previousUpdatableIds: readonly string[],+ nextUpdatableIds: readonly string[],+): readonly string[] {+ const previousUpdatableSet = new Set(previousUpdatableIds);+ const newlyUpdatableSet = new Set(nextUpdatableIds.filter((id) => !previousUpdatableSet.has(id)));+ const hiddenNewlyUpdatableIds = orderSnapshot+ .slice(MAX_VISIBLE_INSTALLED_PLUGINS)+ .filter((id) => newlyUpdatableSet.has(id));+ if (hiddenNewlyUpdatableIds.length === 0) return orderSnapshot;++ const promotedSet = new Set(hiddenNewlyUpdatableIds);+ return [...hiddenNewlyUpdatableIds, ...orderSnapshot.filter((id) => !promotedSet.has(id))];+}++type InstalledPluginPreviewItem = Pick<PresentedGhostPluginItem, 'id' | 'name' | 'iconDataUrl'>;++function InstalledPluginOverflow({+ id,+ expanded,+ children,+}: {+ id: string;+ expanded: boolean;+ children: ReactNode;+}) {+ return (+ <div+ id={id}+ className="plugin-installed-overflow"+ data-expanded={expanded}+ aria-hidden={!expanded}+ inert={!expanded}+ >+ <div className="plugin-installed-overflow-clip">{children}</div>+ </div>+ );+}++function InstalledPluginDisclosure({+ expanded,+ controlsId,+ totalCount,+ previewItems,+ onToggle,+ onIconLoadError,+}: {+ expanded: boolean;+ controlsId: string;+ totalCount: number;+ previewItems: readonly InstalledPluginPreviewItem[];+ onToggle: () => void;+ onIconLoadError?: () => void;+}) {+ const { t } = useTranslation();+ const collapsedPreviewItems = collapsedInstalledPluginPreviewItems(previewItems);++ return (+ <button+ type="button"+ onClick={onToggle}+ aria-expanded={expanded}+ aria-controls={controlsId}+ className="mt-3 inline-flex items-center gap-2.5 rounded-full px-3 py-1.5 text-12 text-[var(--text-secondary)] transition-colors duration-150 hover:bg-[var(--surface-hover-soft)] hover:text-[var(--text-primary)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)]"+ >+ {!expanded ? (+ <span className="plugin-installed-preview-stack" aria-hidden="true">+ {collapsedPreviewItems.map((item, index) => (+ <span+ key={item.id}+ className="plugin-installed-preview-card"+ style={{ zIndex: index + 1 }}+ >+ <GhostPluginIcon+ iconDataUrl={item.iconDataUrl}+ iconId={item.id}+ iconName={item.name}+ onIconLoadError={onIconLoadError}+ size="mini"+ />+ </span>+ ))}+ </span>+ ) : null}+ <span className="inline-flex items-center gap-1.5">+ {t(+ expanded+ ? 'settings.ghosts.page.installedCollapse'+ : 'settings.ghosts.page.installedExpand',+ expanded ? undefined : { count: totalCount },+ )}+ <ChevronDown+ size={13}+ aria-hidden="true"+ className={cn(+ 'transition-transform duration-150 motion-reduce:transition-none',+ expanded && 'rotate-180',+ )}+ />+ </span>+ </button>+ );+}++/** Test-only access to the installed-section layout contract. */+export const __installedPluginLayoutForTests = {+ MAX_VISIBLE_INSTALLED_PLUGINS,+ MAX_COLLAPSED_INSTALLED_PLUGIN_PREVIEWS,+ visibleInstalledPluginItems,+ initializeInstalledPluginOrderSnapshot,+ reconcileInstalledPluginOrderSnapshot,+ shouldInitializeInstalledPluginOrderSnapshot,+ surfaceNewlyUpdatableInstalledPlugins,+ InstalledPluginOverflow,+ InstalledPluginDisclosure,+};+/** 读「忽略本轮更新」的持久值(键按数据归属分桶,见 ignoredRoundStorageKey)。 */function readIgnoredRound(storageKey: string): string {try {@@ -164,20 +331,30 @@ export function GhostPluginPage() {const { user, mode, dataOwnerId } = useAuth();const showEnterprise = user?.membershipKind === 'org';const ghosts = useInstalledGhosts();- const installedGhostIdsKey = ghosts- .map((ghost) => ghost.manifest.id)- .sort()- .join('\0');+ const installedGhostIds = useMemo(() => ghosts.map((ghost) => ghost.manifest.id), [ghosts]);+ const installedGhostIdsKey = useMemo(+ () => [...installedGhostIds].sort().join('\0'),+ [installedGhostIds],+ );const installedGhostLocationsKey = ghosts.map((ghost) => `${ghost.manifest.id}\0${ghost.dir}`).sort().join('\0');const [selectedId, setSelectedId] = useState<string | null>(null);const [query, setQuery] = useState('');+ const [installedExpanded, setInstalledExpanded] = useState(false);+ const [orderSnapshot, setOrderSnapshot] = useState<string[] | null>(null);+ const preOrderSnapshotInstalledGhostIdsRef = useRef(installedGhostIds);+ const installedOverflowId = useId();const [marketSnapshot, setMarketSnapshot] = useState<PluginMarketSnapshot | null>(null);const [openPanelId, setOpenPanelId] = useState<string | null>(null);// 数据归属键:面板宿主与排序快照都按它失效(定义要早于两处消费点)。const panelOwnerKey = ghostPanelOwnerKey(mode, dataOwnerId);+ const orderSnapshotStatusRef = useRef<{+ ownerKey: string | null;+ hasAvailableMarket: boolean;+ updatableIds: string[];+ }>({ ownerKey: panelOwnerKey, hasAvailableMarket: false, updatableIds: [] });const ignoredRoundKey = ignoredRoundStorageKey(mode, dataOwnerId);const [ignoredRound, setIgnoredRound] = useState(() => readIgnoredRound(ignoredRoundKey));// 账号 / 本地云模式切换:换桶重读,不把上一个身份的「忽略本轮」带进来。@@ -211,6 +388,7 @@ export function GhostPluginPage() {const lastMarketRefreshAtRef = useRef(0);const marketDetailRequestRef = useRef(0);const installedGhostIdsKeyRef = useRef(installedGhostIdsKey);+ const installedGhostIdsRef = useRef(installedGhostIds);const legacyRecoveryStatusRequestRef = useRef(0);const legacyRecoveryRetryRequestRef = useRef(0);const [legacyRecoveryStatus, setLegacyRecoveryStatus] =@@ -257,11 +435,22 @@ export function GhostPluginPage() {usePluginMarketForegroundRefresh(refreshMarketOnForeground, lastMarketRefreshAtRef);useEffect(() => {if (installedGhostIdsKeyRef.current === installedGhostIdsKey) return;+ const previousInstalledGhostIds = installedGhostIdsRef.current;installedGhostIdsKeyRef.current = installedGhostIdsKey;+ installedGhostIdsRef.current = installedGhostIds;+ setOrderSnapshot((snapshot) =>+ snapshot === null+ ? null+ : reconcileInstalledPluginOrderSnapshot(+ snapshot,+ previousInstalledGhostIds,+ installedGhostIds,+ ),+ );// refreshMarket(true) reports an unavailable market by rejecting after preserving// the current snapshot; the state update already happened in refreshMarket.void refreshMarket(true).catch(() => undefined);- }, [installedGhostIdsKey, refreshMarket]);+ }, [installedGhostIds, installedGhostIdsKey, refreshMarket]);const activeSessionWorkingDir = useSyncExternalStore(subscribeToLastWorkingDir,getLastWorkingDir,@@ -477,9 +666,9 @@ export function GhostPluginPage() {return counts;}, [searchedAvailableMarketItems]);- // ── 排序快照:进页(市场快照首次就绪)时排一次,页内交互不重排 ──- // 可更新的排最前,其余按最近使用;停留期间清未读/装更新都不许让卡片跳位。- const [orderSnapshot, setOrderSnapshot] = useState<string[] | null>(null);+ // ── 排序快照:首个市场结果先定序;若它不可用,首次恢复时再升级一次 ──+ // 可更新的排最前,其余按最近使用。有效快照建立后保持稳定;只有刷新中新出现+ // 且原本藏在折叠区的更新会临时移入前 8,避免更新提示不可见。// 换账号/模式要丢弃旧顺序:两个 owner 的已装集合、可更新集合与最近使用// 都不同,沿用账号 A 的 id 顺序会把 B 的非更新项排到更新项前面,违背// 「可更新优先」。清空后由下面的 effect 基于**新 owner 的首个市场快照**重排。@@ -487,14 +676,51 @@ export function GhostPluginPage() {useEffect(() => {if (orderOwnerKeyRef.current === panelOwnerKey) return;orderOwnerKeyRef.current = panelOwnerKey;+ orderSnapshotStatusRef.current = {+ ownerKey: null,+ hasAvailableMarket: false,+ updatableIds: [],+ };+ preOrderSnapshotInstalledGhostIdsRef.current = installedGhostIds;setOrderSnapshot(null);- }, [panelOwnerKey]);+ setInstalledExpanded(false);+ }, [installedGhostIds, panelOwnerKey]);useEffect(() => {- if (orderSnapshot !== null) return;+ const orderSnapshotStatus = orderSnapshotStatusRef.current;+ if (orderSnapshot !== null && orderSnapshotStatus.ownerKey !== panelOwnerKey) return;if (marketSnapshot === null) return;- const updatable = new Set(- installedItems.filter((item) => item.marketUpdate !== null).map((item) => item.id),+ const updatableIds = installedItems+ .filter((item) => item.marketUpdate !== null)+ .map((item) => item.id);+ const marketAvailable = marketSnapshot.unavailableReason === null;+ const shouldInitializeOrder = shouldInitializeInstalledPluginOrderSnapshot(+ orderSnapshot !== null,+ orderSnapshotStatus.hasAvailableMarket,+ marketSnapshot,);+ if (!shouldInitializeOrder) {+ if (orderSnapshot === null || !marketAvailable || !orderSnapshotStatus.hasAvailableMarket) {+ return;+ }+ orderSnapshotStatusRef.current = {+ ownerKey: panelOwnerKey,+ hasAvailableMarket: true,+ updatableIds,+ };+ setOrderSnapshot((currentOrderSnapshot) => {+ if (currentOrderSnapshot === null) return currentOrderSnapshot;+ const nextOrderSnapshot = surfaceNewlyUpdatableInstalledPlugins(+ currentOrderSnapshot,+ orderSnapshotStatus.updatableIds,+ updatableIds,+ );+ return nextOrderSnapshot === currentOrderSnapshot+ ? currentOrderSnapshot+ : [...nextOrderSnapshot];+ });+ return;+ }+ const updatable = new Set(updatableIds);const byRecentUse = sortGhostPluginItemsByRecentUse(installedItems, recentGhostIds);const ids = byRecentUse.map((item, stableIndex) => ({ item, stableIndex }))@@ -505,8 +731,26 @@ export function GhostPluginPage() {return a.stableIndex - b.stableIndex;}).map(({ item }) => item.id);- setOrderSnapshot(ids);- }, [orderSnapshot, marketSnapshot, installedItems, recentGhostIds]);+ orderSnapshotStatusRef.current = {+ ownerKey: panelOwnerKey,+ hasAvailableMarket: marketAvailable,+ updatableIds: marketAvailable ? updatableIds : [],+ };+ setOrderSnapshot(+ initializeInstalledPluginOrderSnapshot(+ ids,+ preOrderSnapshotInstalledGhostIdsRef.current,+ installedGhostIds,+ ),+ );+ }, [+ orderSnapshot,+ marketSnapshot,+ installedGhostIds,+ installedItems,+ panelOwnerKey,+ recentGhostIds,+ ]);const displayInstalledItems = useMemo(() => {if (orderSnapshot === null) return searchedInstalledItems;const orderIndex = new Map(orderSnapshot.map((id, index) => [id, index]));@@ -524,6 +768,18 @@ export function GhostPluginPage() {}).map(({ item }) => item);}, [orderSnapshot, searchedInstalledItems]);+ const primaryInstalledItems = useMemo(+ () => visibleInstalledPluginItems(displayInstalledItems),+ [displayInstalledItems],+ );+ const additionalInstalledItems = useMemo(+ () => displayInstalledItems.slice(MAX_VISIBLE_INSTALLED_PLUGINS),+ [displayInstalledItems],+ );+ const hiddenInstalledCount = Math.max(+ 0,+ displayInstalledItems.length - MAX_VISIBLE_INSTALLED_PLUGINS,+ );// ── 更新横幅与批量更新(设计定稿:全部更新;扩权单独确认,绝不静默放行)──const updatableInstalledItems = useMemo(@@ -686,15 +942,12 @@ export function GhostPluginPage() {});if (!approved || !isMarketBusyLeaseActive(input.lease)) return null;- const retried = await window.electronAPI.pluginMarket.install(- input.detail.pluginId,- {- ...input.options,- allowPermissionExpansion: review.installedBaseline !== null,- reviewedBaseline: review.installedBaseline ?? undefined,- approvedPackageSha256: review.packageSha256,- },- );+ const retried = await window.electronAPI.pluginMarket.install(input.detail.pluginId, {+ ...input.options,+ allowPermissionExpansion: review.installedBaseline !== null,+ reviewedBaseline: review.installedBaseline ?? undefined,+ approvedPackageSha256: review.packageSha256,+ });if (retried.ghost !== undefined) return retried.ghost;// 同一 release 的真实包不应漂移;再次要求复核说明已装基线在往返窗口内变化。@@ -1042,135 +1295,138 @@ export function GhostPluginPage() {refreshVisibleMarketIcons,);- const runMarketInstallFlow = useCallback(async (marketDetailArg: PluginMarketDetail) => {- const marketDetail = marketDetailArg;- // 确认框等待期间也持有 lease。账号/模式切换会清除当前 lease,- // 旧确认回调恢复后必须先验权,不能在新会话里继续安装。- const marketBusyLease = acquireMarketBusy(marketDetail.pluginId);- if (!marketBusyLease) return;- // 详情页按钮在 update-available 态复用本入口,后端走原位更新并保留- // 生效状态 —— 文案必须分支,不能对更新路径承诺"装完即开"(review P1)。- const isUpdate = marketDetail.installState === 'update-available';- // 装完即开意味着"确认安装"就是运行授权,确认框里必须如实展示权限清单- // (与本地装入确认框同一信息量,review P1):首装展示完整清单,更新展示- // 与已装版本的权限 diff,并据此决定 allowPermissionExpansion(否则扩权- // 更新从本入口必被 main 的 PRECONDITION_FAILED 拦下)。更新详情来自 Main- // 的现查事实,renderer 的 ghosts 推送缓存可能短暂滞后;仅在 update 态且缓存- // 缺目标时,用既有 listSync 向 Main 现查一次。仍缺失说明状态已经变化,- // 让后端按原有校验拒绝,绝不能拿新清单和自己做 diff 吞掉新增权限。- let installedGhost =- ghosts.find((ghost) => ghost.manifest.id === marketDetail.ghostId) ?? null;- if (isUpdate && !installedGhost) {- try {- installedGhost =- window.electronAPI.ghosts- .listSync()- .ghosts.find((ghost) => ghost.manifest.id === marketDetail.ghostId) ?? null;- } catch {- // bridge 不可用/状态切换时保持 null;下面不展示伪造的空 diff,- // 安装调用也不放开 permission expansion,Main 会按真实状态 fail closed。+ const runMarketInstallFlow = useCallback(+ async (marketDetailArg: PluginMarketDetail) => {+ const marketDetail = marketDetailArg;+ // 确认框等待期间也持有 lease。账号/模式切换会清除当前 lease,+ // 旧确认回调恢复后必须先验权,不能在新会话里继续安装。+ const marketBusyLease = acquireMarketBusy(marketDetail.pluginId);+ if (!marketBusyLease) return;+ // 详情页按钮在 update-available 态复用本入口,后端走原位更新并保留+ // 生效状态 —— 文案必须分支,不能对更新路径承诺"装完即开"(review P1)。+ const isUpdate = marketDetail.installState === 'update-available';+ // 装完即开意味着"确认安装"就是运行授权,确认框里必须如实展示权限清单+ // (与本地装入确认框同一信息量,review P1):首装展示完整清单,更新展示+ // 与已装版本的权限 diff,并据此决定 allowPermissionExpansion(否则扩权+ // 更新从本入口必被 main 的 PRECONDITION_FAILED 拦下)。更新详情来自 Main+ // 的现查事实,renderer 的 ghosts 推送缓存可能短暂滞后;仅在 update 态且缓存+ // 缺目标时,用既有 listSync 向 Main 现查一次。仍缺失说明状态已经变化,+ // 让后端按原有校验拒绝,绝不能拿新清单和自己做 diff 吞掉新增权限。+ let installedGhost =+ ghosts.find((ghost) => ghost.manifest.id === marketDetail.ghostId) ?? null;+ if (isUpdate && !installedGhost) {+ try {+ installedGhost =+ window.electronAPI.ghosts+ .listSync()+ .ghosts.find((ghost) => ghost.manifest.id === marketDetail.ghostId) ?? null;+ } catch {+ // bridge 不可用/状态切换时保持 null;下面不展示伪造的空 diff,+ // 安装调用也不放开 permission expansion,Main 会按真实状态 fail closed。+ }}- }- if (isUpdate && !installedGhost) {- // detail 仍说可更新、Main 的实时已装清单却没有目标:这是明确的状态- // 变化,不要展示伪造的空 diff 后让用户确认一次必失败的更新。- if (isMarketBusyLeaseActive(marketBusyLease)) {- toast.error(t('settings.ghosts.market.errors.stateChanged'));+ if (isUpdate && !installedGhost) {+ // detail 仍说可更新、Main 的实时已装清单却没有目标:这是明确的状态+ // 变化,不要展示伪造的空 diff 后让用户确认一次必失败的更新。+ if (isMarketBusyLeaseActive(marketBusyLease)) {+ toast.error(t('settings.ghosts.market.errors.stateChanged'));+ }+ releaseMarketBusy(marketBusyLease);+ await refreshMarket();+ return;}- releaseMarketBusy(marketBusyLease);- await refreshMarket();- return;- }- const diff = isUpdate- ? diffGhostPermissionItems(installedGhost!.manifest, marketDetail.manifest)- : null;- try {- const confirmed = await confirm({- title: isUpdate- ? t('settings.ghosts.updateConfirm.title', { name: marketDetail.name })- : t('settings.ghosts.market.installConfirmTitle', {- name: marketDetail.name,- }),- description: isUpdate- ? t('settings.ghosts.market.updateConfirmDescription')- : // 自定义市场未经服务端完整性校验,确认文案必须如实区分。- marketDetail.sourceType !== 'server'- ? t('settings.ghosts.market.customInstallConfirmDescription')- : t('settings.ghosts.market.installConfirmDescription'),- // 限高与滚动交给共享 ConfirmDialog(max-h-[85vh] + 内部滚动区 + 打开时- // 闪一下滚动条),这里不再自套一层 min(56vh,520px) —— 两层限高会让- // "到底了没有"取决于内外层谁先触底(2026-07-27 收口)。- content: isUpdate ? (- <GhostUpdateReview diff={diff!} />- ) : (- <GhostPermissionList items={ghostPermissionItems(marketDetail.manifest)} />- ),- maxWidth: 520,- confirmText: isUpdate- ? t('settings.ghosts.updateConfirm.confirm')- : t('settings.ghosts.market.install'),- cancelText: isUpdate- ? t('settings.ghosts.updateConfirm.cancel')- : t('settings.ghosts.installConfirm.cancel'),- autoFocusConfirm: true,- });- if (!confirmed || !isMarketBusyLeaseActive(marketBusyLease)) return;- const ghost = await installReviewedMarketPackage({- detail: marketDetail,- lease: marketBusyLease,- options: {- expectedReleaseId: marketDetail.releaseId,- ...(marketDetail.sourceType !== 'server'- ? { expectedManifest: marketDetail.manifest }- : {}),- ...(isUpdate && diff!.added.length > 0- ? {- allowPermissionExpansion: true,- // 确认框展示期间已装 manifest 可能被换掉;基线交由 Main 在- // 安装锁内复核,不一致就拒绝这次批准而不是沿用旧同意。- ...(installedGhost- ? { reviewedBaseline: ghostPermissionBaselineKey(installedGhost.manifest) }- : {}),- }- : {}),- },- });- if (!ghost) return;- if (!isMarketBusyLeaseActive(marketBusyLease)) return;- // 市场首装装完即开(2026-07-26 定案),toast 用"已安装";更新路径如实- // 用"已更新"(生效状态未被改变)。- toast.success(- isUpdate- ? t('settings.ghosts.toast.updated', {- name: ghost.manifest.name,- version: ghost.manifest.version,- })- : t('settings.ghosts.toast.installed', {- name: ghost.manifest.name,- }),- );- setMarketDetail((current) =>- current?.pluginId === marketDetail.pluginId ? null : current,- );- setSelectedId(ghost.manifest.id);- await refreshMarket();- } catch (error) {- if (isMarketBusyLeaseActive(marketBusyLease)) {- toast.error(t(pluginMarketErrorKey(error)));+ const diff = isUpdate+ ? diffGhostPermissionItems(installedGhost!.manifest, marketDetail.manifest)+ : null;+ try {+ const confirmed = await confirm({+ title: isUpdate+ ? t('settings.ghosts.updateConfirm.title', { name: marketDetail.name })+ : t('settings.ghosts.market.installConfirmTitle', {+ name: marketDetail.name,+ }),+ description: isUpdate+ ? t('settings.ghosts.market.updateConfirmDescription')+ : // 自定义市场未经服务端完整性校验,确认文案必须如实区分。+ marketDetail.sourceType !== 'server'+ ? t('settings.ghosts.market.customInstallConfirmDescription')+ : t('settings.ghosts.market.installConfirmDescription'),+ // 限高与滚动交给共享 ConfirmDialog(max-h-[85vh] + 内部滚动区 + 打开时+ // 闪一下滚动条),这里不再自套一层 min(56vh,520px) —— 两层限高会让+ // "到底了没有"取决于内外层谁先触底(2026-07-27 收口)。+ content: isUpdate ? (+ <GhostUpdateReview diff={diff!} />+ ) : (+ <GhostPermissionList items={ghostPermissionItems(marketDetail.manifest)} />+ ),+ maxWidth: 520,+ confirmText: isUpdate+ ? t('settings.ghosts.updateConfirm.confirm')+ : t('settings.ghosts.market.install'),+ cancelText: isUpdate+ ? t('settings.ghosts.updateConfirm.cancel')+ : t('settings.ghosts.installConfirm.cancel'),+ autoFocusConfirm: true,+ });+ if (!confirmed || !isMarketBusyLeaseActive(marketBusyLease)) return;+ const ghost = await installReviewedMarketPackage({+ detail: marketDetail,+ lease: marketBusyLease,+ options: {+ expectedReleaseId: marketDetail.releaseId,+ ...(marketDetail.sourceType !== 'server'+ ? { expectedManifest: marketDetail.manifest }+ : {}),+ ...(isUpdate && diff!.added.length > 0+ ? {+ allowPermissionExpansion: true,+ // 确认框展示期间已装 manifest 可能被换掉;基线交由 Main 在+ // 安装锁内复核,不一致就拒绝这次批准而不是沿用旧同意。+ ...(installedGhost+ ? { reviewedBaseline: ghostPermissionBaselineKey(installedGhost.manifest) }+ : {}),+ }+ : {}),+ },+ });+ if (!ghost) return;+ if (!isMarketBusyLeaseActive(marketBusyLease)) return;+ // 市场首装装完即开(2026-07-26 定案),toast 用"已安装";更新路径如实+ // 用"已更新"(生效状态未被改变)。+ toast.success(+ isUpdate+ ? t('settings.ghosts.toast.updated', {+ name: ghost.manifest.name,+ version: ghost.manifest.version,+ })+ : t('settings.ghosts.toast.installed', {+ name: ghost.manifest.name,+ }),+ );+ setMarketDetail((current) =>+ current?.pluginId === marketDetail.pluginId ? null : current,+ );+ setSelectedId(ghost.manifest.id);+ await refreshMarket();+ } catch (error) {+ if (isMarketBusyLeaseActive(marketBusyLease)) {+ toast.error(t(pluginMarketErrorKey(error)));+ }+ } finally {+ releaseMarketBusy(marketBusyLease);}- } finally {- releaseMarketBusy(marketBusyLease);- }- }, [- acquireMarketBusy,- confirm,- ghosts,- isMarketBusyLeaseActive,- installReviewedMarketPackage,- refreshMarket,- releaseMarketBusy,- t,- ]);+ },+ [+ acquireMarketBusy,+ confirm,+ ghosts,+ isMarketBusyLeaseActive,+ installReviewedMarketPackage,+ refreshMarket,+ releaseMarketBusy,+ t,+ ],+ );const handleInstallFromMarket = useCallback(async () => {if (!marketDetail) return;await runMarketInstallFlow(marketDetail);@@ -1249,9 +1505,7 @@ export function GhostPluginPage() {onUpdate={() => void handleUpdate()}onUpdateFromFile={() => void handleUpdateFromFile()}updateVersion={selectedMarketUpdate?.version}- updateBusy={- (selectedMarketUpdate !== null && marketBusyId !== null) || batchRunning- }+ updateBusy={(selectedMarketUpdate !== null && marketBusyId !== null) || batchRunning}onUninstall={() => void handleUninstall()}// 官方保留前缀(cindy-/filo-/xd-)的插件走本地装入会被拒,// 导出产物无法重装,不提供导出项。@@ -1287,250 +1541,293 @@ export function GhostPluginPage() {<div className="flex min-h-0 flex-1"><main className="min-h-0 w-full min-w-0 flex-1 overflow-y-auto bg-[var(--surface)] [scrollbar-gutter:stable_both-edges]"><PluginManagementPage>- <header className="plugin-motion-page-header pb-2">- <div className="min-w-0">- <div className="flex flex-wrap items-center justify-between gap-3">- <h1 className="text-28 font-medium leading-tight text-[var(--text-primary)]">- {t('settings.ghosts.title')}- </h1>- <PluginScopePicker- scopeDir={scopeDir}- activeSessionWorkingDir={activeSessionWorkingDir ?? undefined}- recentWorkdirs={recentWorkdirs}- onPick={handlePickScope}- />- </div>- <p className="mt-2 max-w-2xl text-14 leading-6 text-[var(--text-secondary)]">- {t('settings.ghosts.description')}- </p>- </div>- </header>-- {scopeDir ? (- <div className="mt-5 flex items-center justify-between gap-3 rounded-xl border border-[var(--border-default)] bg-[var(--surface-chip)] px-4 py-3">- <div className="flex min-w-0 items-center gap-2.5">- <span className="truncate text-13 font-medium text-[var(--text-primary)]">- {scopeDir}- </span>- <span className="truncate text-12 text-[var(--text-tertiary)]">- {t('settings.ghosts.projectBanner.desc')}- </span>+ <header className="plugin-motion-page-header pb-2">+ <div className="min-w-0">+ <div className="flex flex-wrap items-center justify-between gap-3">+ <h1 className="text-28 font-medium leading-tight text-[var(--text-primary)]">+ {t('settings.ghosts.title')}+ </h1>+ <PluginScopePicker+ scopeDir={scopeDir}+ activeSessionWorkingDir={activeSessionWorkingDir ?? undefined}+ recentWorkdirs={recentWorkdirs}+ onPick={handlePickScope}+ />+ </div>+ <p className="mt-2 max-w-2xl text-14 leading-6 text-[var(--text-secondary)]">+ {t('settings.ghosts.description')}+ </p></div>- <button- type="button"- onClick={() => handlePickScope(null)}- className="shrink-0 rounded-full border border-[var(--border-default)] px-3 py-1 text-12 text-[var(--text-secondary)] transition-colors hover:bg-[var(--surface-hover-soft)]"- >- {t('settings.ghosts.projectBanner.backToGlobal')}- </button>- </div>- ) : null}-- <section className="plugin-motion-page-section mt-6 min-w-0">- <div className="mb-4 flex items-baseline gap-2">- <h2 className="text-20 font-medium text-[var(--text-primary)]">- {t('settings.ghosts.page.installedSection')}- </h2>- <span className="text-13 tabular-nums text-[var(--text-tertiary)]">- {searchedInstalledItems.length}- </span>- </div>-- {legacyRecoveryStatus ? (- <LegacyGhostRecoveryNotice- status={legacyRecoveryStatus}- retrying={legacyRecoveryRetrying}- onRetry={() => void handleRetryLegacyRecovery()}- />- ) : null}+ </header>- {bannerVisible ? (- <div className="mb-4 flex items-center gap-4 rounded-xl border-[0.5px] border-[var(--border-default)] bg-[var(--surface-elevated)] px-4 py-3.5">- <span className="grid size-9 shrink-0 place-items-center rounded-full bg-[var(--surface-chip)] text-[var(--text-primary)]">- <ArrowUp size={16} aria-hidden="true" />- </span>- <div className="min-w-0 flex-1">- <p className="text-13 font-medium text-[var(--text-primary)]">- {t('settings.ghosts.page.updatesAvailable', {- count: updatableInstalledItems.length,- })}- </p>- <p className="truncate text-12 text-[var(--text-secondary)]">- {updatableInstalledItems- .map((item) => `${item.name} v${item.marketUpdate?.version ?? ''}`)- .join(' · ')}- </p>+ {scopeDir ? (+ <div className="mt-5 flex items-center justify-between gap-3 rounded-xl border border-[var(--border-default)] bg-[var(--surface-chip)] px-4 py-3">+ <div className="flex min-w-0 items-center gap-2.5">+ <span className="truncate text-13 font-medium text-[var(--text-primary)]">+ {scopeDir}+ </span>+ <span className="truncate text-12 text-[var(--text-tertiary)]">+ {t('settings.ghosts.projectBanner.desc')}+ </span></div><buttontype="button"- onClick={handleIgnoreRound}- className="shrink-0 rounded-full px-3 py-1.5 text-12 text-[var(--text-secondary)] transition-colors duration-150 hover:bg-[var(--surface-hover-soft)] hover:text-[var(--text-primary)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)]"+ onClick={() => handlePickScope(null)}+ className="shrink-0 rounded-full border border-[var(--border-default)] px-3 py-1 text-12 text-[var(--text-secondary)] transition-colors hover:bg-[var(--surface-hover-soft)]">- {t('settings.ghosts.page.ignoreRound')}- </button>- {/* 单项更新在飞时禁用:与 handleUpdateAll 的守卫同因,按钮如实变灰。 */}- <button- type="button"- onClick={handleUpdateAll}- disabled={marketBusyId !== null}- className="inline-flex h-9 shrink-0 items-center rounded-full bg-[var(--accent-cta-bg)] px-4 text-12 font-medium text-[var(--accent-pure-cta-fg)] transition-transform duration-150 hover:bg-[var(--accent-hover)] active:scale-[0.98] disabled:cursor-not-allowed disabled:opacity-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)]"- >- {t('settings.ghosts.page.updateAll')}+ {t('settings.ghosts.projectBanner.backToGlobal')}</button></div>) : null}- {displayInstalledItems.length > 0 ? (- <div className={cn('plugin-motion-stagger', PLUGIN_MANAGEMENT_CARD_GRID_CLASS)}>- {displayInstalledItems.map((item) => (- <GhostPluginCard- key={item.id}- item={item}- sourceLabel={t(`settings.ghosts.page.origin.${item.origin}`)}- updateVersion={item.marketUpdate?.version}- updateBusy={- (item.marketUpdate !== null && marketBusyId !== null) || batchRunning- }- onUpdate={- item.marketUpdate- ? () => void handleMarketUpdate(item.id)- : undefined- }- effectiveEnabled={effectiveEnabled(item.id, item.enabled)}- onPrimary={() => handlePrimaryAction(item)}- onManage={() => setSelectedId(item.id)}- onIconLoadError={handleMarketIconLoadError}- />- ))}- </div>- ) : !legacyRecoveryStatus ? (- <div className="rounded-xl border-[0.5px] border-[var(--border-default)] px-5 py-10 text-center">- <p className="text-13 text-[var(--text-secondary)]">- {installedItems.length === 0- ? t('settings.ghosts.empty')- : t('settings.ghosts.page.emptyFiltered')}- </p>- {installedItems.length === 0 ? (- <p className="mt-1.5 text-12 text-[var(--text-tertiary)]">- {t('settings.ghosts.emptyHint')}- </p>- ) : null}- </div>- ) : null}- </section>-- {availableMarketItems.length > 0 ||- searchedAvailableMarketItems.length > 0 ||- marketSnapshot?.unavailableReason ? (- <section className="plugin-motion-page-section mt-10 min-w-0">- <div className={PLUGIN_CATALOG_TOOLBAR_CLASS}>- {/* 推荐区标题不带数字(设计定稿):数量感由卡片自身传达。 */}- <h2 className="shrink-0 whitespace-nowrap text-20 font-medium text-[var(--text-primary)]">- {t('settings.ghosts.page.recommendedSection')}+ <section className="plugin-motion-page-section mt-6 min-w-0">+ <div className="mb-4 flex items-baseline gap-2">+ <h2 className="text-20 font-medium text-[var(--text-primary)]">+ {t('settings.ghosts.page.installedSection')}</h2>- <div- className="plugin-catalog-filters flex min-w-0 max-w-full items-center gap-1 overflow-x-auto"- role="group"- aria-label={t('settings.ghosts.page.filtersAria')}- style={WINDOW_NO_DRAG_STYLE}- >- {recommendedFilters.map((filter) => {- const selected = effectiveOriginFilter === filter;- const count =- filter === 'all'- ? searchedAvailableMarketItems.length- : recommendedCounts[filter];- return (- <button- key={filter}- type="button"- aria-pressed={selected}- onClick={() => setOriginFilter(filter)}- className={cn(- 'shrink-0 select-none rounded-full px-3.5 py-2 text-12 transition-colors duration-150',- 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)]',- selected- ? 'bg-[var(--surface-chip)] text-[var(--text-primary)]'- : 'text-[var(--text-secondary)] hover:bg-[var(--surface-hover-soft)] hover:text-[var(--text-primary)]',- )}- >- {filter === 'all'- ? t('settings.ghosts.page.filterAll')- : t(`settings.ghosts.page.origin.${filter}`)}- <span className="ml-1.5 tabular-nums text-[var(--text-tertiary)]">- {count}- </span>- </button>- );- })}- </div>+ <span className="text-13 tabular-nums text-[var(--text-tertiary)]">+ {searchedInstalledItems.length}+ </span></div>- {marketSnapshot?.unavailableReason ? (- <p className="mb-4 rounded-xl border border-[var(--border-default)] bg-[var(--surface-chip)] px-4 py-3 text-12 text-[var(--text-secondary)]">- {t(- marketSnapshot.unavailableReason === 'authentication-required'- ? 'settings.ghosts.market.authenticationRequired'- : marketSnapshot.unavailableReason === 'not-configured'- ? 'settings.ghosts.market.notConfigured'- : 'settings.ghosts.market.unavailable',- )}- </p>+ {legacyRecoveryStatus ? (+ <LegacyGhostRecoveryNotice+ status={legacyRecoveryStatus}+ retrying={legacyRecoveryRetrying}+ onRetry={() => void handleRetryLegacyRecovery()}+ />) : null}- {availableMarketItems.length > 0 ? (- customGroups && customGroups.length > 1 ? (- <div className="flex flex-col gap-6">- {customGroups.map(([marketName, groupItems]) => (- <section key={marketName || 'unknown-source'}>- <header className="mb-3 flex items-baseline gap-2">- <h3 className="text-14 font-medium text-[var(--text-primary)]">- {marketName || t('settings.ghosts.page.origin.custom')}- </h3>- <span className="text-12 tabular-nums text-[var(--text-tertiary)]">- {groupItems.length}- </span>- </header>- <div- className={cn('plugin-motion-stagger', PLUGIN_MANAGEMENT_CARD_GRID_CLASS)}- >- {groupItems.map((item) => (- <MarketPluginCard- key={item.pluginId}- item={item}- busy={marketBusyId !== null}- onSelect={() => void handleSelectMarket(item.pluginId)}- onInstall={() => void handleInstallMarketItem(item.pluginId)}- onIconLoadError={handleMarketIconLoadError}- />- ))}- </div>- </section>- ))}+ {bannerVisible ? (+ <div className="mb-4 flex items-center gap-4 rounded-xl border-[0.5px] border-[var(--border-default)] bg-[var(--surface-elevated)] px-4 py-3.5">+ <span className="grid size-9 shrink-0 place-items-center rounded-full bg-[var(--surface-chip)] text-[var(--text-primary)]">+ <ArrowUp size={16} aria-hidden="true" />+ </span>+ <div className="min-w-0 flex-1">+ <p className="text-13 font-medium text-[var(--text-primary)]">+ {t('settings.ghosts.page.updatesAvailable', {+ count: updatableInstalledItems.length,+ })}+ </p>+ <p className="truncate text-12 text-[var(--text-secondary)]">+ {updatableInstalledItems+ .map((item) => `${item.name} v${item.marketUpdate?.version ?? ''}`)+ .join(' · ')}+ </p></div>- ) : (- <div className={cn('plugin-motion-stagger', PLUGIN_MANAGEMENT_CARD_GRID_CLASS)}>- {availableMarketItems.map((item) => (- <MarketPluginCard- key={item.pluginId}+ <button+ type="button"+ onClick={handleIgnoreRound}+ className="shrink-0 rounded-full px-3 py-1.5 text-12 text-[var(--text-secondary)] transition-colors duration-150 hover:bg-[var(--surface-hover-soft)] hover:text-[var(--text-primary)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)]"+ >+ {t('settings.ghosts.page.ignoreRound')}+ </button>+ {/* 单项更新在飞时禁用:与 handleUpdateAll 的守卫同因,按钮如实变灰。 */}+ <button+ type="button"+ onClick={handleUpdateAll}+ disabled={marketBusyId !== null}+ className="inline-flex h-9 shrink-0 items-center rounded-full bg-[var(--accent-cta-bg)] px-4 text-12 font-medium text-[var(--accent-pure-cta-fg)] transition-transform duration-150 hover:bg-[var(--accent-hover)] active:scale-[0.98] disabled:cursor-not-allowed disabled:opacity-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)]"+ >+ {t('settings.ghosts.page.updateAll')}+ </button>+ </div>+ ) : null}++ {primaryInstalledItems.length > 0 ? (+ <>+ <div className={cn('plugin-motion-stagger', PLUGIN_INSTALLED_CARD_GRID_CLASS)}>+ {primaryInstalledItems.map((item) => (+ <GhostPluginCard+ key={item.id}item={item}- busy={marketBusyId !== null}- onSelect={() => void handleSelectMarket(item.pluginId)}- onInstall={() => void handleInstallMarketItem(item.pluginId)}+ sourceLabel={t(`settings.ghosts.page.origin.${item.origin}`)}+ updateVersion={item.marketUpdate?.version}+ updateBusy={+ (item.marketUpdate !== null && marketBusyId !== null) || batchRunning+ }+ onUpdate={+ item.marketUpdate ? () => void handleMarketUpdate(item.id) : undefined+ }+ effectiveEnabled={effectiveEnabled(item.id, item.enabled)}+ onPrimary={() => handlePrimaryAction(item)}+ onManage={() => setSelectedId(item.id)}onIconLoadError={handleMarketIconLoadError}/>))}</div>- )- ) : marketSnapshot?.unavailableReason ? null : (+ {additionalInstalledItems.length > 0 ? (+ <InstalledPluginOverflow id={installedOverflowId} expanded={installedExpanded}>+ <div+ className={cn(+ PLUGIN_INSTALLED_CARD_GRID_CLASS,+ 'plugin-installed-overflow-grid',+ installedExpanded && 'plugin-motion-stagger',+ )}+ >+ {additionalInstalledItems.map((item) => (+ <GhostPluginCard+ key={item.id}+ item={item}+ sourceLabel={t(`settings.ghosts.page.origin.${item.origin}`)}+ updateVersion={item.marketUpdate?.version}+ updateBusy={+ (item.marketUpdate !== null && marketBusyId !== null) || batchRunning+ }+ onUpdate={+ item.marketUpdate ? () => void handleMarketUpdate(item.id) : undefined+ }+ effectiveEnabled={effectiveEnabled(item.id, item.enabled)}+ onPrimary={() => handlePrimaryAction(item)}+ onManage={() => setSelectedId(item.id)}+ onIconLoadError={handleMarketIconLoadError}+ />+ ))}+ </div>+ </InstalledPluginOverflow>+ ) : null}+ </>+ ) : !legacyRecoveryStatus ? (<div className="rounded-xl border-[0.5px] border-[var(--border-default)] px-5 py-10 text-center"><p className="text-13 text-[var(--text-secondary)]">- {t('settings.ghosts.page.emptyFiltered')}+ {installedItems.length === 0+ ? t('settings.ghosts.empty')+ : t('settings.ghosts.page.emptyFiltered')}</p>+ {installedItems.length === 0 ? (+ <p className="mt-1.5 text-12 text-[var(--text-tertiary)]">+ {t('settings.ghosts.emptyHint')}+ </p>+ ) : null}</div>- )}+ ) : null}+ {hiddenInstalledCount > 0 ? (+ <InstalledPluginDisclosure+ expanded={installedExpanded}+ controlsId={installedOverflowId}+ totalCount={displayInstalledItems.length}+ previewItems={additionalInstalledItems}+ onToggle={() => setInstalledExpanded((expanded) => !expanded)}+ onIconLoadError={handleMarketIconLoadError}+ />+ ) : null}</section>- ) : null}++ {availableMarketItems.length > 0 ||+ searchedAvailableMarketItems.length > 0 ||+ marketSnapshot?.unavailableReason ? (+ <section className="plugin-motion-page-section mt-10 min-w-0">+ <div className={PLUGIN_CATALOG_TOOLBAR_CLASS}>+ {/* 推荐区标题不带数字(设计定稿):数量感由卡片自身传达。 */}+ <h2 className="shrink-0 whitespace-nowrap text-20 font-medium text-[var(--text-primary)]">+ {t('settings.ghosts.page.recommendedSection')}+ </h2>+ <div+ className="plugin-catalog-filters flex min-w-0 max-w-full items-center gap-1"+ role="group"+ aria-label={t('settings.ghosts.page.filtersAria')}+ style={WINDOW_NO_DRAG_STYLE}+ >+ {recommendedFilters.map((filter) => {+ const selected = effectiveOriginFilter === filter;+ const count =+ filter === 'all'+ ? searchedAvailableMarketItems.length+ : recommendedCounts[filter];+ return (+ <button+ key={filter}+ type="button"+ aria-pressed={selected}+ onClick={() => setOriginFilter(filter)}+ className={cn(+ 'shrink-0 select-none rounded-full border border-transparent px-3.5 py-2 text-12 transition-colors duration-150',+ 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)]',+ selected+ ? 'plugin-motion-selected text-[var(--text-primary)]'+ : 'text-[var(--text-secondary)] hover:bg-[var(--surface-hover-soft)] hover:text-[var(--text-primary)]',+ )}+ >+ {filter === 'all'+ ? t('settings.ghosts.page.filterAll')+ : t(`settings.ghosts.page.origin.${filter}`)}+ <span className="ml-1.5 tabular-nums text-[var(--text-tertiary)]">+ {count}+ </span>+ </button>+ );+ })}+ </div>+ </div>++ {marketSnapshot?.unavailableReason ? (+ <p className="mb-4 rounded-xl border border-[var(--border-default)] bg-[var(--surface-chip)] px-4 py-3 text-12 text-[var(--text-secondary)]">+ {t(+ marketSnapshot.unavailableReason === 'authentication-required'+ ? 'settings.ghosts.market.authenticationRequired'+ : marketSnapshot.unavailableReason === 'not-configured'+ ? 'settings.ghosts.market.notConfigured'+ : 'settings.ghosts.market.unavailable',+ )}+ </p>+ ) : null}++ {availableMarketItems.length > 0 ? (+ customGroups && customGroups.length > 1 ? (+ <div className="flex flex-col gap-6">+ {customGroups.map(([marketName, groupItems]) => (+ <section key={marketName || 'unknown-source'}>+ <header className="mb-3 flex items-baseline gap-2">+ <h3 className="text-14 font-medium text-[var(--text-primary)]">+ {marketName || t('settings.ghosts.page.origin.custom')}+ </h3>+ <span className="text-12 tabular-nums text-[var(--text-tertiary)]">+ {groupItems.length}+ </span>+ </header>+ <div+ className={cn(+ 'plugin-motion-stagger',+ PLUGIN_MANAGEMENT_CARD_GRID_CLASS,+ )}+ >+ {groupItems.map((item) => (+ <MarketPluginCard+ key={item.pluginId}+ item={item}+ busy={marketBusyId !== null}+ onSelect={() => void handleSelectMarket(item.pluginId)}+ onInstall={() => void handleInstallMarketItem(item.pluginId)}+ onIconLoadError={handleMarketIconLoadError}+ />+ ))}+ </div>+ </section>+ ))}+ </div>+ ) : (+ <div className={cn('plugin-motion-stagger', PLUGIN_MANAGEMENT_CARD_GRID_CLASS)}>+ {availableMarketItems.map((item) => (+ <MarketPluginCard+ key={item.pluginId}+ item={item}+ busy={marketBusyId !== null}+ onSelect={() => void handleSelectMarket(item.pluginId)}+ onInstall={() => void handleInstallMarketItem(item.pluginId)}+ onIconLoadError={handleMarketIconLoadError}+ />+ ))}+ </div>+ )+ ) : marketSnapshot?.unavailableReason ? null : (+ <div className="rounded-xl border-[0.5px] border-[var(--border-default)] px-5 py-10 text-center">+ <p className="text-13 text-[var(--text-secondary)]">+ {t('settings.ghosts.page.emptyFiltered')}+ </p>+ </div>+ )}+ </section>+ ) : null}</PluginManagementPage></main>{panelAside}@@ -1611,11 +1908,12 @@ export function MarketPluginCard({item: PluginMarketItem;busy: boolean;onSelect: () => void;- /** 卡片直接安装(设计定稿:未安装卡片 = 「安装 + 详情」两个动作)。 */+ /** 卡片直接安装;卡片正文、右侧空白与右上角箭头都进入详情。 */onInstall?: () => void;onIconLoadError: () => void;}) {const { t } = useTranslation();+ const unavailable = busy || item.installState === 'conflict';return (<articleclassName={cn(@@ -1628,14 +1926,17 @@ export function MarketPluginCard({<buttontype="button"onClick={onSelect}- disabled={busy || item.installState === 'conflict'}+ disabled={unavailable}+ aria-label={item.name}className={cn(- 'flex min-w-0 flex-1 items-start gap-4 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)]',- item.installState === 'conflict'- ? 'disabled:cursor-not-allowed'- : 'disabled:cursor-wait',+ 'flex min-w-0 flex-1 items-start gap-4 self-stretch text-left',+ 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)]',+ unavailable+ ? item.installState === 'conflict'+ ? 'cursor-not-allowed'+ : 'cursor-wait'+ : 'cursor-pointer',)}- aria-label={item.name}><GhostPluginIconiconDataUrl={item.icon?.url}@@ -1644,10 +1945,8 @@ export function MarketPluginCard({onIconLoadError={onIconLoadError}/><span className="flex min-w-0 flex-1 flex-col self-stretch pt-0.5">- <span className="flex min-w-0 items-center gap-2">- <span className="truncate text-15 font-medium text-[var(--text-primary)]">- {item.name}- </span>+ <span className="truncate text-15 font-medium text-[var(--text-primary)]">+ {item.name}</span><span className="mt-1 flex min-w-0 items-center gap-1.5 overflow-hidden whitespace-nowrap text-11 text-[var(--text-tertiary)]"><span className="shrink-0">@@ -1675,32 +1974,49 @@ export function MarketPluginCard({</span></span></button>- <div className="flex shrink-0 items-center gap-1.5 self-center">+ <div className="relative flex min-h-[76px] min-w-8 shrink-0 flex-col items-end justify-end self-stretch"><buttontype="button"onClick={onSelect}- disabled={busy || item.installState === 'conflict'}+ disabled={unavailable}+ aria-label={t(+ item.installState === 'conflict'+ ? 'settings.ghosts.market.conflictAria'+ : 'settings.ghosts.market.detailsAria',+ { name: item.name },+ )}className={cn(- 'inline-flex h-8 shrink-0 items-center gap-1.5 rounded-full px-3 text-12 font-medium text-[var(--text-secondary)]',- 'transition-colors duration-150 hover:bg-[var(--surface-hover-soft)] hover:text-[var(--text-primary)]',+ 'group/market-details absolute inset-0 flex items-start justify-end rounded-xl text-[var(--text-tertiary)]','focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)] disabled:cursor-not-allowed disabled:opacity-40',)}>- <ChevronRight size={13} aria-hidden="true" />- {t(- item.installState === 'conflict'- ? 'settings.ghosts.market.conflict'- : 'settings.ghosts.market.details',- )}+ <span+ className={cn(+ 'grid size-8 shrink-0 place-items-center rounded-full',+ 'transition-[background-color,color,transform] duration-150 group-hover/market-details:bg-[var(--surface-hover-soft)] group-hover/market-details:text-[var(--text-primary)] group-active/market-details:scale-[0.96]',+ )}+ >+ <ChevronRight size={16} aria-hidden="true" />+ </span></button>- {onInstall ? (+ {item.installState === 'conflict' ? (+ <span+ role="status"+ className="relative z-[1] inline-flex h-8 shrink-0 select-none items-center rounded-full border border-[var(--border-default)] bg-[var(--surface-elevated)] px-3 text-11 font-medium text-[var(--text-secondary)]"+ >+ {t('settings.ghosts.market.conflict')}+ </span>+ ) : onInstall ? (<buttontype="button"- onClick={onInstall}- disabled={busy || item.installState === 'conflict'}+ onClick={(event) => {+ event.stopPropagation();+ onInstall();+ }}+ disabled={unavailable}aria-label={t('settings.ghosts.page.installAria', { name: item.name })}className={cn(- 'inline-flex h-8 shrink-0 items-center rounded-full border border-[var(--border-default)] px-3.5 text-12 font-medium text-[var(--text-primary)]',+ 'relative z-[1] inline-flex h-8 shrink-0 items-center rounded-full border border-[var(--border-default)] bg-[var(--surface-elevated)] px-3.5 text-12 font-medium text-[var(--text-primary)]','transition-[background-color,border-color,transform,opacity] duration-150 hover:bg-[var(--surface-hover-soft)] active:scale-[0.98]','focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)] disabled:cursor-not-allowed disabled:opacity-40',)}@@ -1755,11 +2071,11 @@ function GhostPluginActions({<DropdownMenuContentalign="end"sideOffset={8}- className="w-52 rounded-[12px] border-[0.5px] border-[var(--border-default)] bg-[var(--surface-elevated)] p-1.5 text-[var(--text-primary)] shadow-[var(--shadow-menu)]"+ className="w-max min-w-52 max-w-[calc(100vw-2rem)] rounded-[12px] border-[0.5px] border-[var(--border-default)] bg-[var(--surface-elevated)] p-1.5 text-[var(--text-primary)] shadow-[var(--shadow-menu)]"><DropdownMenuItemonSelect={onCreateWithCindy}- className="h-10 gap-3 rounded-lg px-3 text-13 focus:bg-[var(--surface-hover-soft)] focus:text-[var(--text-primary)]"+ className="h-10 gap-3 whitespace-nowrap rounded-lg px-3 text-13 focus:bg-[var(--surface-hover-soft)] focus:text-[var(--text-primary)]"><Sparklessize={16}@@ -1772,7 +2088,7 @@ function GhostPluginActions({<DropdownMenuSeparator className="mx-2 my-1 h-px bg-[var(--border-default)]" /><DropdownMenuItemonSelect={onInstall}- className="h-10 gap-3 rounded-lg px-3 text-13 focus:bg-[var(--surface-hover-soft)] focus:text-[var(--text-primary)]"+ className="h-10 gap-3 whitespace-nowrap rounded-lg px-3 text-13 focus:bg-[var(--surface-hover-soft)] focus:text-[var(--text-primary)]"><Uploadsize={16}@@ -1785,7 +2101,7 @@ function GhostPluginActions({<DropdownMenuSeparator className="mx-2 my-1 h-px bg-[var(--border-default)]" /><DropdownMenuItemonSelect={onAddMarketplace}- className="h-10 gap-3 rounded-lg px-3 text-13 focus:bg-[var(--surface-hover-soft)] focus:text-[var(--text-primary)]"+ className="h-10 gap-3 whitespace-nowrap rounded-lg px-3 text-13 focus:bg-[var(--surface-hover-soft)] focus:text-[var(--text-primary)]"><Storesize={16}@@ -1900,9 +2216,7 @@ export function GhostPluginCard({<span className="truncate text-15 font-medium text-[var(--text-primary)]">{item.name}</span>- {unread ? (- <AttentionDot breathing size={6} className="mt-px" />- ) : null}+ {unread ? <AttentionDot breathing size={6} className="mt-px" /> : null}</span><span className="mt-1 block min-w-0 truncate text-11 text-[var(--text-tertiary)]">{sourceLabel ? `${sourceLabel} · ` : ''}v{item.version}diff --git a/apps/desktop/src/renderer/features/plugin/PluginManagementLayout.tsx b/apps/desktop/src/renderer/features/plugin/PluginManagementLayout.tsxindex 264a3c84e9..eeb6daf070 100644--- a/apps/desktop/src/renderer/features/plugin/PluginManagementLayout.tsx+++ b/apps/desktop/src/renderer/features/plugin/PluginManagementLayout.tsx@@ -53,6 +53,15 @@ export const PLUGIN_MANAGEMENT_FRAME_CLASS = 'mx-auto w-full max-w-[920px] px-8export const PLUGIN_MANAGEMENT_CARD_GRID_CLASS ='grid grid-cols-[repeat(auto-fit,minmax(min(100%,22.5rem),1fr))] gap-3';+export const PLUGIN_MANAGEMENT_CONTENT_CONTAINER_CLASS = 'plugin-management-content-frame';++/**+ * Installed cards keep the two-column catalog track even when only one card is+ * present, so a lone installed plugin does not stretch across the whole page.+ * The plugin catalog container collapses this to one column at narrow widths.+ */+export const PLUGIN_INSTALLED_CARD_GRID_CLASS = 'plugin-installed-card-grid grid grid-cols-2 gap-3';+const PLUGIN_MANAGEMENT_STACKED_MAX_WIDTH = 720;export function PluginManagementLayout({@@ -227,7 +236,14 @@ export function PluginManagementHeader({/** Shared breathing room and page-enter hook for both top-level catalogs. */export function PluginManagementPage({ children, className }: PluginManagementPageProps) {return (- <div className={cn(PLUGIN_MANAGEMENT_FRAME_CLASS, 'flex flex-col pb-16 pt-8', className)}>+ <div+ className={cn(+ PLUGIN_MANAGEMENT_FRAME_CLASS,+ PLUGIN_MANAGEMENT_CONTENT_CONTAINER_CLASS,+ 'flex flex-col pb-16 pt-8',+ className,+ )}+ >{children}</div>);@@ -252,17 +268,9 @@ function TabButton({'plugin-management-tab h-8 min-w-[88px] select-none rounded-full border border-transparent px-4 text-13 font-medium transition-colors','focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)]',active- ? 'plugin-motion-selected text-[var(--text-primary)] shadow-[var(--plugin-card-shadow)]'+ ? 'plugin-motion-selected text-[var(--text-primary)]': 'text-[var(--text-secondary)] hover:text-[var(--text-primary)]',)}- style={- active- ? {- background: 'color-mix(in srgb, var(--surface-elevated) 86%, transparent)',- borderColor: 'color-mix(in srgb, var(--border-default) 48%, transparent)',- }- : undefined- }>{label}</button>diff --git a/apps/desktop/src/renderer/features/plugin/__tests__/GhostPluginCard.test.tsx b/apps/desktop/src/renderer/features/plugin/__tests__/GhostPluginCard.test.tsxindex 0ec7d3d754..83fdd9f6bc 100644--- a/apps/desktop/src/renderer/features/plugin/__tests__/GhostPluginCard.test.tsx+++ b/apps/desktop/src/renderer/features/plugin/__tests__/GhostPluginCard.test.tsx@@ -10,7 +10,14 @@ import { fireEvent, render, screen } from '@testing-library/react';import { afterEach, describe, expect, it, vi } from 'vitest';vi.mock('react-i18next', () => ({- useTranslation: () => ({ t: (key: string) => key }),+ useTranslation: () => ({+ t: (key: string, options?: { name?: string }) =>+ (key === 'settings.ghosts.market.detailsAria' ||+ key === 'settings.ghosts.market.conflictAria') &&+ options?.name+ ? `${key}:${options.name}`+ : key,+ }),// 页面经批量更新控制器引 @/i18n,其 init 链路需要这些导出。initReactI18next: { type: '3rdParty', init: vi.fn() },I18nextProvider: ({ children }: { children: React.ReactNode }) => children,@@ -20,9 +27,10 @@ vi.mock('@/contexts/AuthContext', () => ({}));import {+ __installedPluginLayoutForTests,GhostPluginCard,- MarketPluginCard,LegacyGhostRecoveryNotice,+ MarketPluginCard,} from '../GhostPluginPage';import {__ingestGhostBadgeForTest,@@ -31,6 +39,18 @@ import {import type { GhostPluginListItem } from '../lib/ghostPluginViewModel';import type { PluginMarketItem } from '../../../../shared/pluginMarket';+const {+ InstalledPluginDisclosure,+ InstalledPluginOverflow,+ MAX_COLLAPSED_INSTALLED_PLUGIN_PREVIEWS,+ MAX_VISIBLE_INSTALLED_PLUGINS,+ initializeInstalledPluginOrderSnapshot,+ reconcileInstalledPluginOrderSnapshot,+ shouldInitializeInstalledPluginOrderSnapshot,+ surfaceNewlyUpdatableInstalledPlugins,+ visibleInstalledPluginItems,+} = __installedPluginLayoutForTests;+const commandPlugin: GhostPluginListItem = {id: 'filo-google',name: 'Filo Google',@@ -177,9 +197,7 @@ describe('GhostPluginCard', () => {fireEvent.click(screen.getByRole('button', { name: 'Filo Google' }));expect(onManage).toHaveBeenCalledTimes(1);expect(onPrimary).not.toHaveBeenCalled();- expect(- screen.getByRole('button', { name: 'settings.ghosts.page.manageAction' }),- ).toBeTruthy();+ expect(screen.getByRole('button', { name: 'settings.ghosts.page.manageAction' })).toBeTruthy();});it('routes projected icon failures to market recovery', () => {@@ -271,7 +289,34 @@ describe('GhostPluginCard', () => {});describe('MarketPluginCard', () => {- it('exposes both 详情 and 安装 actions for a not-installed plugin', () => {+ it('uses an icon-only details action in the card-level right action rail', () => {+ render(+ <MarketPluginCard+ item={marketPlugin}+ busy={false}+ onSelect={vi.fn()}+ onInstall={vi.fn()}+ onIconLoadError={vi.fn()}+ />,+ );++ const details = screen.getByRole('button', {+ name: 'settings.ghosts.market.detailsAria:Google Calendar',+ });+ expect(details.textContent).toBe('');+ expect(details.parentElement?.className).toContain('flex-col');+ expect(details.parentElement?.className).toContain('items-end');+ expect(screen.queryByText('settings.ghosts.market.details')).toBeNull();+ expect(screen.getByRole('button', { name: 'Google Calendar' }).tagName).toBe('BUTTON');+ expect(+ screen+ .getByRole('button', { name: 'Google Calendar' })+ .closest('article')+ ?.hasAttribute('role'),+ ).toBe(false);+ });++ it('exposes both details and install actions for a not-installed plugin', () => {const onSelect = vi.fn();const onInstall = vi.fn();render(@@ -284,12 +329,57 @@ describe('MarketPluginCard', () => {/>,);- fireEvent.click(screen.getByRole('button', { name: 'settings.ghosts.page.installAria' }));+ const details = screen.getByRole('button', {+ name: 'settings.ghosts.market.detailsAria:Google Calendar',+ });+ const install = screen.getByRole('button', { name: 'settings.ghosts.page.installAria' });+ expect(details.className).toContain('absolute');+ expect(details.className).toContain('inset-0');++ fireEvent.click(details);+ expect(onSelect).toHaveBeenCalledTimes(1);++ fireEvent.click(install);expect(onInstall).toHaveBeenCalledTimes(1);- fireEvent.click(screen.getByText('settings.ghosts.market.details'));expect(onSelect).toHaveBeenCalledTimes(1);});+ it('gives each icon-only market action a plugin-specific accessible name', () => {+ render(+ <>+ <MarketPluginCard+ item={marketPlugin}+ busy={false}+ onSelect={vi.fn()}+ onIconLoadError={vi.fn()}+ />+ <MarketPluginCard+ item={{+ ...marketPlugin,+ pluginId: 'release-github',+ ghostId: 'github',+ name: 'GitHub',+ installState: 'conflict',+ }}+ busy={false}+ onSelect={vi.fn()}+ onIconLoadError={vi.fn()}+ />+ </>,+ );++ expect(+ screen.getByRole('button', {+ name: 'settings.ghosts.market.detailsAria:Google Calendar',+ }),+ ).toBeTruthy();+ expect(+ screen.getByRole('button', {+ name: 'settings.ghosts.market.conflictAria:GitHub',+ }),+ ).toBeTruthy();+ });+it('keeps fixed market metadata on one line while truncating long identities', () => {render(<MarketPluginCard@@ -324,15 +414,14 @@ describe('MarketPluginCard', () => {const cardBody = screen.getByRole('button', { name: 'Google Calendar' });expect((cardBody as HTMLButtonElement).disabled).toBe(true);- expect(cardBody.className).toContain('disabled:cursor-not-allowed');- expect(cardBody.className).not.toContain('disabled:cursor-wait');- expect(- (- screen.getByRole('button', {- name: 'settings.ghosts.page.installAria',- }) as HTMLButtonElement- ).disabled,- ).toBe(true);+ expect(cardBody.className).toContain('cursor-not-allowed');+ expect(cardBody.className).not.toContain('cursor-wait');+ const conflictAction = screen.getByRole('button', {+ name: 'settings.ghosts.market.conflictAria:Google Calendar',+ });+ expect((conflictAction as HTMLButtonElement).disabled).toBe(true);+ expect(screen.getByRole('status').textContent).toBe('settings.ghosts.market.conflict');+ expect(screen.queryByRole('button', { name: 'settings.ghosts.page.installAria' })).toBeNull();rerender(<MarketPluginCard@@ -346,8 +435,168 @@ describe('MarketPluginCard', () => {const busyCardBody = screen.getByRole('button', { name: 'Google Calendar' });expect((busyCardBody as HTMLButtonElement).disabled).toBe(true);- expect(busyCardBody.className).toContain('disabled:cursor-wait');- expect(busyCardBody.className).not.toContain('disabled:cursor-not-allowed');+ expect(busyCardBody.className).toContain('cursor-wait');+ expect(busyCardBody.className).not.toContain('cursor-not-allowed');+ });+});++describe('installed Plugin disclosure', () => {+ it('surfaces newly installed plugins before the collapsed grid cutoff', () => {+ const previousIds = Array.from(+ { length: MAX_VISIBLE_INSTALLED_PLUGINS },+ (_, index) => `plugin-${index}`,+ );++ expect(+ reconcileInstalledPluginOrderSnapshot(previousIds, previousIds, [+ ...previousIds,+ 'new-plugin',+ ]),+ ).toEqual(['new-plugin', ...previousIds]);+ });++ it('seeds installs that arrive before the first market snapshot', () => {+ const preSnapshotIds = Array.from(+ { length: MAX_VISIBLE_INSTALLED_PLUGINS },+ (_, index) => `plugin-${index}`,+ );+ const marketSortedIds = [...preSnapshotIds].reverse();++ expect(+ initializeInstalledPluginOrderSnapshot(marketSortedIds, preSnapshotIds, [+ ...preSnapshotIds,+ 'new-plugin',+ ]),+ ).toEqual(['new-plugin', ...marketSortedIds]);+ });++ it('upgrades a provisional installed order once market data recovers', () => {+ const unavailableMarketSnapshot = {+ items: [],+ unavailableReason: 'authentication-required',+ customSourceNames: [],+ };+ const availableMarketSnapshot = {+ items: [],+ unavailableReason: null,+ customSourceNames: [],+ };++ expect(+ shouldInitializeInstalledPluginOrderSnapshot(false, false, unavailableMarketSnapshot),+ ).toBe(true);+ expect(+ shouldInitializeInstalledPluginOrderSnapshot(true, false, unavailableMarketSnapshot),+ ).toBe(false);+ expect(shouldInitializeInstalledPluginOrderSnapshot(true, false, availableMarketSnapshot)).toBe(+ true,+ );+ expect(shouldInitializeInstalledPluginOrderSnapshot(true, true, availableMarketSnapshot)).toBe(+ false,+ );+ });++ it('surfaces newly update-available plugins only when they were hidden by the cutoff', () => {+ const orderSnapshot = Array.from(+ { length: MAX_VISIBLE_INSTALLED_PLUGINS + 3 },+ (_, index) => `plugin-${index}`,+ );++ expect(surfaceNewlyUpdatableInstalledPlugins(orderSnapshot, [], ['plugin-6'])).toBe(+ orderSnapshot,+ );+ expect(+ surfaceNewlyUpdatableInstalledPlugins(+ orderSnapshot,+ ['plugin-1'],+ ['plugin-1', 'plugin-6', 'plugin-9', 'plugin-10'],+ ),+ ).toEqual([+ 'plugin-9',+ 'plugin-10',+ ...orderSnapshot.filter((id) => id !== 'plugin-9' && id !== 'plugin-10'),+ ]);+ });++ it('shows at most eight installed plugins until the user expands the section', () => {+ const items = Array.from({ length: MAX_VISIBLE_INSTALLED_PLUGINS + 3 }, (_, index) => index);++ expect(visibleInstalledPluginItems(items)).toEqual(+ items.slice(0, MAX_VISIBLE_INSTALLED_PLUGINS),+ );+ });++ it('links the disclosure to its overflow and previews at most three hidden avatars', () => {+ const onToggle = vi.fn();+ const previewItems = Array.from(+ { length: MAX_COLLAPSED_INSTALLED_PLUGIN_PREVIEWS + 2 },+ (_, index) => ({+ ...commandPlugin,+ id: `preview-${index}`,+ name: `Preview ${index}`,+ origin: 'public' as const,+ marketUpdate: null,+ }),+ );+ const { container, rerender } = render(+ <InstalledPluginDisclosure+ expanded={false}+ controlsId="installed-overflow"+ totalCount={11}+ previewItems={previewItems}+ onToggle={onToggle}+ />,+ );++ const collapsedButton = screen.getByRole('button', {+ name: 'settings.ghosts.page.installedExpand',+ });+ expect(collapsedButton.getAttribute('aria-expanded')).toBe('false');+ expect(collapsedButton.getAttribute('aria-controls')).toBe('installed-overflow');+ expect(container.querySelectorAll('.plugin-installed-preview-card')).toHaveLength(+ MAX_COLLAPSED_INSTALLED_PLUGIN_PREVIEWS,+ );+ fireEvent.click(collapsedButton);+ expect(onToggle).toHaveBeenCalledTimes(1);++ rerender(+ <InstalledPluginDisclosure+ expanded+ controlsId="installed-overflow"+ totalCount={11}+ previewItems={previewItems}+ onToggle={onToggle}+ />,+ );+ expect(+ screen+ .getByRole('button', { name: 'settings.ghosts.page.installedCollapse' })+ .getAttribute('aria-expanded'),+ ).toBe('true');+ expect(container.querySelector('.plugin-installed-preview-stack')).toBeNull();+ });++ it('keeps collapsed overflow hidden and inert until expanded', () => {+ const { rerender, container } = render(+ <InstalledPluginOverflow id="installed-overflow" expanded={false}>+ <button type="button">Hidden plugin</button>+ </InstalledPluginOverflow>,+ );++ const collapsedOverflow = container.querySelector('#installed-overflow');+ expect(collapsedOverflow?.getAttribute('aria-hidden')).toBe('true');+ expect(collapsedOverflow?.hasAttribute('inert')).toBe(true);+ expect(collapsedOverflow?.getAttribute('data-expanded')).toBe('false');++ rerender(+ <InstalledPluginOverflow id="installed-overflow" expanded>+ <button type="button">Hidden plugin</button>+ </InstalledPluginOverflow>,+ );+ const expandedOverflow = container.querySelector('#installed-overflow');+ expect(expandedOverflow?.getAttribute('aria-hidden')).toBe('false');+ expect(expandedOverflow?.hasAttribute('inert')).toBe(false);+ expect(expandedOverflow?.getAttribute('data-expanded')).toBe('true');});});@@ -401,9 +650,7 @@ describe('LegacyGhostRecoveryNotice', () => {/>,);- expect(- screen.getByText('settings.ghosts.legacyRecovery.partialBlocked'),- ).toBeTruthy();+ expect(screen.getByText('settings.ghosts.legacyRecovery.partialBlocked')).toBeTruthy();expect(screen.queryByRole('button')).toBeNull();});});diff --git a/apps/desktop/src/renderer/features/plugin/__tests__/GhostPluginDetailSections.test.tsx b/apps/desktop/src/renderer/features/plugin/__tests__/GhostPluginDetailSections.test.tsxindex 4e1e0e15c8..6113ca0422 100644--- a/apps/desktop/src/renderer/features/plugin/__tests__/GhostPluginDetailSections.test.tsx+++ b/apps/desktop/src/renderer/features/plugin/__tests__/GhostPluginDetailSections.test.tsx@@ -320,9 +320,11 @@ describe('Ghost plugin detail sections', () => {);expect(- (screen.getByRole('button', {- name: 'settings.ghosts.market.updateTo',- }) as HTMLButtonElement).disabled,+ (+ screen.getByRole('button', {+ name: 'settings.ghosts.market.updateTo',+ }) as HTMLButtonElement+ ).disabled,).toBe(true);fireEvent.pointerDown(screen.getByRole('button', { name: 'settings.ghosts.detail.moreActions' }),@@ -376,7 +378,8 @@ describe('Ghost plugin detail sections', () => {expect(screen.queryByRole('menuitem', { name: 'settings.ghosts.detail.updateFromFile' }),).toBeNull();- // 卸载等其余菜单项不受影响。+ // 只剩卸载一项时不画悬空分割线。+ expect(screen.queryByRole('separator')).toBeNull();expect(screen.getByRole('menuitem', { name: 'settings.ghosts.uninstall' })).toBeTruthy();vi.unstubAllEnvs();});@@ -414,6 +417,7 @@ describe('Ghost plugin detail sections', () => {expect(screen.getByRole('menuitem', { name: 'settings.ghosts.detail.updateFromFile' }),).toBeTruthy();+ expect(screen.getByRole('separator')).toBeTruthy();vi.unstubAllEnvs();});@@ -445,7 +449,9 @@ describe('Ghost plugin detail sections', () => {screen.getByRole('button', { name: 'settings.ghosts.detail.moreActions' }),{ button: 0, ctrlKey: false },);- expect(screen.queryByRole('menuitem', { name: 'settings.ghosts.detail.exportPackage' })).toBeNull();+ expect(+ screen.queryByRole('menuitem', { name: 'settings.ghosts.detail.exportPackage' }),+ ).toBeNull();unmount();// 提供 onExport(已装插件):点击触发导出回调。@@ -455,9 +461,7 @@ describe('Ghost plugin detail sections', () => {screen.getByRole('button', { name: 'settings.ghosts.detail.moreActions' }),{ button: 0, ctrlKey: false },);- fireEvent.click(- screen.getByRole('menuitem', { name: 'settings.ghosts.detail.exportPackage' }),- );+ fireEvent.click(screen.getByRole('menuitem', { name: 'settings.ghosts.detail.exportPackage' }));expect(onExport).toHaveBeenCalledTimes(1);});diff --git a/apps/desktop/src/renderer/features/plugin/__tests__/PluginManagementLayout.test.tsx b/apps/desktop/src/renderer/features/plugin/__tests__/PluginManagementLayout.test.tsxindex 7b12f96a61..6e2c1f1ca3 100644--- a/apps/desktop/src/renderer/features/plugin/__tests__/PluginManagementLayout.test.tsx+++ b/apps/desktop/src/renderer/features/plugin/__tests__/PluginManagementLayout.test.tsx@@ -24,6 +24,8 @@ vi.mock('react-i18next', () => ({}));import {+ PLUGIN_INSTALLED_CARD_GRID_CLASS,+ PLUGIN_MANAGEMENT_CONTENT_CONTAINER_CLASS,PLUGIN_MANAGEMENT_CARD_GRID_CLASS,PluginManagementLayout,PluginManagementPage,@@ -88,6 +90,7 @@ describe('PluginManagementLayout', () => {expect(tabFrame?.className).toContain('max-w-[920px]');expect(tabFrame?.parentElement?.className).toContain('px-3');expect(pageFrame?.className).toContain('max-w-[920px]');+ expect(pageFrame?.className).toContain(PLUGIN_MANAGEMENT_CONTENT_CONTAINER_CLASS);});it('uses a content-width responsive card grid for both catalogs', () => {@@ -96,6 +99,11 @@ describe('PluginManagementLayout', () => {expect(PLUGIN_MANAGEMENT_CARD_GRID_CLASS).not.toMatch(/\b(?:sm|md|lg):grid-cols-/);});+ it('keeps a lone installed card on one of the two catalog tracks', () => {+ expect(PLUGIN_INSTALLED_CARD_GRID_CLASS).toContain('grid-cols-2');+ expect(PLUGIN_INSTALLED_CARD_GRID_CLASS).not.toContain('auto-fit');+ });+it('keeps catalog children in a height-constrained flex column so their main area can scroll', () => {render(<MemoryRouter>diff --git a/apps/desktop/src/renderer/features/plugin/__tests__/pluginMotionDesign.test.ts b/apps/desktop/src/renderer/features/plugin/__tests__/pluginMotionDesign.test.tsnew file mode 100644index 0000000000..5876c25a85--- /dev/null+++ b/apps/desktop/src/renderer/features/plugin/__tests__/pluginMotionDesign.test.ts@@ -0,0 +1,37 @@+import { readFileSync } from 'node:fs';+import { resolve } from 'node:path';++import { describe, expect, it } from 'vitest';++const pluginMotionCss = readFileSync(resolve(__dirname, '..', 'plugin-motion.css'), 'utf8');++describe('plugin motion design contracts', () => {+ it('separates collapsed plugin previews without an ad-hoc in-page shadow', () => {+ const previewCardRule = pluginMotionCss.match(+ /\.plugin-installed-preview-card\s*\{(?<body>[\s\S]*?)\}/,+ )?.groups?.body;++ expect(previewCardRule).toBeTruthy();+ expect(previewCardRule).toContain('background: var(--surface-elevated);');+ expect(previewCardRule).toContain('outline: 2px solid var(--surface-elevated);');+ expect(previewCardRule).not.toContain('box-shadow');+ expect(previewCardRule).not.toContain('color-mix');+ });++ it('wraps recommended filters against the actual catalog content width', () => {+ const contentQueryStart = pluginMotionCss.indexOf(+ '@container plugin-management-content (max-width: 720px)',+ );+ const layoutQueryStart = pluginMotionCss.indexOf(+ '@container plugin-management (max-width: 720px)',+ );+ const contentQuery = pluginMotionCss.slice(contentQueryStart, layoutQueryStart);++ expect(contentQueryStart).toBeGreaterThanOrEqual(0);+ expect(layoutQueryStart).toBeGreaterThan(contentQueryStart);+ expect(contentQuery).toContain('.plugin-catalog-toolbar');+ expect(contentQuery).toContain('flex-direction: column;');+ expect(contentQuery).toContain('.plugin-catalog-filters');+ expect(contentQuery).toContain('flex-wrap: wrap;');+ });+});diff --git a/apps/desktop/src/renderer/features/plugin/plugin-motion.css b/apps/desktop/src/renderer/features/plugin/plugin-motion.cssindex 634cc5f711..cd81635003 100644--- a/apps/desktop/src/renderer/features/plugin/plugin-motion.css+++ b/apps/desktop/src/renderer/features/plugin/plugin-motion.css@@ -92,14 +92,78 @@--plugin-motion-order: 8;}.plugin-motion-selected {+ background: color-mix(in srgb, var(--surface-elevated) 86%, transparent);+ border-color: color-mix(in srgb, var(--border-default) 48%, transparent);+ box-shadow: var(--plugin-card-shadow);animation: plugin-selection-settle var(--plugin-motion-state) var(--plugin-motion-ease-enter);}+/* Recommended filters use the shared selected surface without the elevated tab shadow. */+.plugin-catalog-filters .plugin-motion-selected {+ box-shadow: none;+}++/* Keep disclosure content mounted so collapse can ease out instead of jumping. */+.plugin-installed-overflow {+ display: grid;+ grid-template-rows: 0fr;+ opacity: 0;+ transform: translate3d(0, -6px, 0);+ transition:+ grid-template-rows var(--motion-base) var(--motion-ease-move),+ opacity var(--motion-base) var(--motion-ease-move),+ transform var(--motion-base) var(--motion-ease-move);+}++.plugin-installed-overflow[data-expanded='true'] {+ grid-template-rows: 1fr;+ opacity: 1;+ transform: translate3d(0, 0, 0);+}++.plugin-installed-overflow-clip {+ min-height: 0;+ overflow: hidden;+}++.plugin-installed-overflow-grid {+ padding-top: 0.75rem;+}++.plugin-installed-preview-stack {+ display: inline-flex;+ align-items: center;+ isolation: isolate;+}++.plugin-installed-preview-card {+ position: relative;+ display: inline-flex;+ width: 1.75rem;+ height: 1.75rem;+ margin-left: -0.45rem;+ border-radius: 0.75rem;+ background: var(--surface-elevated);+ outline: 2px solid var(--surface-elevated);+}++.plugin-installed-preview-card > span {+ border-radius: inherit;+}++.plugin-installed-preview-card:first-child {+ margin-left: 0;+}+/* Catalog chrome responds to the actual main pane, including when the sidebar stays open. */.plugin-management-layout-root {container: plugin-management / inline-size;}+.plugin-management-content-frame {+ container: plugin-management-content / inline-size;+}+.plugin-detail-frame {container: plugin-detail / inline-size;}@@ -141,23 +205,25 @@}}-@container plugin-management (max-width: 720px) {- .plugin-management-layout-root .plugin-catalog-toolbar {- align-items: stretch;- flex-direction: column;- gap: 0.75rem;+@container plugin-management-content (max-width: 720px) {+ .plugin-installed-card-grid {+ grid-template-columns: minmax(0, 1fr);}- .plugin-management-layout-root .plugin-catalog-filters {- width: 100%;- justify-content: space-between;- gap: 0.125rem;+ .plugin-catalog-toolbar {+ align-items: flex-start;+ flex-direction: column;+ gap: 0.75rem;}- .plugin-management-layout-root .plugin-catalog-filters > button {- padding-inline: 0.5rem;+ .plugin-catalog-filters {+ flex-wrap: wrap;+ justify-content: flex-start;+ width: auto;}+}+@container plugin-management (max-width: 720px) {.plugin-management-layout-root .plugin-management-header {height: 7rem;}@@ -221,8 +287,10 @@.plugin-motion-page-header,.plugin-motion-page-section,.plugin-motion-stagger > *,- .plugin-motion-selected+ .plugin-motion-selected,+ .plugin-installed-overflow) {animation: none !important;+ transition: none !important;}}diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.jsonindex 01bd5210a2..163c2da290 100644--- a/apps/desktop/src/renderer/i18n/locales/en/common.json+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json@@ -3163,6 +3163,8 @@"addPlugin": "Add plugin","addPluginAria": "Plugin add options","installedSection": "Installed",+ "installedExpand": "Show all {{count}} installed plugins",+ "installedCollapse": "Hide additional installed plugins","recommendedSection": "Recommended","updatesAvailable": "{{count}} plugin updates available","updateAll": "Update all",@@ -3202,10 +3204,12 @@},"install": "Install","details": "Details",+ "detailsAria": "View details for {{name}}","update": "Update from market","updateTo": "Update to v{{version}}","installed": "Installed","conflict": "Plugin ID conflict",+ "conflictAria": "{{name}} has a plugin ID conflict","unavailable": "The plugin market is temporarily unavailable. Installed plugins remain available.","authenticationRequired": "Sign in to Cindy to view the plugin market.","notConfigured": "The plugin market is not configured for this environment. Installed plugins remain available.",diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.jsonindex eba337e6b1..440ca4eba2 100644--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json@@ -3162,6 +3162,8 @@"addPlugin": "プラグインを追加","addPluginAria": "プラグイン追加オプション","installedSection": "インストール済み",+ "installedExpand": "インストール済みプラグイン {{count}} 件をすべて表示",+ "installedCollapse": "追加のインストール済みプラグインを隠す","recommendedSection": "おすすめ","updatesAvailable": "{{count}} 件のプラグイン更新があります","updateAll": "すべて更新",@@ -3201,10 +3203,12 @@},"install": "インストール","details": "詳細",+ "detailsAria": "{{name}} の詳細を表示","update": "マーケットから更新","updateTo": "v{{version}} に更新","installed": "インストール済み","conflict": "プラグイン ID の競合",+ "conflictAria": "{{name}} にプラグイン ID の競合があります","unavailable": "プラグインマーケットを一時的に利用できません。インストール済みプラグインは引き続き利用できます。","authenticationRequired": "プラグインマーケットを表示するには Cindy にログインしてください。","notConfigured": "この環境ではプラグインマーケットが設定されていません。インストール済みプラグインは引き続き利用できます。",diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.jsonindex 5db2697a03..2b86e66749 100644--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json@@ -3162,6 +3162,8 @@"addPlugin": "플러그인 추가","addPluginAria": "플러그인 추가 옵션","installedSection": "설치됨",+ "installedExpand": "설치된 플러그인 {{count}}개 모두 보기",+ "installedCollapse": "추가 설치 플러그인 숨기기","recommendedSection": "추천","updatesAvailable": "플러그인 업데이트 {{count}}개 사용 가능","updateAll": "모두 업데이트",@@ -3201,10 +3203,12 @@},"install": "설치","details": "상세",+ "detailsAria": "{{name}} 상세 보기","update": "마켓에서 업데이트","updateTo": "v{{version}}(으)로 업데이트","installed": "설치됨","conflict": "플러그인 ID 충돌",+ "conflictAria": "{{name}}에 플러그인 ID 충돌이 있습니다","unavailable": "플러그인 마켓을 일시적으로 사용할 수 없습니다. 설치된 플러그인은 계속 사용할 수 있습니다.","authenticationRequired": "플러그인 마켓을 보려면 Cindy에 로그인하세요.","notConfigured": "이 환경에는 플러그인 마켓이 구성되지 않았습니다. 설치된 플러그인은 계속 사용할 수 있습니다.",diff --git a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.jsonindex ccb579920b..fd49a558fd 100644--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json@@ -3162,6 +3162,8 @@"addPlugin": "添加插件","addPluginAria": "插件添加选项","installedSection": "已安装",+ "installedExpand": "展开全部 {{count}} 个已安装插件",+ "installedCollapse": "收起更多已安装插件","recommendedSection": "推荐","updatesAvailable": "{{count}} 个插件有可用更新","updateAll": "全部更新",@@ -3201,10 +3203,12 @@},"install": "安装","details": "详情",+ "detailsAria": "查看 {{name}} 的详情","update": "从市场更新","updateTo": "更新到 v{{version}}","installed": "已安装","conflict": "插件标识冲突",+ "conflictAria": "{{name}} 存在插件标识冲突","unavailable": "插件市场暂时不可用;已安装插件仍可正常管理和使用。","authenticationRequired": "登录 Cindy 后才能查看插件市场。","notConfigured": "当前环境未配置插件市场;已安装插件仍可正常管理和使用。",