fix: embed uploaded images inline in comments via paperclip button

The paperclip button in comments uploaded images to the issue-level
attachment section but didn't insert a markdown image reference into
the comment body. Now it uses the imageUploadHandler to get the URL
and appends an inline image to the comment text.

Fixes #272

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Matt Van Horn
2026-03-10 16:50:57 -07:00
parent 3a003e11cc
commit d114927814

View File

@@ -335,10 +335,16 @@ export function CommentThread({
async function handleAttachFile(evt: ChangeEvent<HTMLInputElement>) {
const file = evt.target.files?.[0];
if (!file || !onAttachImage) return;
if (!file) return;
setAttaching(true);
try {
await onAttachImage(file);
if (imageUploadHandler) {
const url = await imageUploadHandler(file);
const markdown = `![${file.name}](${url})`;
setBody((prev) => prev ? `${prev}\n${markdown}` : markdown);
} else if (onAttachImage) {
await onAttachImage(file);
}
} finally {
setAttaching(false);
if (attachInputRef.current) attachInputRef.current.value = "";
@@ -367,7 +373,7 @@ export function CommentThread({
contentClassName="min-h-[60px] text-sm"
/>
<div className="flex items-center justify-end gap-3">
{onAttachImage && (
{(imageUploadHandler || onAttachImage) && (
<div className="mr-auto flex items-center gap-3">
<input
ref={attachInputRef}