mcp-data-platform-v1.40.4
Fix: Markdown Thumbnail Capture Race Condition
v1.40.2 and v1.40.3 attempted to fix blank markdown thumbnails but failed — v1.40.2 speculated visibility: hidden was the cause (it wasn't), and v1.40.3 changed positioning without addressing the real issue. This release fixes the actual root cause.
Root Cause
DomCapture used setTimeout(doCapture, 500) — an arbitrary 500ms delay — to wait for ReactMarkdown to finish rendering before capturing the thumbnail. ReactMarkdown renders asynchronously, and if it hadn't completed within 500ms, toPng captured a container with no rendered content, producing a blank PNG.
Fix
Replaced the arbitrary timeout with a MutationObserver that watches for actual rendered elements (p, h1–h3, li, pre, blockquote, table) to appear in the DOM. Once content is detected, capture fires after one requestAnimationFrame to let layout settle. SVG content (set synchronously via dangerouslySetInnerHTML) is caught by an initial element check before the observer is attached.
The existing CAPTURE_TIMEOUT_MS (15s) safety net remains as a fallback.
Verified
Tested end-to-end in the browser with VITE_MSW=true:
toPngproduced a valid 11.8KB PNG blob from the DomCapture containerthumbnail_s3_keyset after capture completed- Save-triggered regeneration re-captured successfully
- Zero console errors
Also Included
- Mock
PUT /assets/:id/thumbnailhandlers added to MSW so thumbnail capture can be tested in dev mode without a real backend.
Changed Files
ui/src/components/ThumbnailGenerator.tsx—DomCapture: MutationObserver replaces setTimeoutui/src/mocks/handlers.ts— mock thumbnail upload endpoints for dev testing