Skip to content

mcp-data-platform-v1.40.4

Choose a tag to compare

@github-actions github-actions released this 12 Mar 20:08
· 42 commits to main since this release
9d1c503

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, h1h3, 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:

  • toPng produced a valid 11.8KB PNG blob from the DomCapture container
  • thumbnail_s3_key set after capture completed
  • Save-triggered regeneration re-captured successfully
  • Zero console errors

Also Included

  • Mock PUT /assets/:id/thumbnail handlers added to MSW so thumbnail capture can be tested in dev mode without a real backend.

Changed Files

  • ui/src/components/ThumbnailGenerator.tsxDomCapture: MutationObserver replaces setTimeout
  • ui/src/mocks/handlers.ts — mock thumbnail upload endpoints for dev testing