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。

fix(plugin-market): clarify ID conflict availability (#1685)

Chris Zhang2249e6ce0456
diff --git a/apps/desktop/src/renderer/features/plugin/GhostPluginPage.tsx b/apps/desktop/src/renderer/features/plugin/GhostPluginPage.tsx
index dba29f54b0..39cc93c848 100644
--- a/apps/desktop/src/renderer/features/plugin/GhostPluginPage.tsx
+++ b/apps/desktop/src/renderer/features/plugin/GhostPluginPage.tsx
@@ -1914,6 +1914,11 @@ export function MarketPluginCard({
}) {
const { t } = useTranslation();
const unavailable = busy || item.installState === 'conflict';
+ const conflictDescriptionId = useId();
+ const conflictDescription =
+ item.installState === 'conflict'
+ ? t('settings.ghosts.market.conflictDescription')
+ : undefined;
return (
<article
className={cn(
@@ -1928,6 +1933,7 @@ export function MarketPluginCard({
onClick={onSelect}
disabled={unavailable}
aria-label={item.name}
+ aria-describedby={conflictDescription ? conflictDescriptionId : undefined}
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)]',
@@ -1969,8 +1975,11 @@ export function MarketPluginCard({
</>
) : null}
</span>
- <span className="mt-1.5 line-clamp-2 text-13 leading-5 text-[var(--text-secondary)]">
- {item.description || item.ghostId}
+ <span
+ id={conflictDescription ? conflictDescriptionId : undefined}
+ className="mt-1.5 line-clamp-2 text-13 leading-5 text-[var(--text-secondary)]"
+ >
+ {conflictDescription ?? (item.description || item.ghostId)}
</span>
</span>
</button>
@@ -1985,6 +1994,7 @@ export function MarketPluginCard({
: 'settings.ghosts.market.detailsAria',
{ name: item.name },
)}
+ aria-describedby={conflictDescription ? conflictDescriptionId : undefined}
className={cn(
'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',
@@ -2015,6 +2025,7 @@ export function MarketPluginCard({
}}
disabled={unavailable}
aria-label={t('settings.ghosts.page.installAria', { name: item.name })}
+ aria-describedby={conflictDescription ? conflictDescriptionId : undefined}
className={cn(
'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]',
diff --git a/apps/desktop/src/renderer/features/plugin/MarketPluginDetailView.tsx b/apps/desktop/src/renderer/features/plugin/MarketPluginDetailView.tsx
index c826946fc6..2f4c2b0923 100644
--- a/apps/desktop/src/renderer/features/plugin/MarketPluginDetailView.tsx
+++ b/apps/desktop/src/renderer/features/plugin/MarketPluginDetailView.tsx
@@ -1,3 +1,4 @@
+import { useId } from 'react';
import { Download, ShieldCheck } from 'lucide-react';
import { useTranslation } from 'react-i18next';
@@ -39,6 +40,13 @@ export function MarketPluginDetailView({
: 'settings.ghosts.market.install';
const actionDisabled =
busy || detail.installState === 'installed' || detail.installState === 'conflict';
+ // 冲突态的行动按钮只说「暂不可用」,原因必须在详情页也给出——列表卡片同一处理。
+ // 详情可能是先以非冲突态打开、随后目录或本地安装状态变化才转冲突的。
+ const conflictDescriptionId = useId();
+ const conflictDescription =
+ detail.installState === 'conflict'
+ ? t('settings.ghosts.market.conflictDescription')
+ : undefined;
return (
<main
@@ -80,6 +88,7 @@ export function MarketPluginDetailView({
type="button"
onClick={onInstall}
disabled={actionDisabled}
+ aria-describedby={conflictDescription ? conflictDescriptionId : undefined}
className={cn(
'plugin-detail-primary-action inline-flex h-10 min-w-[104px] items-center justify-center gap-2 whitespace-nowrap rounded-full px-4 text-13 font-medium',
'bg-[var(--accent-cta-bg)] text-[var(--accent-pure-cta-fg)]',
@@ -92,8 +101,11 @@ export function MarketPluginDetailView({
{t(actionKey)}
</button>
</div>
- <p className="mt-5 text-14 leading-[22px] text-[var(--text-secondary)]">
- {detail.description || detail.ghostId}
+ <p
+ id={conflictDescription ? conflictDescriptionId : undefined}
+ className="mt-5 text-14 leading-[22px] text-[var(--text-secondary)]"
+ >
+ {conflictDescription ?? (detail.description || detail.ghostId)}
</p>
</header>
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 83fdd9f6bc..f82848b1f0 100644
--- a/apps/desktop/src/renderer/features/plugin/__tests__/GhostPluginCard.test.tsx
+++ b/apps/desktop/src/renderer/features/plugin/__tests__/GhostPluginCard.test.tsx
@@ -416,12 +416,19 @@ describe('MarketPluginCard', () => {
expect((cardBody as HTMLButtonElement).disabled).toBe(true);
expect(cardBody.className).toContain('cursor-not-allowed');
expect(cardBody.className).not.toContain('cursor-wait');
+ const conflictDescription = screen.getByText(
+ 'settings.ghosts.market.conflictDescription',
+ );
+ expect(conflictDescription.id).toBeTruthy();
+ expect(cardBody.getAttribute('aria-describedby')).toBe(conflictDescription.id);
const conflictAction = screen.getByRole('button', {
name: 'settings.ghosts.market.conflictAria:Google Calendar',
});
expect((conflictAction as HTMLButtonElement).disabled).toBe(true);
+ expect(conflictAction.getAttribute('aria-describedby')).toBe(conflictDescription.id);
expect(screen.getByRole('status').textContent).toBe('settings.ghosts.market.conflict');
expect(screen.queryByRole('button', { name: 'settings.ghosts.page.installAria' })).toBeNull();
+ expect(screen.queryByText(marketPlugin.description ?? '')).toBeNull();
rerender(
<MarketPluginCard
diff --git a/apps/desktop/src/renderer/features/plugin/__tests__/MarketPluginDetailView.test.tsx b/apps/desktop/src/renderer/features/plugin/__tests__/MarketPluginDetailView.test.tsx
new file mode 100644
index 0000000000..4f8abeb8da
--- /dev/null
+++ b/apps/desktop/src/renderer/features/plugin/__tests__/MarketPluginDetailView.test.tsx
@@ -0,0 +1,89 @@
+/**
+ * Regression coverage for the market Plugin detail view's conflict state:
+ * 行动按钮只说「暂不可用」,不可用的原因必须同时出现在正文并绑给按钮,
+ * 否则详情页比改动前信息更少(改动前按钮文案本身就是「插件标识冲突」)。
+ * [PROTOCOL]: 变更时更新此头部,然后检查 CLAUDE.md
+ * @vitest-environment jsdom
+ */
+
+import { render, screen } from '@testing-library/react';
+import { describe, expect, it, vi } from 'vitest';
+
+vi.mock('react-i18next', () => ({
+ useTranslation: () => ({ t: (key: string) => key }),
+}));
+
+import { MarketPluginDetailView } from '../MarketPluginDetailView';
+import type { PluginMarketDetail } from '../../../../shared/pluginMarket';
+
+const detail: PluginMarketDetail = {
+ pluginId: 'release-google-calendar',
+ ghostId: 'google-calendar',
+ name: 'Google Calendar',
+ description: 'Connect Google Calendar',
+ author: 'Cindy',
+ scope: 'public',
+ organizationId: null,
+ defaultInstall: false,
+ releaseId: 'release-1',
+ version: '1.3.11',
+ publishedAt: '2026-07-25T00:00:00.000Z',
+ icon: null,
+ installState: 'not-installed',
+ enabled: null,
+ sourceType: 'server',
+ sourceMarketName: null,
+ manifest: {
+ schemaVersion: 2,
+ id: 'google-calendar',
+ name: 'Google Calendar',
+ version: '1.3.11',
+ kind: 'chip',
+ entry: 'index.html',
+ slots: [],
+ },
+};
+
+const renderDetail = (overrides: Partial<PluginMarketDetail> = {}) =>
+ render(
+ <MarketPluginDetailView
+ detail={{ ...detail, ...overrides }}
+ busy={false}
+ onBack={vi.fn()}
+ onInstall={vi.fn()}
+ onIconLoadError={vi.fn()}
+ />,
+ );
+
+describe('MarketPluginDetailView', () => {
+ it('shows the marketing description outside the conflict state', () => {
+ renderDetail();
+ const description = screen.getByText('Connect Google Calendar');
+ expect(description.id).toBe('');
+ expect(
+ screen
+ .getByRole('button', { name: /settings\.ghosts\.market\.install/ })
+ .getAttribute('aria-describedby'),
+ ).toBeNull();
+ });
+
+ it('explains why a conflicting plugin is unavailable and binds it to the action', () => {
+ renderDetail({ installState: 'conflict' });
+
+ const reason = screen.getByText('settings.ghosts.market.conflictDescription');
+ expect(reason.id).toBeTruthy();
+ // 冲突态下正文让位给原因,不再显示营销描述。
+ expect(screen.queryByText('Connect Google Calendar')).toBeNull();
+
+ const action = screen.getByRole('button', {
+ name: /settings\.ghosts\.market\.conflict$/,
+ }) as HTMLButtonElement;
+ expect(action.disabled).toBe(true);
+ expect(action.getAttribute('aria-describedby')).toBe(reason.id);
+ });
+
+ it('falls back to the ghostId when a plugin has no description', () => {
+ renderDetail({ description: null });
+ expect(screen.getByText('google-calendar')).toBeTruthy();
+ });
+});
diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.json
index 8fb4dcb952..6fa8d98f81 100644
--- a/apps/desktop/src/renderer/i18n/locales/en/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json
@@ -3208,8 +3208,9 @@
"update": "Update from market",
"updateTo": "Update to v{{version}}",
"installed": "Installed",
- "conflict": "Plugin ID conflict",
+ "conflict": "Unavailable",
"conflictAria": "{{name}} has a plugin ID conflict",
+ "conflictDescription": "This plugin ID is already in use, so this plugin can't be installed.",
"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.json
index 37763c1109..d431bd2223 100644
--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json
@@ -3207,8 +3207,9 @@
"update": "マーケットから更新",
"updateTo": "v{{version}} に更新",
"installed": "インストール済み",
- "conflict": "プラグイン ID の競合",
+ "conflict": "利用不可",
"conflictAria": "{{name}} にプラグイン ID の競合があります",
+ "conflictDescription": "このプラグイン 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.json
index 89a8301570..bc384bf492 100644
--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json
@@ -3207,8 +3207,9 @@
"update": "마켓에서 업데이트",
"updateTo": "v{{version}}(으)로 업데이트",
"installed": "설치됨",
- "conflict": "플러그인 ID 충돌",
+ "conflict": "사용할 수 없음",
"conflictAria": "{{name}}에 플러그인 ID 충돌이 있습니다",
+ "conflictDescription": "이 플러그인 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.json
index dbec758ad4..215da8e88e 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
@@ -3207,8 +3207,9 @@
"update": "从市场更新",
"updateTo": "更新到 v{{version}}",
"installed": "已安装",
- "conflict": "插件标识冲突",
+ "conflict": "暂不可用",
"conflictAria": "{{name}} 存在插件标识冲突",
+ "conflictDescription": "插件标识已被占用,当前无法安装",
"unavailable": "插件市场暂时不可用;已安装插件仍可正常管理和使用。",
"authenticationRequired": "登录 Cindy 后才能查看插件市场。",
"notConfigured": "当前环境未配置插件市场;已安装插件仍可正常管理和使用。",