Skip to content

Commit 3ca53a9

Browse files
geezoriageezoria1337claude
authored
fix(server): agents read RTF paragraphs that end with a backslash (pingdotgg#30848)
Co-authored-by: Geezy <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent 673d9b4 commit 3ca53a9

2 files changed

Lines changed: 3 additions & 0 deletions

File tree

‎apps/server/src/provider/documentTextWorker.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,8 @@ function* rtf(source: string): Generator<string, void> {
409409
i++;
410410
if (fallback) fallback--;
411411
else if (rest[0] === "*") state.skip = true;
412+
// A backslash before a line break is \par; TextEdit ends paragraphs this way.
413+
else if (!state.skip && (rest[0] === "\n" || rest[0] === "\r")) yield "\n";
412414
else if (!state.skip && ["\\", "{", "}"].includes(rest[0]!)) yield rest[0]!;
413415
else if (!state.skip && symbols.has(rest[0]!)) yield symbols.get(rest[0]!)!;
414416
}

‎apps/server/src/provider/userInputAttachments.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ describe("question answer paths", () => {
182182
],
183183
["hyphen symbol fallback", String.raw`{\rtf1\ansi\uc3\u945\~\_\-Z}`, "αZ"],
184184
["control word", String.raw`{\rtf1\ansi A\u9\tab X}`, "A\tX"],
185+
["line break paragraphs", "{\\rtf1\\ansi First\\\nSecond\\\r\nThird}", "First\nSecond\nThird"],
185186
["group close", String.raw`{\rtf1\ansi{\u945}Z}`, "αZ"],
186187
["group open", String.raw`{\rtf1\ansi\u945{Z}}`, "αZ"],
187188
["hex byte", String.raw`{\rtf1\ansi\u945\'3fZ}`, "αZ"],

0 commit comments

Comments
 (0)