Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(chat): deliver component images as group attachments

ylliuuu665260a0f1e49a
diff --git a/apps/desktop/scripts/fixtures/group-control/group-control-fixture.tsx b/apps/desktop/scripts/fixtures/group-control/group-control-fixture.tsx
index 1d53c0cfe7..39f3f40e8b 100644
--- a/apps/desktop/scripts/fixtures/group-control/group-control-fixture.tsx
+++ b/apps/desktop/scripts/fixtures/group-control/group-control-fixture.tsx
@@ -56,6 +56,8 @@ function bodyMessages() {
{ seq: 1, version: 1, op: 'create', id: 'title', kind: 'heading', props: { text: '发布前检查' } },
{ seq: 2, op: 'create', id: 'literal', kind: 'text', props: { text: '保留 <name>、*literal* 和 & 符号' } },
{ seq: 3, op: 'create', id: 'list', kind: 'markdown', props: { text: '- 正文可以阅读\n- **重点**保持格式' } },
+ { seq: 4, op: 'create', id: 'image', kind: 'image', props: { src: 'cindy-media://blobs/fixture-image.png', alt: '图片说明保留', caption: '图片标题保留' } },
+ { seq: 5, op: 'create', id: 'unnamed-image', kind: 'image', props: { src: '/private/tmp/fixture-image.png' } },
].map(item => JSON.stringify(item)).join('\n') + '\n```';
return [
message({ id: 'body-user', sequence: 1, content: '请整理发布前检查', createdAt: T0 }),
diff --git a/apps/desktop/scripts/fixtures/group-control/ui-page.mjs b/apps/desktop/scripts/fixtures/group-control/ui-page.mjs
index fc1da25297..11f75d8e29 100644
--- a/apps/desktop/scripts/fixtures/group-control/ui-page.mjs
+++ b/apps/desktop/scripts/fixtures/group-control/ui-page.mjs
@@ -144,6 +144,10 @@ export default {
assert.ok((await timeline.innerText()).includes('以上是本轮结论。'));
assert.equal(await timeline.getByText('重点', { exact: true }).count(), 1);
assert.ok(!(await timeline.innerText()).includes('"op":"create"'));
+ const text = await timeline.innerText();
+ assert.ok(text.includes('图片说明保留') && text.includes('图片标题保留'));
+ assert.ok(text.includes('🖼'), 'an undescribed image has a neutral placeholder');
+ assert.ok(!text.includes('cindy-media://') && !text.includes('/private/tmp/fixture-image.png'));
return;
}
const input = page.locator('textarea');
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/chatServerReplyImages.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/chatServerReplyImages.test.ts
index f9b46a1567..44c0acaab9 100644
--- a/apps/desktop/src/main/maker-ipc/__tests__/chatServerReplyImages.test.ts
+++ b/apps/desktop/src/main/maker-ipc/__tests__/chatServerReplyImages.test.ts
@@ -6,8 +6,12 @@ vi.mock('../../cindy-media/taskImageDelivery.js', () => ({ materializeTaskImageT
vi.mock('../../cindy-media/ledger.js', () => ({ sessionCanRead: f.canRead }));
vi.mock('../../cindy-media/blobStore.js', async original => ({ ...await original<typeof import('../../cindy-media/blobStore.js')>(), resolveSafe: f.resolve }));
vi.mock('../../localDb/client/current.js', () => ({ getDbClient: () => ({ drizzle: f.db }) }));
+import { materializeTaskImageMarkdown } from '../../cindy-media/taskImageMarkdown.js';
import { prepareChatReplyImages } from '../chatServerReplyImages.js';
const url = `cindy-media://blobs/${'a'.repeat(64)}.png`;
+const other = `cindy-media://blobs/${'b'.repeat(64)}.png`;
+const rich = (...ops: Record<string, unknown>[]) => '```cindy-ui\n' + ops.map((op, i) =>
+ JSON.stringify({ version: 1, seq: i + 1, op: 'create', id: `n${i}`, ...op })).join('\n') + '\n```';
// Unit: public preparation entry; fake ledger/files isolate authorization and
// Markdown collection from settlement. Actual task importer has its own tests.
describe('generated reply image attachments', () => {
@@ -19,9 +23,9 @@ describe('generated reply image attachments', () => {
});
it('imports local task images and deduplicates only rendered references', async () => {
f.materialize.mockResolvedValue({ text: `![First](${url}) ![Again](${url})`, replacements: new Map([['xdt-image:///task/generated.png', url]]), failures: [] });
- const source = '![First](xdt-image:///task/generated.png)';
+ const source = '![First](xdt-image:///task/generated.png) ![Again](xdt-image:///task/generated.png)';
const result = await prepareChatReplyImages(source, 'lane', vi.fn());
- expect(f.materialize).toHaveBeenCalledExactlyOnceWith('lane', source);
+ expect(f.materialize).toHaveBeenCalledExactlyOnceWith('lane', '![](<xdt-image:///task/generated.png>)\n![](<xdt-image:///task/generated.png>)');
expect(result.text).toBe('First Again');
expect(result.attachments).toEqual([expect.objectContaining({ url, path: null, category: 'image', size: 3 })]);
expect(f.canRead).toHaveBeenCalledExactlyOnceWith('a'.repeat(64), 'lane', f.db);
@@ -59,6 +63,79 @@ describe('generated reply image attachments', () => {
expect(f.realpath).not.toHaveBeenCalled();
});
+ // #6892: the production prepare entry must treat final component images as deliveries,
+ // while ignoring code examples and removed/obsolete nodes. Ledger and FS stay boundary fakes.
+ it('delivers the same managed image from Markdown, components, or both without duplication', async () => {
+ const component = rich({ kind: 'image', props: { src: url, alt: 'Diagram' } });
+ for (const source of [`![Diagram](${url})`, component, `${component}\n![Diagram](${url})`]) {
+ const result = await prepareChatReplyImages(source, 'lane', vi.fn());
+ expect(result.attachments).toEqual([expect.objectContaining({ url, category: 'image' })]);
+ }
+ });
+ it('walks the final tree in display order after patch, move and subtree removal', async () => {
+ const source = rich(
+ { kind: 'stack' },
+ { parent: 'n0', kind: 'image', props: { src: url } },
+ { id: 'removed', parent: 'n0', kind: 'image', props: { src: 'cindy-media://invalid' } },
+ { op: 'remove', id: 'removed' },
+ { op: 'patch', id: 'n1', props: { src: other } },
+ { kind: 'image', props: { src: url } },
+ { op: 'move', id: 'n5', parent: 'root', index: 0 },
+ );
+ const result = await prepareChatReplyImages(source, 'lane', vi.fn());
+ expect(result.attachments.map(image => image.url)).toEqual([url, other]);
+ expect(result.text).toBe(source);
+ expect(f.canRead.mock.calls.map(call => call[0])).toEqual(['a'.repeat(64), 'b'.repeat(64)]);
+ });
+ it('ignores code/text/src examples while collecting real image nodes', async () => {
+ const source = rich(
+ { kind: 'code', props: { text: `![example](${other})`, src: other } },
+ { kind: 'text', props: { text: `![example](${other})`, src: other } },
+ { kind: 'video', props: { src: other } },
+ { kind: 'image', props: { src: url } },
+ );
+ expect((await prepareChatReplyImages(source, 'lane', vi.fn())).attachments.map(image => image.url)).toEqual([url]);
+ });
+ it('imports a component local path through the existing importer and deduplicates it with Markdown', async () => {
+ const sourcePath = path.resolve('fixture', 'generated [image] & copy.png');
+ const importImage = vi.fn().mockResolvedValue(url);
+ f.materialize.mockImplementation(async (_session, text) => materializeTaskImageMarkdown(text, { importImage }));
+ const component = rich({ kind: 'image', props: { src: sourcePath, alt: 'Diagram' } });
+ const result = await prepareChatReplyImages(component + `\n![Again](${url})`, 'lane', vi.fn());
+ expect(importImage).toHaveBeenCalledExactlyOnceWith(sourcePath);
+ expect(result.attachments.map(image => image.url)).toEqual([url]);
+ expect(result.text).toBe(component + '\nAgain');
+ });
+ it('keeps literal path characters from injecting extra image references during import', async () => {
+ const sourcePath = path.resolve('fixture', 'literal &<>.png') + `\n![](${other})`;
+ const importImage = vi.fn().mockResolvedValue(url);
+ f.materialize.mockImplementation(async (_session, text) => materializeTaskImageMarkdown(text, { importImage }));
+ const result = await prepareChatReplyImages(rich({ kind: 'image', props: { src: sourcePath } }), 'lane', vi.fn());
+ expect(importImage).toHaveBeenCalledExactlyOnceWith(sourcePath);
+ expect(result.attachments.map(image => image.url)).toEqual([url]);
+ });
+ it('never collects components inside code examples or a malformed document', async () => {
+ const component = rich({ kind: 'image', props: { src: url } });
+ for (const source of [`\`\`\`\`md\n${component}\n\`\`\`\``, component.replace('"seq":1', '"seq":2')]) {
+ expect(await prepareChatReplyImages(source, 'lane', vi.fn())).toEqual({ text: source, attachments: [] });
+ }
+ expect(f.stat).not.toHaveBeenCalled();
+ });
+ it.each(['foreign', 'missing', 'directory', 'empty', 'large', 'mime', 'invalid'])(
+ 'keeps component images behind existing validation: %s', async kind => {
+ if (kind === 'foreign') f.canRead.mockResolvedValue(false);
+ if (kind === 'missing') f.stat.mockRejectedValue(Object.assign(new Error('missing'), { code: 'ENOENT' }));
+ if (['directory', 'empty', 'large'].includes(kind)) f.stat.mockResolvedValue({
+ isFile: () => kind !== 'directory', size: kind === 'empty' ? 0 : kind === 'large' ? 100 * 1024 * 1024 + 1 : 3,
+ });
+ if (kind === 'mime') f.resolve.mockReturnValue({ absPath: path.resolve('fixture', 'video.mp4'), mimeType: 'video/mp4' });
+ await expect(prepareChatReplyImages(rich({ kind: 'image', props: { src: kind === 'invalid' ? url + '?invalid' : url } }), 'lane', vi.fn())).rejects.toThrow();
+ },
+ );
+ it('shares the attachment limit across Markdown and component images', async () => {
+ const markdown = Array.from({ length: 20 }, (_, i) => `![](cindy-media://blobs/${i.toString(16).padStart(64, '0')}.png)`).join('\n');
+ await expect(prepareChatReplyImages(markdown + '\n' + rich({ kind: 'image', props: { src: url } }), 'lane', vi.fn())).rejects.toThrow('ATTACHMENT_UNAVAILABLE');
+ });
it('stops after an execution changes during authorization', async () => {
let current = true; f.canRead.mockImplementation(async () => { current = false; return true; });
await expect(prepareChatReplyImages(`![image](${url})`, 'lane', () => { if (!current) throw new Error('STALE_EXECUTOR'); })).rejects.toThrow('STALE_EXECUTOR');
diff --git a/apps/desktop/src/main/maker-ipc/chatServerReplyImages.ts b/apps/desktop/src/main/maker-ipc/chatServerReplyImages.ts
index ab17b3e677..9cac452fb2 100644
--- a/apps/desktop/src/main/maker-ipc/chatServerReplyImages.ts
+++ b/apps/desktop/src/main/maker-ipc/chatServerReplyImages.ts
@@ -1,5 +1,6 @@
import fs from 'node:fs/promises';
import path from 'node:path';
+import { RichAnswerStream, splitRichAnswer, richString } from '@cindy/maker-shared/rich-answer';
import { BOT_GROUP_ATTACHMENTS_MAX } from '../../shared/botGroupChat.js';
import { parseBlobUrl, resolveSafe } from '../cindy-media/blobStore.js';
import { sessionCanRead } from '../cindy-media/ledger.js';
@@ -12,11 +13,46 @@ import { isNetworkOrDevicePath } from './chatServerReplyAttachments.js';
const imageLabel = (image: { alt: string }) => image.alt.replace(/[\\`*_{}[\]<>#!|]/g, '\\$&');
+type ReplyImageReference = { url: string; start: number; identifier?: string };
+
+/** Collect final rendered references in display order, keeping Markdown scopes independent.
+ * The Markdown AST still owns reference definitions and code-example exclusion; the
+ * component parser owns patches, moves and removed subtrees.
+ */
+function replyImageReferences(text: string): ReplyImageReference[] {
+ const markdown = taskImageReferences(text);
+ return splitRichAnswer(text).flatMap<ReplyImageReference>(part => {
+ if (part.kind === 'markdown') return markdown.filter(ref =>
+ ref.start >= part.key && ref.start < part.key + part.source.length);
+ const doc = new RichAnswerStream().update(part.source, true);
+ if (doc.issues) return [];
+ const images: Array<{ url: string; start: number }> = [];
+ const visit = (id: string) => {
+ const node = doc.nodes.get(id);
+ if (!node) return;
+ if (node.kind === 'image') {
+ const src = richString(node, 'src');
+ if (src) images.push({ url: src, start: part.key });
+ }
+ node.children.forEach(visit);
+ };
+ doc.roots.forEach(visit);
+ return images;
+ });
+}
+
+/** Feed exact references to the existing importer without exposing synthetic text.
+ * Character references prevent source paths from injecting Markdown structure.
+ */
+function imageReferenceMarkdown(refs: Array<{ url: string }>): string {
+ return refs.map(ref => `![](<${ref.url.replace(/[&<>\\\r\n]/g, char => `&#${char.charCodeAt(0)};`)}>)`).join('\n');
+}
+
/** Prepare only rendered, task-owned generated images. Never reads legacy caches. */
export async function prepareChatReplyImages(text: string, sessionId: string, assertCurrent: () => void,
authorizedFiles: ChatUploadAttachment[] = []) {
assertCurrent();
- const originalImages = taskImageReferences(text);
+ const originalImages = replyImageReferences(text);
const localSources = new Map<string, string>();
for (const ref of originalImages) {
const local = localTaskImagePath(ref.url);
@@ -49,12 +85,15 @@ export async function prepareChatReplyImages(text: string, sessionId: string, as
if (fileOnlyAttachments.size > BOT_GROUP_ATTACHMENTS_MAX) throw new Error('ATTACHMENT_UNAVAILABLE');
}
text = rewriteTaskImageReferences(text, fileOnly, imageLabel);
+ let refs = originalImages.filter(ref => !fileOnly.has(ref.url));
+ const imageMarkdown = imageReferenceMarkdown(refs);
let replacements = new Map<string, string>();
- if (hasLocalTaskImages(text)) {
- const imported = await materializeTaskImageTextResult(sessionId, text);
+ if (hasLocalTaskImages(imageMarkdown)) {
+ const imported = await materializeTaskImageTextResult(sessionId, imageMarkdown);
assertCurrent();
if (imported.failures.length || hasLocalTaskImages(imported.text)) throw new Error('ATTACHMENT_UNAVAILABLE');
- text = imported.text;
+ refs = taskImageReferences(imported.text);
+ text = rewriteTaskImageReferences(text, imported.replacements);
replacements = imported.replacements;
}
const positions = new Map<string, number>();
@@ -70,7 +109,7 @@ export async function prepareChatReplyImages(text: string, sessionId: string, as
}
const attachments: ChatUploadAttachment[] = [];
const delivered = new Map<string, string>();
- for (const ref of taskImageReferences(text)) {
+ for (const ref of refs) {
if (!/^(cindy-media|xdt-image):\/\//.test(ref.url) || delivered.has(ref.url)) continue;
const blob = parseBlobUrl(ref.url);
if (!blob || attachments.length >= BOT_GROUP_ATTACHMENTS_MAX
diff --git a/docs/product-rules/bot-group-chat.md b/docs/product-rules/bot-group-chat.md
index 6624365f48..05ccadafb6 100644
--- a/docs/product-rules/bot-group-chat.md
+++ b/docs/product-rules/bot-group-chat.md
@@ -525,6 +525,8 @@ Chat Server 声明 `capabilities.groupSingleSpeaker: 1` 时,服务器群按下
普通回复中明确展示的当前任务生成图片作为群附件交付,其他有权限的成员可以查看和下载;图片交付失败不降级为丢图的纯文字成功回复。
有文件访问授权的伙伴普通回复(含讨论队列)中,明确链接的当前任务工作目录内 PDF 等文件作为群附件交付;交付失败明确报错,不把本机路径当作成功交付,也不自动收集目录内其他文件。
文件交付在读取、上传和封存前复验群成员、伙伴归属、授权版本及执行租约;工具调用结束时的授权不能替代交付时的授权。明确撤权则停止交付,临时校验失败保留同一执行结果重试,不重新运行 Agent。
+Markdown 图片与 `cindy-ui` 的图片节点遵守同一规则;修改或删除图片节点后,只交付最终保留的图片,同一张图不重复交付。
+群正文保留媒体的说明、替代文字与图注,不展示内部媒体地址;没有说明时保留类型占位,不凭媒体地址宣称附件已送达。
Chris 已明确扩展到多人各带伙伴,并选择「主人按群预先授权」。正式群聊统一使用 Chat Server;已有本地群及消息自动迁移,不保留并行本地群入口。Agent 工作目录与私人资料仍留在执行端,外部成员的访问继续受下述授权边界约束。服务端群历史与 Agent 本机/云端执行分离,人和伙伴共用成员、群角色和消息合同,国内与国际账号可以互邀。
diff --git a/docs/verification/issue-6892/README.md b/docs/verification/issue-6892/README.md
new file mode 100644
index 0000000000..9121f8b5e6
--- /dev/null
+++ b/docs/verification/issue-6892/README.md
@@ -0,0 +1,114 @@
+# #6892:群聊组件图片交付验收
+
+验证日期:2026-10-23。分支:`fix/6892-group-component-images`。
+
+## 改动与结论
+
+伙伴回复中的 `cindy-ui` 图片节点现在复用现有图片附件交付通道。按组件最终树提取图片,
+应用 patch / move / remove 后再与 Markdown 图片统一去重;继续执行任务读取授权、
+MIME、大小、数量及执行状态检查。群正文保留说明、替代文字与图注,隐藏媒体地址,
+没有说明时显示类型占位,不凭地址宣称图片已送达。
+
+本轮 macOS Desktop 双账号核心验收通过,用户已确认验收完成。图片通过真实伙伴回复
+结算路径上传,接收账号可以查看、打开和保存;发送端离线后接收端冷启动仍可查看。
+
+## 实机范围
+
+- 同一台 macOS 电脑上的两个独立 Desktop 进程、两个真实账号,连接真实群服务。
+- 发送端基线 `415f2fc19ebe54f1598995be81cf7dac1a83a218`,包含本次修复。
+- 接收端基线 `8af10eb2470e49906e73022d8c78ba533d1c3eff`,仅移植本次共享正文投影
+ 及其回归测试;这是旧基线接收端兼容性验收,不是发送端基线的完整接收构建验收。
+- 经仓库安全启动入口确认实例 ready,再从普通群输入框点名测试伙伴发送。
+ 接收端沿用原隔离环境,未复制凭证或数据库,未修改数据库 schema。
+
+| 场景 | 观察结果 |
+| --- | --- |
+| `QA6892-M2`:合法 Markdown 图片 | 接收账号得到 1 个真实图片附件 |
+| `QA6892-C`:组件 image | 得到 1 个附件,正文保留说明且不显示内部 src |
+| `QA6892-MIX`:同图 Markdown 与组件混合 | 仅交付 1 个附件 |
+| `QA6892-FINAL`:创建后修改、删除节点 | 仅交付最终保留的有效图片;旧路径和删除节点未上传 |
+| `QA6892-UNIQUE`:本轮独有图片 | 首次查看、看图器打开、保存文件并校验内容均通过 |
+| 历史重开与重载 | 切走再返回群、页面重载后图片仍可读 |
+| 发送端离线 | 确认发送进程退出、调试端口关闭后,接收端冷启动,图片与看图器仍正常 |
+| Light / Dark | 真实群消息截图均已目检,正文与图片正常 |
+| `QA6892-MISSING`:不存在的组件图片 | 明确失败,没有提交丢图的成功回复 |
+| `QA6892-RECOVERY`:失败后重新发起 | 用有效图片人工发起新一轮后正常交付,混合去重仍为 1 个 |
+
+首次 `QA6892-M` 输出的路径含空格但未使用合法 Markdown 包裹,未产生附件,未计为成功。
+纠正语法后的 `QA6892-M2` 通过;本次不将普通文本中的任意路径扩展为图片指令。
+
+## 保存与离线证据
+
+独有图片为 73×59 PNG,12,070 字节。接收端通过看图器“另存为”触发原生窗口,
+用户完成保存并确认“已保存”;实际文件的格式、尺寸、字节数及 SHA-256 均已校验:
+
+```text
+9f3bcb22b49cf4c5535c76e2dd63cb80d0b66c1ecaa9da7f24a8d0741917d646
+```
+
+发送端离线后,接收端冷启动并重新读取同一图片,打开看图器成功。接收端仍联网;
+这里的“离线”专指发送端退出。未删除磁盘缓存,未在此阶段再次执行“另存为”。
+缺失图片后的恢复是人工新发起的一轮,不等同于网络错误自动重试或完成回执恢复。
+
+原始截图、消息与附件标识、文件校验和实例状态保留在本机验收记录,未随提交发布。
+此文保存脱敏后的结果;自动回归与实现一同提交。
+
+## 自动验证
+
+以下检查在最终代码上完成,整理本文时未再修改产品源码:
+
+| 检查 | 结果 |
+| --- | --- |
+| Desktop 完整类型检查 | 通过 |
+| Mobile 完整类型检查 | 通过 |
+| maker-shared `tsc --noEmit` | 通过 |
+| Desktop 回复图片、群服务与媒体上传定向测试 | 347 项通过 |
+| Desktop quota 测试夹具相关回归 | 4 项通过,579 项按名称过滤 |
+| Mobile 菜单、输入栏、粘贴、群正文及附件相关测试 | 5 个文件,29 项通过 |
+| maker-shared 全套测试 | 100 个文件,1,798 项通过 |
+| 任务图片交付回归 | 58 项通过 |
+| Desktop 附件组件回归 | 3 项通过 |
+| 群正文 `body-answer` 组件场景 | Light / Dark 共 2 项通过,overview 已目检 |
+| 接收端补丁副本 | 58 项正文回归及 maker-shared 类型检查通过 |
+| 文档、测试规范、diff 空白检查 | 通过 |
+
+Desktop 类型错误通过补齐测试夹具必需的 `statDirectory` 依赖修复。
+Mobile 类型错误来自依赖安装不完整;按现有锁文件重新安装并应用仓库已有补丁后通过,
+未修改 Mobile 源码、依赖清单、锁文件或原生配置。
+
+主要复查命令(在本分支根目录运行):
+
+```sh
+pnpm --filter desktop run --if-present typecheck
+pnpm --filter mobile run --if-present typecheck
+pnpm --dir packages/maker-shared exec tsc --noEmit
+pnpm --dir apps/desktop exec vitest run src/main/maker-ipc/__tests__/chatServerReplyImages.test.ts src/main/maker-ipc/__tests__/chatServer.test.ts src/main/maker-ipc/__tests__/chatServerMedia.test.ts --maxWorkers=1
+pnpm --dir apps/desktop exec vitest run src/main/maker-ipc/__tests__/agent-input-coordinator.test.ts -t 'preserves bootstrap quota through the send transaction' --maxWorkers=1
+pnpm ui:check --page group-chat --case body-answer --theme all --locale zh-CN --viewport 720x700
+pnpm check:dev-docs
+pnpm check:test-hygiene
+git diff --check
+```
+
+## 未覆盖项
+
+本轮未验证 Mobile 实机、Windows、两台物理电脑、网络上传故障注入、完成回执丢失、
+跨账号撤权实测;单元测试不能替代这些实测。未运行整仓全量测试或远端 CI。
+接收端首次编译曾超过启动器时限,随后确认 ready 才开展验收;后续冷启动直接 ready。
+
+## 2026-10-27:同步主干后的补充检查
+
+提交 PR 前同步 `origin/main@a94dc25130`,解决图片准备入口、测试及产品规则的冲突。
+保留主干新增的已授权文件分类、原始附件位置和来源路径,组件图片按同一准备入口处理。
+主干已经补齐 quota 测试夹具的 `statDirectory`,本分支不再重复修改该夹具。
+
+- 图片、文件、群服务及媒体上传:4 个文件 494 项通过,总耗时 8.61 秒。
+- maker-shared:104 个文件 1,923 项通过,总耗时 19.41 秒;`tsc --noEmit` 通过。
+- 图片准备测试单独运行:26 项通过,总耗时 0.836 秒;正文投影测试单独运行:
+ 62 项通过,总耗时 0.202 秒。
+- Desktop 完整类型检查通过。首次同步检查因夹具重复属性报 `TS1117`,移除重复变更后重跑通过。
+- Mobile 完整类型检查通过;群正文与附件 2 个测试文件 18 项通过,总耗时 3.95 秒。
+- quota 夹具回归重跑:4 项通过,593 项按名称过滤,总耗时 4.46 秒。
+- 群正文 `body-answer`:Light / Dark 共 2 项通过,总耗时 7.7 秒,overview 已目检。
+
+上文双账号实机验收来自 2026-10-23 的构建,未在同步主干后重做;原始限制继续有效。
diff --git a/packages/maker-shared/src/__tests__/botGroupPresentation.test.ts b/packages/maker-shared/src/__tests__/botGroupPresentation.test.ts
index 369b205c93..42dd4e503f 100644
--- a/packages/maker-shared/src/__tests__/botGroupPresentation.test.ts
+++ b/packages/maker-shared/src/__tests__/botGroupPresentation.test.ts
@@ -231,12 +231,22 @@ describe('group body component display', () => {
it.each([rich({ kind: 'text', props: { text: '' } }), rich({ kind: 'range' }), '```cindy-ui\ninvalid\n```'])('retains unreadable source %s', content => {
expect(botGroupBodyParts(content, 'bot')).toEqual([{ kind: 'markdown', content }]);
});
+ it.each(['image', 'video', 'audio', 'svg'])('keeps %s descriptions but never the media source or an attachment promise', kind => {
+ for (const src of ['cindy-media://blobs/example.png', 'file:///private/image.png', 'xdt-file:///image.png', '/private/image.png', 'https://example.test/image.png']) {
+ expect(botGroupBodyParts(rich({ kind, props: { label: 'Title', alt: 'Description', caption: 'Caption', src } }), 'bot'))
+ .toEqual([{ kind: 'text', content: 'Title\nDescription\nCaption' }]);
+ }
+ });
+ it('keeps an undescribed image visible as a placeholder without exposing protocol source', () => {
+ expect(botGroupBodyParts(rich({ kind: 'image', props: { src: 'cindy-media://blobs/example.png' } }), 'bot'))
+ .toEqual([{ kind: 'text', content: '🖼' }]);
+ });
it('uses final tree content and exposes media descriptions without requesting local media', () => {
const content = rich({ kind: 'stack', props: { label: 'Summary' } }, { parent: 'n0', kind: 'text', props: { text: 'Old' } },
{ op: 'patch', id: 'n1', props: { text: 'Updated' } }, { kind: 'image', props: { alt: 'Diagram', src: 'cindy-media://blobs/example.png' } });
expect(botGroupBodyParts(content, 'bot')).toEqual([
{ kind: 'text', content: 'Summary' }, { kind: 'text', content: 'Updated' },
- { kind: 'text', content: 'Diagram\ncindy-media://blobs/example.png' },
+ { kind: 'text', content: 'Diagram' },
]);
});
});
diff --git a/packages/maker-shared/src/botGroupPresentation.ts b/packages/maker-shared/src/botGroupPresentation.ts
index a16c956915..1afed9de6f 100644
--- a/packages/maker-shared/src/botGroupPresentation.ts
+++ b/packages/maker-shared/src/botGroupPresentation.ts
@@ -404,7 +404,10 @@ export function botGroupBodyParts(content: string, authorKind?: BotGroupMessageV
const label = richString(node, 'label');
if (['image', 'video', 'audio', 'svg'].includes(node.kind)) {
// Group body has no task-local media authority. Keep its description readable.
- add([label, richString(node, 'alt'), richString(node, 'caption'), richString(node, 'src')].filter(Boolean).join('\n'));
+ const description = [label, richString(node, 'alt'), richString(node, 'caption')].filter(text => text.trim()).join('\n');
+ // A neutral type marker is not a promise that an attachment was delivered.
+ const placeholder = node.kind === 'image' ? '🖼' : node.kind === 'video' ? '🎞' : node.kind === 'audio' ? '♪' : '◇';
+ add(description || placeholder);
} else {
const markdown = richMarkdown(node);
if (markdown !== null) {