Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(chat): refresh snapshot reaction aggregates
Zhao Dengfeng3e7c7cad1029
diff --git a/packages/maker-shared/src/__tests__/chatHistory.test.ts b/packages/maker-shared/src/__tests__/chatHistory.test.tsindex 8d02da2981..53f0536563 100644--- a/packages/maker-shared/src/__tests__/chatHistory.test.ts+++ b/packages/maker-shared/src/__tests__/chatHistory.test.ts@@ -173,6 +173,24 @@ describe('durable chat history', () => {expect(f.api.mock.calls.map(([route]) => route)).toEqual(['/conversations/room/messages?limit=100&before=5']);});+ // Unit: snapshot() must expose refreshed reactions after reaction.changed; the wire body has no aggregates.+ // Message 9 has no page coverage, so the page regression above misses the stale second snapshot and absent refetch.+ it('refreshes snapshot-only reaction aggregates on the next snapshot read', async () => {+ const f = fixture(); let reactions: unknown[] = [];+ const original = f.api.getMockImplementation()!;+ f.api.mockImplementation(async route => route.endsWith('/snapshot')+ ? { room: { id: 'room' }, cursor: '10', messages: [{ ...f.message('9'), reactions }] }+ : original(route));+ const cache = f.open(); await cache.snapshot('room');+ await cache.receive('room', { cursor: '11', changes: [{ type: 'reaction.changed', entityId: '9', data: { message: f.message('9') } }] }, '10');+ reactions = [{ emoji: 'like', count: 2 }]; f.api.mockClear();+ expect(await cache.snapshot('room')).toMatchObject({ messages: [{ id: '9', reactions }] });+ expect(f.api.mock.calls.map(([route]) => route)).toEqual([+ '/changes?scope=conversation:room&after=11&limit=100',+ '/conversations/room/snapshot',+ ]);+ });+it('does not advance a durable cursor when saving an event fails, and replays it on restart', async () => {const f = fixture(); const cache = f.open();await cache.page('room', f.page);diff --git a/packages/maker-shared/src/chatHistory.ts b/packages/maker-shared/src/chatHistory.tsindex 59d0f12f10..b0af6c2a26 100644--- a/packages/maker-shared/src/chatHistory.ts+++ b/packages/maker-shared/src/chatHistory.ts@@ -104,6 +104,7 @@ export function createChatHistory(input: { api: Api; store: ChatHistoryStore; cuif (/^(message\.|reaction\.|pin\.)/.test(change.type)) {if (!message) return false;if (change.type === 'reaction.changed') {+ if (state.snapshot.messages.some(m => m.id === message.id)) state.metadataDirty = true;for (const [key, ids] of Object.entries(state.pages)) if (ids.includes(message.id)) stale(state, key);}if (message) {