Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(plugin-market): 修正空市场提示的错误根因推断 (#2272)
nanaco7794ed67936d
diff --git a/apps/desktop/src/renderer/features/plugin/MarketplaceDiscoveryNotice.tsx b/apps/desktop/src/renderer/features/plugin/MarketplaceDiscoveryNotice.tsxindex 75fb2e2201..b478298dc3 100644--- a/apps/desktop/src/renderer/features/plugin/MarketplaceDiscoveryNotice.tsx+++ b/apps/desktop/src/renderer/features/plugin/MarketplaceDiscoveryNotice.tsx@@ -3,9 +3,8 @@** 三类信息刻意分行、语义分开(与 discover.ts 的注释要求一致):* - skippedCount:内容**永久**非法,跳过即结论;- * - 可用 0 且存在被跳过条目:典型成因是市场仓库把插件目录做成了 Git submodule- * (clone 有意不递归,见 sources/git.ts),目录存在但内容为空——清单完全合法,- * 不触发任何错误码,不专门点明的话用户与市场作者完全无从排查;+ * - 可用 0 且存在被跳过条目:只报告“所有条目均被跳过”。跳过原因包含永久非法+ * 形态和当前版本尚不支持的合法 source,不能仅凭总数判断有效性或具体根因;* - unreadableCount:**事实不明**(权限 / 文件锁 / 瞬时 I/O),刷新可解,* 不得与 skipped 混同展示。*/@@ -22,11 +21,10 @@ export interface MarketplaceDiscoveryNoticeProps {export function MarketplaceDiscoveryNotice({ summary, action }: MarketplaceDiscoveryNoticeProps) {const { t } = useTranslation();- // "清单有条目但可用 0"由既有字段推导,不在 IPC 上加冗余布尔。推导依据的不变量:- // discover.ts 对每个清单条目恰好计入 plugins/skipped/unreadable 三者之一,即- // declared = accepted + skipped + unreadable 恒成立——改 summary 字段语义时必须- // 同步审视这里。unreadable-only 的 0 可用不算:那是瞬时问题,刷新提示已覆盖。- const emptyWithSkips = summary.pluginCount === 0 && summary.skippedCount > 0;+ // skippedCount 汇总永久非法原因和当前版本尚不支持的合法 source,不能从中推断+ // 条目有效性或具体根因。unreadable-only 的 0 可用由重试提示单独覆盖。+ const emptyWithSkippedEntries =+ summary.pluginCount === 0 && summary.skippedCount > 0 && summary.unreadableCount === 0;return (<divrole="status"@@ -45,9 +43,9 @@ export function MarketplaceDiscoveryNotice({ summary, action }: MarketplaceDisco{t('settings.ghosts.market.sources.skippedEntries', { count: summary.skippedCount })}</p>) : null}- {emptyWithSkips ? (+ {emptyWithSkippedEntries ? (<p className="mt-1 text-11 leading-4 text-[var(--warning-fg)]">- {t('settings.ghosts.market.sources.emptyWithEntries')}+ {t('settings.ghosts.market.sources.emptyWithSkippedEntries')}</p>) : null}{summary.unreadableCount > 0 ? (diff --git a/apps/desktop/src/renderer/features/plugin/MarketplaceSourcesDialog.tsx b/apps/desktop/src/renderer/features/plugin/MarketplaceSourcesDialog.tsxindex 751145b5ce..2b83f3136b 100644--- a/apps/desktop/src/renderer/features/plugin/MarketplaceSourcesDialog.tsx+++ b/apps/desktop/src/renderer/features/plugin/MarketplaceSourcesDialog.tsx@@ -235,14 +235,11 @@ export function MarketplaceSourcesDialog({})}</p>) : null}- {source.pluginCount === 0 && source.skippedCount > 0 ? (- // 可用 0 但清单有条目:常见成因是插件目录被做成 Git- // submodule(clone 有意不递归),清单合法、无错误码,- // 不点明成因用户无从排查。推导不变量见- // MarketplaceDiscoveryNotice(declared = accepted +- // skipped + unreadable)。+ {source.pluginCount === 0 &&+ source.skippedCount > 0 &&+ source.unreadableCount === 0 ? (<p className="text-[var(--warning-fg)]">- {t('settings.ghosts.market.sources.emptyWithEntries')}+ {t('settings.ghosts.market.sources.emptyWithSkippedEntries')}</p>) : null}{source.unreadableCount > 0 ? (diff --git a/apps/desktop/src/renderer/features/plugin/__tests__/AddMarketplaceDialog.test.tsx b/apps/desktop/src/renderer/features/plugin/__tests__/AddMarketplaceDialog.test.tsxindex 411f4181ad..b41093ac98 100644--- a/apps/desktop/src/renderer/features/plugin/__tests__/AddMarketplaceDialog.test.tsx+++ b/apps/desktop/src/renderer/features/plugin/__tests__/AddMarketplaceDialog.test.tsx@@ -137,7 +137,7 @@ describe('AddMarketplaceDialog', () => {await waitFor(() =>expect(screen.getByText('settings.ghosts.market.sources.addedReceipt')).toBeTruthy(),);- expect(screen.getByText('settings.ghosts.market.sources.emptyWithEntries')).toBeTruthy();+ expect(screen.getByText('settings.ghosts.market.sources.emptyWithSkippedEntries')).toBeTruthy();expect(screen.getByText('settings.ghosts.market.sources.skippedEntries')).toBeTruthy();});diff --git a/apps/desktop/src/renderer/features/plugin/__tests__/MarketplaceDiscoveryNotice.test.tsx b/apps/desktop/src/renderer/features/plugin/__tests__/MarketplaceDiscoveryNotice.test.tsxindex c21d1532d3..bff7158293 100644--- a/apps/desktop/src/renderer/features/plugin/__tests__/MarketplaceDiscoveryNotice.test.tsx+++ b/apps/desktop/src/renderer/features/plugin/__tests__/MarketplaceDiscoveryNotice.test.tsx@@ -1,5 +1,5 @@/**- * 市场发现回执:插件数回执、skipped 与 unreadable 分开、submodule 空目录专门提示。+ * 市场发现回执:插件数回执、skipped 与 unreadable 分开、零可用且所有条目被跳过时给出通用提示。* [PROTOCOL]: 变更时更新此头部,然后检查 CLAUDE.md* @vitest-environment jsdom*/@@ -56,14 +56,24 @@ describe('MarketplaceDiscoveryNotice', () => {expect(screen.queryByText(/emptyWithEntries/)).toBeNull();});- it('calls out the submodule-shaped empty market when entries exist but none are usable', () => {+ it('reports that all entries were skipped without judging validity or root cause', () => {render(<MarketplaceDiscoveryNoticesummary={{ ...base, pluginCount: 0, skippedCount: 2 }}action="added"/>,);- expect(screen.getByText('settings.ghosts.market.sources.emptyWithEntries')).toBeTruthy();+ expect(screen.getByText('settings.ghosts.market.sources.emptyWithSkippedEntries')).toBeTruthy();+ });++ it('does not show the all-skipped notice when unreadable entries are mixed in', () => {+ render(+ <MarketplaceDiscoveryNotice+ summary={{ ...base, pluginCount: 0, skippedCount: 2, unreadableCount: 1 }}+ action="refreshed"+ />,+ );+ expect(screen.queryByText(/emptyWithSkippedEntries/)).toBeNull();});it('does not blame submodules for an unreadable-only zero result', () => {diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.jsonindex 9662672f6f..ecd09feeeb 100644--- a/apps/desktop/src/renderer/i18n/locales/en/common.json+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json@@ -3309,7 +3309,7 @@"unreadableEntries": "{{count}} plugin entries are temporarily unreadable; refresh to retry","addedReceipt": "Added \"{{name}}\" with {{count}} plugins discovered","refreshedReceipt": "Refreshed \"{{name}}\" with {{count}} plugins discovered",- "emptyWithEntries": "The manifest lists entries but no usable plugins were discovered. A common cause is plugin directories being git submodules (their contents are not fetched) — ask the marketplace author to put plugin directories directly into the repository.",+ "emptyWithSkippedEntries": "No usable plugins were discovered because all listed entries were skipped. Check the source types, plugin directories, and manifest entries.","localBadge": "Local","defaultRef": "Default branch","neverSynced": "Never synced",diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.jsonindex 1c48783023..d0f187b7ff 100644--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json@@ -3308,7 +3308,7 @@"unreadableEntries": "プラグイン項目 {{count}} 件を一時的に読み込めません。更新して再試行してください","addedReceipt": "「{{name}}」を追加し、プラグイン {{count}} 件を検出しました","refreshedReceipt": "「{{name}}」を更新し、プラグイン {{count}} 件を検出しました",- "emptyWithEntries": "マニフェストに項目はありますが、利用可能なプラグインは見つかりませんでした。よくある原因はプラグインディレクトリが git submodule になっていること(内容は取得されません)です。マーケットプレイス作者にプラグインディレクトリを直接リポジトリに入れるよう依頼してください。",+ "emptyWithSkippedEntries": "利用可能なプラグインが見つかりませんでした。マニフェストの項目はすべてスキップされました。ソースの種類、プラグインのディレクトリ、マニフェストを確認してください。","localBadge": "ローカル","defaultRef": "デフォルトブランチ","neverSynced": "未同期",diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.jsonindex 1e7d252bcd..0d65b943b8 100644--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json@@ -3308,7 +3308,7 @@"unreadableEntries": "플러그인 항목 {{count}}개를 일시적으로 읽을 수 없습니다. 새로고침하여 다시 시도하세요","addedReceipt": "\"{{name}}\"을(를) 추가했고 플러그인 {{count}}개를 발견했습니다","refreshedReceipt": "\"{{name}}\"을(를) 새로고침했고 플러그인 {{count}}개를 발견했습니다",- "emptyWithEntries": "매니페스트에 항목이 있지만 사용 가능한 플러그인을 찾지 못했습니다. 흔한 원인은 플러그인 디렉터리가 git submodule인 경우입니다(내용을 가져오지 않음). 마켓플레이스 작성자에게 플러그인 디렉터리를 저장소에 직접 넣도록 요청하세요.",+ "emptyWithSkippedEntries": "사용 가능한 플러그인을 찾지 못했습니다. 매니페스트의 모든 항목을 건너뛰었습니다. 소스 유형, 플러그인 디렉터리, 매니페스트를 확인하세요.","localBadge": "로컬","defaultRef": "기본 브랜치","neverSynced": "동기화되지 않음",diff --git a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.jsonindex aefa06b1a3..88f2ae1304 100644--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json@@ -3308,7 +3308,7 @@"unreadableEntries": "{{count}} 个插件条目暂时无法读取,请刷新重试","addedReceipt": "已添加“{{name}}”,发现 {{count}} 个插件","refreshedReceipt": "已刷新“{{name}}”,发现 {{count}} 个插件",- "emptyWithEntries": "清单有条目但没有发现可用插件。常见原因是插件目录为 git submodule(内容不会被拉取)——请市场作者将插件目录直接放入仓库。",+ "emptyWithSkippedEntries": "未发现可用插件:清单中的条目均被跳过。请检查来源类型、插件目录和清单配置。","localBadge": "本地","defaultRef": "默认分支","neverSynced": "尚未同步",