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(plugin): 允许未解析任务焦点重试

DavidShenbaa1a5177807
diff --git a/apps/desktop/src/main/cindy-brain/__tests__/subscriptionGateway.test.ts b/apps/desktop/src/main/cindy-brain/__tests__/subscriptionGateway.test.ts
index d3ba5aac86..d39bcd9fac 100644
--- a/apps/desktop/src/main/cindy-brain/__tests__/subscriptionGateway.test.ts
+++ b/apps/desktop/src/main/cindy-brain/__tests__/subscriptionGateway.test.ts
@@ -165,6 +165,25 @@ describe('createGhostPrimarySessionFocusTracker', () => {
await expect(pending[0]?.claim()).resolves.toBe(false);
});
+ it('allows the same unresolved focus to retry after the first lookup fails', async () => {
+ let attempts = 0;
+ const published: string[] = [];
+ const notify = vi.fn(async (sessionId: string, claim: () => Promise<boolean>) => {
+ if (await claim()) published.push(sessionId);
+ });
+ const tracker = createGhostPrimarySessionFocusTracker(async () => {
+ attempts += 1;
+ return attempts === 1 ? null : 'lead';
+ }, notify);
+
+ tracker.note('worker');
+ await vi.waitFor(() => expect(attempts).toBe(1));
+ tracker.note('worker');
+ await vi.waitFor(() => expect(published).toEqual(['lead']));
+
+ expect(attempts).toBe(3);
+ });
+
it('clears deduplication when focus leaves the session or resolution fails', async () => {
const published: string[] = [];
const notify = vi.fn(async (sessionId: string, claim: () => Promise<boolean>) => {
diff --git a/apps/desktop/src/main/cindy-brain/subscriptionGateway.ts b/apps/desktop/src/main/cindy-brain/subscriptionGateway.ts
index 46f1231173..b9d154e189 100644
--- a/apps/desktop/src/main/cindy-brain/subscriptionGateway.ts
+++ b/apps/desktop/src/main/cindy-brain/subscriptionGateway.ts
@@ -648,6 +648,8 @@ export function createGhostPrimarySessionFocusTracker(
.then((primarySessionId) => {
if (currentGeneration !== generation) return;
if (primarySessionId === null) {
+ // 解析失败不应占用 raw focus;同一焦点的后续上报需要能够重试。
+ lastRawSessionId = null;
lastPrimarySessionId = null;
return;
}
@@ -662,7 +664,10 @@ export function createGhostPrimarySessionFocusTracker(
});
})
.catch(() => {
- if (currentGeneration === generation) lastPrimarySessionId = null;
+ if (currentGeneration === generation) {
+ lastRawSessionId = null;
+ lastPrimarySessionId = null;
+ }
});
},
};