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(skillhub): 交由服务端过滤分类以兼容旧计数

xd-bobo6a56afa743f3
diff --git a/apps/desktop/src/main/skillhub/__tests__/marketService.test.ts b/apps/desktop/src/main/skillhub/__tests__/marketService.test.ts
index 0e4a96dbc8..3cb686e46e 100644
--- a/apps/desktop/src/main/skillhub/__tests__/marketService.test.ts
+++ b/apps/desktop/src/main/skillhub/__tests__/marketService.test.ts
@@ -380,7 +380,7 @@ describe('SkillhubMarketService', () => {
}]);
});
- it.each(['market', 'team'] as const)('excludes empty browse tags from older %s servers, including nested tags', async (scope) => {
+ it.each(['market', 'team'] as const)('delegates %s browse filtering to the server without dropping legacy tags', async (scope) => {
const { fetch, calls } = makeFetch([[
{ slug: 'empty', name: 'Empty', skillCount: 0, mySkillCount: 2,
children: [{ slug: 'used', name: 'Used', skillCount: 3, mySkillCount: 1 }] },
@@ -390,13 +390,26 @@ describe('SkillhubMarketService', () => {
await expect(service.listCategories(scope, false)).resolves.toEqual({
success: true,
- categories: [{ slug: 'used', name: 'Used', count: 3, myCount: 1 }],
+ categories: [
+ { slug: 'empty', name: 'Empty', count: 0, myCount: 2 },
+ { slug: 'used', name: 'Used', count: 3, myCount: 1 },
+ { slug: 'missing-count', name: 'Missing', count: 0, myCount: 0 },
+ ],
totalCount: 3,
- myTotalCount: 1,
+ myTotalCount: 3,
});
expect(calls[0]?.path).toBe(`/api/skills-hub/categories?scope=${scope}&includeEmpty=false`);
});
+ it.each(['market', 'team'] as const)('preserves the filtered category result from updated %s servers', async (scope) => {
+ const { fetch } = makeFetch([[{ slug: 'used', name: 'Used', skillCount: 3 }], []]);
+ const service = new SkillhubMarketService({ fetch });
+ await expect(service.listCategories(scope, false)).resolves.toMatchObject({
+ categories: [{ slug: 'used', count: 3 }],
+ });
+ await expect(service.listCategories(scope, false)).resolves.toMatchObject({ categories: [] });
+ });
+
it('keeps unused tags selectable in explicit full-list mode', async () => {
const { fetch, calls } = makeFetch([[{ slug: 'empty', name: 'Empty', skillCount: 0 }]]);
const service = new SkillhubMarketService({ fetch });
diff --git a/apps/desktop/src/main/skillhub/marketService.ts b/apps/desktop/src/main/skillhub/marketService.ts
index 8703a6fb5d..ad492a6025 100644
--- a/apps/desktop/src/main/skillhub/marketService.ts
+++ b/apps/desktop/src/main/skillhub/marketService.ts
@@ -310,8 +310,9 @@ export class SkillhubMarketService {
mySkillCount?: number;
}>;
}>>(`/api/skills-hub/categories?scope=${scope}${includeEmpty ? '' : '&includeEmpty=false'}`);
- // Older servers may ignore includeEmpty; keep their empty tags out of browse results too.
- const categories = flattenHubCategories(items ?? []).filter((category) => includeEmpty || category.count > 0);
+ // Filtering belongs to the server: legacy counts may be absent, and older servers'
+ // team responses may contain public-market counts rather than team counts.
+ const categories = flattenHubCategories(items ?? []);
const totalCount = categories.reduce((s, c) => s + c.count, 0);
const myTotalCount = categories.reduce((s, c) => s + c.myCount, 0);
return { success: true as const, categories, totalCount, myTotalCount };