Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(bots): restore 分工 in single-speaker groups
Chrisa134558e4c58
diff --git a/apps/desktop/scripts/fixtures/group-control/ui-page.mjs b/apps/desktop/scripts/fixtures/group-control/ui-page.mjsindex df09a2e719..6f8d58fd4f 100644--- a/apps/desktop/scripts/fixtures/group-control/ui-page.mjs+++ b/apps/desktop/scripts/fixtures/group-control/ui-page.mjs@@ -60,9 +60,13 @@ export default {data: { ...base, members: QUEUE_CROWD, arrangement: 'long' },},settings: {- about: 'Single-speaker group settings: reply mode remains independent; no speaking mode, organizer or project folder',+ about: 'Single-speaker group settings: reply mode, organizer and project folder as before; no speaking mode',data: { ...base, arrangement: 'running', settings: true },},+ division: {+ about: 'Single-speaker group: 「+」→ 安排分工 is offered again; tagged, the composer says steps may be written out',+ data: { ...base, arrangement: 'done' },+ },'thread-unread': {about: 'Server read state: unread thread entries (with @you), the in-chat 话题 hint above the composer and its list of this group\'s Threads',data: { ...base, bubbles: true, threadUnread: true },@@ -121,8 +125,17 @@ export default {await replyMode.click();await page.getByRole('option', { name: await ui.t('bots.groupChat.settings.replyModeMentioned'), exact: true }).click();assert.equal(await replyMode.innerText(), await ui.t('bots.groupChat.settings.replyModeMentioned'));- for (const key of ['bots.groupChat.settings.speakingMode', 'bots.groupChat.organizer', 'bots.groupChat.settings.projectDir'])- assert.equal(await drawer.getByText(await ui.t(key), { exact: true }).count(), 0, key);+ // Reply mode and the 分工 settings stay; one teammate at a time leaves no speaking mode (bot-group-chat.md §4.0).+ assert.equal(await drawer.getByText(await ui.t('bots.groupChat.settings.speakingMode'), { exact: true }).count(), 0, 'speakingMode');+ for (const key of ['bots.groupChat.organizer', 'bots.groupChat.settings.projectDir'])+ assert.ok(await drawer.getByText(await ui.t(key), { exact: true }).count() > 0, key);+ return;+ }+ if (ui.case === 'division') {+ await page.getByRole('button', { name: '更多操作' }).click();+ await page.getByRole('menuitem', { name: /安排分工/ }).click();+ await page.waitForFunction(() => document.querySelector('textarea')?.getAttribute('placeholder')?.startsWith('写好谁做什么'));+ await ui.capture('tagged');return;}if (ui.case === 'work-mentioned') {diff --git a/apps/desktop/src/main/maker-ipc/__tests__/chatServer.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/chatServer.test.tsindex d804b99ab8..929f71d511 100644--- a/apps/desktop/src/main/maker-ipc/__tests__/chatServer.test.ts+++ b/apps/desktop/src/main/maker-ipc/__tests__/chatServer.test.ts@@ -1614,24 +1614,78 @@ describe('Chat Server result delivery and refresh', () => {expect(deliveries()[0][2]).not.toHaveProperty('continueDiscussion');});- it('sends without holding the request for a helper-model arrangement decision', async () => {- singleSpeaker();- deps.decidePlan = vi.fn() as typeof deps.decidePlan;- expect(await service.sendMessage({ groupId: roomId, text: 'Make a draft', clientId: 'single-speaker-send', mentions: { all: false, botIds: [] }, division: true }))- .toMatchObject({ ok: true });- await vi.advanceTimersByTimeAsync(0);- const post = fixture.handle.mock.calls.find(([route, method]) => route === `/conversations/${roomId}/messages` && method === 'POST')!;- expect(post[2].deferExecution).toBe(false);- expect(deps.decidePlan).not.toHaveBeenCalled();+ // bot-group-chat.md §7.0 (2026-10-23): 「安排分工」 is back on these servers. A request that writes+ // out who does what becomes that card and starts, with no helper model; otherwise the organizer+ // arranges it. The request is held so the server's own queue does not answer it first.+ describe('安排分工', () => {+ const sourceId = '50000000-0000-4000-8000-000000000031', planId = '80000000-0000-4000-8000-000000000031';+ const named = () => members().map(m => m.id === otherBot ? { ...m, name: 'Nova' } : m);+ function divisionServer(open: object[] = []) {+ singleSpeaker((route, method) => {+ if (route.endsWith('/snapshot')) return { body: { room: room(roomId), members: named(), messages: [], cursor: '1' } };+ if (route === `/conversations/${roomId}/messages` && method === 'POST') return { body: { id: sourceId } };+ if (route === `/conversations/${roomId}/plans` && method === 'POST') return { body: { id: planId, revision: 1 } };+ if (route === `/conversations/${roomId}/plans`) return { body: open };+ return undefined;+ });+ }+ const posts = () => fixture.handle.mock.calls.filter(([, method]) => method === 'POST');+ const send = async (text: string) => {+ expect(await service.sendMessage({ groupId: roomId, text, clientId: `division-${text.length}`, mentions: { all: false, botIds: [] }, division: true }))+ .toMatchObject({ ok: true });+ await vi.advanceTimersByTimeAsync(0);+ };++ it('starts the card a request writes out, without the organizer', async () => {+ divisionServer();+ deps.decidePlan = vi.fn() as typeof deps.decidePlan;+ await send('登录页:@Bot (Owner) 出方案,然后 @Nova (Owner) 按方案实现');+ expect(posts().find(([route]) => route === `/conversations/${roomId}/messages`)![2]).toMatchObject({ deferExecution: true });+ expect(posts().find(([route]) => route === `/conversations/${roomId}/plans`)![2]).toMatchObject({ sourceMessageId: sourceId,+ steps: [{ botId, task: '出方案' }, { botId: otherBot, task: '按方案实现' }] });+ expect(posts().find(([route]) => route === `/conversations/${roomId}/plans/${planId}`)![2]).toMatchObject({ action: 'start', expectedRevision: 1 });+ expect(deps.decidePlan).not.toHaveBeenCalled();+ });++ it('asks the organizer when the steps are not written out', async () => {+ divisionServer();+ deps.decidePlan = vi.fn(async () => ({ needsPlan: true as const, steps: [{ botId: otherBot, task: 'build' }] }));+ await send('@Bot (Owner) 和 @Nova (Owner) 一起做登录页');+ expect(deps.decidePlan).toHaveBeenCalledWith(expect.objectContaining({ mode: 'forced' }), expect.anything());+ expect(posts().find(([route]) => route === `/conversations/${roomId}/plans`)![2]).toMatchObject({ steps: [{ botId: otherBot, task: 'build' }] });+ expect(posts().some(([route]) => route === `/conversations/${roomId}/plans/${planId}`)).toBe(false);+ });++ it('answers the request at once when no card comes of it, instead of a queue two minutes later', async () => {+ divisionServer();+ deps.decidePlan = vi.fn(async () => { throw new Error('model unavailable'); });+ await send('Make a draft');+ expect(posts().some(([route]) => route === `/conversations/${roomId}/messages/${sourceId}/continue`)).toBe(true);+ });++ it('ends your queue waiting for 继续 before opening the card', async () => {+ const queue = { id: '80000000-0000-4000-8000-000000000032', revision: 4, source_message_id: execution.source_message_id, request_text: 'Q', organizer_id: botId,+ creator_id: selfId, note_message_ids: [], status: 'waiting', current_step: 4, kind: 'talk', created_at: '2026-10-03T00:00:00Z', updated_at: '2026-10-03T00:00:00Z',+ steps: [{ position: 4, botId, botName: 'Bot', task: '', status: 'done' }] };+ divisionServer([queue]);+ await send('@Bot (Owner) 出方案');+ const routes = posts().map(([route]) => route);+ expect(routes.indexOf(`/conversations/${roomId}/plans/${queue.id}`)).toBeLessThan(routes.indexOf(`/conversations/${roomId}/plans`));+ expect(posts().find(([route]) => route === `/conversations/${roomId}/plans/${queue.id}`)![2]).toMatchObject({ action: 'stop', expectedRevision: 4 });+ });});+ // Words for a card under way reach its current step when they would wake anyone: the requester+ // adding to a turn, or asking the teammate who just finished a 分工 step to redo it (§4.0, §7.4).it.each([['waiting for 继续: a new request replaces it', 'waiting', `/conversations/${roomId}/messages`],['mid-turn: the words go to the teammate answering', 'running', `/conversations/${roomId}/plans/80000000-0000-4000-8000-000000000002/messages`],- ['mention-only mid-turn: unmentioned words stay ordinary messages', 'running', `/conversations/${roomId}/messages`, 'mentioned'],- ] as const)('with an open queue %s', async (_label, status, route, responseMode: string = 'all') => {+ ['mention-only mid-turn: unmentioned words stay ordinary messages', 'running', `/conversations/${roomId}/messages`, 'talk', 'mentioned'],+ ['of a 分工 waiting for 继续: a redo for its teammate', 'waiting', `/conversations/${roomId}/plans/80000000-0000-4000-8000-000000000002/messages`, 'work'],+ ['of a 分工 waiting for 继续 in a mention-only group: an ordinary message', 'waiting', `/conversations/${roomId}/messages`, 'work', 'mentioned'],+ ] as const)('with an open card %s', async (_label, status, route, kind: string = 'talk', responseMode: string = 'all') => {const queue = { id: '80000000-0000-4000-8000-000000000002', revision: 1, source_message_id: execution.source_message_id, request_text: 'Q', organizer_id: botId,- creator_id: selfId, note_message_ids: [], status, current_step: 0, kind: 'talk', created_at: '2026-10-03T00:00:00Z', updated_at: '2026-10-03T00:00:00Z',+ creator_id: selfId, note_message_ids: [], status, current_step: 0, kind, created_at: '2026-10-03T00:00:00Z', updated_at: '2026-10-03T00:00:00Z',steps: [{ position: 0, botId, botName: 'Bot', task: '', status: status === 'waiting' ? 'done' : 'running' }, { position: 1, botId: otherBot, botName: 'Peer', task: '', status: 'pending' }] };singleSpeaker(route => route === `/conversations/${roomId}/plans` ? { body: [queue] }: route.endsWith('/snapshot') ? { body: { room: { ...room(roomId), response_mode: responseMode }, members: members(), messages: [], cursor: '1' } } : undefined);diff --git a/apps/desktop/src/main/maker-ipc/botGroupDivision.ts b/apps/desktop/src/main/maker-ipc/botGroupDivision.tsindex 2ad3ab273d..e47751a9f8 100644--- a/apps/desktop/src/main/maker-ipc/botGroupDivision.ts+++ b/apps/desktop/src/main/maker-ipc/botGroupDivision.ts@@ -147,21 +147,35 @@ export function parsePlanDecision(if (!Array.isArray(record.steps) || record.steps.length === 0 || record.steps.length > BOT_GROUP_PLAN_MAX_STEPS) {return null;}- const steps: PlanStepDraft[] = [];+ const items: Array<{ botId: string; task: string }> = [];for (const item of record.steps) {if (!item || typeof item !== 'object') return null;const { botId, task } = item as { botId?: unknown; task?: unknown };if (typeof botId !== 'string' || !memberIds.has(botId)) return null;if (typeof task !== 'string') return null;+ items.push({ botId, task });+ }+ const steps = draftPlanSteps(items);+ if (!steps) return null;+ if (mode === 'auto' && new Set(steps.map((step) => step.botId)).size < 2) return { needsPlan: false };+ return { needsPlan: true, steps };+}++/**+ * Card steps from an organizer's answer or a request that wrote them out (§7.0). Each step stops+ * for 继续, so one member's consecutive work is one step; code, not a prompt, keeps it so.+ * Null when a task is empty or the merged steps exceed the plan limit.+ */+export function draftPlanSteps(items: ReadonlyArray<{ botId: string; task: string }>): PlanStepDraft[] | null {+ const steps: PlanStepDraft[] = [];+ for (const { botId, task } of items) {const flat = task.replace(/\s+/g, ' ').trim();if (!flat) return null;- // Each step stops for 继续, so one member's consecutive work is one step (code, not prompt, keeps it so).const previous = steps[steps.length - 1];if (previous && previous.botId === botId) previous.task = clamp(`${previous.task};${flat}`, BOT_GROUP_PLAN_TASK_MAX_CHARS);else steps.push({ botId, task: clamp(flat, BOT_GROUP_PLAN_TASK_MAX_CHARS) });}- if (mode === 'auto' && new Set(steps.map((step) => step.botId)).size < 2) return { needsPlan: false };- return { needsPlan: true, steps };+ return steps.length && steps.length <= BOT_GROUP_PLAN_MAX_STEPS ? steps : null;}export interface PlanStepBriefInput {diff --git a/apps/desktop/src/main/maker-ipc/chatServer.ts b/apps/desktop/src/main/maker-ipc/chatServer.tsindex dc54875354..2809cf7850 100644--- a/apps/desktop/src/main/maker-ipc/chatServer.ts+++ b/apps/desktop/src/main/maker-ipc/chatServer.ts@@ -19,7 +19,8 @@ import { chatErrorDiagnostic, chatGroupFailure, missingGroupCode } from './chatSimport { createChatMedia } from './chatServerMedia.js';import { prepareChatReplyImages } from './chatServerReplyImages.js';import { chatServerWorkspaces } from './chatServerWorkspaces.js';-import { buildPlanStepBrief } from './botGroupDivision.js';+import { buildPlanStepBrief, draftPlanSteps, type PlanStepDraft } from './botGroupDivision.js';+import { splitBotGroupRelaySteps } from '@cindy/maker-shared/botGroupMentions';import { chatMigrationReceipts } from './chatMigrationReceipts.js';import { prepareBotGroupTaskPost, type BotGroupTaskPostSnapshot } from './botGroupTaskPostSnapshot.js';import { registerGroupToolAuthority, GroupToolAuthorizationError } from './botGroupToolAuthorization.js';@@ -225,6 +226,8 @@ const quoteAttachments = (count: number, name: string | null) => count ? { attac/** A main-group reply reads only the latest messages, each shortened; its lane keeps earlier turns. */const MAIN_GROUP_CONTEXT_MESSAGES = 12;const MAIN_GROUP_CONTEXT_CHARS = 600;+/** The answer right before a queue turn, as much as a 分工 step's hand-off note (botGroupDivision). */+const PREVIOUS_ANSWER_CHARS = 2000;function mainGroupContext<V extends { text: string }>(messages: Message[], view: (m: Message) => V) {const recent = messages.slice(-MAIN_GROUP_CONTEXT_MESSAGES).map(m => {const v = view(m);@@ -238,10 +241,16 @@ function mainGroupContext<V extends { text: string }>(messages: Message[], view:*/function discussionTurnBrief(plan: ServerPlan, position: number, history: readonly Message[]) {const step = plan.steps[position];- const earlierAnswers = plan.steps.filter(s => s.position < position).flatMap(s => {+ const answers = plan.steps.filter(s => s.position < position).flatMap(s => {const result = history.find(m => m.id === s.resultMessageId);return result ? [{ from: s.botName, text: bodyText(result) }] : [];});+ // Each turn builds on the one before it: that answer keeps the hand-off allowance of a 分工+ // step, older ones a main-group message's, so a long queue does not resend every answer in full.+ const earlierAnswers = answers.map((answer, index) => {+ const max = index === answers.length - 1 ? PREVIOUS_ANSWER_CHARS : MAIN_GROUP_CONTEXT_CHARS;+ return answer.text.length > max ? { ...answer, text: `${answer.text.slice(0, max)}…`, shortened: true } : answer;+ });const notes = history.filter(m => plan.note_message_ids?.includes(m.id)).map(bodyText);return [`Teammates answer this request one at a time. You are turn ${position + 1} of ${plan.steps.length}.${step?.task ? ` Your focus: ${step.task}.` : ''} Give your own view and build on the earlier answers instead of repeating them.`,@@ -1383,23 +1392,63 @@ function createChatServer(local: BotGroupChatService, deps: BotGroupChatServiceD}), request: text,requestAttachments: attachments.map(a => a.name), currentSteps: proposed?.steps,...(quote ? { requestQuote: { from: quote.authorName, text: quote.excerpt, ...quoteAttachments(quote.attachmentCount, quote.attachmentName) } } : {}) }, controller.signal);- // Steps read the plan's request; keep what it quotes beside it when the server's limit allows.- const quoteLine = quote ? buildBotGroupQuoteCard(quote).fallback : '';- const request = quoteLine && text.length + quoteLine.length + 2 <= 8000 ? `${text}\n\n${quoteLine}` : text;+ const request = planRequest(text, quote);if (!current() || controller.signal.aborted || planIntents.get(s.room.id) !== intent) return;if (decision?.needsPlan) await api(`/conversations/${s.room.id}/plans`, 'POST', {operationId: `plan:${sourceId}`, sourceMessageId: sourceId, organizerId: organizer.id, request, steps: decision.steps });- else if (explicit) await cancelPlanning(s.room.id, sourceId, true);+ else if (explicit) await settleExplicitRequest(s.room.id, sourceId, forced && !proposed);else await api(`/conversations/${s.room.id}/messages/${sourceId}/continue`, 'POST', { operationId: `discuss:${sourceId}`, ...(groupDiscussionParity ? { automatic: true } : {}) });} catch (error) {if (current() && !controller.signal.aborted) {// An organizer failure must not swallow the user's posted request.- if (explicit) await cancelPlanning(s.room.id, sourceId, true);+ if (explicit) await settleExplicitRequest(s.room.id, sourceId, forced);else await api(`/conversations/${s.room.id}/messages/${sourceId}/continue`, 'POST', { operationId: `discuss:${sourceId}`, ...(groupDiscussionParity ? { automatic: true } : {}) });deps.log?.warn('Group arrangement could not be prepared', { groupId: s.room.id });}} finally { delete intent.sourceId; if (planning.get(s.room.id) === pending) { planning.delete(s.room.id); changed(s.room.id); } }}+ /** Steps read the plan's request; keep what it quotes beside it when the server's limit allows. */+ function planRequest(text: string, quote: BotGroupQuoteView | null) {+ const quoteLine = quote ? buildBotGroupQuoteCard(quote).fallback : '';+ return quoteLine && text.length + quoteLine.length + 2 <= 8000 ? `${text}\n\n${quoteLine}` : text;+ }+ /**+ * A 分工 with no card. Servers that can cancel a planning hold are told so. A single-speaker+ * server cannot, and would queue the held request two minutes later; a 「安排分工」 request is+ * answered right away instead (named teammates, else the first), and a note on your proposed+ * card stays a note.+ */+ async function settleExplicitRequest(roomId: string, sourceId: string, answer: boolean) {+ if (!singleSpeaker) return cancelPlanning(roomId, sourceId, true);+ if (answer) await api(`/conversations/${roomId}/messages/${sourceId}/continue`, 'POST', { operationId: `discuss:${sourceId}` });+ }+ /** Steps a 分工 request wrote out (§7.0), as teammates this account may give work to. */+ function writtenPlanSteps(s: Snapshot, text: string): PlanStepDraft[] | null {+ const bots = s.members.filter(m => m.kind === 'bot' && m.state === 'joined');+ const written = splitBotGroupRelaySteps(text, { allLabels: [],+ members: bots.map(m => ({ botId: m.id, name: memberName(m), displayName: m.name, nickname: m.nickname })) });+ // A step for a teammate you may not give work to goes to the organizer, not into a neighbour's task.+ const assignable = (botId: string) => bots.some(m => m.id === botId && (m.ownerActorId === selfId || m.guestAccess !== 'none')+ && (!localBot(m.id) || localBot(m.id)?.status === 'active'));+ return written?.every(step => assignable(step.botId)) ? draftPlanSteps(written) : null;+ }+ /** The user wrote the card, so it starts at once; each step still stops for 继续 (§7.4). */+ async function openWrittenPlan(s: Snapshot, sourceId: string, request: string, steps: PlanStepDraft[], intent: PlanIntent) {+ if (!current() || planIntents.get(s.room.id) !== intent) return;+ const organizerId = steps.some(step => step.botId === s.room.organizer_id) ? s.room.organizer_id! : steps[0]!.botId;+ let plan: ServerPlan;+ try {+ plan = await api<ServerPlan>(`/conversations/${s.room.id}/plans`, 'POST', {+ operationId: `plan:${sourceId}`, sourceMessageId: sourceId, organizerId, request, steps });+ } catch (error) {+ await settleExplicitRequest(s.room.id, sourceId, true);+ throw error;+ } finally { delete intent.sourceId; }+ // Not started (the card stays proposed with 开始) if a newer action took over meanwhile.+ if (current() && planIntents.get(s.room.id) === intent) await api(`/conversations/${s.room.id}/plans/${plan.id}`, 'POST', {+ operationId: `start:${plan.id}`, expectedRevision: plan.revision, action: 'start' });+ changed(s.room.id);+ }async function updateExecution(run: Running, action: string, extra: Record<string, unknown> = {}) {return api(`/conversations/${run.execution.conversation_id}/executions/${run.execution.id}`, 'POST', {// Each heartbeat must extend the lease rather than replay a cached receipt.@@ -2416,15 +2465,23 @@ function createChatServer(local: BotGroupChatService, deps: BotGroupChatServiceDconst plans = await plansRead;const openPlan = plans.find(p => ['proposed','running','waiting'].includes(p.status));const proposed = openPlan?.status === 'proposed' && openPlan.creator_id === selfId;- // A single-speaker server arranges turns itself (several named teammates, or everyone when- // nobody is named); the send no longer asks a helper model whether to divide the work first.- if (i.division && openPlan && !proposed && !singleSpeaker) throw new Error('PLAN_OPEN');- // Reply mode decides whether a message triggers work; single-speaker only decides its order.- const canTrigger = (!singleSpeaker && i.division) || s.room.response_mode !== 'mentioned' || !namesNobody(i.mentions);- // A queue waiting for 继续 gives way to a new request; only a turn under way takes additions (§4.0).- const commentPlan = canTrigger && openPlan && openPlan.status !== 'proposed' && !(singleSpeaker && openPlan.kind === 'talk' && openPlan.status === 'waiting') && !i.mentions.botIds.length && !i.mentions.all && (openPlan.creator_id === selfId || s.members.some(m => m.id === selfId && ['owner','admin'].includes(m.role))) ? openPlan : undefined;- const shouldPlan = canTrigger && !singleSpeaker && !!deps.decidePlan && (i.division || (!i.mentions.botIds.length && (!proposed || !i.mentions.all)))- && (!openPlan || proposed);+ // Additions are written as the human, so a teammate's role does not count (planView's canAdd).+ const mayAdd = !!openPlan && (openPlan.creator_id === selfId || s.members.some(m => m.id === selfId && ['owner','admin'].includes(m.role)));+ // The server opens one card at a time: a queue of yours waiting for 继续 ends when you ask for a+ // 分工; anything else still open refuses it (bot-group-chat.md §7.0).+ const settleQueue = singleSpeaker && i.division && openPlan?.kind === 'talk' && openPlan.status === 'waiting' && mayAdd ? openPlan : undefined;+ if (i.division && openPlan && !proposed && !settleQueue) throw new Error('PLAN_OPEN');+ // Reply mode decides whether an unaddressed message wakes anyone (single-speaker servers apply it too).+ const canTrigger = i.division || s.room.response_mode !== 'mentioned' || !namesNobody(i.mentions);+ // Words for a card under way reach its current step only when they would wake anyone (§4.0,+ // §7.4); a queue waiting for 继续 gives way to a new request instead.+ const commentPlan = canTrigger && openPlan && openPlan.status !== 'proposed' && !(singleSpeaker && openPlan.kind === 'talk' && openPlan.status === 'waiting') && !i.mentions.botIds.length && !i.mentions.all && mayAdd ? openPlan : undefined;+ // Single-speaker servers queue turns themselves; only a 分工, or words about your proposed card,+ // wait for the arrangement. A 分工 that writes out its steps needs no helper model.+ const shouldPlan = singleSpeaker+ ? i.division || (proposed && namesNobody(i.mentions) && !!deps.decidePlan)+ : canTrigger && !!deps.decidePlan && (i.division || (!i.mentions.botIds.length && (!proposed || !i.mentions.all)))+ && (!openPlan || proposed);const prepared = i.attachments?.length ? await deps.prepareAttachments?.({ groupId: i.groupId, attachments: i.attachments, controllerDeviceId: origin?.controllerDeviceId }) : undefined;if (i.attachments?.length && (!prepared || !prepared.ok)) {const error = new Error(prepared && !prepared.ok ? prepared.errorCode === 'INVALID_PARAMS' ? 'INVALID_ATTACHMENT' : prepared.errorCode : 'INVALID_ATTACHMENT');@@ -2473,7 +2530,16 @@ function createChatServer(local: BotGroupChatService, deps: BotGroupChatServiceDif (!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);+ const arrange = async () => {+ // If the queue moved on meanwhile, the server refuses the card and the request is answered instead.+ if (settleQueue) await api(`/conversations/${roomId}/plans/${settleQueue.id}`, 'POST', {+ operationId: `settle:${settleQueue.id}:${messageId}`, expectedRevision: settleQueue.revision, action: 'stop' })+ .catch(error => deps.log?.warn('Waiting queue could not be ended', { groupId: roomId, ...chatErrorDiagnostic(error) }));+ const written = singleSpeaker && i.division && !i.mentions.all ? writtenPlanSteps(s, i.text) : null;+ if (written) await openWrittenPlan(s, messageId, planRequest(i.text, quote), written, intent);+ else await decideArrangement(s, messageId, i.text, i.division === true, prepared?.ok ? prepared.attachments : [], intent, quote);+ };+ void arrange().catch(error => deps.log?.warn('Group arrangement failed', { groupId: roomId, ...chatErrorDiagnostic(error) }));}}})().catch(error => deps.log?.warn('Group send bookkeeping failed', { groupId: roomId, ...chatErrorDiagnostic(error) }));diff --git a/apps/desktop/src/renderer/features/bots/BotGroupChatView.tsx b/apps/desktop/src/renderer/features/bots/BotGroupChatView.tsxindex 46047fe73e..122cea4158 100644--- a/apps/desktop/src/renderer/features/bots/BotGroupChatView.tsx+++ b/apps/desktop/src/renderer/features/bots/BotGroupChatView.tsx@@ -1239,7 +1239,7 @@ function BotGroupChatContent({ groupId }: { groupId: string }) {members={group.members}running={running}planState={botGroupComposerPlanState(openPlan, group.replyMode)}- divisionAvailable={!group.singleSpeaker}+ divisionSteps={!!group.singleSpeaker}attachments={attachmentState}attachmentScope={attachmentScope}dragOver={dragOver}diff --git a/apps/desktop/src/renderer/features/bots/BotGroupComposer.tsx b/apps/desktop/src/renderer/features/bots/BotGroupComposer.tsxindex 0045d0fb72..1b1edc2739 100644--- a/apps/desktop/src/renderer/features/bots/BotGroupComposer.tsx+++ b/apps/desktop/src/renderer/features/bots/BotGroupComposer.tsx@@ -169,7 +169,7 @@ export function BotGroupComposer({running,disabled = false,planState = null,- divisionAvailable = true,+ divisionSteps = false,attachments: attachmentState = NO_ATTACHMENTS,attachmentScope = '',dragOver = false,@@ -193,8 +193,8 @@ export function BotGroupComposer({disabled?: boolean;/** The group's open plan, for placeholders and the 「安排分工」 gate. */planState?: BotGroupComposerPlanState | null;- /** False when the server arranges turns itself: the lead splits work when asked (§7). */- divisionAvailable?: boolean;+ /** Server groups: a 分工 that writes out who does what starts as written; otherwise the organizer arranges it (§7.0). */+ divisionSteps?: boolean;attachments?: BotGroupComposerAttachments;/** Scope for writing annotated images before send (see botGroupAttachmentScope). */attachmentScope?: string;@@ -503,7 +503,7 @@ export function BotGroupComposer({: !hasMembers? t('bots.groupChat.composer.noMembers'): division- ? t('bots.groupChat.composer.placeholderDivision')+ ? t(divisionSteps ? 'bots.groupChat.composer.placeholderDivisionSteps' : 'bots.groupChat.composer.placeholderDivision'): planState?.kind === 'proposed'? t('bots.groupChat.composer.placeholderPlanProposed'): planState?.kind === 'running' && planState.botName@@ -667,7 +667,7 @@ export function BotGroupComposer({{t('extraDirs.addFiles')}</span></DropdownMenuItem>- {divisionAvailable ? <DropdownMenuItem+ <DropdownMenuItemdisabled={divisionBlocked}className={cn(MENU_ITEM_CLASS, 'h-auto items-start gap-2.5 py-2')}onSelect={() => {@@ -684,11 +684,11 @@ export function BotGroupComposer({{t(divisionBlocked? 'bots.groupChat.composer.divisionBusy'- : 'bots.groupChat.composer.divisionDescription',+ : divisionSteps ? 'bots.groupChat.composer.divisionDescriptionSteps' : 'bots.groupChat.composer.divisionDescription',)}</span></span>- </DropdownMenuItem> : null}+ </DropdownMenuItem></DropdownMenuContent></DropdownMenu></>)}diff --git a/apps/desktop/src/renderer/features/bots/ChatGroupSettings.tsx b/apps/desktop/src/renderer/features/bots/ChatGroupSettings.tsxindex 97499091ca..9bd24a9017 100644--- a/apps/desktop/src/renderer/features/bots/ChatGroupSettings.tsx+++ b/apps/desktop/src/renderer/features/bots/ChatGroupSettings.tsx@@ -132,19 +132,18 @@ export function ChatGroupSettings({ group }: { group: BotGroupSummary }) {onChange={event => { editGroup(); setTopic(event); }} />}</FormField><FormField label={t(key('description'))}>{props => <Input {...props} value={description} maxLength={2000} disabled={!manager || busy}onChange={event => { editGroup(); setDescription(event); }} />}</FormField>- {/* Whether unmentioned messages trigger replies is independent of the speaking order. */}+ {/* Whether unaddressed messages wake anyone; independent of the order teammates answer in. */}<FormField label={t(shared('replyMode'))}>{props => <Select {...props} label={t(shared('replyMode'))} value={replyMode}disabled={!manager || busy} options={(['all', 'mentioned'] as const).map(value => ({ value, label: t(REPLY_MODE_LABELS[value]) }))}onValueChange={value => { editGroup(); setReplyMode(value as typeof replyMode); }} />}</FormField>- {group.singleSpeaker ? null : <>- <FormField label={t(shared('speakingMode'))}>{props => <Select {...props} label={t(shared('speakingMode'))} value={speakingMode}+ {/* Single-speaker servers always answer one teammate at a time, so there is no speaking mode. */}+ {group.singleSpeaker ? null : <FormField label={t(shared('speakingMode'))}>{props => <Select {...props} label={t(shared('speakingMode'))} value={speakingMode}disabled={!manager || busy} options={(['auto', 'sequential'] as const).map(value => ({ value, label: t(SPEAKING_MODE_LABELS[value]) }))}- onValueChange={value => { editGroup(); setSpeakingMode(value as typeof speakingMode); }} />}</FormField>- </>}+ onValueChange={value => { editGroup(); setSpeakingMode(value as typeof speakingMode); }} />}</FormField>}{manager && <Button type="submit" size="sm" variant="secondary" disabled={busy || !name.trim()}>{t(key('save'))}</Button>}</form>- {/* Organizer and project folder only serve a division of work, which single-speaker groups do not have. */}- {group.singleSpeaker ? null : <section className="space-y-3 border-t border-[var(--border-default)] pt-5">+ {/* The organizer arranges a 分工 whose steps are not written out; a 分工 works in the project folder. */}+ <section className="space-y-3 border-t border-[var(--border-default)] pt-5"><FormField label={t('bots.groupChat.organizer')} hint={t('bots.groupChat.settings.organizerNote')}>{props =><Select {...props} label={t('bots.groupChat.organizer')} value={group.organizerBotId ?? ''}disabled={!manager || busy} options={companions.filter(m => m.status === 'active').map(m => ({ value: m.botId, label: m.name }))}@@ -155,7 +154,7 @@ export function ChatGroupSettings({ group }: { group: BotGroupSummary }) {{group.projectDir && <Button size="sm" variant="secondary" disabled={busy} onClick={() => void updateWorkSettings({ projectDir: null })}>{t('bots.groupChat.settings.projectDirClear')}</Button>}<Button size="sm" variant="secondary" disabled={busy} onClick={() => void chooseProjectDir()}>{t('bots.groupChat.settings.projectDirChoose')}</Button></div>}</FormField>- </section>}+ </section><section className="space-y-3 border-t border-[var(--border-default)] pt-5"><div className="flex items-center justify-between gap-3"><h3 className="text-14 font-medium text-[var(--text-primary)]">{t(key('myProfile'))}</h3>diff --git a/apps/desktop/src/renderer/features/bots/__tests__/ChatGroupSettings.test.tsx b/apps/desktop/src/renderer/features/bots/__tests__/ChatGroupSettings.test.tsxindex afd9701e38..6bee67a41a 100644--- a/apps/desktop/src/renderer/features/bots/__tests__/ChatGroupSettings.test.tsx+++ b/apps/desktop/src/renderer/features/bots/__tests__/ChatGroupSettings.test.tsx@@ -134,12 +134,15 @@ it('labels reply and speaking modes with the same words as the local group settiexpect(screen.queryByText(key('replyMode'))).toBeNull();});-it('saves mention-only replies for single-speaker groups without restoring orchestration settings', async () => {+// bot-group-chat.md §4.0 (2026-10-23): single-speaker groups keep 「只有被 @ 的回答」 and the+// 分工 settings (organizer, project folder); only the speaking mode no longer applies.+it('keeps reply mode and 分工 settings for single-speaker groups and saves mention-only replies', async () => {render(<MemoryRouter><ChatGroupSettings group={{ ...group(true), singleSpeaker: true, replyMode: 'all', speakingMode: 'auto' }} /></MemoryRouter>);+ expect(screen.queryByRole('combobox', { name: 'bots.groupChat.settings.speakingMode' })).toBeNull();+ expect(screen.getByRole('combobox', { name: 'bots.groupChat.organizer' })).toBeTruthy();+ expect(screen.getByText('bots.groupChat.settings.projectDir')).toBeTruthy();fireEvent.click(screen.getByRole('combobox', { name: 'bots.groupChat.settings.replyMode' }));fireEvent.click(screen.getByRole('option', { name: 'bots.groupChat.settings.replyModeMentioned' }));- expect(screen.queryByRole('combobox', { name: 'bots.groupChat.settings.speakingMode' })).toBeNull();- expect(screen.queryByRole('combobox', { name: 'bots.groupChat.organizer' })).toBeNull();fireEvent.submit(screen.getByRole('textbox', { name: key('name') }).closest('form')!);await waitFor(() => expect(mocks.manage).toHaveBeenCalledWith({ groupId: 'room', action: expect.objectContaining({type: 'update', responseMode: 'mentioned', expectedRevision: 1,diff --git a/apps/desktop/src/renderer/features/bots/__tests__/botGroupMentions.test.ts b/apps/desktop/src/renderer/features/bots/__tests__/botGroupMentions.test.tsindex 4c54cd6d9e..e0337a84d4 100644--- a/apps/desktop/src/renderer/features/bots/__tests__/botGroupMentions.test.ts+++ b/apps/desktop/src/renderer/features/bots/__tests__/botGroupMentions.test.ts@@ -7,6 +7,7 @@ import {resolveBotGroupMentions,retainBotGroupTrackedMentions,splitBotGroupMentionSegments,+ splitBotGroupRelaySteps,} from '../botGroupMentions';import {continuableRoundEndId,@@ -179,6 +180,30 @@ describe('mention picker helpers', () => {});});+// bot-group-chat.md §7.0: a 分工 request that writes out its steps becomes the card as written;+// anything else must stay with the organizer, so a mention inside a sentence never splits work.+describe('splitBotGroupRelaySteps', () => {+ const split = (text: string) => splitBotGroupRelaySteps(text, { members, allLabels: ['所有人'] });++ it.each([+ ['one line per step', '@阿布 出方案\n@小满 按方案实现', [['abu', '出方案'], ['xiaoman', '按方案实现']]],+ ['punctuation and connectors', '做登录页:@阿布 出方案,然后 @小满 实现;最后 @咪咪 测一遍。',+ [['abu', '出方案'], ['xiaoman', '实现'], ['mimi', '测一遍']]],+ ['one teammate', '@Ann review the diff', [['ann', 'review the diff']]],+ ] as const)('reads %s', (_label, text, expected) => {+ expect(split(text)).toEqual(expected.map(([botId, task]) => ({ botId, task })));+ });++ it.each([+ ['a mention inside a sentence', '@阿布 和 @小满 一起做登录页'],+ ['a step without a task', '@阿布,@小满 实现'],+ ['everyone', '@所有人 出方案,@小满 实现'],+ ['no mention', '做一个登录页'],+ ])('leaves %s to the organizer', (_label, text) => {+ expect(split(text)).toBeNull();+ });+});+function message(overrides: Partial<BotGroupMessageView>): BotGroupMessageView {return {id: 'm',diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.jsonindex eff8d2e207..e363aad57e 100644--- a/apps/desktop/src/renderer/i18n/locales/en/common.json+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json@@ -9492,10 +9492,12 @@"more": "More Actions","division": "Split the Work","divisionDescription": "The organizer splits the work first, then teammates take it step by step",+ "divisionDescriptionSteps": "Follow the steps you write, or let the organizer split the work; teammates take it step by step","divisionBusy": "A work split is underway. Finish or stop it before starting another.","divisionTag": "Work split","removeDivision": "Remove Work Split","placeholderDivision": "Describe what to get done. The organizer will split the work first…",+ "placeholderDivisionSteps": "Write who does what (@A drafts a plan, @B builds it), or just the goal for the organizer to split…","placeholderPlanProposed": "To change who does what, just say so…","placeholderPlanWaiting": "Want {{name}} to change something? Just say so…","placeholderPlanRunning": "What you say goes to {{name}}, who’s working on it…",diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.jsonindex ef86e6424f..cb237cce7a 100644--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json@@ -9458,10 +9458,12 @@"more": "その他の操作","division": "役割分担する","divisionDescription": "まとめ役が先に役割を分け、仲間が一歩ずつ進めます",+ "divisionDescriptionSteps": "書いた手順どおり、またはまとめ役が分けて、仲間が一歩ずつ進めます","divisionBusy": "役割分担の途中です。終わるか停止してから新しく始めてください","divisionTag": "役割分担","removeDivision": "役割分担を外す","placeholderDivision": "やりたいことを書いてください。まとめ役が先に役割を分けます…",+ "placeholderDivisionSteps": "誰が何をするか書く(@A 方針を作成、@B 実装)か、目標だけ書いてまとめ役に任せます…","placeholderPlanProposed": "担当や手順を変えたいときは、そのまま話しかけてください…","placeholderPlanWaiting": "{{name}} に直してほしいことがあれば、そのまま話しかけてください…","placeholderPlanRunning": "送った内容は作業中の {{name}} に届きます…",diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.jsonindex e0bdf41b61..fcbafff06b 100644--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json@@ -9458,10 +9458,12 @@"more": "더 보기","division": "역할 분담하기","divisionDescription": "담당자가 먼저 역할을 나누고, 동료들이 한 단계씩 진행합니다",+ "divisionDescriptionSteps": "적은 단계대로, 또는 담당자가 나눠서 동료들이 한 단계씩 진행합니다","divisionBusy": "역할 분담이 진행 중입니다. 끝내거나 중지한 뒤 새로 시작하세요","divisionTag": "역할 분담","removeDivision": "역할 분담 해제","placeholderDivision": "하고 싶은 일을 적어 주세요. 담당자가 먼저 역할을 나눕니다…",+ "placeholderDivisionSteps": "누가 무엇을 할지 적거나(@A 방안 작성, @B 구현), 목표만 적어 담당자에게 맡기세요…","placeholderPlanProposed": "담당이나 단계를 바꾸려면 그냥 말해 주세요…","placeholderPlanWaiting": "{{name}} 님에게 고칠 점이 있으면 그냥 말해 주세요…","placeholderPlanRunning": "보내는 말은 작업 중인 {{name}} 님에게 전달됩니다…",diff --git a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.jsonindex 751df5ec8e..283a079c79 100644--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json@@ -9458,10 +9458,12 @@"more": "更多操作","division": "安排分工","divisionDescription": "让负责人先分好工,伙伴们一步步做",+ "divisionDescriptionSteps": "按你写的步骤,或由负责人来分;伙伴们一步步做","divisionBusy": "正在分工,做完或停止后才能安排新的","divisionTag": "分工","removeDivision": "去掉分工","placeholderDivision": "说说要做成什么,负责人会先分好工…",+ "placeholderDivisionSteps": "写好谁做什么(@A 出方案,@B 实现),或只说目标让负责人来分…","placeholderPlanProposed": "想换人或改步骤,直接说…","placeholderPlanWaiting": "想让{{name}}改改,直接说…","placeholderPlanRunning": "说的话会带给正在做的{{name}}…",diff --git a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.jsonindex 8f666862f1..45b3cab4d4 100644--- a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json+++ b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json@@ -9458,10 +9458,12 @@"more": "更多操作","division": "安排分工","divisionDescription": "讓負責人先分好工,夥伴們一步步做",+ "divisionDescriptionSteps": "按你寫的步驟,或由負責人來分;夥伴們一步步做","divisionBusy": "正在分工,做完或停止後才能安排新的","divisionTag": "分工","removeDivision": "移除分工","placeholderDivision": "說說要做成什麼,負責人會先分好工…",+ "placeholderDivisionSteps": "寫好誰做什麼(@A 出方案,@B 實作),或只說目標讓負責人來分…","placeholderPlanProposed": "想換人或改步驟,直接說…","placeholderPlanWaiting": "想讓{{name}}改改,直接說…","placeholderPlanRunning": "說的話會帶給正在做的{{name}}…",diff --git a/apps/mobile/src/__tests__/BotGroupChatScreen.test.tsx b/apps/mobile/src/__tests__/BotGroupChatScreen.test.tsxindex d35a20aeb1..5e09fd9b20 100644--- a/apps/mobile/src/__tests__/BotGroupChatScreen.test.tsx+++ b/apps/mobile/src/__tests__/BotGroupChatScreen.test.tsx@@ -740,12 +740,12 @@ describe('group composer', () => {expect(last).not.toHaveProperty('division');});- // Remote resource -> screen regression: transport through Desktop must not expose- // unsupported division in a single-speaker room (component tier).- it.each([true, false])('gates remote 安排分工 using singleSpeaker=%s', async singleSpeaker => {- h.chat.server = false;+ // bot-group-chat.md §7.0 (2026-10-23): the computer arranges a 分工 in single-speaker rooms too,+ // so a phone working through it keeps 安排分工; a phone talking to the server directly does not (component tier).+ it.each([[true, false, true], [false, false, true], [true, true, false]])('offers 安排分工 (singleSpeaker=%s, direct=%s)', async (singleSpeaker, direct, offered) => {+ h.chat.server = direct;await render(parseBotGroupChatData(group({ serverBacked: true, singleSpeaker, replyMode: 'mentioned', openPlan: null }))!);- expect(!!byId('botGroup.composer.menu.action.division')).toBe(!singleSpeaker);+ expect(!!byId('botGroup.composer.menu.action.division')).toBe(offered);});it.each(['all', 'mentioned'] as const)('keeps the running work-plan gate and uses truthful %s copy', async replyMode => {diff --git a/apps/mobile/src/i18n/locales/en/groupChat.json b/apps/mobile/src/i18n/locales/en/groupChat.jsonindex b0908402eb..133974157c 100644--- a/apps/mobile/src/i18n/locales/en/groupChat.json+++ b/apps/mobile/src/i18n/locales/en/groupChat.json@@ -171,6 +171,7 @@"replyModeAll": "Anyone Can Reply","replyModeMentioned": "Only @Mentioned Reply","replyModeNote": "Teammates with nothing to add stay quiet. Each round runs up to 3 passes and 10 messages, then waits for you to click “Continue Discussion”.",+ "replyModeNoteQueue": "Teammates answer one at a time; the first five go on by themselves. Quoting a teammate or replying in its thread also calls it.","replyModeSaveFailed": "Couldn’t save the reply setting. Try again.","delete": "Delete Group Chat","deleteNote": "Only this group chat and its messages are deleted. The teammates, their memory, and their private chats aren’t affected.",diff --git a/apps/mobile/src/i18n/locales/ja/groupChat.json b/apps/mobile/src/i18n/locales/ja/groupChat.jsonindex 14a82cde55..d29ad02f6c 100644--- a/apps/mobile/src/i18n/locales/ja/groupChat.json+++ b/apps/mobile/src/i18n/locales/ja/groupChat.json@@ -171,6 +171,7 @@"replyModeAll": "誰でも返信できる","replyModeMentioned": "@ された仲間だけ返信","replyModeNote": "付け加えることがない仲間は発言しません。1 ラウンドは最大 3 周・10 件までで、その後は「議論を続ける」を押すまで待ちます。",+ "replyModeNoteQueue": "仲間が順番に一人ずつ答え、最初の 5 人は自動で続きます。仲間のメッセージを引用したり、そのスレッドに返信したりしても呼び出せます。","replyModeSaveFailed": "返信の設定を保存できませんでした。もう一度お試しください","delete": "グループチャットを削除","deleteNote": "削除されるのはこのグループチャットとそのメッセージだけです。仲間本人、その記憶、個別のチャットには影響しません。",diff --git a/apps/mobile/src/i18n/locales/ko/groupChat.json b/apps/mobile/src/i18n/locales/ko/groupChat.jsonindex c35a5f50b5..a8e3bbb7a5 100644--- a/apps/mobile/src/i18n/locales/ko/groupChat.json+++ b/apps/mobile/src/i18n/locales/ko/groupChat.json@@ -171,6 +171,7 @@"replyModeAll": "누구나 답할 수 있음","replyModeMentioned": "@된 동료만 답함","replyModeNote": "더 보탤 말이 없는 동료는 말하지 않습니다. 한 라운드는 최대 3바퀴, 메시지 10개까지이며, 그 후에는 ‘토론 계속하기’를 누를 때까지 기다립니다.",+ "replyModeNoteQueue": "동료들이 한 명씩 차례로 답하고, 처음 5명은 자동으로 이어집니다. 동료의 메시지를 인용하거나 그 스레드에 답장해도 부를 수 있습니다.","replyModeSaveFailed": "답변 방식을 저장하지 못했습니다. 다시 시도하세요","delete": "그룹 채팅 삭제","deleteNote": "이 그룹 채팅과 그 안의 메시지만 삭제됩니다. 동료 자체와 동료의 기억, 개인 대화에는 영향이 없습니다.",diff --git a/apps/mobile/src/i18n/locales/zh-CN/groupChat.json b/apps/mobile/src/i18n/locales/zh-CN/groupChat.jsonindex 6b028a9106..dc1f87240f 100644--- a/apps/mobile/src/i18n/locales/zh-CN/groupChat.json+++ b/apps/mobile/src/i18n/locales/zh-CN/groupChat.json@@ -171,6 +171,7 @@"replyModeAll": "大家都可以接话","replyModeMentioned": "只有被 @ 的回答","replyModeNote": "没什么可补充的伙伴不会说话。每轮最多聊 3 圈、10 条,之后等你点「继续讨论」。",+ "replyModeNoteQueue": "伙伴们排队依次回答,前 5 位自动接着说。引用伙伴的消息或回复它的话题,也会叫到它。","replyModeSaveFailed": "回复方式没能保存,请再试一次","delete": "删除群聊","deleteNote": "只删除这个群和群里的消息,伙伴本身、它们的记忆和私聊都不受影响。",diff --git a/apps/mobile/src/i18n/locales/zh-TW/groupChat.json b/apps/mobile/src/i18n/locales/zh-TW/groupChat.jsonindex 5abd27e4c5..4991fb7997 100644--- a/apps/mobile/src/i18n/locales/zh-TW/groupChat.json+++ b/apps/mobile/src/i18n/locales/zh-TW/groupChat.json@@ -171,6 +171,7 @@"replyModeAll": "大家都可以接話","replyModeMentioned": "只有被 @ 的回答","replyModeNote": "沒什麼可補充的夥伴不會說話。每輪最多聊 3 圈、10 則,之後等你點「繼續討論」。",+ "replyModeNoteQueue": "夥伴們排隊依序回答,前 5 位自動接著說。引用夥伴的訊息或回覆它的話題,也會叫到它。","replyModeSaveFailed": "回覆方式沒能儲存,請再試一次","delete": "刪除群聊","deleteNote": "只刪除這個群聊和其中的訊息,夥伴本身、它們的記憶和私聊都不受影響。",diff --git a/apps/mobile/src/session/BotGroupChatScreen.tsx b/apps/mobile/src/session/BotGroupChatScreen.tsxindex 7aebc90a44..1ffdaf2551 100644--- a/apps/mobile/src/session/BotGroupChatScreen.tsx+++ b/apps/mobile/src/session/BotGroupChatScreen.tsx@@ -372,7 +372,7 @@ export function BotGroupChatScreen({ deviceId, deviceName, groupId }: { deviceId</ScrollView><BotGroupComposer members={group.members} identityFor={identityFor} deviceId={deviceId} online={chat.online && !group.archived && !group.dissolvedAt}running={group.round.status === 'running'} planState={botGroupComposerPlanState(openBotGroupPlan(group), group.replyMode)}- divisionSupported={!chat.server && !group.singleSpeaker} attachmentsSupported={group.supportsAttachments === true} onSend={send} onStop={stop} />+ divisionSupported={!chat.server} attachmentsSupported={group.supportsAttachments === true} onSend={send} onStop={stop} /></KeyboardAvoidingView>;}diff --git a/apps/mobile/src/session/BotGroupSettingsSheet.tsx b/apps/mobile/src/session/BotGroupSettingsSheet.tsxindex 07445f2ac9..60c08dc007 100644--- a/apps/mobile/src/session/BotGroupSettingsSheet.tsx+++ b/apps/mobile/src/session/BotGroupSettingsSheet.tsx@@ -332,11 +332,12 @@ function BotGroupSettingsContent({ visible, group, host, identityFor, online, ac{ value: 'all', label: t('groupChat.settings.replyModeAll') },{ value: 'mentioned', label: t('groupChat.settings.replyModeMentioned') },])}- <Text style={styles.note}>{t('groupChat.settings.replyModeNote')}</Text>+ <Text style={styles.note}>{t(group.singleSpeaker ? 'groupChat.settings.replyModeNoteQueue' : 'groupChat.settings.replyModeNote')}</Text>{error('replyMode')}</View>- <View style={styles.section}>+ {/* Single-speaker servers always answer one teammate at a time, so there is no speaking mode. */}+ {group.singleSpeaker ? null : <View style={styles.section}><Text style={styles.sectionTitle}>{t('groupChat.settings.speakingMode')}</Text>{segmented<BotGroupSpeakingMode>('speakingMode', group.speakingMode, [{ value: 'auto', label: t('groupChat.settings.speakingModeAuto') },@@ -346,7 +347,7 @@ function BotGroupSettingsContent({ visible, group, host, identityFor, online, ac? 'groupChat.settings.speakingModeSequentialNote': 'groupChat.settings.speakingModeAutoNote')}</Text>{error('speakingMode')}- </View>+ </View>}</View>{(!group.serverBacked || (canManageBotGroup(group) && !leavesGroup && !group.dissolvedAt)) && <View style={[styles.section, (readOnly || !online) && styles.inheritedInactive]}>diff --git a/docs/dev-rules/protocol-compatibility.md b/docs/dev-rules/protocol-compatibility.mdindex 6293921538..321f16dcda 100644--- a/docs/dev-rules/protocol-compatibility.md+++ b/docs/dev-rules/protocol-compatibility.md@@ -2670,12 +2670,18 @@ Chat Server `/me` 追加 `capabilities.groupSingleSpeaker: 1`,服务端派发它们本就声明 `planVersion: 1` 领取安排步骤、渲染安排卡并能「继续」;仍发送的 `deferExecution` /`continueDiscussion` 被接受(后者只记录、不续圈),旧的「继续讨论」只叫被 @ 的伙伴或第一位伙伴。-新 Desktop 只在看到该能力时:不再发 `deferExecution`、不做发送前的辅助判断、不发 `continueDiscussion`;+新 Desktop 只在看到该能力时:普通消息不再发 `deferExecution`、不做发送前的辅助判断、不发 `continueDiscussion`;队列停着等继续时新消息按新请求发送(不作为补充)。队列前 5 位由服务端自动接续,无需客户端参与。`chat_plan.kind` 是附加字段,旧客户端忽略;新客户端缺字段时按旧分工卡呈现。手机解析电脑的群资源时,保留经校验的可选 `kind`(talk/work)与 `canAdd`(boolean);缺失或非法时沿用旧分工呈现,不把字符串当作补充权限。-`mentioned` 的运行中 talk 队列及存量 work 分工不接受普通无 @ 消息作为自动补充,两端输入框不得承诺交给正在答的伙伴;存量 work 分工仍保留未结束时阻止新建分工的限制。-手机须保留电脑投影的 `singleSpeaker: true`,据此隐藏不支持的「安排分工」;远程电脑传输不等于旧群。缺字段的旧电脑沿用原入口。+`mentioned` 的运行中 talk 队列及 work 分工不接受普通无 @ 消息作为自动补充,两端输入框不得承诺交给正在答的伙伴;work 分工仍保留未结束时阻止新建分工的限制。+手机须保留电脑投影的 `singleSpeaker: true`(据此隐藏「发言方式」);远程电脑传输不等于旧群。++2026-10-23 起客户端在同一能力下恢复「安排分工」,**不改服务端、不新增 wire 字段**,只组合现有接口:+主群消息带 `deferExecution: true` 挂起;请求写好步骤时 `POST /plans`(`kind` 缺省为 `work`)后立即+`action: start`,否则负责人出卡;没有卡时 `POST /messages/:id/continue` 立即回答(该服务端没有 `cancel-planning`,+不处理会在两分钟后被排成讨论队列)。本人等继续的 `talk` 队列先 `action: stop` 再建卡,否则服务端返回 `PLAN_OPEN`。+手机经电脑发起分工走同一路径;手机直连服务器不提供「安排分工」。停止的范围收窄与主群上下文精简都只在看到该能力时启用,旧服务器保留整轮停止与完整主群历史;收窄只在执行端实现(成员只停自己的请求与伙伴,群主或管理员——含本账号拥有的管理员伙伴——可 `all`),沿用既有 control /plan action 的服务端权限,IPC `bot-group:stop` 追加可选 `scope`;手机经电脑的远程动作不变(停止为本人范围)。发布顺序:服务端整集群先上,再发客户端。diff --git a/docs/product-rules/bot-group-chat.md b/docs/product-rules/bot-group-chat.mdindex c0af3f433a..097f1c8b09 100644--- a/docs/product-rules/bot-group-chat.md+++ b/docs/product-rules/bot-group-chat.md@@ -123,20 +123,26 @@ Chat Server 声明 `capabilities.groupSingleSpeaker: 1` 时,服务器群按下回答者选择、同时想与自动续圈(4.1–4.3 仍描述本地旧群与未声明该能力的服务器)。规则由服务端派发与宿主代码执行,不靠提示词约束;Chris 2026-10-21 定稿(去掉负责人,原型见设计资产 `group-coordination`)。-- **一次只有一位伙伴说话,没有负责人**。@ 一位伙伴,只有它回答;@ 多位伙伴或 @所有人,按 @ 的先后排队;+- **一次只有一位伙伴说话**。@ 一位伙伴,只有它回答;@ 多位伙伴或 @所有人,按 @ 的先后排队;**没有 @ 人时按群设置决定是否回答**:`all`(默认,「大家都可以接话」)让所有能回答的伙伴排成一个队列(按成员列表顺序);`mentioned`(「只有被 @ 的回答」)不唤醒伙伴、不新建或替换队列。群里只有一位伙伴能回答时不排队,它直接回答。伙伴的回复不叫醒任何伙伴,也不能替自己往队列里加人。-- **排队的形态只有一种:队列卡**(即第 7 节的安排卡)。卡上一步一位伙伴、一次模型调用,宿主按顺序依次派发,+- **两种编排(2026-10-23 修正,Chris:「整个原本的分工交接全没了」「重新做好编排…服务器最好不用改」)**:+ - **讨论**(队列卡,`talk`):上面那条规则,大家对同一个问题依次说看法。+ - **分工**(安排卡,`work`,第 7 节):几位伙伴接力把一件事做完,每做完一步停下等「继续」,在项目文件夹里干活。+ 只由「+」→「安排分工」发起,见 7.0。10-21 去掉的分工入口、负责人与项目文件夹在服务器群里恢复。+- **讨论的队列卡**:卡上一步一位伙伴、一次模型调用,宿主按顺序依次派发,不另调模型来排顺序。**前 5 位依次自动回答,第 6 位起每位等用户点「继续」**;用户觉得够了就点停止、「结束」或不再继续。轮到的伙伴没什么可补充时回复 `NO_REPLY`,群里不显示,但这一步照样算说完。- 每位伙伴的回复都是独立消息;安排卡单独一条,只表达顺序与进度,不并入谁的回复。-- 群设置保留独立的「没有 @ 人的时候」,控制是否响应无 @ 消息,与排队顺序无关(2026-10-23 修正)。- 不再有「发言方式」「负责人」「项目文件夹」,群头像行不再标「负责人」,- 也不再自动第 2、3 圈;继续由队列卡的「继续」完成。-- 队列停着等「继续」时又发了符合回复条件的新消息,就是新问题:旧队列结束,按新消息另排。队列里正有伙伴在答时,发起人- 不 @ 人说的话仅在 `all` 时作为这一步的补充交给正在答的伙伴;@ 了人则按 @ 依次普通回复、`all` 且没 @ 人只由第一位伙伴回答,- 不另开队列。话题里的消息不排队列:点名多位依次回答,`all` 且没有接收人只由第一位伙伴回答,`mentioned` 且没有接收人保持安静。+- 群设置保留独立的「没有 @ 人的时候」,控制是否响应无 @ 消息,与排队顺序无关(2026-10-23 修正);+ 「负责人」「项目文件夹」随「安排分工」一起保留(第 7 节)。不再有「发言方式」,群头像行不再标「负责人」,+ 也不再自动第 2、3 圈;继续由卡上的「继续」完成。+- 队列停着等「继续」时又发了符合回复条件的新消息,就是新问题:旧队列结束,按新消息另排。卡片进行中(讨论有伙伴正在答,+ 或分工在做、停着等继续)时,发起人或管理员不 @ 人说的话仅在 `all` 时交给当前这一步:讨论里作为补充交给正在答的伙伴,+ 分工里是补充或让刚做完的伙伴返工(7.4);`mentioned` 时它们是普通消息、保持安静。@ 了人则按 @ 依次普通回复、+ `all` 且没 @ 人只由第一位伙伴回答,不另开队列。话题里的消息不排队列:点名多位依次回答,`all` 且没有接收人只由第一位伙伴回答,+ `mentioned` 且没有接收人保持安静。这里的「没有 @」指没有定向接收人的普通消息;保留第 10 节已有的定向回复例外:引用回复伙伴,或在伙伴消息下回复话题时,宿主会把仍在群里的原作者加入接收人,所以无需再手动 @,`mentioned` 下也会回答。回复人类根消息的话题不增加伙伴接收人。- 主群里的普通回复只带最近 12 条主群消息、每条截至 600 字(更早的标为已省略),群专线自带此前的轮次;@@ -259,7 +265,7 @@ Chat Server 声明 `capabilities.groupSingleSpeaker: 1` 时,服务器群按下变更头复用;自动分工判断整体不超过 8 秒(单候选 5 秒),超时按「不要」处理,不让第一条回复等它。- 新建群聊:填写群名称,选择 2–6 位伙伴。- 群设置:群名称、成员(添加与移出、设为负责人)、项目文件夹、「没有 @ 人的时候」回复方式、「发言方式」(自动/始终轮流)、删除群聊(二次确认)。- 本地群与服务器群的这几项用同一套文案。+ 本地群与服务器群的这几项用同一套文案。声明 `groupSingleSpeaker` 的服务器群没有「发言方式」(一次只有一位伙伴说话),其余照常(Desktop 与手机一致)。- 话题面板与主时间线同一套消息样式(合并、悬停操作、@ 高亮、引用块、附件),同一个输入框(话题模式:没有「+」菜单、附件与引用,发送键是「发送回复」,失败原因写在输入框上方,同一段文字重发沿用同一个 clientId)。- 视觉遵循 [`DESIGN.md`](../design-rules/DESIGN.md);Light 与 Dark 同时实现。@@ -275,23 +281,42 @@ Chat Server 声明 `capabilities.groupSingleSpeaker: 1` 时,服务器群按下## 7. 分工(第二阶段)-> 服务器群声明 `groupSingleSpeaker` 时(4.0),安排卡也承载讨论,下面 7.0 优先于 7.1–7.4 的对应条款。+> 服务器群声明 `groupSingleSpeaker` 时(4.0),安排卡既承载讨论(`talk`)也承载分工(`work`),下面 7.0 优先于+> 7.1–7.4 的对应条款。-### 7.0 服务器群的安排卡(2026-10-21)+### 7.0 服务器群的安排卡(2026-10-21,分工部分 2026-10-23 修正)-- 服务器建的卡都是队列(`talk`):每一步写「说说看法」,状态为「正在说 / 说完了」。旧服务器或旧版- 建的分工卡(`work`)保持原样。-- 不再由辅助模型在发送前判断要不要分工,也不再有「+ 安排分工」入口和「开始 / 不用了」。+讨论的队列卡(`talk`):++- 服务器自己排的卡是队列:每一步写「说说看法」,状态为「正在说 / 说完了」。- **前 5 位自动接续,第 6 位起每位等「继续」**,没有开关。「下一步 · 继续 / 结束」只给发起人、群主或管理员看。- **卡片自动折叠**:超过 4 位时只露当前这一位前后共 3 行,卡底「共 N 位」展开全部、「收起」折回。- 排队时群名下写「某某 正在说…」;有人正在说时输入框提示话会带给他,停着等继续时输入框是普通提示,不暗示「让上一位改改」。- 每一步跑在这张卡自己的 Session 里,上下文只有原问题、前面各位的回答、以及这一步期间你补的话,- 不带主群历史;不准备项目文件夹或 worktree,不收集产物文件。+ 不带主群历史;不准备项目文件夹或 worktree,不收集产物文件。前面的回答只有上一位的给到 2000 字(与分工+ 交接同一上限),更早的每条截至 600 字并标为已省略,长队列不再把每位的回答整段重发一遍。- 队列有伙伴正在答时,`all` 模式下发起人或管理员不 @ 人说的话并入这一步;队列停着等继续时,符合回复条件的新消息另起队列(4.0)。- 队列卡作为独立一条显示在请求下面,不挂任何伙伴名义;每位伙伴的回答是各自独立的消息。+分工的安排卡(`work`,2026-10-23 恢复;10-21 起新版服务器群里开不了新的分工,用户实际依赖它让角色伙伴接力干活):++- 输入框「+」→「安排分工」重新可用,触发由宿主代码决定,**只看分工标签,不看话怎么说**;不加标签的话照 4.0 讨论。+- **写好了步骤就照写的建卡并直接开始**,不调辅助模型:每个 @ 后面写这位伙伴做什么,后一位从新的一行或标点之后开始+ (「登录页:@A 出方案,然后 @B 按方案实现;@C 测一遍」)。第一个 @ 前的话是共同背景;「然后、接着、最后、再」这类+ 连接词不算进任何一步;同一位伙伴相邻的几步合成一步;最多 6 步,每步任务最多 200 字(服务端上限)。+ @ 夹在句子里(「@A 和 @B 一起做」)、某个 @ 后面没写活、@所有人、重名分不清或点到不能派活的伙伴时,不当作写好的步骤。+ 解析在 `@cindy/maker-shared/botGroupMentions` 的 `splitBotGroupRelaySteps`。+- **没写成步骤就交给负责人**出安排卡(「开始 / 不用了」),沿用 7.2 手动分工的流程与每候选 20 秒的预算;开始前+ 不 @ 人说话仍是修改意见(7.3)。安排不出来、或负责人认为不用分工时,这条请求立即按 4.0 回答(点名的依次答,+ 否则第一位伙伴答),不让它干等服务端两分钟后再排队。+- 发出前宿主让消息先挂起,服务端不会先拿它去排讨论队列;建卡后挂起解除。你自己的讨论队列停着等「继续」时,先把它结束+ 再建分工卡;还有别人的卡或正在进行的卡时拒绝(`PLAN_OPEN`),与旧版一致。+- 执行、返工、换人、重试、停止与工作目录沿用 7.3–7.5:每一步在这位伙伴自己的分工 Session 里做,保留它自己的技能、+ 记忆、工具与模型;做完一步停下等「继续」;等继续时不 @ 人说话就是让刚做完的伙伴返工(输入框写「想让 X 改改,直接说…」;「只有被 @ 的回答」的群里不适用,见 4.0)。+- 负责人与项目文件夹回到群设置;负责人只在请求没写步骤时排分工,群头像行仍不标「负责人」。+用户心智:照常说话。事情需要几位伙伴一起做时,负责人先回一个安排,用户点「开始」;伙伴一位接一位做,每做完一步停下来,用户点「继续」交给下一位。界面上统一叫「分工」,不叫「协同」「协作」「接力」——「协同」是 Orca 多 Agent 协同的功能名(角色 Lead / Worker),「协作」用于共享任务。diff --git a/packages/maker-shared/src/botGroupMentions.ts b/packages/maker-shared/src/botGroupMentions.tsindex 6e3afac645..b52e921bed 100644--- a/packages/maker-shared/src/botGroupMentions.ts+++ b/packages/maker-shared/src/botGroupMentions.ts@@ -144,6 +144,41 @@ export function resolveBotGroupMentions(return { all, botIds };}+export interface BotGroupRelayStep {+ botId: string;+ task: string;+}++/** Words that join one step to the next (「,然后 @B」); they belong to neither step's task. */+const STEP_CONNECTOR = /(?:然后|接着|随后|之后|最后|再由|再|then|and then|next)\s*$/i;+/** A later step starts on a new line or after sentence / list punctuation. */+const STEP_BOUNDARY = /(?:^|[\n,,。.;;、→>::])\s*$/;+const STEP_EDGE = /^[\s,,。.;;、→>::\-]+|[\s,,。.;;、→>::\-]+$/g;++/**+ * Steps written out in a 分工 request: every `@name` names one teammate and the words after it,+ * up to the next step, are its task (「@A 出方案,@B 按方案实现,然后 @C 测一遍」).+ * Returns null unless the whole text reads that way, so anything else goes to the organizer:+ * a mention inside a sentence (「@A 和 @B 一起做」), an empty task, @所有人 or an ambiguous name+ * (bot-group-chat.md §7.0). Text before the first step is shared context, not a step.+ */+export function splitBotGroupRelaySteps(+ text: string,+ input: { members: readonly BotGroupMentionMember[]; allLabels: readonly string[] },+): BotGroupRelayStep[] | null {+ const tokens = scanMentionTokens(text, buildLabelEntries(input.members, input.allLabels, []));+ if (!tokens.length) return null;+ const steps: BotGroupRelayStep[] = [];+ for (const [index, token] of tokens.entries()) {+ if (token.entry.all || token.entry.botIds.length !== 1) return null;+ if (index > 0 && !STEP_BOUNDARY.test(text.slice(tokens[index - 1]!.end, token.start).replace(STEP_CONNECTOR, ''))) return null;+ const task = text.slice(token.end, tokens[index + 1]?.start ?? text.length).replace(STEP_CONNECTOR, '').replace(STEP_EDGE, '');+ if (!task) return null;+ steps.push({ botId: token.entry.botIds[0]!, task });+ }+ return steps;+}+/** Move intact picked tokens with a text edit; forget tokens the edit replaces. */export function retainBotGroupTrackedMentions(previousText: string,