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): notify list and open rooms after the registry projection changes

Chrisfd9f2f33ef61
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 bb1760be24..5e758e4ade 100644
--- a/apps/desktop/src/main/maker-ipc/__tests__/chatServer.test.ts
+++ b/apps/desktop/src/main/maker-ipc/__tests__/chatServer.test.ts
@@ -1409,6 +1409,19 @@ describe('Chat Server result delivery and refresh', () => {
expect(after).toBeGreaterThan(before);
expect(await room()).toBe(after);
});
+ it('asks the list and open rooms to read again when a later registration changes names or avatars', async () => {
+ await service.getGroup(roomId);
+ await vi.advanceTimersByTimeAsync(300);
+ vi.mocked(deps.onChanged!).mockClear();
+ fixture.handle.mockImplementation(route => route === '/actors'
+ ? { body: [{ id: botId, kind: 'bot', externalId: 'local-bot', name: 'Renamed' }] } : response(route));
+ // Reads return on the old registry; the next background registration replaces it afterwards.
+ await vi.advanceTimersByTimeAsync(6000);
+ await service.getGroup(roomId);
+ await vi.advanceTimersByTimeAsync(300);
+ expect(deps.onChanged).toHaveBeenCalledWith(expect.objectContaining({ groupId: '' }), undefined);
+ expect(deps.onChanged).toHaveBeenCalledWith(expect.objectContaining({ groupId: roomId }), undefined);
+ });
it('refreshes a reset room and resumes realtime from the authorized snapshot cursor', async () => {
await service.getGroup(roomId);
await vi.advanceTimersByTimeAsync(2000);
diff --git a/apps/desktop/src/main/maker-ipc/chatServer.ts b/apps/desktop/src/main/maker-ipc/chatServer.ts
index 5e4a3a0211..adab2736d5 100644
--- a/apps/desktop/src/main/maker-ipc/chatServer.ts
+++ b/apps/desktop/src/main/maker-ipc/chatServer.ts
@@ -667,7 +667,13 @@ function createChatServer(local: BotGroupChatService, deps: BotGroupChatServiceD
registeredAt = Date.now();
const key = JSON.stringify([selfId, actors.map(a => [a.id, a.kind, a.externalId, a.name, a.avatar ?? null]),
profiles.map(p => [p.id, p.status, p.displayName, p.avatar, p.avatarColor])]);
- if (key !== registryKey) { registryKey = key; summaries.clear(); snapshots.clear(); }
+ if (key !== registryKey) {
+ const replaced = registryKey !== '';
+ registryKey = key; summaries.clear(); snapshots.clear();
+ // A list or room read may have finished on the old registry while this ran (a background
+ // refresh, or actor.changed racing its own list notice): tell them to read again.
+ if (replaced) { changed(''); for (const roomId of rooms.keys()) changed(roomId); }
+ }
})().finally(() => { refreshActors = undefined; });
return refreshActors;
}