From e357d53d55c90737e2f67135329aee616b5d3d36 Mon Sep 17 00:00:00 2001 From: Wes Date: Fri, 8 May 2026 10:20:27 -0700 Subject: [PATCH] Fix backslash escaping in chat messages with hard breaks (#511) Co-authored-by: Claude Opus 4.6 --- desktop/src/features/messages/lib/useRichTextEditor.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/desktop/src/features/messages/lib/useRichTextEditor.ts b/desktop/src/features/messages/lib/useRichTextEditor.ts index 4c2324748..6b2ae945b 100644 --- a/desktop/src/features/messages/lib/useRichTextEditor.ts +++ b/desktop/src/features/messages/lib/useRichTextEditor.ts @@ -370,7 +370,12 @@ function getMarkdownFromEditor(editor: Editor): string { | { getMarkdown?: () => string } | undefined; if (storage?.getMarkdown) { - return storage.getMarkdown(); + let md = storage.getMarkdown(); + // tiptap-markdown serializes hard breaks as "\" + newline (CommonMark hard + // line break syntax). Chat messages are plain text, not rendered markdown, + // so strip the backslashes to keep clean newlines. + md = md.replace(/\\\n/g, "\n"); + return md; } // Fallback: plain text return editor.state.doc.textContent;