Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(plugin): 保留主任务切换去重状态
DavidShen64be7205dd73
diff --git a/apps/desktop/src/main/cindy-brain/__tests__/subscriptionGateway.test.ts b/apps/desktop/src/main/cindy-brain/__tests__/subscriptionGateway.test.tsindex d39bcd9fac..9141592174 100644--- a/apps/desktop/src/main/cindy-brain/__tests__/subscriptionGateway.test.ts+++ b/apps/desktop/src/main/cindy-brain/__tests__/subscriptionGateway.test.ts@@ -184,7 +184,31 @@ describe('createGhostPrimarySessionFocusTracker', () => {expect(attempts).toBe(3);});- it('clears deduplication when focus leaves the session or resolution fails', async () => {+ it('preserves the published lead while a same-lead worker focus is unresolved', async () => {+ let workerBAttempts = 0;+ const published: string[] = [];+ const notify = vi.fn(async (sessionId: string, claim: () => Promise<boolean>) => {+ if (await claim()) published.push(sessionId);+ });+ const tracker = createGhostPrimarySessionFocusTracker(async (sessionId) => {+ if (sessionId === 'worker-b') {+ workerBAttempts += 1;+ return workerBAttempts === 1 ? null : 'lead-a';+ }+ return 'lead-a';+ }, notify);++ tracker.note('worker-a');+ await vi.waitFor(() => expect(published).toEqual(['lead-a']));+ tracker.note('worker-b');+ await vi.waitFor(() => expect(workerBAttempts).toBe(1));+ tracker.note('worker-b');+ await vi.waitFor(() => expect(workerBAttempts).toBe(3));++ expect(published).toEqual(['lead-a']);+ });++ it('clears deduplication when focus explicitly leaves the session', async () => {const published: string[] = [];const notify = vi.fn(async (sessionId: string, claim: () => Promise<boolean>) => {if (await claim()) published.push(sessionId);@@ -199,8 +223,7 @@ describe('createGhostPrimarySessionFocusTracker', () => {tracker.note(null);tracker.note('lead');await vi.waitFor(() => expect(published).toHaveLength(2));- tracker.note('hidden-worker');- await Promise.resolve();+ tracker.note(null);tracker.note('lead');await vi.waitFor(() => expect(published).toHaveLength(3));diff --git a/apps/desktop/src/main/cindy-brain/subscriptionGateway.ts b/apps/desktop/src/main/cindy-brain/subscriptionGateway.tsindex b9d154e189..6c479ae552 100644--- a/apps/desktop/src/main/cindy-brain/subscriptionGateway.ts+++ b/apps/desktop/src/main/cindy-brain/subscriptionGateway.ts@@ -650,7 +650,6 @@ export function createGhostPrimarySessionFocusTracker(if (primarySessionId === null) {// 解析失败不应占用 raw focus;同一焦点的后续上报需要能够重试。lastRawSessionId = null;- lastPrimarySessionId = null;return;}notify(primarySessionId, async () => {@@ -666,7 +665,6 @@ export function createGhostPrimarySessionFocusTracker(.catch(() => {if (currentGeneration === generation) {lastRawSessionId = null;- lastPrimarySessionId = null;}});},