From 2ba0f5914fad770ba2fc1a5a13c281489afc7e68 Mon Sep 17 00:00:00 2001 From: Matt Van Horn <455140+mvanhorn@users.noreply.github.com> Date: Sat, 14 Mar 2026 09:02:20 -0700 Subject: [PATCH] fix(ui): escape brackets in filename and use paragraph break for inline images Escape `[` and `]` in filenames to prevent malformed markdown when attaching images. Use `\n\n` instead of `\n` so the image renders as its own paragraph instead of inline with preceding text. Co-Authored-By: Claude Opus 4.6 (1M context) --- ui/src/components/CommentThread.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ui/src/components/CommentThread.tsx b/ui/src/components/CommentThread.tsx index 0323bf88..d93fa8b1 100644 --- a/ui/src/components/CommentThread.tsx +++ b/ui/src/components/CommentThread.tsx @@ -340,8 +340,9 @@ export function CommentThread({ try { if (imageUploadHandler) { const url = await imageUploadHandler(file); - const markdown = `![${file.name}](${url})`; - setBody((prev) => prev ? `${prev}\n${markdown}` : markdown); + const safeName = file.name.replace(/[[\]]/g, "\\$&"); + const markdown = `![${safeName}](${url})`; + setBody((prev) => prev ? `${prev}\n\n${markdown}` : markdown); } else if (onAttachImage) { await onAttachImage(file); }