Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(bots): 手机经非主力电脑打开群时,群任务卡改到伙伴主力电脑读取实时状态
Chris2b788a6d456f
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/chatServer.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/chatServer.test.tsindex 3d03e4b78f..2be98c6687 100644--- a/apps/desktop/src/main/maker-ipc/__tests__/chatServer.test.ts+++ b/apps/desktop/src/main/maker-ipc/__tests__/chatServer.test.ts@@ -1232,6 +1232,16 @@ describe('Chat Server result delivery and refresh', () => {expect(deps.workDir.prepare).not.toHaveBeenCalled();expect(deps.dispatch).toHaveBeenCalledWith(expect.objectContaining({ toolsDisabled: true, message: expect.stringContaining('Discuss the draft') }));});+ it('projects which computer runs my companion, so a phone reaching the group through here reads its tasks there', async () => {+ fixture.profiles = [{ id: 'local-bot', displayName: 'Bot', status: 'active' }];+ fixture.handle.mockImplementation(route => route === '/actors'+ ? { body: [{ id: botId, kind: 'bot', externalId: 'local-bot', name: 'Bot', homeDeviceId: 'home-pc' }] }+ : route.endsWith('/snapshot') ? { body: { ...response(route).body,+ members: [{ id: botId, kind: 'bot', name: 'Bot', state: 'joined', role: 'member', ownerActorId: selfId, ownerName: 'Me' }] } } : response(route));+ await service.listGroups();+ const result = await service.getGroup(roomId);+ expect(result.ok && result.group.members[0]).toMatchObject({ botId: 'local-bot', isOwned: true, homeDeviceId: 'home-pc' });+ });it('projects hidden paused local companions with their real local identity and never claims work for them', async () => {fixture.profiles = [{ id: 'local-bot', displayName: 'Bot', status: 'paused', hiddenAt: 1 }];fixture.handle.mockImplementation(route => route.endsWith('/snapshot') ? { body: { ...response(route).body,diff --git a/apps/desktop/src/main/maker-ipc/chatServer.ts b/apps/desktop/src/main/maker-ipc/chatServer.tsindex 0fc34417d6..329cf192c8 100644--- a/apps/desktop/src/main/maker-ipc/chatServer.ts+++ b/apps/desktop/src/main/maker-ipc/chatServer.ts@@ -785,6 +785,9 @@ function createChatServer(local: BotGroupChatService, deps: BotGroupChatServiceDreturn { botId: p?.id ?? m.id, actorId: m.id, actorKind: m.kind, isSelf: m.id === selfId,role: m.role, nickname: m.nickname, displayName: m.displayName, ownerActorId: m.ownerActorId, ownerName: m.ownerName,isOwned: m.ownerActorId === selfId, guestAccess: m.guestAccess, accessRevision: m.accessRevision,+ // Which computer runs my companion: a phone reaching this group through this computer+ // reads the companion's tasks there, not here (bot-group-chat.md §10).+ ...(m.ownerActorId === selfId && m.kind === 'bot' ? { homeDeviceId: actors.find(a => a.id === m.id)?.homeDeviceId ?? null } : {}),avatarUrl: m.avatar?.startsWith('https://') ? m.avatar : null,name: memberName(m), avatar: p?.avatar ?? (m.avatar?.startsWith('https://') ? '' : m.avatar) ?? '', avatarColor: p?.avatarColor ?? 'violet', status: p?.status ?? 'active' };}), organizerBotId: s.room.organizer_id ? localBot(s.room.organizer_id)?.id ?? s.room.organizer_id : s.members.find(m => m.kind === 'bot' && m.state === 'joined')?.id ?? null, projectDir: workspace?.projectDir ?? null, lastMessage: lastView ? {diff --git a/apps/mobile/src/__tests__/BotGroupChatScreen.test.tsx b/apps/mobile/src/__tests__/BotGroupChatScreen.test.tsxindex 238c3824a6..de6a33c08c 100644--- a/apps/mobile/src/__tests__/BotGroupChatScreen.test.tsx+++ b/apps/mobile/src/__tests__/BotGroupChatScreen.test.tsx@@ -201,8 +201,9 @@ vi.mock('@/session/useBotGroupSettingsManagement', () => ({ useBotGroupSettingsMvi.mock('@/hooks/useReduceMotion', () => ({ useReduceMotionEnabled: () => true }));vi.mock('@/session/CompanionPresenceRing', () => ({ CompanionPresenceRing: () => null }));vi.mock('@/session/ThinkingDots', () => ({ ThinkingDots: () => null }));-// The live card of my own teammate's task reads the computer over device-link; not under test here.-vi.mock('@/session/CompanionMessageCard', () => ({ CompanionTaskCard: () => null }));+// The live card of my own teammate's task reads the computer over device-link; only which computer is under test.+const taskCardDevices = vi.hoisted(() => [] as string[]);+vi.mock('@/session/CompanionMessageCard', () => ({ CompanionTaskCard: ({ deviceId }: { deviceId: string }) => { taskCardDevices.push(deviceId); return null; } }));import { BotGroupChatScreen } from '@/session/BotGroupChatScreen';import { parseBotGroupChatData } from '@/session/botGroupRemote';@@ -340,6 +341,22 @@ describe('group timeline', () => {expect(byId('botGroup.task')!.textContent).toContain('整理行程');});+ it('reads my own teammate\'s live task on its home computer when the group is opened through another computer', async () => {+ const meta = { v: 1 as const, role: 'delegation-request' as const, delegationId: 'task-5', fromBotId: 'mimi', fromBotName: '咪咪', toBotId: null,+ toBotName: 'Cindy', parentSessionId: 'group-lane', childSessionId: 'child-5', objective: '写官网首页' };+ const data = group({ serverBacked: true, members: [+ { botId: 'mimi', name: '咪咪', avatar: '🐱', avatarColor: 'red', status: 'active', isOwned: true, homeDeviceId: 'pc' },+ { botId: 'abu', name: '阿布', avatar: '🦉', avatarColor: 'blue', status: 'active', isOwned: true, homeDeviceId: null },+ ] });+ data.messages.push(message('t5', 24, { authorBotId: 'mimi', authorName: '咪咪', content: '我开了个任务', task: { meta, state: 'started', title: '官网首页' } }),+ message('t6', 25, { authorBotId: 'abu', authorName: '阿布', content: '我也开了', task: { meta: { ...meta, delegationId: 'task-6', fromBotId: 'abu' }, state: 'started', title: '整理行程' } }));+ taskCardDevices.length = 0;+ // Opened through 'mac', which is not 咪咪's home; 阿布's home is unknown, so it stays on 'mac'.+ await render(parseBotGroupChatData(data)!);+ expect(all('botGroup.task.live')).toHaveLength(2);+ expect([...new Set(taskCardDevices)].sort()).toEqual(['mac', 'pc']);+ });+it('shows a task from an author who has left the group as a snapshot, never a lookup on this phone\'s computer', async () => {const meta = { v: 1 as const, role: 'delegation-request' as const, delegationId: 'task-2', fromBotId: 'gone', fromBotName: '离开的伙伴', toBotId: null,toBotName: 'Cindy', parentSessionId: 'group-lane', childSessionId: 'child-2', objective: '整理行程' };diff --git a/apps/mobile/src/session/BotGroupChatScreen.tsx b/apps/mobile/src/session/BotGroupChatScreen.tsxindex c8464ca8d5..a5a285f8d9 100644--- a/apps/mobile/src/session/BotGroupChatScreen.tsx+++ b/apps/mobile/src/session/BotGroupChatScreen.tsx@@ -541,10 +541,11 @@ function BotGroupTimelineItem({{/* A task this teammate started from the group; mine is live, another owner's is a snapshot.An author no longer in the group is unknown: its task may run on another computer, so itstays a snapshot rather than a lookup on this one (same rule as the desktop timeline).- A group opened straight from the Chat Server carries no computer: the live card reads- the owned companion's home computer instead. */}+ The live card reads the owned companion's home computer when it is known (the group may+ be opened through another computer, or straight from the Chat Server with none); else+ the computer the group was opened through. */}{message.task ? <BotGroupTaskCard task={message.task} owned={member !== undefined && member.isOwned !== false}- deviceId={deviceId || member?.homeDeviceId || ''} /> : null}+ deviceId={member?.homeDeviceId || deviceId || ''} /> : null}{message.attachments?.length ? <BotGroupMessageAttachments messageId={message.id} attachments={message.attachments} align="left" onResolveRemoteMedia={resolveMedia} resolveServerMedia={resolveServerMedia} /> : null}{message.content.trim() ? <BotGroupMarkdownText content={message.content} /> : null}<BotGroupHandoffFiles files={message.files} />diff --git a/apps/mobile/src/session/botGroupRemote.ts b/apps/mobile/src/session/botGroupRemote.tsindex 3a26930e19..6e913cc62f 100644--- a/apps/mobile/src/session/botGroupRemote.ts+++ b/apps/mobile/src/session/botGroupRemote.ts@@ -156,6 +156,8 @@ function parseMember(value: unknown): BotGroupMemberView | null {...(id(record.actorId) ? { actorId: id(record.actorId)! } : {}),...(record.actorKind === 'human' || record.actorKind === 'bot' || record.actorKind === 'integration' ? { actorKind: record.actorKind } : {}),...(typeof record.isOwned === 'boolean' ? { isOwned: record.isOwned } : {}),+ // The computer running my companion: its group tasks are read there, not on the route's computer.+ ...(id(record.homeDeviceId) ? { homeDeviceId: id(record.homeDeviceId)! } : {}),...(typeof record.isSelf === 'boolean' ? { isSelf: record.isSelf } : {}),...(record.role === 'owner' || record.role === 'admin' || record.role === 'member' || record.role === 'guest' ? { role: record.role } : {}),avatar: text(record.avatar, 4_096) ?? '',diff --git a/docs/product-rules/bot-group-chat.md b/docs/product-rules/bot-group-chat.mdindex 0b527f013d..30f6e65247 100644--- a/docs/product-rules/bot-group-chat.md+++ b/docs/product-rules/bot-group-chat.md@@ -349,7 +349,7 @@ Chris 已明确扩展到多人各带伙伴,并选择「主人按群预先授群专线的 `role=group` 是来源身份,不等于只读历史任务,也不单独构成授权。读取自己的 Profile、能力与 Skill 目录时,必须核对活跃执行、伙伴归属、成员状态、授权版本及执行租约;只聊天的专线仍不可读取私人资料。群主身份不能替代伙伴主人身份。-只有伙伴主人发起且当前授权有效的执行,才能从群里启动独立开发任务或发送私聊。独立任务保留群内调用身份与来源范围,沿用普通任务的权限档、审批、隔离目录和工作目录注册。**从群里启动的任务住在这个群里**:父任务就是发起它的群专线,不再改挂或新建私聊。任务一建立,伙伴就以自己的身份在群里发一条带任务卡(`cindy.task` 卡片块,带 fallback 文字;fallback 由发送端按本机界面语言生成,卡片数据本身不含语言)的消息;群通道暂时不可用时,这条「进行中」卡在任务仍在进行期间按退避持续重试,应用重启后由启动恢复再发一次(按幂等 ID 去重,不会重复出现),任务已结束就不再补发;子任务要确认时再发一条「等你确认」的卡(权限请求只说需要批准,不带工具名和参数;提问带问题原文),主人从卡片打开任务作答;任务结束后结果正文、终态卡与交付文件作为伙伴的群消息回到群里。终态卡与主人实时任务卡同一口径:超时任务显示「已超时」,不是「失败了」。交付文件逐个上传,本机发不出去的文件(空文件、超过 100 MB)和服务端明确拒绝的文件跳过并记日志,其余照常送达;只有临时故障才整条稍后重试。超过一条消息 20 个附件上限的文件,与超长正文一样,在同一幂等 ID 家族的后续消息里继续发,不截断。这些消息在任何执行之外以伙伴 actor 发出,不唤醒群专线,也不唤醒私聊;工具返回 `completion_destination=group`,伙伴只需告诉群里开了什么。群的消息通道明确拒绝(伙伴已不在群、群已归档、本机旧式群)时,结果退回该主人与该伙伴的私聊,不丢失。主人的桌面与手机看到的是实时任务卡(桌面在伙伴的主力电脑上读本机委派行,主人在自己的其他电脑上打开群时看快照;手机直接从 Chat Server 进入的群没有电脑路由,按该伙伴的主力电脑读,主力电脑未知时退回快照),其他成员看到卡片发出时的标题与状态。非主人获得的群工具授权不包含此独立任务能力。群内只能查询或控制由同一授权专线创建的独立任务;主人仍可从私聊管理已启动的任务。群执行结束不会取消已经正式启动的独立任务,后续群内操作必须重新验证当前执行。主人在桌面或手机上从群里的实时任务卡点「停止任务」是主人自己的操作,不是群工具调用:只要求这张卡所在的专线能看到该任务,不要求发起它的群执行仍在进行。+只有伙伴主人发起且当前授权有效的执行,才能从群里启动独立开发任务或发送私聊。独立任务保留群内调用身份与来源范围,沿用普通任务的权限档、审批、隔离目录和工作目录注册。**从群里启动的任务住在这个群里**:父任务就是发起它的群专线,不再改挂或新建私聊。任务一建立,伙伴就以自己的身份在群里发一条带任务卡(`cindy.task` 卡片块,带 fallback 文字;fallback 由发送端按本机界面语言生成,卡片数据本身不含语言)的消息;群通道暂时不可用时,这条「进行中」卡在任务仍在进行期间按退避持续重试,应用重启后由启动恢复再发一次(按幂等 ID 去重,不会重复出现),任务已结束就不再补发;子任务要确认时再发一条「等你确认」的卡(权限请求只说需要批准,不带工具名和参数;提问带问题原文),主人从卡片打开任务作答;任务结束后结果正文、终态卡与交付文件作为伙伴的群消息回到群里。终态卡与主人实时任务卡同一口径:超时任务显示「已超时」,不是「失败了」。交付文件逐个上传,本机发不出去的文件(空文件、超过 100 MB)和服务端明确拒绝的文件跳过并记日志,其余照常送达;只有临时故障才整条稍后重试。超过一条消息 20 个附件上限的文件,与超长正文一样,在同一幂等 ID 家族的后续消息里继续发,不截断。这些消息在任何执行之外以伙伴 actor 发出,不唤醒群专线,也不唤醒私聊;工具返回 `completion_destination=group`,伙伴只需告诉群里开了什么。群的消息通道明确拒绝(伙伴已不在群、群已归档、本机旧式群)时,结果退回该主人与该伙伴的私聊,不丢失。主人的桌面与手机看到的是实时任务卡(桌面在伙伴的主力电脑上读本机委派行,主人在自己的其他电脑上打开群时看快照;手机按该伙伴的主力电脑读,不论群是经哪台电脑打开还是直接从 Chat Server 进入;主力电脑未知时,经电脑打开的群读那台电脑,直接进入的群退回快照),其他成员看到卡片发出时的标题与状态。非主人获得的群工具授权不包含此独立任务能力。群内只能查询或控制由同一授权专线创建的独立任务;主人仍可从私聊管理已启动的任务。群执行结束不会取消已经正式启动的独立任务,后续群内操作必须重新验证当前执行。主人在桌面或手机上从群里的实时任务卡点「停止任务」是主人自己的操作,不是群工具调用:只要求这张卡所在的专线能看到该任务,不要求发起它的群执行仍在进行。非主人群工具授权仅允许读取伙伴自身资料、已选能力和自己的技能;应用级能力目录与默认模型查询仍须当前主人执行授权。