Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(mobile): 分享图纯文本布局只在连续删除线范围两端加 ~~
Dashb2cb8628b69d
diff --git a/apps/mobile/src/__tests__/conversationShareSvg.test.ts b/apps/mobile/src/__tests__/conversationShareSvg.test.tsindex c8a1a61e76..34b135b636 100644--- a/apps/mobile/src/__tests__/conversationShareSvg.test.ts+++ b/apps/mobile/src/__tests__/conversationShareSvg.test.ts@@ -407,6 +407,25 @@ describe("ConversationShareSvg", () => {);});+ it("wraps a strikethrough range split by a link once in the redacted fallback", () => {+ const layout = buildConversationShareSvgLayout({+ allShareableIds: ["m"],+ colors,+ messages: [+ {+ body: "改为 ~~见 https://a.example/x 旧版~~ 新版\n\npassword: private-secret",+ clientId: "m",+ kind: "assistant",+ },+ ],+ width: 390,+ });+ const text = layout.bubbles[0]!.textBlocks.flatMap((block) => block.lines).join("");+ expect(text).toContain("改为 ~~见 https://a.example/x 旧版~~ 新版");+ expect(text).not.toContain("~~~~");+ expect(text).not.toContain("private-secret");+ });+it("waits for both footer assets before allowing export", async () => {const gate = createConversationShareAssetGate(["character", "logo"]);let ready = false;diff --git a/apps/mobile/src/session/conversationShareSvgLayout.ts b/apps/mobile/src/session/conversationShareSvgLayout.tsindex e9ad513e2d..3057ef9620 100644--- a/apps/mobile/src/session/conversationShareSvgLayout.ts+++ b/apps/mobile/src/session/conversationShareSvgLayout.ts@@ -413,27 +413,32 @@ function markdownInlineParts(images: ConversationShareMessage["images"],): ShareBodyPart[] {const parts: ShareBodyPart[] = [];+ const appendText = (text: string) => {+ const last = parts[parts.length - 1];+ if (last && "text" in last) last.text += text;+ else parts.push({ text });+ };+ // 删除线里的链接等会把一段删除线拆成多个 inline:`~~` 只加在连续删除线范围的两端,+ // 不给每个片段各包一层(否则边界处出现 `~~~~`)。+ let struck = false;for (const inline of inlines) {const image = inline.type === "image" ? images?.get(inline.url) : undefined;+ const nextStruck = !image && mobileMarkdownInlineHasMark(inline, "strikethrough");+ if (struck !== nextStruck) {+ appendText("~~");+ struck = nextStruck;+ }if (image) {parts.push({ image });continue;}- const text = (() => {- if (inline.type === "image") {- return (- inline.alt.trim() || i18n.t("message.renderer.imageFallbackTitle")- );- }- if (mobileMarkdownInlineHasMark(inline, "strikethrough")) {- return `~~${inline.text}~~`;- }- return inline.text;- })();- const last = parts[parts.length - 1];- if (last && "text" in last) last.text += text;- else parts.push({ text });+ appendText(+ inline.type === "image"+ ? inline.alt.trim() || i18n.t("message.renderer.imageFallbackTitle")+ : inline.text,+ );}+ if (struck) appendText("~~");return parts;}