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-bobo5004489cab97
diff --git a/apps/desktop/src/renderer/features/cc-agent/lib/projectGrouping.ts b/apps/desktop/src/renderer/features/cc-agent/lib/projectGrouping.ts
index 562de9a411..4c6854c5af 100644
--- a/apps/desktop/src/renderer/features/cc-agent/lib/projectGrouping.ts
+++ b/apps/desktop/src/renderer/features/cc-agent/lib/projectGrouping.ts
@@ -142,6 +142,8 @@ export interface GroupSessionsOptions {
* when every conversation inside it is pinned.
*/
includePinnedInProjects?: boolean;
+ /** Resource catalogues include created project sessions even before their first message. */
+ includeDraftsInProjects?: boolean;
/**
* sessionId → 它属于哪个伙伴。
*
@@ -499,7 +501,7 @@ export function groupSessions(
const isAutoPlacedSession = s.source === 'scheduler' || s.source === 'plugin';
if (
dir == null ||
- (!isAutoPlacedSession && !isOrcaLead && s.userSendAt == null && noPhysicalMessages)
+ (!options.includeDraftsInProjects && !isAutoPlacedSession && !isOrcaLead && s.userSendAt == null && noPhysicalMessages)
) {
unclassified.push(s);
} else {
diff --git a/apps/desktop/src/renderer/features/skillhub/SkillhubFeatureLayout.tsx b/apps/desktop/src/renderer/features/skillhub/SkillhubFeatureLayout.tsx
index 83d96e4c86..6a58e384cd 100644
--- a/apps/desktop/src/renderer/features/skillhub/SkillhubFeatureLayout.tsx
+++ b/apps/desktop/src/renderer/features/skillhub/SkillhubFeatureLayout.tsx
@@ -134,7 +134,7 @@ export function useSkillhubStoreSync(): void {
const skillhubProjects = useMemo<SkillhubProject[] | null>(() => {
if (sessionsLoading) return null;
- const { projects } = groupSessions(sessions);
+ const { projects } = groupSessions(sessions, { includePinnedInProjects: true, includeDraftsInProjects: true });
return projects
.filter((p) => p.scope === 'local')
.map((p) => ({
diff --git a/apps/desktop/src/renderer/features/skillhub/__tests__/SkillhubStoreSync.test.tsx b/apps/desktop/src/renderer/features/skillhub/__tests__/SkillhubStoreSync.test.tsx
new file mode 100644
index 0000000000..3e4ed99858
--- /dev/null
+++ b/apps/desktop/src/renderer/features/skillhub/__tests__/SkillhubStoreSync.test.tsx
@@ -0,0 +1,47 @@
+// @vitest-environment jsdom
+import { cleanup, renderHook } from '@testing-library/react';
+import { afterEach, expect, it, vi } from 'vitest';
+import type { Session } from '@/lib/ccAgent.types';
+import { projectHash } from '../lib/projectHash';
+
+const mocks = vi.hoisted(() => ({
+ sessions: [] as Session[], loading: true, syncProjects: vi.fn(),
+ state: { skills: [], syncResults: new Map(), bootstrapped: false },
+}));
+vi.mock('@/hooks/useCCSessions', () => ({ useCCSessions: () => ({ sessions: mocks.sessions, isLoading: mocks.loading }) }));
+vi.mock('@/contexts/AuthContext', () => ({ useAuth: () => ({ dataOwnerId: 'local', mode: 'local' }) }));
+vi.mock('@/features/cc-agent/useRegisterCCAgentSidebar', () => ({ useRegisterCCAgentSidebar: vi.fn() }));
+vi.mock('../hooks/useSkillSync', () => ({ useSkillSync: vi.fn() }));
+vi.mock('../hooks/useSkillhub', () => ({
+ useSkillhub: () => mocks.state, syncProjects: mocks.syncProjects,
+ bootstrapSkillhub: vi.fn(), refresh: vi.fn(), setSkillhubDataOwner: vi.fn(),
+}));
+import { useSkillhubStoreSync } from '../SkillhubFeatureLayout';
+
+afterEach(cleanup);
+
+it('keeps pinned and newly created local project directories in the scan catalogue', () => {
+ const session = (id: string, workingDir: string, extra: Partial<Session> = {}) => ({
+ id, workingDir, workspaceKind: 'project', status: 'active',
+ createdAt: '2026-09-08T00:00:00Z', updatedAt: '2026-09-08T00:00:00Z',
+ userSendAt: '2026-09-08T00:00:00Z', pinnedAt: null, ...extra,
+ } as Session);
+ mocks.sessions = [
+ session('pinned', '/repo/pinned', { pinnedAt: '2026-09-08T01:00:00Z' }),
+ session('created', '/repo/created', { userSendAt: null }),
+ session('ssh', '/remote', { remoteHostId: 'ssh-host', pinnedAt: '2026-09-08T01:00:00Z' }),
+ ];
+ const { rerender } = renderHook(useSkillhubStoreSync);
+ expect(mocks.syncProjects).not.toHaveBeenCalled();
+ mocks.loading = false;
+ rerender();
+ const projects = mocks.syncProjects.mock.lastCall![0];
+ expect(projects).toHaveLength(2);
+ expect(projects).toEqual(expect.arrayContaining([
+ expect.objectContaining({ projectRoot: '/repo/pinned', hash: projectHash('/repo/pinned') }),
+ expect.objectContaining({ projectRoot: '/repo/created', hash: projectHash('/repo/created') }),
+ ]));
+ mocks.sessions = mocks.sessions.map((item) => ({ ...item, pinnedAt: null }));
+ rerender();
+ expect(mocks.syncProjects.mock.lastCall![0]).toEqual(projects);
+});
diff --git a/docs/dev-rules/protocol-compatibility.md b/docs/dev-rules/protocol-compatibility.md
index 8215c373fc..17a42125bd 100644
--- a/docs/dev-rules/protocol-compatibility.md
+++ b/docs/dev-rules/protocol-compatibility.md
@@ -49,7 +49,9 @@
身份,导航或身份变化撤销确认。同一窗口最多一个待确认卸载,取消不产生文件或注册副作用。
物理卸载的清理快照汇总已扫描 scope 的同源发现链接,外部导入只移除所选 scope 的入口
与对应词法注册记录,不追加其它范围的全局候选。斜杠详情路径携带 scope 与工作目录,
- 同源多副本按范围和最近项目匹配;旧路径无法唯一消歧时不任意选择副本。
+ 同源多副本按范围和最近项目匹配;旧路径无法唯一消歧时不任意选择副本。SkillHub
+ 项目目录包含置顶任务和已创建但尚未发消息的项目任务,不沿用侧栏的展示排除规则;
+ 仍只扫描本地目录,并由 Main 的项目目录白名单复核。
源目录形状不能单独证明归属:同一分组必须有直接、非符号链接的发现入口,才可按独立
实体卸载;检查覆盖入口、发现根及引擎配置目录各级,拒绝其中的符号链接,保留发现
布局以上的已跟踪项目别名兼容。外部入口移除及清理重试保留源文件和按物理身份共享的