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-groups): end waiting server plans from shared controls

Chris85fa052552bb
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/chatServerParity.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/chatServerParity.test.ts
index 4335649120..8b438bbfbe 100644
--- a/apps/desktop/src/main/maker-ipc/__tests__/chatServerParity.test.ts
+++ b/apps/desktop/src/main/maker-ipc/__tests__/chatServerParity.test.ts
@@ -102,6 +102,23 @@ describe('server group feature parity', () => {
});
}
async function flush() { await vi.advanceTimersByTimeAsync(0); }
+ it.each([
+ ['proposed', 'dismiss'],
+ ['waiting', 'stop'],
+ ])('dismisses a %s plan using the server %s action', async (status, expectedAction) => {
+ arrange({ ...proposed, status });
+ const base = fixture.handle.getMockImplementation()!;
+ fixture.handle.mockImplementation((route, method, data) => {
+ if (route === `/conversations/${roomId}/plans/${planId}` && method === 'POST') {
+ const accepted = status === 'waiting' ? data.action === 'stop' : data.action === 'dismiss';
+ return accepted ? { body: {} } : { status: 409, body: { error: { code: 'PLAN_CLOSED' } } };
+ }
+ return base(route, method, data);
+ });
+ expect(await service.dismissPlan({ groupId: roomId, planId })).toEqual({ ok: true });
+ expect(fixture.handle.mock.calls.find(([route, method]) => route === `/conversations/${roomId}/plans/${planId}` && method === 'POST')?.[2])
+ .toMatchObject({ action: expectedAction, expectedRevision: 1 });
+ });
it.each([
['ordinary request', {}, undefined],
['@all', { mentions: { all: true, botIds: [] } }, undefined],
diff --git a/apps/desktop/src/main/maker-ipc/chatServer.ts b/apps/desktop/src/main/maker-ipc/chatServer.ts
index 027be01d4e..78924ff2e0 100644
--- a/apps/desktop/src/main/maker-ipc/chatServer.ts
+++ b/apps/desktop/src/main/maker-ipc/chatServer.ts
@@ -537,8 +537,11 @@ function createChatServer(local: BotGroupChatService, deps: BotGroupChatServiceD
const plans = await api<ServerPlan[]>(`/conversations/${room}/plans?ids=${i.planId}`);
const plan = plans.find(p => p.id === i.planId); if (!plan) throw new Error('PLAN_CLOSED');
const botId = i.botId ? actors.find(a => a.externalId === i.botId)?.id ?? id.parse(i.botId) : undefined;
+ // The shared UI uses dismiss for both an unstarted proposal and ending a paused plan.
+ // Chat Server distinguishes these actions; preserve the local service's waiting semantics.
+ const serverAction = action === 'dismiss' && plan.status === 'waiting' ? 'stop' : i.action ?? action;
await api(`/conversations/${room}/plans/${plan.id}`, 'POST', { operationId: randomUUID(), expectedRevision: plan.revision,
- action: i.action ?? action, position: i.position, botId });
+ action: serverAction, position: i.position, botId });
changed(room); return { ok: true as const };
}
async function decideArrangement(s: Snapshot, sourceId: string, text: string, forced: boolean, attachments: BotGroupAttachment[], intent: PlanIntent) {