Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(mobile): MB drop private-protocol image links from the companion's reply in the cloud conversation
nana3ce259517f52
diff --git a/apps/mobile/src/__tests__/cloudCompanion.test.ts b/apps/mobile/src/__tests__/cloudCompanion.test.tsindex 1885c80013..f754b4c443 100644--- a/apps/mobile/src/__tests__/cloudCompanion.test.ts+++ b/apps/mobile/src/__tests__/cloudCompanion.test.ts@@ -73,6 +73,22 @@ describe('cloud companion rows', () => {{ id: id(11), text: '〔来自飞书〕\nlook', names: [[id(41), 'a.png'], [id(42), expect.any(String)]] },]);});+ it('drops private-protocol image links from the companion\'s reply and keeps everything else', () => {+ const base = { author: { kind: 'bot', name: '' }, createdAt: '2026-10-13T00:00:00Z', deleted: false, threadRootId: null };+ const reply = (n: number, text: string, authorId = id(1)): ChatMessage => ({ ...base, id: id(n), seq: String(n), authorId, content: [{ type: 'text', text }] });+ const hash = 'a'.repeat(64);+ const view = cloudCompanionMessages([+ reply(1, `Here is the frog.\n\n\n\nEnjoy`),+ reply(2, ``),+ reply(3, ` [link](cindy-media://x) \`\`\n\n\`\`\`\n\n\`\`\``),+ reply(4, ``, id(9)),+ ], id(1));+ expect(view.map(item => item.text)).toEqual([+ 'Here is the frog.\n\nEnjoy',+ ` [link](cindy-media://x) \`\`\n\n\`\`\`\n\n\`\`\``,+ ``,+ ]);+ });it('orders by message time, so older history uploaded later still appears first', () => {const at = (n: number, time: string): ChatMessage => ({ id: id(n), seq: String(n), authorId: id(9), author: { kind: 'human', name: '' },createdAt: time, deleted: false, threadRootId: null, content: [{ type: 'text', text: `m${n}` }] });diff --git a/apps/mobile/src/chat/cloudCompanion.ts b/apps/mobile/src/chat/cloudCompanion.tsindex 178d3896e2..e1524255dc 100644--- a/apps/mobile/src/chat/cloudCompanion.ts+++ b/apps/mobile/src/chat/cloudCompanion.ts@@ -75,6 +75,18 @@ export function cloudHomeTargets<T extends { deviceId: string; online: boolean }export interface CloudMessage { id: string; fromCompanion: boolean; text: string; attachments: BotGroupAttachment[]; createdAt: number }+const PRIVATE_IMAGE = /!\[[^\]\n]*\]\((?:cindy-media|xdt-image|xdt-video|file):\/\/[^)\s]*\)/gi;++/**+ * A reply names the images it produced with the computer's private addresses, which the phone cannot open;+ * the same files already arrive as attachments. Drops those image links, leaving http(s) images, links and code.+ */+export function stripPrivateImageLinks(text: string): string {+ const parts = text.split(/(```[\s\S]*?(?:```|$)|`[^`\n]*`)/);+ const cleaned = parts.map((part, index) => (index % 2 ? part : part.replace(PRIVATE_IMAGE, ''))).join('');+ return cleaned === text ? text : cleaned.replace(/[ \t]+\n/g, '\n').replace(/\n{3,}/g, '\n\n');+}+/*** Oldest first, deduplicated; the companion's actor wrote its replies, everyone else is the owner.* A message with only attachments stays; one with neither text nor attachments is dropped.@@ -90,10 +102,12 @@ export function cloudCompanionMessages(messages: readonly ChatMessage[], actorIdreturn left < right ? -1 : left > right ? 1 : 0;});return unique.flatMap(message => {- const text = chatMessageText(message).trim();+ const fromCompanion = message.authorId === actorId;+ const raw = chatMessageText(message);+ const text = (fromCompanion ? stripPrivateImageLinks(raw) : raw).trim();const attachments = chatMessageAttachments(message);return text || attachments.length- ? [{ id: message.id, fromCompanion: message.authorId === actorId, text, attachments, createdAt: Date.parse(message.createdAt) }] : [];+ ? [{ id: message.id, fromCompanion, text, attachments, createdAt: Date.parse(message.createdAt) }] : [];});}