Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(desktop): treat only talk plans as queues
zqchris49f5bdc0ad67
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/chatServer.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/chatServer.test.tsindex e9766370f6..c1ed360e7a 100644--- a/apps/desktop/src/main/maker-ipc/__tests__/chatServer.test.ts+++ b/apps/desktop/src/main/maker-ipc/__tests__/chatServer.test.ts@@ -1374,27 +1374,43 @@ describe('Chat Server result delivery and refresh', () => {expect(delivery[2]).not.toHaveProperty('continueDiscussion');});- it('gives a discussion turn only the request, earlier answers on its card and the requester\'s additions', async () => {+ // A queue turn reads only its own card; a division of work (every older plan is kind=work after+ // the server migration) keeps the main-group context it had, including chat-only steps without a workspace.+ it.each(['talk', 'work'] as const)('gives a %s step the context of its kind', async (kind) => {const planId = '80000000-0000-4000-8000-000000000001';const answerId = '50000000-0000-4000-8000-000000000011', noteId = '50000000-0000-4000-8000-000000000012';+ const unrelatedFile = '60000000-0000-4000-8000-000000000021', answerFile = '60000000-0000-4000-8000-000000000022';const plan = { id: planId, revision: 3, source_message_id: execution.source_message_id, request_text: 'One reply per message?', organizer_id: otherBot, creator_id: selfId,- note_message_ids: [noteId], status: 'running', current_step: 1, kind: 'talk', created_at: '2026-10-03T00:00:00Z', updated_at: '2026-10-03T00:00:00Z',- steps: [{ position: 0, botId: otherBot, botName: 'Peer', task: '', status: 'done', resultMessageId: answerId }, { position: 1, botId, botName: 'Bot', task: 'tests', status: 'running' }] };+ note_message_ids: [noteId], status: 'running', current_step: 1, kind, created_at: '2026-10-03T00:00:00Z', updated_at: '2026-10-03T00:00:00Z',+ steps: [{ position: 0, botId: otherBot, botName: 'Peer', task: 'draft', status: 'done', resultMessageId: answerId }, { position: 1, botId, botName: 'Bot', task: 'tests', status: 'running' }] };+ const file = (mediaId: string, caption: string) => ({ type: 'media', mediaId, caption });singleSpeaker((route, _method, body) => {- if (route === '/executions/claim' && !claimed) { claimed = true; return { body: { execution: { ...execution, access_mode: 'owner', plan_id: planId, plan_step: 1 } } }; }+ if (route === '/executions/claim' && !claimed) { claimed = true; return { body: { execution: { ...execution, access_mode: kind === 'talk' ? 'owner' : 'chat', plan_id: planId, plan_step: 1 } } }; }if (route.includes('/plans?ids=')) return { body: [plan] };- if (route.includes('/messages?all=true')) return { body: [message('50000000-0000-4000-8000-000000000013', 'unrelated main group chatter'),- message(answerId, 'The first answer', { authorId: otherBot, author: { kind: 'bot', name: 'Peer' }, origin: 'bot' }), message(noteId, 'Mind the old groups')] };+ if (route.includes('/messages?all=true')) return { body: [+ message('50000000-0000-4000-8000-000000000013', 'unrelated main group chatter', { content: [{ type: 'text', text: 'unrelated main group chatter' }, file(unrelatedFile, 'old.png')] }),+ message(answerId, 'The first answer', { authorId: otherBot, author: { kind: 'bot', name: 'Peer' }, origin: 'bot', content: [{ type: 'text', text: 'The first answer' }, file(answerFile, 'draft.png')] }),+ message(noteId, 'Mind the old groups')] };if (route.endsWith(`/messages/${execution.source_message_id}`)) return { body: message(execution.source_message_id, 'One reply per message?') };return body ? undefined : undefined;});+ fixture.download.mockImplementation(async (_room: string, mediaId: string) => ({ id: mediaId, name: `${mediaId}.png`, category: 'image',+ mimeType: 'image/png', size: 1, path: `/test/${mediaId}.png`, url: null }));await start();- expect(prompt()).toContain('You are turn 2 of 2. Your focus: tests.');expect(prompt()).toContain('The first answer');expect(prompt()).toContain('Mind the old groups');- expect(prompt()).not.toContain('unrelated main group chatter');- // A discussion only talks: no project folder or worktree, and a plain lane without a work directory.- expect(deps.ensureLane).toHaveBeenCalledWith(expect.objectContaining({ plan: { planId, workDir: '', sessionId: undefined } }));+ const downloaded = fixture.download.mock.calls.map(([, mediaId]) => mediaId);+ if (kind === 'talk') {+ expect(prompt()).toContain('You are turn 2 of 2. Your focus: tests.');+ expect(prompt()).not.toContain('unrelated main group chatter');+ expect(downloaded).toEqual([answerFile]);+ // A discussion only talks: no project folder or worktree, and a plain lane without a work directory.+ expect(deps.ensureLane).toHaveBeenCalledWith(expect.objectContaining({ plan: { planId, workDir: '', sessionId: undefined } }));+ } else {+ expect(prompt()).not.toContain('You are turn');+ expect(prompt()).toContain('unrelated main group chatter');+ expect(downloaded).toEqual(expect.arrayContaining([answerFile, unrelatedFile]));+ }});it('sends without holding the request for a helper-model arrangement decision', async () => {diff --git a/apps/desktop/src/main/maker-ipc/chatServer.ts b/apps/desktop/src/main/maker-ipc/chatServer.tsindex 29ae7ef2d6..a8f9c58587 100644--- a/apps/desktop/src/main/maker-ipc/chatServer.ts+++ b/apps/desktop/src/main/maker-ipc/chatServer.ts@@ -1557,10 +1557,15 @@ function createChatServer(local: BotGroupChatService, deps: BotGroupChatServiceD// Text stays bounded, but unseen attachments may precede the latest text page.// The server watermark is scoped to this bot/grant/plan step and advances only on success.// A Thread lane offers only its own Thread's files.- const attachmentHistory = thread ? [...focusMessages]- : [...history, ...focusMessages.filter(message => !history.some(known => known.id === message.id))];+ // A queue turn sees only its request, the earlier answers and the requester's additions;+ // it takes only their files, never the rest of the group's (bot-group-chat.md §7.0).+ const talkPlan = run.plan?.kind === 'talk' ? run.plan : undefined;+ const talkIds = talkPlan ? new Set([talkPlan.source_message_id, ...(talkPlan.note_message_ids ?? []),+ ...talkPlan.steps.filter(step => step.position < execution.plan_step!).flatMap(step => step.resultMessageId ? [step.resultMessageId] : [])]) : null;+ const known = [...history, ...focusMessages.filter(message => !history.some(other => other.id === message.id))];+ const attachmentHistory = thread ? [...focusMessages] : talkIds ? known.filter(message => talkIds.has(message.id)) : known;const after = BigInt(execution.attachment_after_seq ?? '0');- while (!thread && execution.attachment_after_seq !== undefined && page.length === 100) {+ while (!thread && !talkIds && execution.attachment_after_seq !== undefined && page.length === 100) {const before = page.reduce((min, m) => BigInt(m.seq) < min ? BigInt(m.seq) : min, contextBefore);if (before <= after + 1n) break;page = await api<Message[]>(`/conversations/${s.room.id}/messages?all=true&limit=100&before=${before}`);@@ -1629,7 +1634,7 @@ function createChatServer(local: BotGroupChatService, deps: BotGroupChatServiceDconst conversation = thread ? {thread: { root: thread.root ? focusMessage(thread.root) : { id: threadRootId, unavailable: true },replies: chronological(thread.replies).map(focusMessage), earlierRepliesOmitted: thread.earlierRepliesOmitted },- } : run.plan ? {} : mainGroupContext(chronological(history.filter(message => !message.threadRootId)), promptMessage);+ } : run.plan?.kind === 'talk' ? {} : mainGroupContext(chronological(history.filter(message => !message.threadRootId)), promptMessage);const talk = run.plan?.kind === 'talk' ? run.plan : undefined;const prompt = [run.context.kind === 'member.joined'diff --git a/apps/desktop/src/renderer/features/bots/BotGroupPlan.tsx b/apps/desktop/src/renderer/features/bots/BotGroupPlan.tsxindex 5be2e8f197..7afcfd7c2e 100644--- a/apps/desktop/src/renderer/features/bots/BotGroupPlan.tsx+++ b/apps/desktop/src/renderer/features/bots/BotGroupPlan.tsx@@ -274,7 +274,7 @@ export function botGroupQueueWindow(plan: BotGroupPlanView): { start: number; en/*** Body of the 安排卡. A legacy plan is the organizer's message (the usual Bot header plus the- * 负责人 tag). A server queue (`plan.kind`) stands on its own under the request: only its turns,+ * 负责人 tag). A server queue (`kind: 'talk'`) stands on its own under the request: only its turns,* folded to a few around the current one.* `actionable` = the group's open plan, still waiting for 开始;* `reassignable` = the open plan stopped after a step (steps not done can change hands).@@ -317,7 +317,8 @@ export function BotGroupPlanCard({const timing: StepTiming = { runningSince, doneAt, locale };const canReassign = reassignable && plan.steps.some((step) => step.status === 'pending' || step.status === 'failed');const underWay = plan.status === 'running' || plan.status === 'waiting';- const arranged = plan.kind !== undefined;+ // Only a server queue stands on its own; a division of work keeps its organizer card and actions.+ const arranged = plan.kind === 'talk';const turns = arranged ? botGroupQueueWindow(plan) : { start: 0, end: plan.steps.length };const folded = !expanded && turns.end - turns.start < plan.steps.length;const shown = folded ? plan.steps.slice(turns.start, turns.end) : plan.steps;diff --git a/apps/desktop/src/renderer/features/bots/BotGroupTimelineItem.tsx b/apps/desktop/src/renderer/features/bots/BotGroupTimelineItem.tsxindex c5dc57d325..b593f251d4 100644--- a/apps/desktop/src/renderer/features/bots/BotGroupTimelineItem.tsx+++ b/apps/desktop/src/renderer/features/bots/BotGroupTimelineItem.tsx@@ -443,7 +443,7 @@ function BotGroupTimelineItemImpl(props: BotGroupTimelineItemProps) {// A server queue stands on its own under the request: the turns it lines up, never folded// into someone's reply (bot-group-chat.md §7).- if (message.kind === 'plan' && props.plan?.kind) {+ if (message.kind === 'plan' && props.plan?.kind === 'talk') {return (<Row {...rowProps} block="author"><div className="flex min-w-0 gap-2.5">diff --git a/apps/desktop/src/renderer/features/bots/__tests__/BotGroupChatView.test.tsx b/apps/desktop/src/renderer/features/bots/__tests__/BotGroupChatView.test.tsxindex a714dc9039..4a1c1674fe 100644--- a/apps/desktop/src/renderer/features/bots/__tests__/BotGroupChatView.test.tsx+++ b/apps/desktop/src/renderer/features/bots/__tests__/BotGroupChatView.test.tsx@@ -2099,8 +2099,9 @@ describe('BotGroupChatView', () => {});describe('分工', () => {- it('shows the organizer’s plan card and starts or skips the open plan', async () => {- mocks.getBotGroup.mockResolvedValue({ ok: true, group: withPlan(plan()) });+ // A server's queue migration marks every older plan kind=work: it stays a division of work.+ it.each([undefined, 'work'] as const)('shows the organizer’s plan card and starts or skips the open plan (kind=%s)', async (kind) => {+ mocks.getBotGroup.mockResolvedValue({ ok: true, group: withPlan(plan(kind ? { kind } : {})) });renderView();const card = await screen.findByTestId('bot-group-plan');expect(card.textContent).toContain('bots.groupChat.plan.intro');