Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(bots): 进行中条不选正在安排的伙伴;被顶替发送的安排取消失败立即重试一次
Chrisad0f79bf47cb
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/chatServer.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/chatServer.test.tsindex e36afbcb54..01bd698edd 100644--- a/apps/desktop/src/main/maker-ipc/__tests__/chatServer.test.ts+++ b/apps/desktop/src/main/maker-ipc/__tests__/chatServer.test.ts@@ -1667,6 +1667,41 @@ describe('Chat Server result delivery and refresh', () => {expect(deps.decidePlan).toHaveBeenCalledTimes(2);});+ it('retries at once when cancelling a send that a newer send overtook fails', async () => {+ const base = fixture.handle.getMockImplementation()!;+ let finishFirst!: () => void;+ const cancels: string[] = [];+ let posts = 0;+ fixture.handle.mockImplementation((route, method, data) => {+ if (route === '/me') return { body: { actor: { id: selfId }, capabilities: { groupDiscussionParity: 1 } } };+ if (route.endsWith('/messages') && method === 'POST') {+ posts += 1;+ const body = { id: `5000000${posts}-0000-4000-8000-000000000001` };+ // The first send is answered only after the second one has installed its intent.+ return posts === 1 ? new Promise(resolve => { finishFirst = () => resolve({ body }); }) : { body };+ }+ if (route.endsWith('/cancel-planning')) {+ cancels.push(route);+ return cancels.length === 1 ? { status: 503, body: { error: { code: 'UNAVAILABLE' } } } : { body: {} };+ }+ return base(route, method, data);+ });+ deps.decidePlan = vi.fn(() => new Promise(() => {})) as typeof deps.decidePlan;+ const first = send('latency-plan-d');+ await vi.advanceTimersByTimeAsync(0);+ expect(await send('latency-plan-e')).toMatchObject({ ok: true, messageId: '50000002-0000-4000-8000-000000000001' });+ await vi.advanceTimersByTimeAsync(0);+ expect(deps.decidePlan).toHaveBeenCalledOnce();+ finishFirst();+ expect(await first).toMatchObject({ ok: true, messageId: '50000001-0000-4000-8000-000000000001' });+ await vi.advanceTimersByTimeAsync(0);+ // The overtaken message is cancelled; the transient failure is retried right away, and+ // the overtaken message never starts an arrangement of its own.+ const cancel = `/conversations/${roomId}/messages/50000001-0000-4000-8000-000000000001/cancel-planning`;+ expect(cancels).toEqual([cancel, cancel]);+ expect(deps.decidePlan).toHaveBeenCalledOnce();+ });+it('shows the organizer as a planning speaker while the decision runs and removes it after', async () => {let decide!: (value: null) => void;deps.decidePlan = vi.fn(() => new Promise(resolve => { decide = resolve; })) as typeof deps.decidePlan;diff --git a/apps/desktop/src/main/maker-ipc/chatServer.ts b/apps/desktop/src/main/maker-ipc/chatServer.tsindex cd6351e503..54c5b4f605 100644--- a/apps/desktop/src/main/maker-ipc/chatServer.ts+++ b/apps/desktop/src/main/maker-ipc/chatServer.ts@@ -296,6 +296,14 @@ function createChatServer(local: BotGroupChatService, deps: BotGroupChatServiceDif (previousSourceId) await cancelPlanning(roomId, previousSourceId);for (const [sourceId, failed] of pendingPlanCancels.get(roomId) ?? []) await cancelPlanning(roomId, sourceId, failed);}+ /** A failed cancel stays pending and is retried once here (and by the next intent). */+ async function cancelPlanningWithRetry(roomId: string, cancel: () => Promise<void>) {+ try { await cancel(); }+ catch (error) {+ deps.log?.warn('Group arrangement cancel will retry', { groupId: roomId, ...chatErrorDiagnostic(error) });+ await flushPlanCancels(roomId).catch(retryError => deps.log?.warn('Group arrangement cancel failed', { groupId: roomId, ...chatErrorDiagnostic(retryError) }));+ }+ }async function replacePlanIntent(roomId: string, version = ++nextIntentVersion) {const { intent, previousSourceId } = installPlanIntent(roomId, version);await flushPlanCancels(roomId, previousSourceId);@@ -1758,17 +1766,12 @@ function createChatServer(local: BotGroupChatService, deps: BotGroupChatServiceD// Installing the intent is synchronous, so a newer send or control action still// supersedes this one in order; only the cancels of replaced decisions are awaited.const installed = intentVersion > (acceptedIntentVersions.get(roomId) ?? 0) ? installPlanIntent(roomId, intentVersion) : null;- if (installed) {- try { await flushPlanCancels(roomId, installed.previousSourceId); }- catch (error) {- // A failed cancel stays pending and is retried once here (and by the next intent).- deps.log?.warn('Group arrangement cancel will retry', { groupId: roomId, ...chatErrorDiagnostic(error) });- await flushPlanCancels(roomId).catch(retryError => deps.log?.warn('Group arrangement cancel failed', { groupId: roomId, ...chatErrorDiagnostic(retryError) }));- }- }+ if (installed) await cancelPlanningWithRetry(roomId, () => flushPlanCancels(roomId, installed.previousSourceId));const intent = installed?.intent ?? null;if (shouldPlan) {- if (!intent || planIntents.get(roomId) !== intent) await cancelPlanning(roomId, messageId);+ // Overtaken by a newer message or control action: this message must not stay deferred,+ // so its cancel gets the same immediate retry as a replaced decision's.+ if (!intent || planIntents.get(roomId) !== intent) await cancelPlanningWithRetry(roomId, () => cancelPlanning(roomId, messageId));else {intent.sourceId = messageId;void decideArrangement(s, messageId, i.text, i.division === true, prepared?.ok ? prepared.attachments : [], intent, quote).catch(() => undefined);diff --git a/apps/desktop/src/renderer/features/bots/BotGroupLiveStatus.tsx b/apps/desktop/src/renderer/features/bots/BotGroupLiveStatus.tsxindex e36700d291..b796007346 100644--- a/apps/desktop/src/renderer/features/bots/BotGroupLiveStatus.tsx+++ b/apps/desktop/src/renderer/features/bots/BotGroupLiveStatus.tsx@@ -114,7 +114,9 @@ export function BotGroupProgressStrip({? speakers.find((speaker) => speaker.activity === 'step' && speaker.member.botId === step.step.botId)?? speakers.find((speaker) => speaker.member.botId === step.step.botId): undefined;- const lead = step ? stepSpeaker : speakers.find((speaker) => speaker.activity !== 'planning') ?? speakers[0];+ // Deciding about a split is 「正在安排」 in the header and timeline, not speaking: it never+ // pins the strip, so an organizer still deciding after a few seconds is not shown as talking.+ const lead = step ? stepSpeaker : speakers.find((speaker) => speaker.activity !== 'planning');const sessionId = lead?.sessionId ?? null;const live = useAgentIslandActivity(sessionId ?? '');const since = live?.startedAtMs ?? (step ? step.plan.updatedAt : mountedAt);diff --git a/apps/desktop/src/renderer/features/bots/__tests__/BotGroupChatView.test.tsx b/apps/desktop/src/renderer/features/bots/__tests__/BotGroupChatView.test.tsxindex 4a55b57136..ad928b78c3 100644--- a/apps/desktop/src/renderer/features/bots/__tests__/BotGroupChatView.test.tsx+++ b/apps/desktop/src/renderer/features/bots/__tests__/BotGroupChatView.test.tsx@@ -2314,6 +2314,24 @@ describe('Telegram / Slack-grade timeline', () => {expect(screen.getByTestId('content-header').textContent).toContain('bots.groupChat.header.planning:咪咪');});+ it('does not pin the progress strip for an organizer still deciding about a split', async () => {+ mocks.getBotGroup.mockResolvedValue({ ok: true, group: detail({+ speakingBotIds: ['mimi'],+ planningBotId: 'mimi',+ round: { status: 'running', speakers: [{ botId: 'mimi', sessionId: null, activity: 'planning' }], canContinue: false },+ }) });+ // Well past the few seconds after which a speaking teammate would pin the strip.+ mocks.activity = { compactDetail: '', startedAtMs: Date.now() - 5_000, phase: 'running' };+ try {+ renderView();+ const row = await screen.findByTestId('bot-group-speaking');+ expect(row.getAttribute('data-activity')).toBe('planning');+ expect(screen.queryByTestId('bot-group-progress')).toBeNull();+ } finally {+ mocks.activity = null;+ }+ });+it('pins a progress strip above the composer while a plan step runs', async () => {const running = plan({status: 'running',