Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(bot-groups): 不向伙伴上下文传递贴回卡片的回退文字
Dasha94c2903e8c8
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/chatServer.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/chatServer.test.tsindex 07c15315ee..66e2f97edb 100644--- a/apps/desktop/src/main/maker-ipc/__tests__/chatServer.test.ts+++ b/apps/desktop/src/main/maker-ipc/__tests__/chatServer.test.ts@@ -1833,17 +1833,34 @@ describe('Chat Server result delivery and refresh', () => {it('tells companions a share is a reference whose quoted @names address no one', async () => {claimed = false;fixture.handle.mockImplementation((route, method, body) => route.includes('all=true')- ? { body: [shares[0], { ...msg(execution.source_message_id, 1, selfId), content: [{ type: 'text', text: 'Bot, summarize' }] }] }+ ? { body: [...shares, { ...msg(execution.source_message_id, 1, selfId), content: [{ type: 'text', text: 'Bot, summarize' }] }] }: route.endsWith('/snapshot') || route.endsWith('/members') ? threadResponse(route, method, body) : response(route));await vi.advanceTimersByTimeAsync(2000);expect(deps.dispatch).toHaveBeenCalledOnce();const prompt = vi.mocked(deps.dispatch).mock.calls[0][0].message;expect(prompt).toContain('A message with sharedReplyId re-posts an existing thread reply');const history = [...prompt.matchAll(/<untrusted-data>\n(.*?)\n<\/untrusted-data>/g)].map(match => JSON.parse(match[1])).find(block => block.messages)!.messages;- expect(history.find((m: { id: string }) => m.id === shares[0].id)).toMatchObject({ sharedReplyId: botReply });+ for (const share of shares) expect(history.find((m: { id: string }) => m.id === share.id))+ .toMatchObject({ sharedReplyId: expect.any(String), text: '' });+ expect(prompt).not.toContain('forged words');expect(history.find((m: { id: string }) => m.id === execution.source_message_id)).not.toHaveProperty('sharedReplyId');});+ it('omits share fallback from arrangement context while retaining ordinary text', async () => {+ deps.decidePlan = vi.fn(async () => null);+ fixture.handle.mockImplementation((route, method, body) => route.endsWith('/messages') && method === 'POST'+ ? { body: { id: execution.source_message_id } } : threadResponse(route, method, body));+ expect(await service.sendMessage({ groupId: roomId, text: 'Plan our trip', clientId: 'share-context-plan',+ division: true, mentions: { all: false, botIds: [] } })).toMatchObject({ ok: true });+ await vi.advanceTimersByTimeAsync(0);+ expect(deps.decidePlan).toHaveBeenCalledOnce();+ const context = vi.mocked(deps.decidePlan).mock.calls[0][0];+ expect(context.recent.filter(m => m.sharedReplyId)).toHaveLength(shares.length);+ expect(context.recent.filter(m => m.sharedReplyId).every(m => m.text === '')).toBe(true);+ expect(JSON.stringify(context)).not.toContain('forged words');+ expect(context.recent).toContainEqual(expect.objectContaining({ text: '@Alice 去爬山\n[附件: map.png]' }));+ });+it('marks a share in the main-group background of a Thread request as a reference too', async () => {claimed = false;const rootId = '90000000-0000-4000-8000-0000000000bb';@@ -1857,7 +1874,8 @@ describe('Chat Server result delivery and refresh', () => {const prompt = vi.mocked(deps.dispatch).mock.calls[0][0].message;expect(prompt).toContain('A message with sharedReplyId re-posts an existing thread reply');const background = [...prompt.matchAll(/<untrusted-data>\n(.*?)\n<\/untrusted-data>/g)].map(match => JSON.parse(match[1])).find(block => block.mainGroupBackground)!.mainGroupBackground;- expect(background).toEqual([expect.objectContaining({ id: shares[0].id, sharedReplyId: botReply })]);+ expect(background).toEqual([expect.objectContaining({ id: shares[0].id, sharedReplyId: botReply, text: '' })]);+ expect(prompt).not.toContain('forged words');});});});diff --git a/apps/desktop/src/main/maker-ipc/chatServer.ts b/apps/desktop/src/main/maker-ipc/chatServer.tsindex c9ab863863..82893f60d1 100644--- a/apps/desktop/src/main/maker-ipc/chatServer.ts+++ b/apps/desktop/src/main/maker-ipc/chatServer.ts@@ -112,7 +112,8 @@ const bodyBlocks = (m: Message) => m.content.filter(b => (b.namespace !== 'cindyconst contentText = (m: Message, forModel: boolean) => m.deleted ? '(消息已删除)' : readImportedBotGroupRuntimeFailureCode(m) ? '' : bodyBlocks(m).flatMap(b => b.type !== 'media' ? [b.text ?? b.fallback ?? ''] : forModel ? [b.text ?? b.fallback ?? `[附件: ${b.caption ?? '文件'}]`] : []).join('\n');/** What a Bot reads: each attachment stays a `[附件: …]` line beside the text. */-const bodyText = (m: Message) => contentText(m, true);+// A share's fallback is an old-client display only, never authoritative model context.+const bodyText = (m: Message) => readBotGroupThreadShareCard(m) ? '' : contentText(m, true);/** What people read: attachments render from the media blocks (`messageViews`), not as text. */const displayText = (m: Message) => contentText(m, false);// The server makes a caption optional; an unnamed attachment still needs a visible name.diff --git a/docs/product-rules/bot-group-chat.md b/docs/product-rules/bot-group-chat.mdindex 1916804a0f..088c95bff9 100644--- a/docs/product-rules/bot-group-chat.md+++ b/docs/product-rules/bot-group-chat.md@@ -579,6 +579,7 @@ Desktop 主聊天直接展示话题里的最新回复,并能把话题回复贴原回复改过后再贴,服务端返回 `OPERATION_CONFLICT`,显示为「已经贴过」,不再发第二条。不同的人分别贴同一条回复是各自的分享。- **不重复唤起伙伴**:贴回消息的 `mentions` 只含分享者本人。服务端定向消息从不放宽到其他人,所以不会启动伙伴回合,引用里的 @ 也不会再点名任何人;新回复本身的 @ 按原规则只在话题里生效一次。「继续讨论」不会把贴回消息当作新请求。伙伴读到群历史时,贴回消息带 `sharedReplyId`,并被说明为引用、不是新请求。+ 普通回复、话题背景与分工判断共用的模型文本投影不带贴回卡片的 fallback,只保留引用标识;原回复如在所读历史中,仍按原消息独立提供。- **更早页面上的贴回**:「查看更早的消息」加载出的贴回卡片会跟着原回复变化。每次刷新时,客户端把已显示的旧卡片(最多 200 张)交给主进程,按同一套缓存、失效和权限判定重新解析;原回复被编辑后显示新内容,删除或失去查看权限后显示无法查看,不需要点击或重新打开群聊。超过 200 张时,过期或仍在读取的卡片优先,其余取最新的;这次没核对、而在最近一次编辑/删除/重置之前核对过的卡片,