feat(link): expand crawler galleries into per-image rows

Merged
MP
4mo ago
+702-2

Summary

Implements MAT-134 (Lot 2): a supported gallery URL pasted into the Link Grabber now resolves into one selectable, downloadable row per image.

handle_resolve_links gains a gallery branch for crawler plugins: when extract_links answers with a kind: "gallery" payload, the gallery URL expands 1→N, mirroring the existing hoster expansion. The branch is gated on category == Crawler && !is_media_url(url) so yt-dlp-backed crawlers (YouTube, Vimeo, SoundCloud) keep the cheap probe path and never shell out per pasted URL.

Changes

  • application/commands/resolve_links_gallery.rs (new): parses the plugin's gallery JSON and builds per-image ResolvedLinkDto rows — gallery order preserved, plugin filenames kept (URL basename as fallback), mediaType: "image", isMedia: false so no yt-dlp dialog, requiresOnlineProbe: false since the provider API already vouched for the URLs
  • Per-item errors (R-05): an invalid image entry becomes an individual error row naming the offending item; the valid images survive. An empty gallery reports a single NoFile error row. A non-gallery payload falls through to the generic HEAD probe
  • resolve_links.rs: crawler gate wiring; gallery rows go through push_bounded_result so the MAX_URLS cap holds
  • types.ts: mediaType union gains "image"
  • No frontend logic change was needed for R-03: image rows start through the existing download_start command path

Testing

  • 6 new host tests in resolve_links_gallery_tests.rs: order/names/types, empty gallery, partially invalid gallery, extraction failure, non-gallery fallthrough, media-host crawlers never call extract_links
  • 3 new vitest cases in GalleryLinks.test.tsx: rows render in gallery order without a media button, Start Selected invokes download_start per selected image, a per-item error row doesn't block the valid images
  • cargo clippy --workspace -- -D warnings clean, 1690 backend tests pass, npx oxlint . clean, 728 frontend tests pass

Companion PR on the plugin repo declares the Imgur/Flickr config keys (R-01): mpiton/vortex-mod-gallery#4

MAT-134


Summary by cubic

Pasting a supported gallery URL now expands into one selectable row per image in Link Grabber. Order and filenames are preserved, per-item failures show as error rows, and the expansion is hardened with strict validation and limits.

  • New Features

    • Crawler gallery expansion: when a crawler returns kind: "gallery", one URL becomes N image rows (mediaType: "image", isMedia: false, requiresOnlineProbe: false).
    • Gated to crawler pages only (!is_media_url) so yt-dlp-backed hosts (YouTube, Vimeo, SoundCloud) keep the cheap probe path; non-gallery payloads fall back to the generic probe.
    • Empty galleries return a single NoFile error; invalid items produce named error rows without dropping valid images. Frontend adds "image" to mediaType; downloads still start via existing Tauri commands.
    • Satisfies Linear MAT-134 R-02–R-06 (R-01 is handled in the companion plugin repo).
  • Bug Fixes

    • Malformed extract_links JSON now yields a plugin error row instead of probing the gallery page.
    • Expansion is capped to the remaining resolve limit; oversized galleries truncate instead of failing the whole request.
    • Image URLs are validated with url (http/https, host required, scheme case-insensitive).

Summary by CodeRabbit

  • New Features

    • Gallery links from Imgur, Flickr, and supported webpages now expand into selectable per-image download rows.
    • Gallery order, filenames, and image type are preserved.
    • Individual image failures are reported without stopping the rest of the gallery.
    • Empty galleries display a dedicated error.
    • Selected gallery images can be downloaded through the existing download flow.
  • Bug Fixes

    • Non-gallery and media links continue using their appropriate existing resolution behavior.