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(bots): 话题缓存在游标重置后失效

Dash1822d2657e6e
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/chatServer.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/chatServer.test.ts
index 4599f4b623..e047cf6ce9 100644
--- a/apps/desktop/src/main/maker-ipc/__tests__/chatServer.test.ts
+++ b/apps/desktop/src/main/maker-ipc/__tests__/chatServer.test.ts
@@ -1285,6 +1285,12 @@ describe('Chat Server result delivery and refresh', () => {
changes: [{ type: 'message.updated', entityId: outside }] }));
await service.getGroup(roomId);
expect(reads()).toBe(2);
+ // A cursor reset skips the pushes in between, so nothing cached may survive it.
+ Object.assign(socket, { readyState: 1 });
+ socket.emit('message', JSON.stringify({ type: 'scope_error', scope: `conversation:${roomId}`, error: { code: 'RESET_REQUIRED' } }));
+ await vi.advanceTimersByTimeAsync(0);
+ await service.getGroup(roomId);
+ expect(reads()).toBe(3);
});
it('does not let 「继续讨论」 restart a re-posted reply', async () => {
diff --git a/apps/desktop/src/main/maker-ipc/chatServer.ts b/apps/desktop/src/main/maker-ipc/chatServer.ts
index d0d901d878..33514d40d5 100644
--- a/apps/desktop/src/main/maker-ipc/chatServer.ts
+++ b/apps/desktop/src/main/maker-ipc/chatServer.ts
@@ -464,6 +464,8 @@ function createChatServer(local: BotGroupChatService, deps: BotGroupChatServiceD
if (event.error?.code === 'RESET_REQUIRED') {
void api<Snapshot>(`/conversations/${roomId}/snapshot`).then(value => {
if (!current() || socket !== ws || ws.readyState !== WebSocket.OPEN) return;
+ // Edits and deletions before the new cursor will never be pushed.
+ threads.reset();
changed(roomId);
ws.send(JSON.stringify({ type: 'subscribe', scope: event.scope, after: value.cursor }));
}).catch(() => ws.close());