Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(bots): 本地旧群按本地记录识别,群任务消息交本地服务拒绝后退回私聊
Chris39fdfb092364
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/chatServer.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/chatServer.test.tsindex 0c2b467c7e..68d58387bb 100644--- a/apps/desktop/src/main/maker-ipc/__tests__/chatServer.test.ts+++ b/apps/desktop/src/main/maker-ipc/__tests__/chatServer.test.ts@@ -641,6 +641,22 @@ describe('Chat Server result delivery and refresh', () => {if (posts) expect(sent[0][2].content).toEqual([{ type: 'text', text: 'Done.' }, taskCard]);});+ it('hands an old local-only group (a UUID too) to the local service, which refuses for good', async () => {+ const localPost = vi.fn(async () => ({ ok: false as const, errorCode: 'GROUP_CHANNEL_UNAVAILABLE', retryable: false }));+ // The local history lists this group and nothing upgraded it: it is not a server room.+ const legacy = withChatServer({ listGroups: vi.fn(async () => ({ ok: true, groups: [{ id: roomId }] })), postCompanionTaskMessage: localPost,+ settleLaneTurn: vi.fn(async () => false), dispose: vi.fn() } as unknown as BotGroupChatService, deps);+ const requestsBefore = fixture.requests.length;+ try {+ fixture.token = '';+ const input = { groupId: roomId, botId: 'local-bot', clientId: 'bot-delegation-task:task-1:started', text: '', card: taskCard };+ expect(await legacy.postCompanionTaskMessage(input)).toEqual({ ok: false, errorCode: 'GROUP_CHANNEL_UNAVAILABLE', retryable: false });+ expect(localPost).toHaveBeenCalledExactlyOnceWith(input);+ // Decided from local records alone: no registration, no request, even while logged out.+ expect(fixture.requests).toHaveLength(requestsBefore);+ } finally { legacy.dispose(); }+ });+it('refuses for good when the teammate is no longer a member', async () => {fixture.profiles = [{ id: 'local-bot', displayName: 'Bot', avatar: null, status: 'active' }];fixture.handle.mockImplementation(route => route.endsWith('/snapshot')diff --git a/apps/desktop/src/main/maker-ipc/chatServer.ts b/apps/desktop/src/main/maker-ipc/chatServer.tsindex 3a1c7ca227..2bcb83b71f 100644--- a/apps/desktop/src/main/maker-ipc/chatServer.ts+++ b/apps/desktop/src/main/maker-ipc/chatServer.ts@@ -435,6 +435,18 @@ function createChatServer(local: BotGroupChatService, deps: BotGroupChatServiceDconst mirrors = new Set(links.flatMap(link => /^group:([^:]+):access:/.exec(link.routeKey ?? '')?.[1] ?? []));return result.groups.filter(group => !mirrors.has(group.id) && !workspaces().read(group.id));}+ /**+ * The server room a task started from `groupId` posts into, without touching the network:+ * the upgraded room of an old local group, or the id itself for a server room. `null` is an old+ * local group that has no room (yet): its local history row exists and is still a local source.+ */+ const taskRoomFor = async (groupId: string): Promise<string | null> => {+ if (upgradedGroups.has(groupId)) return upgradedGroups.get(groupId)!;+ if (!id.safeParse(groupId).success) return null;+ const [localRow] = await getDbClient().drizzle.select({ id: botGroups.id }).from(botGroups).where(eq(botGroups.id, groupId)).limit(1);+ if (localRow && (await localSources()).some(group => group.id === groupId)) return null;+ return groupId;+ };const resolveGroup = async (groupId: string) => {await register();if (upgradedGroups.has(groupId)) return upgradedGroups.get(groupId)!;@@ -1563,7 +1575,11 @@ function createChatServer(local: BotGroupChatService, deps: BotGroupChatServiceDconst refused = (errorCode: string): BotGroupTaskPostResult => ({ ok: false, errorCode, retryable: false });try {if (!current()) return refused('OWNER_CHANGED');- const roomId = id.safeParse(input.groupId).success ? input.groupId : null;+ // An old local-only group has a UUID too: it is told from a server room by its local+ // history row and upgrade mapping, never by id shape. Such a group cannot carry a+ // teammate's own message, so the local service refuses for good and the result falls+ // back to the owner's private chat instead of retrying forever (bot-group-chat.md §10).+ const roomId = await taskRoomFor(input.groupId);if (!roomId) return local.postCompanionTaskMessage(input);await register();const actor = actors.find(a => a.kind === 'bot' && a.externalId === input.botId);