Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

feat(plugins): 精简列表统计并统一详情头部指标

nana73b7cfc5a1d3
diff --git a/apps/desktop/src/renderer/features/plugin/GhostPluginDetailView.tsx b/apps/desktop/src/renderer/features/plugin/GhostPluginDetailView.tsx
index d8117bfad7..0f735f4c51 100644
--- a/apps/desktop/src/renderer/features/plugin/GhostPluginDetailView.tsx
+++ b/apps/desktop/src/renderer/features/plugin/GhostPluginDetailView.tsx
@@ -30,6 +30,8 @@ import { useTranslation } from 'react-i18next';
import { CindyCapabilityPrefs } from '@/cindy-brain/CindyCapabilityPrefs';
import { PluginUsageCard } from './PluginUsageCard';
+import { PluginSharedUsage } from './PluginSharedUsage';
+import type { PluginMarketItem } from '../../../shared/pluginMarket';
import { GhostLibrarySection } from './GhostLibrarySection';
import { PluginTaskPrefs } from '@/cindy-brain/PluginTaskPrefs';
import { GhostSettingsWebview } from '@/cindy-brain/GhostSettingsWebview';
@@ -63,6 +65,7 @@ import './plugin-motion.css';
interface GhostPluginDetailViewProps {
ghost: InstalledGhost | null;
detail: GhostPluginDetail;
+ marketItem?: PluginMarketItem | null;
panelStatus: string | null;
enabledOverride?: boolean;
onBack: () => void;
@@ -111,6 +114,7 @@ export function GhostPluginDetailView({
onBack,
onToggle,
onUse,
+ marketItem,
usageOwnerKey,
confirmClearUsage,
mainViewSidebarVisible = true,
@@ -238,11 +242,11 @@ export function GhostPluginDetailView({
size="detail"
onIconLoadError={onIconLoadError}
/>
- <div className="min-w-0">
+ <div className="plugin-detail-heading min-w-0">
<h1 className="truncate text-28 font-medium leading-[1.214] text-[var(--text-primary)]">
{detail.name}
</h1>
- <GhostPluginMetadata author={detail.author} version={detail.version} />
+ <GhostPluginMetadata author={detail.author} version={detail.version} marketItem={marketItem} />
</div>
<div
@@ -584,13 +588,15 @@ export function OauthScopeStaleBadge() {
export function GhostPluginMetadata({
author,
version,
+ marketItem,
}: {
author?: string | null;
version: string;
+ marketItem?: PluginMarketItem | null;
}) {
const { t } = useTranslation();
return (
- <div className="plugin-detail-metadata mt-2 flex min-w-0 flex-nowrap items-center gap-2 overflow-hidden whitespace-nowrap text-13 leading-5 text-[var(--text-tertiary)]">
+ <div className="plugin-detail-metadata mt-2 flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-13 leading-5 text-[var(--text-tertiary)]">
{author ? (
<>
<span className="min-w-0 truncate">
@@ -600,6 +606,7 @@ export function GhostPluginMetadata({
</>
) : null}
<span className="shrink-0">v{version}</span>
+ {marketItem ? <PluginSharedUsage detail={marketItem} /> : null}
</div>
);
}
diff --git a/apps/desktop/src/renderer/features/plugin/GhostPluginPage.tsx b/apps/desktop/src/renderer/features/plugin/GhostPluginPage.tsx
index 901dc67dac..13610f6984 100644
--- a/apps/desktop/src/renderer/features/plugin/GhostPluginPage.tsx
+++ b/apps/desktop/src/renderer/features/plugin/GhostPluginPage.tsx
@@ -26,7 +26,6 @@ import {
AlertTriangle,
ArrowUp,
Bot,
- Check,
ChevronDown,
ChevronRight,
MessageCircle,
@@ -130,6 +129,7 @@ import {
import { usePluginListScrollRestoration } from './lib/usePluginListScrollRestoration';
import { GhostPagePanelHost } from './GhostPagePanelHost';
import { GhostPluginDetailView } from './GhostPluginDetailView';
+import { PluginSharedUsage } from './PluginSharedUsage';
import {
currentMainViewVisibilityOwner,
readMainViewSidebarVisible,
@@ -167,6 +167,8 @@ type PluginPresentationFilter = 'all' | PluginPresentationOrigin;
type PresentedGhostPluginItem = GhostPluginListItem & {
origin: PluginPresentationOrigin;
+ marketItem: PluginMarketItem | null;
+ author: string | null;
/** 市场存在更新时的市场记录;列表卡片据此显示更新徽标与直达入口。 */
marketUpdate: PluginMarketItem | null;
};
@@ -744,6 +746,8 @@ export function GhostPluginPage({
return {
...toGhostPluginListItem(ghost, presentation),
origin: pluginPresentationOrigin(marketItem),
+ marketItem,
+ author: presentation?.author ?? ghost.manifest.author ?? null,
// 同版本展示刷新由 main 标成 installed;legacy-unresolved 仍保留
// update-available,以便用户用市场包替换未验证的本地字节。
marketUpdate: ghost.retirement ? null : pluginUpdateForInstalledVersion(marketItem),
@@ -1673,6 +1677,7 @@ export function GhostPluginPage({
confirmClearUsage={() => confirm({ title: t('settings.ghosts.usage.clearTitle'), description: t('settings.ghosts.usage.clearDescription'), confirmText: t('settings.ghosts.usage.clear'), confirmVariant: 'destructive' })}
ghost={selectedGhost}
detail={selectedDetail}
+ marketItem={selectedMarketInstall}
panelStatus={panelStatus}
enabledOverride={
selectedGhost
@@ -1860,6 +1865,8 @@ export function GhostPluginPage({
key={item.id}
item={item}
sourceLabel={t(`settings.ghosts.page.origin.${item.origin}`)}
+ marketItem={item.marketItem}
+ author={item.author}
updateVersion={item.marketUpdate?.version}
updateNeedsConsent={item.marketUpdate?.updateRequiresConsent === true}
updateBusy={
@@ -1890,6 +1897,8 @@ export function GhostPluginPage({
key={item.id}
item={item}
sourceLabel={t(`settings.ghosts.page.origin.${item.origin}`)}
+ marketItem={item.marketItem}
+ author={item.author}
updateVersion={item.marketUpdate?.version}
updateNeedsConsent={item.marketUpdate?.updateRequiresConsent === true}
updateBusy={
@@ -2156,6 +2165,7 @@ export function MarketPluginCard({
onIconLoadError: () => void;
}) {
const { t } = useTranslation();
+ const metadataId = useId();
const marketIcon = usePluginMarketIcon(item, { deferUntilVisible: true });
const unavailable = busy;
const replacementDescriptionId = useId();
@@ -2175,7 +2185,7 @@ export function MarketPluginCard({
onClick={onSelect}
disabled={unavailable}
aria-label={item.name}
- aria-describedby={replacementDescription ? replacementDescriptionId : undefined}
+ aria-describedby={replacementDescription ? `${metadataId} ${replacementDescriptionId}` : metadataId}
className={cn(
'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)]',
@@ -2194,26 +2204,17 @@ export function MarketPluginCard({
<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 id={metadataId} className="mt-1 flex min-w-0 flex-wrap items-center gap-x-1.5 gap-y-1 text-11 text-[var(--text-tertiary)]">
<span className="shrink-0">
{t(`settings.ghosts.page.origin.${pluginPresentationOrigin(item)}`)}
</span>
- <span className="shrink-0" aria-hidden="true">
- ·
- </span>
- <span className="shrink-0">v{item.version}</span>
- <span className="shrink-0" aria-hidden="true">
- ·
- </span>
- <span className="min-w-0 truncate font-mono">{item.ghostId}</span>
{item.author ? (
<>
- <span className="shrink-0" aria-hidden="true">
- ·
- </span>
- <span className="min-w-0 truncate">{item.author}</span>
+ <span aria-hidden="true">·</span>
+ <span className="min-w-0 max-w-[120px] truncate">{item.author}</span>
</>
) : null}
+ <PluginSharedUsage detail={item} variant="list" />
</span>
<span
id={replacementDescription ? replacementDescriptionId : undefined}
@@ -2369,6 +2370,8 @@ function GhostPluginActions({
export function GhostPluginCard({
item,
sourceLabel,
+ marketItem,
+ author,
updateVersion,
updateNeedsConsent = false,
updateBusy = false,
@@ -2381,6 +2384,8 @@ export function GhostPluginCard({
}: {
item: GhostPluginListItem;
sourceLabel?: string;
+ marketItem?: PluginMarketItem | null;
+ author?: string | null;
/** 市场存在新版本时的目标版本;与 onUpdate 同时提供。 */
updateVersion?: string;
/** 新版本权限变多、后台更新已暂停等用户确认(Main 按真实包判定)。 */
@@ -2395,6 +2400,7 @@ export function GhostPluginCard({
onIconLoadError?: () => void;
}) {
const { t } = useTranslation();
+ const metadataId = useId();
const enabled = effectiveEnabled ?? item.enabled;
// 未读(badge 槽):单条卡片走**呼吸**点(AttentionDot 形态规范——聚合入口
// 静态、单条呼吸)。有摘要时顶替静态描述:用户扫一眼就知道新内容是什么。
@@ -2446,6 +2452,7 @@ export function GhostPluginCard({
onClick={onManage}
onKeyDown={handleCardKeyDown}
aria-label={item.name}
+ aria-describedby={metadataId}
className={cn(
'group flex min-h-[108px] w-full cursor-pointer select-none items-start gap-4 rounded-xl border-[0.5px] border-[var(--border-default)] bg-[var(--surface-elevated)] p-4 text-left',
'transition-[background-color,border-color,transform] duration-150 ease-out',
@@ -2469,8 +2476,15 @@ export function GhostPluginCard({
</span>
{item.retirement?.unread ? <AttentionDot tone="awaiting" size={6} className="mt-px" /> : 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}
+ <span id={metadataId} className="mt-1 flex min-w-0 flex-wrap items-center gap-x-1.5 gap-y-1 text-11 text-[var(--text-tertiary)]">
+ {sourceLabel ? <span className="shrink-0">{sourceLabel}</span> : null}
+ {author ? (
+ <>
+ {sourceLabel ? <span aria-hidden="true">·</span> : null}
+ <span className="min-w-0 max-w-[120px] truncate">{author}</span>
+ </>
+ ) : null}
+ {marketItem ? <PluginSharedUsage detail={marketItem} variant="list" /> : null}
{item.retirement ? (
<span> · {t('settings.ghosts.retirement.status')}</span>
) : item.oauthAuthorizationExpired ? (
@@ -2479,12 +2493,6 @@ export function GhostPluginCard({
<AlertTriangle size={11} className="inline" aria-hidden="true" />
<span>{t('settings.ghosts.page.oauthAuthorizationExpired')}</span>
</span>
- ) : !updateVersion ? (
- <span className="inline-flex items-center gap-1">
- {' · '}
- <Check size={11} className="inline" aria-hidden="true" />
- {t('settings.ghosts.page.upToDate')}
- </span>
) : updateNeedsConsent ? (
<span className="inline-flex items-center gap-1 text-[var(--text-secondary)]">
{' · '}
diff --git a/apps/desktop/src/renderer/features/plugin/MarketPluginDetailView.tsx b/apps/desktop/src/renderer/features/plugin/MarketPluginDetailView.tsx
index d5e38e06c3..e417fe75d2 100644
--- a/apps/desktop/src/renderer/features/plugin/MarketPluginDetailView.tsx
+++ b/apps/desktop/src/renderer/features/plugin/MarketPluginDetailView.tsx
@@ -70,11 +70,11 @@ export function MarketPluginDetailView({
onIconLoadError={() => marketIcon.onIconLoadError(onIconLoadError)}
size="detail"
/>
- <div className="min-w-0">
+ <div className="plugin-detail-heading min-w-0">
<h1 className="truncate text-28 font-medium leading-[1.214] text-[var(--text-primary)]">
{detail.name}
</h1>
- <div className="mt-1.5 flex flex-wrap items-center gap-2 text-12 text-[var(--text-tertiary)]">
+ <div className="plugin-detail-metadata mt-1.5 flex min-w-0 flex-wrap items-center gap-2 text-12 text-[var(--text-tertiary)]">
<span>{t(`settings.ghosts.market.scope.${presentationOrigin}`)}</span>
<span aria-hidden="true">·</span>
<span>v{detail.version}</span>
@@ -99,7 +99,7 @@ export function MarketPluginDetailView({
aria-label={t(actionKey)}
aria-busy={busy || undefined}
aria-describedby={replacementDescription ? replacementDescriptionId : undefined}
- className="plugin-detail-primary-action min-w-[104px] whitespace-nowrap"
+ className="plugin-detail-actions plugin-detail-primary-action min-w-[104px] whitespace-nowrap"
>
<Download size={15} aria-hidden="true" />
{t(actionKey)}
diff --git a/apps/desktop/src/renderer/features/plugin/PluginSharedUsage.tsx b/apps/desktop/src/renderer/features/plugin/PluginSharedUsage.tsx
index 68d1612d2d..02c258f20e 100644
--- a/apps/desktop/src/renderer/features/plugin/PluginSharedUsage.tsx
+++ b/apps/desktop/src/renderer/features/plugin/PluginSharedUsage.tsx
@@ -1,29 +1,61 @@
-import { ArrowDownToLine } from 'lucide-react';
+import { Activity, ArrowDownToLine } from 'lucide-react';
import { useTranslation } from 'react-i18next';
import { Tip } from '@/components/ui/tooltip';
import type { PluginMarketItem } from '../../../shared/pluginMarket';
-/** Only server-authorized download counts; custom public flags never grant shared statistics. */
-export function PluginSharedUsage({ detail }: { detail: PluginMarketItem }) {
+/** Shared counters from the authorized server catalog; personal/custom sources never grant access. */
+export function PluginSharedUsage({
+ detail,
+ variant = 'detail',
+}: {
+ detail: PluginMarketItem;
+ variant?: 'detail' | 'list';
+}) {
const { t, i18n } = useTranslation();
if (detail.sourceType !== 'server' || detail.scope === 'personal') return null;
- const downloads = detail.downloadStatistics;
- if (!downloads) return null;
- return (
- <>
- <span aria-hidden="true">·</span>
- <Tip text={t('settings.ghosts.usage.downloadExplanation')}>
- <button
- type="button"
- className="inline-flex min-h-7 items-center gap-1 rounded-full focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)]"
- >
- <ArrowDownToLine size={12} aria-hidden="true" />
- <span>
- {t('settings.ghosts.usage.downloads')}{' '}
- {BigInt(downloads.requestCount).toLocaleString(i18n.language)}
+ const metrics = [
+ ...(detail.downloadStatistics
+ ? [
+ {
+ key: 'downloadsValue',
+ count: detail.downloadStatistics.requestCount,
+ explanation: 'downloadExplanation',
+ Icon: ArrowDownToLine,
+ },
+ ]
+ : []),
+ ...(variant === 'detail' && detail.usageStatistics?.usageCount !== undefined
+ ? [
+ {
+ key: 'usesValue',
+ count: detail.usageStatistics.usageCount,
+ explanation: 'usesExplanation',
+ Icon: Activity,
+ },
+ ]
+ : []),
+ ];
+ return metrics.map(({ key, count, explanation, Icon }) => {
+ const label = t(`settings.ghosts.usage.${key}`, {
+ value: BigInt(count).toLocaleString(i18n.language),
+ });
+ const description = t(`settings.ghosts.usage.${explanation}`);
+ return (
+ <span key={key} className="inline-flex max-w-full items-center gap-1.5">
+ <span aria-hidden="true">·</span>
+ <Tip text={description}>
+ <span
+ role="group"
+ aria-label={label}
+ aria-description={description}
+ tabIndex={variant === 'detail' ? 0 : undefined}
+ className={`inline-flex min-w-0 items-center gap-1 rounded-full tabular-nums focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)] ${variant === 'detail' ? '-mx-1 min-h-7 px-1' : ''}`}
+ >
+ <Icon size={12} className="shrink-0" aria-hidden="true" />
+ <span className="break-words [overflow-wrap:anywhere]">{label}</span>
</span>
- </button>
- </Tip>
- </>
- );
+ </Tip>
+ </span>
+ );
+ });
}
diff --git a/apps/desktop/src/renderer/features/plugin/PluginUsageCard.tsx b/apps/desktop/src/renderer/features/plugin/PluginUsageCard.tsx
index ef9a44d36e..baa871b2a2 100644
--- a/apps/desktop/src/renderer/features/plugin/PluginUsageCard.tsx
+++ b/apps/desktop/src/renderer/features/plugin/PluginUsageCard.tsx
@@ -1,14 +1,7 @@
import { useCallback, useEffect, useId, useState } from 'react';
import { useTranslation } from 'react-i18next';
-import { MoreHorizontal } from 'lucide-react';
import { Button } from '@/components/ui/button';
import { Tip } from '@/components/ui/tooltip';
-import {
- DropdownMenu,
- DropdownMenuContent,
- DropdownMenuItem,
- DropdownMenuTrigger,
-} from '@/components/ui/dropdown-menu';
import type { PluginUsageSummary } from '../../../shared/pluginUsage';
export function PluginUsageCard({
@@ -57,9 +50,10 @@ export function PluginUsageCard({
}
};
const clear = async () => {
- if (!summary || clearing || !(await confirmClear?.())) return;
+ if (!summary || clearing || !confirmClear) return;
setClearing(true);
try {
+ if (!(await confirmClear())) return;
await window.electronAPI.ghosts.clearUsage(summary.subjectId);
await refresh();
} catch {
@@ -94,35 +88,22 @@ export function PluginUsageCard({
</button>
</Tip>
</h2>
- <DropdownMenu>
- <Tip text={t('settings.ghosts.usage.more')}>
- <DropdownMenuTrigger asChild>
- <button
- type="button"
- aria-label={t('settings.ghosts.usage.more')}
- className="-mr-1 flex h-7 w-7 items-center justify-center rounded-full text-[var(--text-tertiary)] hover:bg-[var(--surface-hover)] focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)]"
- >
- <MoreHorizontal size={16} aria-hidden="true" />
- </button>
- </DropdownMenuTrigger>
- </Tip>
- <DropdownMenuContent align="end">
- <DropdownMenuItem
- disabled={state === 'loading' || clearing}
- onSelect={() => void refresh()}
- >
- {t('settings.ghosts.usage.refresh')}
- </DropdownMenuItem>
- {summary && confirmClear ? (
- <DropdownMenuItem
- disabled={state === 'loading' || clearing}
- onSelect={() => void clear()}
- >
- {t('settings.ghosts.usage.clear')}
- </DropdownMenuItem>
- ) : null}
- </DropdownMenuContent>
- </DropdownMenu>
+ {confirmClear ? (
+ <Button
+ variant="secondary"
+ tone="quiet"
+ size="sm"
+ compact
+ type="button"
+ disabled={!summary || state !== 'ready' || clearing}
+ loading={clearing}
+ onClick={() => void clear()}
+ aria-label={t('settings.ghosts.usage.clear')}
+ className="-mr-3 shrink-0"
+ >
+ {t('settings.ghosts.usage.clearAction')}
+ </Button>
+ ) : null}
</div>
{state === 'loading' ? (
<p aria-live="polite" className="mt-3 text-13 leading-5 text-[var(--text-secondary)]">
@@ -149,7 +130,7 @@ export function PluginUsageCard({
: time(summary.lastUsedAt)}
</dd>
</div>
- <div className="min-w-0 border-l border-[var(--border-default)] pl-5">
+ <div className="min-w-0">
<dt className="text-12 leading-[1.5] text-[var(--text-secondary)]">
{t('settings.ghosts.usage.last7Days')}
</dt>
diff --git a/apps/desktop/src/renderer/features/plugin/__tests__/GhostPluginCard.test.tsx b/apps/desktop/src/renderer/features/plugin/__tests__/GhostPluginCard.test.tsx
index 7e95b4857f..635c80ca55 100644
--- a/apps/desktop/src/renderer/features/plugin/__tests__/GhostPluginCard.test.tsx
+++ b/apps/desktop/src/renderer/features/plugin/__tests__/GhostPluginCard.test.tsx
@@ -12,12 +12,13 @@ import { afterEach, describe, expect, it, vi } from 'vitest';
vi.mock('react-i18next', () => ({
useTranslation: () => ({
- t: (key: string, options?: { name?: string }) =>
+ t: (key: string, options?: { name?: string; value?: string }) =>
(key === 'settings.ghosts.market.detailsAria' ||
key === 'settings.ghosts.market.replaceAria') &&
options?.name
? `${key}:${options.name}`
- : key,
+ : options?.value !== undefined ? `${options.value} ${key}` : key,
+ i18n: { language: 'en' },
}),
// 页面经批量更新控制器引 @/i18n,其 init 链路需要这些导出。
initReactI18next: { type: '3rdParty', init: vi.fn() },
@@ -638,25 +639,33 @@ describe('MarketPluginCard', () => {
).toBeTruthy();
});
- it('keeps fixed market metadata on one line while truncating long identities', () => {
- render(
+ it('shows scope, author and downloads without crowding the list with version or machine id', () => {
+ const { container } = render(
<MarketPluginCard
- item={marketPlugin}
+ item={{ ...marketPlugin, downloadStatistics: { requestCount: '12480' } }}
busy={false}
onSelect={vi.fn()}
onIconLoadError={vi.fn()}
/>,
);
-
- const origin = screen.getByText('settings.ghosts.page.origin.public');
- const metadata = origin.parentElement;
- expect(metadata?.className).toContain('whitespace-nowrap');
- expect(metadata?.className).toContain('overflow-hidden');
- expect(origin.className).toContain('shrink-0');
- expect(screen.getByText('v1.3.11').className).toContain('shrink-0');
- expect(screen.getByText('google-calendar').className).toContain('truncate');
- expect(screen.getByText('google-calendar').className).toContain('min-w-0');
- expect(screen.getByText('Cindy').className).toContain('truncate');
+ const metadata = screen.getByText('settings.ghosts.page.origin.public').parentElement;
+ expect(metadata?.textContent).toBe('settings.ghosts.page.origin.public·Cindy·12,480 settings.ghosts.usage.downloadsValue');
+ expect(screen.queryByText('v1.3.11')).toBeNull();
+ expect(screen.queryByText('google-calendar')).toBeNull();
+ expect(container.querySelector('button button')).toBeNull();
+ });
+
+ it('keeps shared downloads in installed cards alongside exceptional authorization status', () => {
+ render(<GhostPluginCard
+ item={{ ...commandPlugin, oauthAuthorizationExpired: true }}
+ author="Cindy"
+ sourceLabel="Public"
+ marketItem={{ ...marketPlugin, downloadStatistics: { requestCount: '0' } }}
+ onPrimary={vi.fn()} onManage={vi.fn()}
+ />);
+ expect(screen.getByText('0 settings.ghosts.usage.downloadsValue')).toBeTruthy();
+ expect(screen.getByText('settings.ghosts.page.oauthAuthorizationExpired')).toBeTruthy();
+ expect(screen.queryByText('v1.0.0')).toBeNull();
});
it('offers explicit replacement while still blocking actions during busy operations', () => {
@@ -677,7 +686,7 @@ describe('MarketPluginCard', () => {
expect(cardBody.className).not.toContain('cursor-wait');
const replacementDescription = screen.getByText('settings.ghosts.market.replaceDescription');
expect(replacementDescription.id).toBeTruthy();
- expect(cardBody.getAttribute('aria-describedby')).toBe(replacementDescription.id);
+ expect(cardBody.getAttribute('aria-describedby')?.split(' ')).toContain(replacementDescription.id);
const replaceAction = screen.getByRole('button', {
name: 'settings.ghosts.market.replaceAria:Google Calendar',
});
diff --git a/apps/desktop/src/renderer/features/plugin/__tests__/GhostPluginDetailSections.test.tsx b/apps/desktop/src/renderer/features/plugin/__tests__/GhostPluginDetailSections.test.tsx
index 539afcbafe..8f243f6482 100644
--- a/apps/desktop/src/renderer/features/plugin/__tests__/GhostPluginDetailSections.test.tsx
+++ b/apps/desktop/src/renderer/features/plugin/__tests__/GhostPluginDetailSections.test.tsx
@@ -83,8 +83,9 @@ vi.mock('react-i18next', () => ({
'settings.ghosts.detail.oauthScopeStale':
'This authorization does not include newly added permissions. Reconnect to enable them.',
};
- return labels[key] ?? key;
+ return labels[key] ?? (options?.value !== undefined ? `${options.value} ${key}` : key);
},
+ i18n: { language: 'en' },
}),
}));
@@ -1434,3 +1435,14 @@ describe('Ghost plugin detail sections', () => {
).toBeTruthy();
});
});
+
+it('adds shared counts to installed detail metadata while preserving author and version', () => {
+ const { container } = render(<GhostPluginMetadata author="Cindy" version="1.7.5" marketItem={{
+ sourceType: 'server', scope: 'organization',
+ downloadStatistics: { requestCount: '1284' },
+ usageStatistics: { usageCount: '8932', usageCountLast7Days: '12', asOf: '2026-10-13T00:00:00Z' },
+ } as import('../../../../shared/pluginMarket').PluginMarketItem} />);
+ expect(container.textContent).toContain('By Cindy·v1.7.5');
+ expect(container.textContent).toContain('1,284 settings.ghosts.usage.downloadsValue');
+ expect(container.textContent).toContain('8,932 settings.ghosts.usage.usesValue');
+});
diff --git a/apps/desktop/src/renderer/features/plugin/__tests__/MarketPluginDetailView.test.tsx b/apps/desktop/src/renderer/features/plugin/__tests__/MarketPluginDetailView.test.tsx
index cbfe6adbe7..bb15221b5c 100644
--- a/apps/desktop/src/renderer/features/plugin/__tests__/MarketPluginDetailView.test.tsx
+++ b/apps/desktop/src/renderer/features/plugin/__tests__/MarketPluginDetailView.test.tsx
@@ -9,7 +9,7 @@ import { render, screen } from '@testing-library/react';
import { describe, expect, it, vi } from 'vitest';
vi.mock('react-i18next', () => ({
- useTranslation: () => ({ t: (key: string) => key }),
+ useTranslation: () => ({ t: (key: string, options?: { value?: string }) => options?.value !== undefined ? `${options.value} ${key}` : key, i18n: { language: 'en' } }),
}));
import { MarketPluginDetailView } from '../MarketPluginDetailView';
@@ -58,6 +58,18 @@ const renderDetail = (overrides: Partial<PluginMarketDetail> = {}) =>
);
describe('MarketPluginDetailView', () => {
+ it('shows real download and use counts in the gray header of an uninstalled plugin', () => {
+ const { container } = renderDetail({
+ downloadStatistics: { requestCount: '0' },
+ usageStatistics: { usageCount: '8932', usageCountLast7Days: '12', asOf: '2026-10-13T00:00:00Z' },
+ });
+ const header = container.querySelector('header');
+ expect(header?.textContent).toContain('v1.3.11');
+ expect(header?.textContent).toContain('0 settings.ghosts.usage.downloadsValue');
+ expect(header?.textContent).toContain('8,932 settings.ghosts.usage.usesValue');
+ expect(container.textContent).not.toContain('settings.ghosts.usage.title');
+ });
+
it('shows the marketing description outside the conflict state', () => {
renderDetail();
const description = screen.getByText('Connect Google Calendar');
diff --git a/apps/desktop/src/renderer/features/plugin/__tests__/PluginUsageCard.test.tsx b/apps/desktop/src/renderer/features/plugin/__tests__/PluginUsageCard.test.tsx
index a86e422909..5333cec5b8 100644
--- a/apps/desktop/src/renderer/features/plugin/__tests__/PluginUsageCard.test.tsx
+++ b/apps/desktop/src/renderer/features/plugin/__tests__/PluginUsageCard.test.tsx
@@ -6,7 +6,11 @@ import { PluginSharedUsage } from '../PluginSharedUsage';
import type { PluginUsageSummary } from '../../../../shared/pluginUsage';
import type { PluginMarketItem } from '../../../../shared/pluginMarket';
vi.mock('react-i18next', () => ({
- useTranslation: () => ({ t: (key: string) => key, i18n: { language: 'en' } }),
+ useTranslation: () => ({
+ t: (key: string, options?: { value?: string }) =>
+ options?.value !== undefined ? `${options.value} ${key}` : key,
+ i18n: { language: 'en' },
+ }),
}));
afterEach(cleanup);
const summary: PluginUsageSummary = {
@@ -27,19 +31,16 @@ function api(load = vi.fn(async () => summary)) {
});
return { load, clear };
}
-it('shows only two personal metrics and clears from the menu after confirmation', async () => {
+it('shows two personal metrics with a direct clear action after confirmation', async () => {
const { load, clear } = api();
const confirm = vi.fn(async () => true);
render(<PluginUsageCard ghostId="plugin" confirmClear={confirm} />);
await screen.findByText('7');
expect(screen.queryByText('Current title')).toBeNull();
expect(screen.queryByText('settings.ghosts.usage.tasks')).toBeNull();
- expect(screen.queryByText('settings.ghosts.usage.clear')).toBeNull();
- fireEvent.keyDown(screen.getByRole('button', { name: 'settings.ghosts.usage.more' }), {
- key: 'Enter',
- });
- await screen.findByRole('menuitem', { name: 'settings.ghosts.usage.clear' });
- fireEvent.click(screen.getByText('settings.ghosts.usage.clear'));
+ expect(screen.queryByRole('menuitem')).toBeNull();
+ expect(screen.queryByRole('button', { name: 'settings.ghosts.usage.more' })).toBeNull();
+ fireEvent.click(screen.getByRole('button', { name: 'settings.ghosts.usage.clear' }));
await waitFor(() => expect(clear).toHaveBeenCalledWith('subject1'));
await waitFor(() => expect(load).toHaveBeenCalledTimes(2));
});
@@ -47,12 +48,13 @@ it('cancelled confirmation never deletes records', async () => {
const { clear } = api();
render(<PluginUsageCard ghostId="plugin" confirmClear={async () => false} />);
await screen.findByText('7');
- fireEvent.keyDown(screen.getByRole('button', { name: 'settings.ghosts.usage.more' }), {
- key: 'Enter',
- });
- await screen.findByRole('menuitem', { name: 'settings.ghosts.usage.clear' });
- fireEvent.click(screen.getByText('settings.ghosts.usage.clear'));
- await Promise.resolve();
+ fireEvent.click(screen.getByRole('button', { name: 'settings.ghosts.usage.clear' }));
+ await waitFor(() =>
+ expect(
+ (screen.getByRole('button', { name: 'settings.ghosts.usage.clear' }) as HTMLButtonElement)
+ .disabled,
+ ).toBe(false),
+ );
expect(clear).not.toHaveBeenCalled();
});
it('distinguishes unavailable from actual zero with no invented usage', async () => {
@@ -74,97 +76,106 @@ it('distinguishes unavailable from actual zero with no invented usage', async ()
await screen.findByText('settings.ghosts.usage.never');
expect(screen.getByText('0')).toBeTruthy();
});
-it('hides shared usage and legacy installations when download data is absent', () => {
- const detail = { sourceType: 'server', scope: 'public' } as PluginMarketItem;
- const view = render(<PluginSharedUsage detail={detail} />);
- expect(view.container.childElementCount).toBe(0);
+it('does not dispatch a clear while confirmation is pending', async () => {
+ const { clear } = api();
+ let answer!: (confirmed: boolean) => void;
+ const confirm = vi.fn(
+ () =>
+ new Promise<boolean>((resolve) => {
+ answer = resolve;
+ }),
+ );
+ render(<PluginUsageCard ghostId="plugin" confirmClear={confirm} />);
+ await screen.findByText('7');
+ const button = screen.getByRole('button', { name: 'settings.ghosts.usage.clear' });
+ fireEvent.click(button);
+ fireEvent.click(button);
+ expect(confirm).toHaveBeenCalledTimes(1);
+ expect((button as HTMLButtonElement).disabled).toBe(true);
+ expect(clear).not.toHaveBeenCalled();
+ answer(false);
+ await waitFor(() => expect((button as HTMLButtonElement).disabled).toBe(false));
+ expect(clear).not.toHaveBeenCalled();
+});
+
+const shared = {
+ sourceType: 'server',
+ scope: 'public',
+ downloadStatistics: { requestCount: '12' },
+ usageStatistics: { usageCount: '10', usageCountLast7Days: '5', asOf: '2026-10-13T00:00:00Z' },
+} as PluginMarketItem;
+
+it('hides absent metrics independently without inventing zero', () => {
+ const view = render(
+ <PluginSharedUsage
+ detail={{ ...shared, downloadStatistics: undefined, usageStatistics: undefined }}
+ />,
+ );
+ expect(view.container.textContent).toBe('');
view.rerender(
<PluginSharedUsage
detail={{
- ...detail,
- usageStatistics: {
- installationCount: '0',
- usageCount: '10',
- usageCountLast7Days: '5',
- asOf: '2026-10-12T00:00:00.000Z',
- },
+ ...shared,
+ downloadStatistics: undefined,
+ usageStatistics: { usageCountLast7Days: '5', asOf: '2026-10-13T00:00:00Z' },
}}
/>,
);
- expect(view.container.childElementCount).toBe(0);
- view.rerender(<PluginSharedUsage detail={detail} />);
- expect(view.container.childElementCount).toBe(0);
+ expect(view.container.textContent).toBe('');
+ view.rerender(<PluginSharedUsage detail={{ ...shared, downloadStatistics: undefined }} />);
+ expect(screen.getByText('10 settings.ghosts.usage.usesValue')).toBeTruthy();
+ expect(view.container.textContent).not.toContain('downloadsValue');
+ view.rerender(<PluginSharedUsage detail={{ ...shared, usageStatistics: undefined }} />);
+ expect(screen.getByText('12 settings.ghosts.usage.downloadsValue')).toBeTruthy();
+ expect(view.container.textContent).not.toContain('usesValue');
+ expect(view.container.textContent?.match(/·/g)).toHaveLength(1);
});
+
it.each([
['git-market', 'public'],
+ ['local-market', 'public'],
['server', 'personal'],
])('hides aggregates outside the authorized scope (%s, %s)', (sourceType, scope) => {
- const detail = {
- sourceType,
- scope,
- downloadStatistics: { requestCount: '12' },
- usageStatistics: {
- installationCount: '12',
- usageCount: '10',
- usageCountLast7Days: '5',
- asOf: '2026-10-12T00:00:00.000Z',
- },
- } as PluginMarketItem;
- const view = render(<PluginSharedUsage detail={detail} />);
- expect(view.container.textContent).toBe('');
-});
-
-it('does not expose aggregate calls in the marketplace header', () => {
- const detail = {
- sourceType: 'server',
- scope: 'public',
- usageStatistics: {
- usageCount: '0',
- usageCountLast7Days: '0',
- asOf: '2026-10-12T00:00:00.000Z',
- },
- } as PluginMarketItem;
- const view = render(<PluginSharedUsage detail={detail} />);
- expect(view.container.childElementCount).toBe(0);
- expect(view.container.textContent).not.toContain('installs');
- view.rerender(
- <PluginSharedUsage
- detail={{
- ...detail,
- usageStatistics: {
- usageCountLast7Days: '3',
- asOf: '2026-10-12T00:00:00.000Z',
- },
- }}
- />,
+ const view = render(
+ <PluginSharedUsage detail={{ ...shared, sourceType, scope } as PluginMarketItem} />,
);
- expect(view.container.childElementCount).toBe(0);
+ expect(view.container.textContent).toBe('');
});
it.each(['public', 'organization'] as const)(
- 'shows only the cumulative download value in %s without invented installs or usage',
+ 'shows exact cumulative shared metrics in %s',
(scope) => {
- const detail = {
- sourceType: 'server',
- scope,
- downloadStatistics: { requestCount: '123456', last7DaysRequestCount: '12' },
- } as PluginMarketItem;
- const view = render(<PluginSharedUsage detail={detail} />);
- expect(screen.getByText('settings.ghosts.usage.downloads 123,456')).toBeTruthy();
- expect(view.container.textContent).not.toContain('installs');
- expect(view.container.textContent).not.toContain('uses');
+ const view = render(<PluginSharedUsage detail={{ ...shared, scope }} />);
+ expect(screen.getByText('12 settings.ghosts.usage.downloadsValue')).toBeTruthy();
+ expect(screen.getByText('10 settings.ghosts.usage.usesValue')).toBeTruthy();
expect(view.container.textContent).not.toContain('last7Days');
- view.rerender(
- <PluginSharedUsage detail={{ ...detail, downloadStatistics: { requestCount: '0' } }} />,
- );
- expect(screen.getByText('settings.ghosts.usage.downloads 0')).toBeTruthy();
- view.rerender(
- <PluginSharedUsage
- detail={{ ...detail, downloadStatistics: { requestCount: '18446744073709551615' } }}
- />,
- );
- expect(
- screen.getByText('settings.ghosts.usage.downloads 18,446,744,073,709,551,615'),
- ).toBeTruthy();
+ expect(view.container.textContent).not.toContain('installs');
+ for (const count of ['0', '18446744073709551615']) {
+ view.rerender(
+ <PluginSharedUsage
+ detail={{
+ ...shared,
+ scope,
+ downloadStatistics: { requestCount: count },
+ usageStatistics: { ...shared.usageStatistics!, usageCount: count },
+ }}
+ />,
+ );
+ const formatted = BigInt(count).toLocaleString('en');
+ expect(screen.getByText(`${formatted} settings.ghosts.usage.downloadsValue`)).toBeTruthy();
+ expect(screen.getByText(`${formatted} settings.ghosts.usage.usesValue`)).toBeTruthy();
+ }
},
);
+
+it('shows download-only list metadata inside a card without nesting a button', () => {
+ const view = render(
+ <button type="button">
+ <PluginSharedUsage detail={shared} variant="list" />
+ </button>,
+ );
+ expect(screen.getByText('12 settings.ghosts.usage.downloadsValue')).toBeTruthy();
+ expect(view.container.textContent).not.toContain('usesValue');
+ expect(view.container.querySelectorAll('button')).toHaveLength(1);
+ expect(view.container.querySelector('[tabindex]')).toBeNull();
+});
diff --git a/apps/desktop/src/renderer/features/plugin/plugin-motion.css b/apps/desktop/src/renderer/features/plugin/plugin-motion.css
index 85cfd4769d..506ac9c756 100644
--- a/apps/desktop/src/renderer/features/plugin/plugin-motion.css
+++ b/apps/desktop/src/renderer/features/plugin/plugin-motion.css
@@ -97,9 +97,26 @@
}
}
-@container plugin-detail (max-width: 420px) {
+@container plugin-detail (max-width: 520px) {
+ .plugin-detail-frame .plugin-detail-heading {
+ display: contents;
+ }
+
+ .plugin-detail-frame .plugin-detail-heading > h1 {
+ grid-column: 2;
+ grid-row: 1;
+ align-self: center;
+ }
+
+ .plugin-detail-frame .plugin-detail-actions {
+ grid-column: 3;
+ grid-row: 1;
+ }
+
.plugin-detail-frame .plugin-detail-metadata {
- display: none;
+ grid-column: 1 / -1;
+ grid-row: 2;
+ margin-top: 0;
}
}
diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.json
index fae80aa43a..21783a741d 100644
--- a/apps/desktop/src/renderer/i18n/locales/en/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json
@@ -6723,7 +6723,11 @@
"downloads": "Downloads",
"downloadExplanation": "Cumulative download URL requests. Each successfully issued package URL counts once, including updates, reinstalls and retries that request a new URL. This is not a count of completed installations.",
"refresh": "Refresh records",
- "more": "Record options"
+ "more": "Record options",
+ "clearAction": "Clear",
+ "downloadsValue": "{{value}} downloads",
+ "usesValue": "{{value}} uses",
+ "usesExplanation": "Cumulative shared tool calls across all releases in the authorized audience. Your calls below count only this account on this computer."
}
},
"mcp": {
diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.json
index 1d24dc56a5..4bc5a770f8 100644
--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json
@@ -6698,7 +6698,11 @@
"downloads": "ダウンロード",
"downloadExplanation": "ダウンロード URL の累計リクエスト数です。パッケージ URL の発行成功ごとに 1 回と数え、更新、再インストール、新しい URL を取得する再試行も含みます。インストール成功数ではありません。",
"refresh": "記録を更新",
- "more": "記録のオプション"
+ "more": "記録のオプション",
+ "clearAction": "消去",
+ "downloadsValue": "{{value}} ダウンロード",
+ "usesValue": "{{value}} 利用",
+ "usesExplanation": "許可された共有範囲の全バージョンにおける累計ツール呼び出し数です。下の個人の呼び出しは、この端末の現在のアカウントのみを集計します。"
}
},
"mcp": {
diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.json
index 0aabb3bc10..3e128397de 100644
--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json
@@ -6698,7 +6698,11 @@
"downloads": "다운로드",
"downloadExplanation": "누적 다운로드 URL 요청 수입니다. 패키지 URL 발급 성공마다 1회로 집계하며 업데이트, 재설치, 새 URL을 요청하는 재시도도 포함합니다. 설치 완료 횟수가 아닙니다.",
"refresh": "기록 새로고침",
- "more": "기록 옵션"
+ "more": "기록 옵션",
+ "clearAction": "지우기",
+ "downloadsValue": "{{value}} 다운로드",
+ "usesValue": "{{value}} 사용",
+ "usesExplanation": "허용된 공유 범위의 모든 버전에서 누적된 도구 호출 수입니다. 아래 내 호출은 이 컴퓨터의 현재 계정만 집계합니다."
}
},
"mcp": {
diff --git a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
index 3a6b7403b8..f7c1bf770f 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
@@ -6698,7 +6698,11 @@
"downloads": "下载",
"downloadExplanation": "累计下载请求次数:成功获取安装包下载地址后计一次,包括更新、重装及重新获取地址的重试;不代表成功安装次数。",
"refresh": "刷新记录",
- "more": "记录选项"
+ "more": "记录选项",
+ "clearAction": "清除",
+ "downloadsValue": "{{value}} 下载",
+ "usesValue": "{{value}} 使用",
+ "usesExplanation": "当前共享范围内各版本累计的工具调用次数。下方个人调用仅统计本机当前账户,口径不同。"
}
},
"mcp": {
diff --git a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
index ea031abcc8..d1ee190d92 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
@@ -6698,7 +6698,11 @@
"downloads": "下載",
"downloadExplanation": "累計下載請求次數:成功取得安裝包下載位址後計一次,包括更新、重新安裝及重新取得位址的重試;不代表成功安裝次數。",
"refresh": "重新整理記錄",
- "more": "記錄選項"
+ "more": "記錄選項",
+ "clearAction": "清除",
+ "downloadsValue": "{{value}} 下載",
+ "usesValue": "{{value}} 使用",
+ "usesExplanation": "目前共享範圍內各版本累計的工具呼叫次數。下方個人呼叫僅統計本機目前帳戶,口徑不同。"
}
},
"mcp": {