Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(cindy-brain): 保留订阅唤醒结束补投
liugaowei0f2ba0174895
diff --git a/apps/desktop/src/main/cindy-brain/__tests__/subscriptionGateway.test.ts b/apps/desktop/src/main/cindy-brain/__tests__/subscriptionGateway.test.tsindex 49bd20047b..267b0d478e 100644--- a/apps/desktop/src/main/cindy-brain/__tests__/subscriptionGateway.test.ts+++ b/apps/desktop/src/main/cindy-brain/__tests__/subscriptionGateway.test.ts@@ -404,6 +404,34 @@ describe('did- 旁听扇出', () => {]);});+ it('补投首次唤醒 flush 期间新入队的终止事件', async () => {+ const delivered: GhostPipeEventPush[] = [];+ let gateway!: GhostSubscriptionGateway;+ const created = makeGateway({+ sendToGhost: (_ghostId, payload) => {+ delivered.push(payload);+ if ((payload as { name?: string }).name === 'did-turn-start') {+ queueMicrotask(() => {+ gateway.publish('turn', 'did-turn-end', {+ ...TURN_DATA,+ durationMs: 5,+ endReason: 'completed',+ });+ });+ }+ },+ });+ gateway = created.gw;++ gateway.publish('turn', 'did-turn-start', TURN_DATA);++ await vi.waitFor(() => expect(delivered).toHaveLength(2));+ expect(delivered.map((payload) => (payload as { name: string }).name)).toEqual([+ 'did-turn-start',+ 'did-turn-end',+ ]);+ });+it('缓冲溢出丢最旧,dropped 计数随补投首条带出', async () => {const running = new Set<string>();const wake = vi.fn(async () => {}); // 先唤不醒(不置 running):纯堆缓冲diff --git a/apps/desktop/src/main/cindy-brain/subscriptionGateway.ts b/apps/desktop/src/main/cindy-brain/subscriptionGateway.tsindex d64dc5cb3d..eea3128f16 100644--- a/apps/desktop/src/main/cindy-brain/subscriptionGateway.ts+++ b/apps/desktop/src/main/cindy-brain/subscriptionGateway.ts@@ -316,6 +316,11 @@ export class GhostSubscriptionGateway {}).finally(() => {e.waking = false;+ // Events queued between flush's callback and this microtask must not wait+ // for another event to wake them up (the queued event may be terminal).+ const ghostId = installedGhostStoragePart(ghost);+ if (this.entries.get(ghostId) === e && this.ownerScopeUsable(ownerScope)+ && e.buffer.length > 0 && this.deps.isRunning(ghostId)) this.flush(ghostId, e, ownerScope);});}