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(desktop): 恢复 Git 市场插件头像 (#2210)

nanacodb33c1f98ed6
diff --git a/apps/desktop/src/renderer/cindy-brain/__tests__/ghostPluginViewModel.test.ts b/apps/desktop/src/renderer/cindy-brain/__tests__/ghostPluginViewModel.test.ts
index 54ad4b184d..9a74150857 100644
--- a/apps/desktop/src/renderer/cindy-brain/__tests__/ghostPluginViewModel.test.ts
+++ b/apps/desktop/src/renderer/cindy-brain/__tests__/ghostPluginViewModel.test.ts
@@ -249,7 +249,7 @@ describe('ghostPluginViewModel', () => {
]);
});
- it('treats a market null icon as an explicit presentation override', () => {
+ it('treats a server market null icon as an explicit presentation override', () => {
const ghost = installed({ iconDataUrl: 'data:image/png;base64,OLD' });
const presentation = marketPresentationForInstalledGhost(ghost, marketItem({ icon: null }));
@@ -257,6 +257,25 @@ describe('ghostPluginViewModel', () => {
expect(toGhostPluginListItem(ghost, presentation)).not.toHaveProperty('iconDataUrl');
});
+ it('uses the installed package icon for an exact Git market mapping', () => {
+ const ghost = installed({ iconDataUrl: 'data:image/png;base64,LOCAL' });
+ const presentation = marketPresentationForInstalledGhost(
+ ghost,
+ marketItem({
+ sourceType: 'git-market',
+ sourceMarketName: 'community-plugins',
+ icon: null,
+ }),
+ );
+
+ expect(toGhostPluginListItem(ghost, presentation)).toMatchObject({
+ iconDataUrl: 'data:image/png;base64,LOCAL',
+ });
+ expect(toGhostPluginDetail(ghost, presentation)).toMatchObject({
+ iconDataUrl: 'data:image/png;base64,LOCAL',
+ });
+ });
+
it.each([
['local market miss', null],
['not installed', marketItem({ installState: 'not-installed' })],
diff --git a/apps/desktop/src/renderer/features/plugin/lib/ghostPluginViewModel.ts b/apps/desktop/src/renderer/features/plugin/lib/ghostPluginViewModel.ts
index 142590423d..26ed0442c2 100644
--- a/apps/desktop/src/renderer/features/plugin/lib/ghostPluginViewModel.ts
+++ b/apps/desktop/src/renderer/features/plugin/lib/ghostPluginViewModel.ts
@@ -73,8 +73,8 @@ export interface GhostPluginDetail extends GhostPluginListItem {
/**
* 展示投影只覆盖用户能看到的四个字段;运行时仍完全来自本地安装包。
*
- * `iconDataUrl` 是有意要求存在的字段:市场项的 `icon: null` 也必须覆盖本地
- * 包图标,而不是因为缺少 URL 又显示旧图标。
+ * `iconDataUrl` 是有意要求存在的字段:服务端市场项的 `icon: null` 仍覆盖本地
+ * 包图标。Git 市场是窄例外:精确匹配到已安装版本时,可复用安装包里已验证的图标。
*/
export interface GhostPluginMarketPresentation {
name: string;
@@ -89,11 +89,18 @@ export interface GhostPluginMarketPresentation {
* market item, or a pending version update must keep using its local manifest.
*/
export function marketPresentationForInstalledGhost(
- ghost: Pick<InstalledGhost, 'manifest'>,
+ ghost: Pick<InstalledGhost, 'manifest' | 'iconDataUrl'>,
marketItem:
| Pick<
PluginMarketItem,
- 'ghostId' | 'installState' | 'version' | 'name' | 'description' | 'author' | 'icon'
+ | 'ghostId'
+ | 'installState'
+ | 'version'
+ | 'name'
+ | 'description'
+ | 'author'
+ | 'icon'
+ | 'sourceType'
>
| null
| undefined,
@@ -110,7 +117,10 @@ export function marketPresentationForInstalledGhost(
name: marketItem.name,
description: marketItem.description ?? '',
author: marketItem.author,
- iconDataUrl: marketItem.icon?.url,
+ iconDataUrl:
+ marketItem.sourceType === 'git-market' && !marketItem.icon
+ ? ghost.iconDataUrl
+ : marketItem.icon?.url,
};
}