Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(plugin): 释放资格重试的焦点去重
DavidShenafaabbd0e2a8
diff --git a/apps/desktop/src/main/cindy-brain/__tests__/sessionFocusRetryContract.test.ts b/apps/desktop/src/main/cindy-brain/__tests__/sessionFocusRetryContract.test.tsindex 16e9cc3d3f..d1cef7a368 100644--- a/apps/desktop/src/main/cindy-brain/__tests__/sessionFocusRetryContract.test.ts+++ b/apps/desktop/src/main/cindy-brain/__tests__/sessionFocusRetryContract.test.ts@@ -32,4 +32,16 @@ describe('session focus retry wiring', () => {expect(body).toContain('lastRawSessionId = null;');expect(body).toContain('primarySessionId === lastPrimarySessionId');});++ it('releases raw focus when session-switch eligibility is temporarily unavailable', () => {+ const start = mainSource.indexOf('export function notifyGhostSessionEvent(');+ const end = mainSource.indexOf('\n}\n\n/**\n * 会话切换上报入口', start);+ const body = mainSource.slice(start, end);++ expect(body).toContain('onRetry: () => void = () => {}');+ expect(body).toContain("if (info.outcome === 'retry') onRetry();");+ expect(mainSource).toContain(+ "notifyGhostSessionEvent('switched', { sessionId }, claim, releaseRaw)",+ );+ });});diff --git a/apps/desktop/src/main/cindy-brain/index.ts b/apps/desktop/src/main/cindy-brain/index.tsindex 9216927b3f..cdc084e295 100644--- a/apps/desktop/src/main/cindy-brain/index.ts+++ b/apps/desktop/src/main/cindy-brain/index.ts@@ -1860,6 +1860,7 @@ export function notifyGhostSessionEvent(kind: 'created' | 'archived' | 'switched',data: { sessionId: string; workdir?: string },shouldPublish: () => boolean | Promise<boolean> = () => true,+ onRetry: () => void = () => {},): void {void (async () => {try {@@ -1874,7 +1875,10 @@ export function notifyGhostSessionEvent(data.sessionId,kind === 'switched' ? 'session-switch' : 'default',);- if (info.outcome !== 'eligible') return;+ if (info.outcome !== 'eligible') {+ if (info.outcome === 'retry') onRetry();+ return;+ }// switched 的调用方(renderer 路由上报)只有 sessionId,workdir 从资格// 查询顺手补上,与 created/archived 的载荷形状对齐。const payload =@@ -1911,7 +1915,8 @@ const ghostPrimarySessionFocusTracker = createGhostPrimarySessionFocusTracker(async (workerSessionId) =>(await getTeamByWorkerSession(workerSessionId))?.leadSessionId ?? null,),- (sessionId, claim) => notifyGhostSessionEvent('switched', { sessionId }, claim),+ (sessionId, claim, releaseRaw) =>+ notifyGhostSessionEvent('switched', { sessionId }, claim, releaseRaw),);// 原始焦点只供 preview 使用;不能用它的 raw-id 去重阻断 primary tracker 的重试。const ghostSessionFocusTracker = createGhostSessionFocusTracker(() => {});diff --git a/apps/desktop/src/main/cindy-brain/subscriptionGateway.ts b/apps/desktop/src/main/cindy-brain/subscriptionGateway.tsindex fa5cd1404f..2cac90f2dc 100644--- a/apps/desktop/src/main/cindy-brain/subscriptionGateway.ts+++ b/apps/desktop/src/main/cindy-brain/subscriptionGateway.ts@@ -627,7 +627,11 @@ export function createGhostSessionFocusTracker(*/export function createGhostPrimarySessionFocusTracker(resolve: (sessionId: string) => Promise<string | null>,- notify: (sessionId: string, claim: () => Promise<boolean>) => void,+ notify: (+ sessionId: string,+ claim: () => Promise<boolean>,+ releaseRaw: () => void,+ ) => void,): { note(sessionId: string | null): void } {let lastRawSessionId: string | null = null;let lastPrimarySessionId: string | null = null;@@ -672,6 +676,8 @@ export function createGhostPrimarySessionFocusTracker(if (primarySessionId === lastPrimarySessionId) return false;lastPrimarySessionId = primarySessionId;return true;+ }, () => {+ if (currentGeneration === generation) lastRawSessionId = null;});}).catch(() => {