Skip to content

A local-first multi-agent app development platform, built on PenguinHarness

fix(ui,server): tildes in a reply show as typed, not strikethrough

lmlihengc6e849bb4677
diff --git a/changelog/unreleased/2026-10-13-no-strikethrough.md b/changelog/unreleased/2026-10-13-no-strikethrough.md
new file mode 100644
index 00000000..b4086bda
--- /dev/null
+++ b/changelog/unreleased/2026-10-13-no-strikethrough.md
@@ -0,0 +1,18 @@
+# Tildes in a reply show as typed; strikethrough is not rendered
+
+- **Date:** 2026-10-13
+- **Type:** fix
+- **Scope:** `ui`, `server`
+
+[中文版](2026-10-13-no-strikethrough.zh.md)
+
+Ported from upstream PenguinHarness (#1017, commit `362c9997`).
+
+Replies use `~` for ranges (`3~5 天`) and for "about" (`~30 秒`) far more often than for
+strikethrough, and two of them in one paragraph struck out every word between them. Strikethrough
+is no longer rendered: a `~text~` or `~~text~~` shows its tildes as written, and whatever sits
+between them keeps its own formatting. This holds in the Web App, wherever a reply is rendered as
+Markdown (chat, Trace, plugin pages, file previews), and in replies relayed to Feishu, Telegram,
+QQ and WeChat. The rest of GFM, such as tables, task lists, autolinks and footnotes, is unchanged.
+
+No API, wire format or stored data changes.
diff --git a/changelog/unreleased/2026-10-13-no-strikethrough.zh.md b/changelog/unreleased/2026-10-13-no-strikethrough.zh.md
new file mode 100644
index 00000000..24454024
--- /dev/null
+++ b/changelog/unreleased/2026-10-13-no-strikethrough.zh.md
@@ -0,0 +1,13 @@
+# 回复中的波浪号按原样显示,不再渲染删除线
+
+- **Date:** 2026-10-13
+- **Type:** fix
+- **Scope:** `ui`, `server`
+
+[English](2026-10-13-no-strikethrough.md)
+
+移植自上游 PenguinHarness(#1017,提交 `362c9997`)。
+
+回复里的 `~` 多用来表示范围(`3~5 天`)或「大约」(`~30 秒`),很少用作删除线;同一段里出现两个时,二者之间的文字会被整段划掉。现在不再渲染删除线:`~text~` 与 `~~text~~` 的波浪号按原样显示,夹在中间的内容保留各自的格式。这在 Web App 中凡是以 Markdown 渲染回复的地方(对话、Trace、插件页、文件预览)都生效,转发到飞书、Telegram、QQ 与微信的回复也一样。GFM 的其余部分(表格、任务列表、自动链接、脚注)不变。
+
+接口、线上格式与已存数据都没有变化。
diff --git a/packages/server/src/runtime/messaging/markdown.ts b/packages/server/src/runtime/messaging/markdown.ts
index 0eda2681..2dfff57f 100644
--- a/packages/server/src/runtime/messaging/markdown.ts
+++ b/packages/server/src/runtime/messaging/markdown.ts
@@ -40,7 +40,63 @@ const processor = unified().use(remarkParse).use(remarkGfm);
/** Reads a reply as Markdown. Never throws: any text at all is a valid document. */
export function parseMarkdown(text: string): Root {
- return processor.parse(text);
+ const root = processor.parse(text);
+ literalStrikethrough(root, text);
+ return root;
+}
+
+/**
+ * Strikethrough is not rendered: every `delete` node GFM produced becomes its own text again —
+ * the opening tildes, its children as parsed, the closing tildes — so each channel's renderer
+ * escapes the tildes like any other literal text and the reader sees what the model typed.
+ *
+ * Model replies use `~` for ranges (`3~5 天`) and "about" (`~30 秒`) far more often than for
+ * strikethrough, and two such tildes in one paragraph strike out everything between them. The
+ * Web App renders replies the same way (packages/ui's remark-literal-tildes.ts), so a reply reads
+ * alike in the transcript and in every chat. remark-gfm has no switch for strikethrough alone,
+ * and the rest of GFM — tables, task lists, autolinks — stays wanted, hence a pass on the tree.
+ * The markers are read from the source at the node's offset, so `~` stays one tilde and `~~` two;
+ * the synthesized text nodes carry the markers' own spans.
+ */
+function literalStrikethrough(node: Nodes, source: string): void {
+ if (!("children" in node)) return;
+ const out: Nodes[] = [];
+ for (const child of node.children as Nodes[]) {
+ literalStrikethrough(child, source);
+ if (child.type !== "delete") {
+ out.push(child);
+ continue;
+ }
+ const start = child.position?.start;
+ const end = child.position?.end;
+ let run = 0;
+ if (start?.offset !== undefined) {
+ while (run < 2 && source[start.offset + run] === "~") run++;
+ }
+ const marker = run === 0 ? "~~" : "~".repeat(run);
+ const markerNode = (from: typeof start, to: typeof end): Nodes =>
+ from !== undefined && to !== undefined
+ ? { type: "text", value: marker, position: { start: from, end: to } }
+ : { type: "text", value: marker };
+ const openEnd =
+ start?.offset !== undefined
+ ? {
+ line: start.line,
+ column: start.column + marker.length,
+ offset: start.offset + marker.length,
+ }
+ : undefined;
+ const closeStart =
+ end?.offset !== undefined
+ ? { line: end.line, column: end.column - marker.length, offset: end.offset - marker.length }
+ : undefined;
+ out.push(
+ markerNode(start, openEnd),
+ ...(child.children as Nodes[]),
+ markerNode(closeStart, end),
+ );
+ }
+ (node as { children: Nodes[] }).children = out;
}
/**
diff --git a/packages/server/test/messaging-markdown.test.ts b/packages/server/test/messaging-markdown.test.ts
index 08093972..8e636c8e 100644
--- a/packages/server/test/messaging-markdown.test.ts
+++ b/packages/server/test/messaging-markdown.test.ts
@@ -76,9 +76,34 @@ describe("isSafeUrl", () => {
// Telegram — HTML, a closed tag set with no headings, lists or tables
// ---------------------------------------------------------------------------
+describe("tildes in a reply", () => {
+ // Replies use `~` for ranges and "about" far more than for strikethrough; two of them in one
+ // paragraph must not strike out the words between them, on any channel.
+ const RANGE = "3~5 天,约 ~30 秒";
+
+ it("parse as text, never as strikethrough, keeping what sits between them", () => {
+ const root = parseMarkdown("a ~~**gone**~~ b ~c~");
+ const para = root.children[0]!;
+ expect(para.type).toBe("paragraph");
+ const types = "children" in para ? para.children.map((n) => n.type) : [];
+ expect(types).not.toContain("delete");
+ expect(types).toContain("strong");
+ const text =
+ "children" in para ? para.children.map((n) => ("value" in n ? n.value : "")).join("") : "";
+ expect(text).toBe("a ~~~~ b ~c~");
+ });
+
+ it("show as typed on every channel", () => {
+ expect(telegramHtmlOf(`~~s~~ ${RANGE}`)).toBe(`~~s~~ ${RANGE}`);
+ expect(feishuMarkdownOf("~~s~~ 3~5")).toBe("&#126;&#126;s&#126;&#126; 3&#126;5");
+ expect(qqMarkdownOf("~~s~~ 3~5")).toBe("\\~\\~s\\~\\~ 3\\~5");
+ expect(wechatMarkdownOf("~~s~~ 3~5")).toBe("\\~\\~s\\~\\~ 3\\~5");
+ });
+});
+
describe("telegramHtmlOf", () => {
it("renders the inline constructs Telegram has tags for", () => {
- expect(telegramHtmlOf("**b** *i* ~~s~~ `c`")).toBe("<b>b</b> <i>i</i> <s>s</s> <code>c</code>");
+ expect(telegramHtmlOf("**b** *i* `c`")).toBe("<b>b</b> <i>i</i> <code>c</code>");
expect(telegramHtmlOf("[label](https://x.com/p)")).toBe('<a href="https://x.com/p">label</a>');
expect(telegramHtmlOf("> quoted\n> more")).toBe("<blockquote>quoted\nmore</blockquote>");
});
@@ -150,7 +175,7 @@ describe("telegramHtmlOf", () => {
describe("feishuMarkdownOf", () => {
it("keeps every construct the rich-text component renders", () => {
expect(feishuMarkdownOf("# One\n###### Six")).toBe("# One\n\n###### Six");
- expect(feishuMarkdownOf("**b** *i* ~~s~~ `c`")).toBe("**b** *i* ~~s~~ `c`");
+ expect(feishuMarkdownOf("**b** *i* `c`")).toBe("**b** *i* `c`");
expect(feishuMarkdownOf("```python\nprint(1)\n```")).toBe("```python\nprint(1)\n```");
expect(feishuMarkdownOf("- a\n - b")).toBe("- a\n - b");
expect(feishuMarkdownOf("1. one\n2. two")).toBe("1. one\n2. two");
@@ -216,7 +241,7 @@ describe("feishuMarkdownOf", () => {
describe("qqMarkdownOf", () => {
it("keeps the constructs QQ documents", () => {
expect(qqMarkdownOf("## Two")).toBe("## Two");
- expect(qqMarkdownOf("**b** *i* ~~s~~")).toBe("**b** *i* ~~s~~");
+ expect(qqMarkdownOf("**b** *i*")).toBe("**b** *i*");
expect(qqMarkdownOf("- a\n - b")).toBe("- a\n - b");
expect(qqMarkdownOf("1. one\n2. two")).toBe("1. one\n2. two");
expect(qqMarkdownOf("> quoted")).toBe("> quoted");
@@ -268,7 +293,7 @@ describe("wechatMarkdownOf", () => {
it("keeps the constructs WeChat reads, which is the most of the four", () => {
expect(wechatMarkdownOf("## Two")).toBe("## Two");
- expect(wechatMarkdownOf("**b** ~~s~~")).toBe("**b** ~~s~~");
+ expect(wechatMarkdownOf("**b** *i*")).toBe("**b** *i*");
expect(wechatMarkdownOf("- a\n - b")).toBe("- a\n - b");
expect(wechatMarkdownOf("1. one\n2. two")).toBe("1. one\n2. two");
expect(wechatMarkdownOf("> quoted")).toBe("> quoted");
diff --git a/packages/ui/src/components/content/prose/markdown-plugins.ts b/packages/ui/src/components/content/prose/markdown-plugins.ts
index cb610e62..3ed725ea 100644
--- a/packages/ui/src/components/content/prose/markdown-plugins.ts
+++ b/packages/ui/src/components/content/prose/markdown-plugins.ts
@@ -38,6 +38,7 @@ import remarkMath from "remark-math";
import rehypeKatex from "rehype-katex";
import type { Options } from "react-markdown";
import { remarkAutolinkBoundary } from "./remark-autolink-boundary";
+import { remarkLiteralTildes } from "./remark-literal-tildes";
import { remarkMathBrackets } from "./remark-math-brackets";
import { remarkMathDollars } from "./remark-math-dollars";
@@ -79,6 +80,8 @@ const KATEX_OPTIONS = {
/** The remark (Markdown -> mdast) stage. */
export const REMARK_PLUGINS: PluginList = [
remarkGfm,
+ // Strikethrough is shown as the tildes the model typed (see remark-literal-tildes.ts).
+ remarkLiteralTildes,
remarkAutolinkBoundary,
[remarkMath, { singleDollarTextMath: false }],
remarkMathBrackets,
diff --git a/packages/ui/src/components/content/prose/remark-literal-tildes.ts b/packages/ui/src/components/content/prose/remark-literal-tildes.ts
new file mode 100644
index 00000000..1a4167f2
--- /dev/null
+++ b/packages/ui/src/components/content/prose/remark-literal-tildes.ts
@@ -0,0 +1,65 @@
+/**
+ * Strikethrough is not rendered: a `~text~` or `~~text~~` shows its tildes as written.
+ *
+ * GFM reads one or two tildes on each side of a run as strikethrough. Model replies use the
+ * tilde for other things far more often than for that — ranges (`3~5 天`, `10~20%`), "about"
+ * (`~30 秒`), a casual sign-off — and two such tildes in one paragraph strike out everything
+ * between them, which reads as content the model withdrew. The rendered message then says the
+ * opposite of what was written.
+ *
+ * remark-gfm has no switch for strikethrough alone (`singleTilde: false` keeps `~~`), and the
+ * rest of GFM — tables, task lists, autolinks, footnotes — stays wanted. So this pass runs on the
+ * tree remark-gfm produced and turns every `delete` node back into its own text: the opening
+ * tildes, the children as they were parsed (so a `**bold**` inside stays bold), the closing
+ * tildes. The markers are read from the source at the node's offset, so `~` stays one tilde and
+ * `~~` two.
+ *
+ * The server's messaging parse does the same for the chat channels
+ * (packages/server/src/runtime/messaging/markdown.ts), so a reply reads alike everywhere.
+ */
+interface Point {
+ offset?: number;
+}
+interface Node {
+ type: string;
+ value?: string;
+ children?: Node[];
+ position?: { start: Point; end: Point };
+}
+
+/** The tilde run (one or two) a strikethrough opened with, read from the source at its offset. */
+function markerAt(source: string, offset: number | undefined): string {
+ if (offset === undefined) return "~~";
+ let run = 0;
+ while (run < 2 && source[offset + run] === "~") run++;
+ return run === 0 ? "~~" : "~".repeat(run);
+}
+
+/** Replaces every `delete` node under `node` with its tildes and its children, in place. */
+export function literalStrikethrough(node: Node, source: string): void {
+ if (node.children === undefined) return;
+ const out: Node[] = [];
+ for (const child of node.children) {
+ literalStrikethrough(child, source);
+ if (child.type !== "delete") {
+ out.push(child);
+ continue;
+ }
+ const marker = markerAt(source, child.position?.start.offset);
+ out.push({ type: "text", value: marker }, ...(child.children ?? []), {
+ type: "text",
+ value: marker,
+ });
+ }
+ node.children = out;
+}
+
+/** The remark plugin: runs after remark-gfm, against the file's own text. */
+export function remarkLiteralTildes() {
+ return (tree: Node, file: { value?: unknown }): void => {
+ literalStrikethrough(
+ tree,
+ typeof file.value === "string" ? file.value : String(file.value ?? ""),
+ );
+ };
+}
diff --git a/packages/ui/test/remark-literal-tildes.test.ts b/packages/ui/test/remark-literal-tildes.test.ts
new file mode 100644
index 00000000..3508f4ae
--- /dev/null
+++ b/packages/ui/test/remark-literal-tildes.test.ts
@@ -0,0 +1,37 @@
+/**
+ * Strikethrough is not rendered: a reply's tildes show as typed. Replies use `~` for ranges and
+ * "about" far more often than for strikethrough, and two in one paragraph used to strike out the
+ * words between them.
+ */
+import { createElement } from "react";
+import { describe, expect, it } from "vitest";
+import { Md } from "../src/components/content/prose/prose";
+import { renderStatic } from "../src/testing";
+
+const render = (text: string) => renderStatic(createElement(Md, { text }));
+
+describe("tildes in a reply", () => {
+ it("never strike out the words between a range and an 'about'", () => {
+ const html = render("需要 3~5 天,每次约 ~30 秒");
+ expect(html).not.toContain("<del>");
+ expect(html).toContain("需要 3~5 天,每次约 ~30 秒");
+ });
+
+ it("show double and single strikethrough markers as the characters typed", () => {
+ const html = render("a ~~b~~ c ~d~ e");
+ expect(html).not.toContain("<del>");
+ expect(html).toContain("a ~~b~~ c ~d~ e");
+ });
+
+ it("keep what sat between them formatted as it was written", () => {
+ const html = render("~~**bold** and `code`~~");
+ expect(html).not.toContain("<del>");
+ expect(html).toContain("~~<strong>bold</strong> and <code>code</code>~~");
+ });
+
+ it("leave the rest of GFM alone: tables and task lists still render", () => {
+ const html = render("| a |\n| - |\n| 1 |\n\n- [x] done");
+ expect(html).toContain("<table>");
+ expect(html).toContain('type="checkbox"');
+ });
+});