Skip to content

Commit aa0e841

Browse files
committed
fix: add loop="infinite" to img tags to ensure GIFs play continuously (fixes #1480)
GIFs generated by eigent agents were only playing once and then stopping on the last frame. Added loop="infinite" attribute to all img tags in the MarkDown component to ensure they loop properly. This affects: - Images rendered from relative paths (data URLs) - Images rendered from absolute URLs - Image preview dialog While HTML img tags should loop GIFs by default, this explicit attribute ensures consistent behavior across browsers and Electron.
1 parent b5ae10c commit aa0e841

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

src/components/ChatBox/MessageItem/MarkDown.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,8 @@ export const MarkDown = memo(
199199
await electronAPI.readFileAsDataUrl(resolvedPath);
200200

201201
// Add cursor-pointer class and data attributes for click handling
202-
const newTag = `<img${beforeSrc}src="${dataUrl}"${afterSrc} class="cursor-pointer hover:opacity-90 transition-opacity" data-clickable="true" style="max-height: 320px; object-fit: contain;">`;
202+
// Add loop="infinite" to ensure GIFs play continuously (fixes issue #1480)
203+
const newTag = `<img${beforeSrc}src="${dataUrl}"${afterSrc} class="cursor-pointer hover:opacity-90 transition-opacity" data-clickable="true" style="max-height: 320px; object-fit: contain;" loop="infinite">`;
203204
rawHtml = rawHtml.replace(fullTag, newTag);
204205
} else {
205206
// Fallback: show alt text or placeholder
@@ -213,10 +214,10 @@ export const MarkDown = memo(
213214
// Keep original tag if loading fails
214215
}
215216
} else {
216-
// For absolute URLs, add click handler
217+
// For absolute URLs, add click handler and loop attribute
217218
const newTag = fullTag.replace(
218219
'<img',
219-
'<img class="cursor-pointer hover:opacity-90 transition-opacity" data-clickable="true" style="max-height: 320px; object-fit: contain;"'
220+
'<img class="cursor-pointer hover:opacity-90 transition-opacity" data-clickable="true" style="max-height: 320px; object-fit: contain;" loop="infinite"'
220221
);
221222
rawHtml = rawHtml.replace(fullTag, newTag);
222223
}
@@ -332,6 +333,7 @@ export const MarkDown = memo(
332333
src={previewImage}
333334
alt="Preview"
334335
className="h-auto max-h-[90vh] w-auto max-w-full rounded object-contain"
336+
loop="infinite"
335337
/>
336338
)}
337339
</DialogContent>

0 commit comments

Comments
 (0)