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(bot-group): drop queue notices of rooms the companion lost access to

zqchris68e9c8abde41
diff --git a/apps/desktop/src/main/maker-ipc/chatServer.ts b/apps/desktop/src/main/maker-ipc/chatServer.ts
index ad512c108c..b78e1d3f5e 100644
--- a/apps/desktop/src/main/maker-ipc/chatServer.ts
+++ b/apps/desktop/src/main/maker-ipc/chatServer.ts
@@ -1858,7 +1858,15 @@ function createChatServer(local: BotGroupChatService, deps: BotGroupChatServiceD
for (const run of runs) rooms.add(run.execution.conversation_id);
}
for (const room of [...rooms].sort()) {
- const rows = await api<Execution[]>(`/conversations/${room}/executions`);
+ let rows: Execution[];
+ try {
+ rows = await api<Execution[]>(`/conversations/${room}/executions`);
+ } catch (error) {
+ // Left or removed from the room: its notices can never be taken, and the next rooms still are.
+ if (!(error instanceof ChatResponseError) || ![403, 404, 410].includes(error.status)) throw error;
+ for (const [executionId, hinted] of hints) if (hinted === room) hints.delete(executionId);
+ continue;
+ }
const queued = rows.filter(row => row.bot_id === actorId && row.status === 'queued')
.sort((a, b) => (a.created_at ?? '').localeCompare(b.created_at ?? '') || a.id.localeCompare(b.id));
// A notice is dropped once its work is no longer queued, or once it waits behind a turn in