Skip to content

Commit b474297

Browse files
geezoria1337claude
andcommitted
fix(server): agents read RTF paragraphs that end with a backslash
RTF treats a backslash followed by a carriage return or line feed as \par, and macOS TextEdit ends every paragraph that way. The document text extractor skipped the pair, so an attached TextEdit file reached the agent as one run-on paragraph. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 8b44f42 commit b474297

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
@@ -408,6 +408,8 @@ function* rtf(source: string): Generator<string, void> {
408408
i++;
409409
if (fallback) fallback--;
410410
else if (rest[0] === "*") state.skip = true;
411+
// A backslash before a line break is \par; TextEdit ends paragraphs this way.
412+
else if (!state.skip && (rest[0] === "\n" || rest[0] === "\r")) yield "\n";
411413
else if (!state.skip && ["\\", "{", "}"].includes(rest[0]!)) yield rest[0]!;
412414
else if (!state.skip && symbols.has(rest[0]!)) yield symbols.get(rest[0]!)!;
413415
}

‎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)