+ {tabStore.activeTabId === "VIDEO" &&
}
{(tabStore.activeTabId === "IMAGE" ||
tabStore.activeTabId === "VIDEO" ||
tabStore.activeTabId === "AUDIO") &&
}
diff --git a/frontend/libs/common/src/lib/utils/thumbnail-utils.ts b/frontend/libs/common/src/lib/utils/thumbnail-utils.ts
index 774c647b00..95b21d2384 100644
--- a/frontend/libs/common/src/lib/utils/thumbnail-utils.ts
+++ b/frontend/libs/common/src/lib/utils/thumbnail-utils.ts
@@ -84,6 +84,41 @@ export function getMediaThumbnail(
return thumbnailUrl;
}
+// Still-frame thumbnail for a video (first frame), for hosts that let the
+// user turn off animated previews. Falls back to the regular thumbnail
+// template when the backend hasn't attached still previews.
+export function getMediaStillThumbnail(
+ mediaLinks:
+ | {
+ maybe_thumbnail_template?: string | null;
+ maybe_video_previews?: {
+ still?: string | null;
+ still_thumbnail_template?: string | null;
+ } | null;
+ }
+ | null
+ | undefined,
+ options: MediaThumbnailOptions = {},
+): string | null {
+ if (!mediaLinks) return null;
+
+ const { size = THUMBNAIL_SIZES.MEDIUM } = options;
+ const previews = mediaLinks.maybe_video_previews;
+
+ if (previews?.still_thumbnail_template) {
+ return getThumbnailUrl(previews.still_thumbnail_template, { width: size });
+ }
+ if (previews?.still) {
+ return previews.still;
+ }
+ if (mediaLinks.maybe_thumbnail_template) {
+ return getThumbnailUrl(mediaLinks.maybe_thumbnail_template, {
+ width: size,
+ });
+ }
+ return null;
+}
+
export function getContextImageThumbnail(
contextImage: {
media_links: {
diff --git a/frontend/libs/components/generation-list/src/index.ts b/frontend/libs/components/generation-list/src/index.ts
index 448224d40d..4a7bca1fd1 100644
--- a/frontend/libs/components/generation-list/src/index.ts
+++ b/frontend/libs/components/generation-list/src/index.ts
@@ -5,6 +5,7 @@ export * from "./lib/prompts-cache";
export * from "./lib/media-prompt-token-cache";
export * from "./lib/gallery-view-store";
export * from "./lib/GalleryViewToggle";
+export * from "./lib/GalleryAutoplayToggle";
export * from "./lib/useGalleryData";
export * from "./lib/useSessionMediaByClass";
export * from "./lib/useGalleryEntries";
diff --git a/frontend/libs/components/generation-list/src/lib/GalleryAutoplayToggle.tsx b/frontend/libs/components/generation-list/src/lib/GalleryAutoplayToggle.tsx
new file mode 100644
index 0000000000..d3d792e8ff
--- /dev/null
+++ b/frontend/libs/components/generation-list/src/lib/GalleryAutoplayToggle.tsx
@@ -0,0 +1,51 @@
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { faPause, faPlay } from "@fortawesome/pro-solid-svg-icons";
+import type { IconDefinition } from "@fortawesome/fontawesome-svg-core";
+import { Tooltip } from "@storyteller/ui-tooltip";
+import { useGalleryViewStore } from "./gallery-view-store";
+
+const OPTIONS: {
+ autoplay: boolean;
+ icon: IconDefinition;
+ label: string;
+}[] = [
+ { autoplay: true, icon: faPlay, label: "Play video previews" },
+ { autoplay: false, icon: faPause, label: "Still thumbnails" },
+];
+
+// Segmented playing/still switch for video preview thumbnails. Sits next to
+// GalleryViewToggle on the video page; the selection is shared with the
+// gallery via useGalleryViewStore.
+export function GalleryAutoplayToggle() {
+ const autoplayVideos = useGalleryViewStore((s) => s.autoplayVideos);
+ const setAutoplayVideos = useGalleryViewStore((s) => s.setAutoplayVideos);
+
+ return (
+
+ {OPTIONS.map(({ autoplay, icon, label }) => {
+ const active = autoplayVideos === autoplay;
+ return (
+
+
+
+ );
+ })}
+
+ );
+}
diff --git a/frontend/libs/components/generation-list/src/lib/GalleryCard.tsx b/frontend/libs/components/generation-list/src/lib/GalleryCard.tsx
index 7945ac7fe2..d1cb1ff853 100644
--- a/frontend/libs/components/generation-list/src/lib/GalleryCard.tsx
+++ b/frontend/libs/components/generation-list/src/lib/GalleryCard.tsx
@@ -185,6 +185,7 @@ export const GalleryCard = memo(function GalleryCard({
) : (
s.autoplayVideos);
+ // With autoplay off, videos freeze on their still first frame. The still is
+ // also what the retry machinery below polls in that mode.
+ const thumbnail =
+ isVideo && !autoplayVideos && stillThumbnail
+ ? stillThumbnail
+ : animatedThumbnail;
// "retrying" flips to true only after the first error, so videos with ready
// thumbnails render the normal
path with zero overhead. While retrying,
// a hidden
loads via ref (no re-renders) and the spinner stays stable.
diff --git a/frontend/libs/components/generation-list/src/lib/gallery-view-store.ts b/frontend/libs/components/generation-list/src/lib/gallery-view-store.ts
index ae8cfc5c4b..b8191cdd39 100644
--- a/frontend/libs/components/generation-list/src/lib/gallery-view-store.ts
+++ b/frontend/libs/components/generation-list/src/lib/gallery-view-store.ts
@@ -10,6 +10,10 @@ export type GalleryViewMode = "grid" | "list";
interface GalleryViewState {
viewMode: GalleryViewMode;
setViewMode: (mode: GalleryViewMode) => void;
+ // Whether video cards play their animated previews. When off, they show the
+ // still first-frame thumbnail instead (toggled from the video page TopBar).
+ autoplayVideos: boolean;
+ setAutoplayVideos: (autoplay: boolean) => void;
}
export const useGalleryViewStore = create()(
@@ -17,6 +21,8 @@ export const useGalleryViewStore = create()(
(set) => ({
viewMode: "grid",
setViewMode: (viewMode) => set({ viewMode }),
+ autoplayVideos: true,
+ setAutoplayVideos: (autoplayVideos) => set({ autoplayVideos }),
}),
{ name: "artcraft-gallery-view" },
),
diff --git a/frontend/libs/components/generation-list/src/lib/types.ts b/frontend/libs/components/generation-list/src/lib/types.ts
index 893b161fae..dea2117e0f 100644
--- a/frontend/libs/components/generation-list/src/lib/types.ts
+++ b/frontend/libs/components/generation-list/src/lib/types.ts
@@ -42,6 +42,9 @@ export interface GalleryItem {
id: string;
label: string;
thumbnail: string | null;
+ // Still first-frame thumbnail for videos, shown when the user turns off
+ // animated previews (thumbnail holds the animated one).
+ stillThumbnail?: string | null;
fullImage: string | null;
createdAt: string;
mediaClass: string;
diff --git a/frontend/libs/components/generation-list/src/lib/useGalleryData.ts b/frontend/libs/components/generation-list/src/lib/useGalleryData.ts
index 7f2d797056..ce0e2d6e60 100644
--- a/frontend/libs/components/generation-list/src/lib/useGalleryData.ts
+++ b/frontend/libs/components/generation-list/src/lib/useGalleryData.ts
@@ -4,7 +4,11 @@ import {
FilterMediaClasses,
FilterMediaType,
} from "@storyteller/api";
-import { getMediaThumbnail, THUMBNAIL_SIZES } from "@storyteller/common";
+import {
+ getMediaStillThumbnail,
+ getMediaThumbnail,
+ THUMBNAIL_SIZES,
+} from "@storyteller/common";
import type { GalleryItem } from "./types";
import { is3DMediaClass } from "./types";
@@ -83,6 +87,12 @@ export function useGalleryData(options: {
id: item.token,
label: getLabel(item),
thumbnail,
+ stillThumbnail:
+ item.media_class === "video"
+ ? getMediaStillThumbnail(item.media_links, {
+ size: THUMBNAIL_SIZES.LARGE,
+ })
+ : null,
fullImage: item.media_links?.cdn_url || null,
createdAt: item.created_at,
mediaClass: item.media_class || "image",
diff --git a/frontend/libs/components/generation-list/src/lib/useGenerationJobs.ts b/frontend/libs/components/generation-list/src/lib/useGenerationJobs.ts
index 0e893dbbf0..f9fabc9c21 100644
--- a/frontend/libs/components/generation-list/src/lib/useGenerationJobs.ts
+++ b/frontend/libs/components/generation-list/src/lib/useGenerationJobs.ts
@@ -1,7 +1,11 @@
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import { JobsApi, JobStatus, MediaFilesApi } from "@storyteller/api";
import type { Job, Prompts } from "@storyteller/api";
-import { getMediaThumbnail, THUMBNAIL_SIZES } from "@storyteller/common";
+import {
+ getMediaStillThumbnail,
+ getMediaThumbnail,
+ THUMBNAIL_SIZES,
+} from "@storyteller/common";
import {
getModelDisplayName,
getProviderDisplayName,
@@ -252,6 +256,12 @@ function jobToGalleryItem(
id: result.entity_token,
label: getPrompt(job, promptsMap) || "Generation",
thumbnail,
+ stillThumbnail:
+ mediaClass === "video"
+ ? getMediaStillThumbnail(result.media_links, {
+ size: THUMBNAIL_SIZES.LARGE,
+ })
+ : null,
fullImage: result.media_links?.cdn_url || null,
// Sort by job creation time (not completion time) so the completed card
// occupies the same Masonry slot the pending card held — no layout shift.
@@ -294,6 +304,12 @@ async function expandBatchItems(
id: file.token,
label: item.label,
thumbnail,
+ stillThumbnail:
+ item.mediaClass === "video"
+ ? getMediaStillThumbnail(file.media_links, {
+ size: THUMBNAIL_SIZES.LARGE,
+ })
+ : null,
fullImage: cdnUrl,
createdAt: item.createdAt,
mediaClass: item.mediaClass,