Repository navigation
Minimal exr preview support. #20740
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Minimal exr preview support. #20740
Changes from all commits
eec107c
5152046
1dcd64f
3774267
c4fac5d
1b83eaa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,7 +2,7 @@ | |||||||||||||||||||||||||||||||||
| <div | ||||||||||||||||||||||||||||||||||
| class="relative flex items-center gap-2 overflow-hidden rounded-lg p-2 select-none" | ||||||||||||||||||||||||||||||||||
| :aria-describedby=" | ||||||||||||||||||||||||||||||||||
| videoStatus === 'failed' ? videoFailedDescriptionId : undefined | ||||||||||||||||||||||||||||||||||
|
Check failure on line 5 in src/platform/assets/components/AssetsListItem.vue
|
||||||||||||||||||||||||||||||||||
| " | ||||||||||||||||||||||||||||||||||
| > | ||||||||||||||||||||||||||||||||||
| <div | ||||||||||||||||||||||||||||||||||
|
|
@@ -61,11 +61,17 @@ | |||||||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||||||||
| </template> | ||||||||||||||||||||||||||||||||||
| <img | ||||||||||||||||||||||||||||||||||
| v-else | ||||||||||||||||||||||||||||||||||
| v-else-if="failedImageUrl !== previewUrl" | ||||||||||||||||||||||||||||||||||
| :src="previewUrl" | ||||||||||||||||||||||||||||||||||
| :alt="previewAlt" | ||||||||||||||||||||||||||||||||||
| class="size-full object-cover" | ||||||||||||||||||||||||||||||||||
| :draggable="false" | ||||||||||||||||||||||||||||||||||
| @error="failedImageUrl = previewUrl" | ||||||||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||||||||
| <i | ||||||||||||||||||||||||||||||||||
| v-else | ||||||||||||||||||||||||||||||||||
| aria-hidden="true" | ||||||||||||||||||||||||||||||||||
| class="absolute inset-0 m-auto icon-[lucide--image] size-4 text-text-secondary" | ||||||||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+71
to
75
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P3 (optional): The fallback always shows the image icon. The sidebar now sends previews for 3D and audio items, and job rows pass job-state icons through
Suggested change
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Very low likelihood, but agreed. Will hit in a followup PR |
||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||
| <div | ||||||||||||||||||||||||||||||||||
|
|
@@ -154,7 +160,7 @@ | |||||||||||||||||||||||||||||||||
| </template> | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| <script setup lang="ts"> | ||||||||||||||||||||||||||||||||||
| import { useId } from 'vue' | ||||||||||||||||||||||||||||||||||
| import { ref, useId } from 'vue' | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| import { useRetryableMediaSrc } from '@/composables/media/useRetryableMediaSrc' | ||||||||||||||||||||||||||||||||||
| import { useProgressBarBackground } from '@/composables/useProgressBarBackground' | ||||||||||||||||||||||||||||||||||
|
|
@@ -207,6 +213,7 @@ | |||||||||||||||||||||||||||||||||
| } = useRetryableMediaSrc(() => (isVideoPreview ? previewUrl : undefined)) | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| const videoFailedDescriptionId = useId() | ||||||||||||||||||||||||||||||||||
| const failedImageUrl = ref<string>() | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| const { | ||||||||||||||||||||||||||||||||||
| progressBarContainerClass, | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -248,6 +248,18 @@ describe('MediaAssetCard', () => { | |
| expect(emitted().zoom).toEqual([[asset]]) | ||
| }) | ||
|
|
||
| it('previews an exr asset from its preview_url', async () => { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Deja vu... |
||
| const previewUrl = '/api/assets/exr-preview/content' | ||
| renderCard({ | ||
| loading: false, | ||
| asset: { ...asset, name: 'render.exr', preview_url: previewUrl } | ||
| }) | ||
|
|
||
| expect( | ||
| await screen.findByRole('img', { name: 'render.exr' }) | ||
| ).toHaveAttribute('src', previewUrl) | ||
| }) | ||
|
|
||
| it('selects non-video assets from the preview', async () => { | ||
| const user = userEvent.setup() | ||
| const { container, emitted } = renderCard({ | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -175,6 +175,7 @@ import { | |||||||||||||||||||||||||||||
| getMediaTypeFromFilename, | ||||||||||||||||||||||||||||||
| isPreviewableMediaType | ||||||||||||||||||||||||||||||
| } from '@/utils/formatUtil' | ||||||||||||||||||||||||||||||
| import { isHdrImageFilename } from '@/utils/hdrFormatUtil' | ||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2 (optional): Import for the
Suggested change
|
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| import { getAssetType } from '../composables/media/assetMappers' | ||||||||||||||||||||||||||||||
| import { startAssetDrag } from '../utils/assetDragUtil' | ||||||||||||||||||||||||||||||
|
|
@@ -255,6 +256,7 @@ const fileKind = computed((): MediaKind => { | |||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| const previewKind = computed((): PreviewKind => { | ||||||||||||||||||||||||||||||
| if (asset?.preview_url && isHdrImageFilename(asset.name)) return 'image' | ||||||||||||||||||||||||||||||
| return getMediaTypeFromFilename(asset?.name || '') | ||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||
|
Comment on lines
258
to
261
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2 (optional): History-backed assets always have a
Suggested change
|
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -11,7 +11,8 @@ export const zResultItem = z.object({ | |||||||||||
| subfolder: z.string().optional(), | ||||||||||||
| type: resultItemType.optional(), | ||||||||||||
| display_name: z.string().optional(), | ||||||||||||
| id: z.string().optional() | ||||||||||||
| id: z.string().optional(), | ||||||||||||
| preview_id: z.string().optional() | ||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P3 (optional), question:
Suggested change
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've been conferring with Simon on the backend. And I believe there'es guarantee that the value will always be present and set to the real asset id when no preview has been assigned. The premise, however, is good. Will be certain to make use of it in the future. |
||||||||||||
| }) | ||||||||||||
| export type ResultItem = z.infer<typeof zResultItem> | ||||||||||||
| // Uses .passthrough() because custom nodes can output arbitrary keys. | ||||||||||||
|
|
||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -26,14 +26,22 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @click="handleGridClick(index)" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| > | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <img | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| v-if="!isHdrImageUrl(imageUrls[index])" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| :src="url" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| :alt="`${$t('g.galleryThumbnail')} ${index + 1}`" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| draggable="false" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| class="pointer-events-none size-full object-contain" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @load="updateAspectRatio($event, index)" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| v-if="!isHdrPlaceholder(imageUrls[index])" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2 (optional): Part of the computed change on lines 309-318.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| class="pointer-events-none relative size-full" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| > | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <img | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| :src="url" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| :alt="`${$t('g.galleryThumbnail')} ${index + 1}`" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| draggable="false" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| class="size-full object-contain" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @load="updateAspectRatio($event, index)" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <i | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| v-if="isHdrImageUrl(imageUrls[index])" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| class="absolute top-1 left-1 icon-[lucide--sun] size-4 text-base-foreground drop-shadow-sm" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+40
to
+43
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2 (optional): Part of the computed change on lines 309-318. Inside the non-placeholder branch, an HDR URL always has a preview, so
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| v-else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| class="flex size-full flex-col items-center justify-center gap-1 text-base-foreground" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -84,13 +92,13 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <!-- Loading State --> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| v-if="showLoader && !imageError && !currentImageIsHdr" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| v-if="showLoader && !imageError && !isHdrPlaceholder(currentImageUrl)" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2 (optional): Part of the computed change on lines 309-318.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| class="size-full" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| > | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Skeleton class="size-full rounded-sm" /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <button | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| v-if="!imageError && currentImageIsHdr" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| v-if="!imageError && isHdrPlaceholder(currentImageUrl)" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2 (optional): Part of the computed change on lines 309-318.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type="button" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| data-testid="hdr-open-button" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| class="absolute inset-0 flex cursor-pointer flex-col items-center justify-center gap-3 border-0 bg-transparent text-base-foreground" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -106,9 +114,9 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </button> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <!-- Main Image --> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <img | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| v-if="!imageError && !currentImageIsHdr" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| v-if="!imageError && !isHdrPlaceholder(currentImageUrl)" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2 (optional): Part of the computed change on lines 309-318.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| data-testid="main-image" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| :src="currentImageUrl" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| :src="currentHdrPreviewUrl ?? currentImageUrl" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2 (optional): Rendering the preview here means if (nodeId && !currentHdrPreviewUrl.value) {
nodeOutputStore.syncLegacyNodeImgs(nodeId, img, currentIndex.value)
} |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| :alt="imageAltText" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| draggable="false" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| class="pointer-events-none absolute inset-0 block size-full object-contain" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -131,6 +139,16 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <i-comfy:mask class="size-4" /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </button> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <button | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
DrJKL marked this conversation as resolved.
Resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| v-if="!imageError && currentHdrPreviewUrl" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2 (optional): When the preview fails to load (the cloud workspace case from the description, or a preview removed by ComfyUI#16898's reclaim cascade),
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| :class="actionButtonClass" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| :title="$t('hdrViewer.openInHdrViewer')" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| :aria-label="$t('hdrViewer.openInHdrViewer')" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @click="openHdrViewer(currentImageUrl)" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| > | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <i class="icon-[lucide--sun] size-4" /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </button> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <!-- Layer Editor Button --> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <button | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| v-if="hasMultipleImages && !imageError" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -168,7 +186,7 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <!-- Image Dimensions (gallery mode only) --> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| v-if="viewMode === 'gallery' && !currentImageIsHdr" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| v-if="viewMode === 'gallery' && !isHdrPlaceholder(currentImageUrl)" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2 (optional): Part of the computed change on lines 309-318.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| class="pt-2 text-center text-xs text-base-foreground" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| > | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <span | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -235,7 +253,7 @@ import { useToast } from '@/components/ui/toast/toastStore' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { openHdrViewer } from '@/services/hdrViewerService' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { useNodeOutputStore } from '@/stores/nodeOutputStore' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import type { NodeId } from '@/types/nodeId' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { isHdrImageUrl } from '@/utils/hdrFormatUtil' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { getHdrPreviewUrl, isHdrImageUrl } from '@/utils/hdrFormatUtil' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { getGridThumbnailUrl } from '@/utils/imageUtil' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { resolveNode } from '@/utils/litegraphUtil' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { cn } from '@comfyorg/tailwind-utils' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -288,8 +306,16 @@ const { start: startDelayedLoader, stop: stopDelayedLoader } = useTimeoutFn( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const currentImageUrl = computed(() => imageUrls[currentIndex.value] ?? '') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const isHdrPlaceholder = (url: string | undefined) => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can this not also be a computed? |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| isHdrImageUrl(url) && !getHdrPreviewUrl(url) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const currentImageIsHdr = computed(() => isHdrImageUrl(currentImageUrl.value)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const gridImageUrls = computed(() => imageUrls.map(getGridThumbnailUrl)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const currentHdrPreviewUrl = computed(() => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| getHdrPreviewUrl(currentImageUrl.value) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const gridImageUrls = computed(() => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| imageUrls.map((url) => getHdrPreviewUrl(url) ?? getGridThumbnailUrl(url)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+309
to
+318
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2 (optional): Following up on the computed question at line 309: the HDR state is derived by function calls spread across the template (
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const hasMultipleImages = computed(() => imageUrls.length > 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const canExportOutputs = computed(() => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const node = nodeId ? resolveNode(nodeId) : undefined | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -421,7 +447,7 @@ async function openImageInGallery(index: number) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| function handleGridClick(index: number) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const url = imageUrls[index] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (isHdrImageUrl(url)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (isHdrPlaceholder(url)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2 (optional): Part of the computed change on lines 309-318.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| openHdrViewer(url) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,6 +1,7 @@ | ||||||||||||||||||
| import { describe, expect, it } from 'vitest' | ||||||||||||||||||
|
|
||||||||||||||||||
| import { | ||||||||||||||||||
| getHdrPreviewUrl, | ||||||||||||||||||
| getImageFilenameFromUrl, | ||||||||||||||||||
| isHdrImageFilename, | ||||||||||||||||||
| isHdrImageUrl, | ||||||||||||||||||
|
|
@@ -55,6 +56,24 @@ describe('isHdrImageUrl', () => { | |||||||||||||||||
| }) | ||||||||||||||||||
| }) | ||||||||||||||||||
|
|
||||||||||||||||||
| describe('getHdrPreviewUrl', () => { | ||||||||||||||||||
| it.for([ | ||||||||||||||||||
| { | ||||||||||||||||||
| url: '/api/view?filename=scene.exr&preview_id=p1', | ||||||||||||||||||
| expected: '/api/assets/p1/content?disposition=inline' | ||||||||||||||||||
| }, | ||||||||||||||||||
| { | ||||||||||||||||||
| url: '/api/view?filename=scene.HDR&preview_id=p1', | ||||||||||||||||||
| expected: '/api/assets/p1/content?disposition=inline' | ||||||||||||||||||
| }, | ||||||||||||||||||
|
Comment on lines
+65
to
+68
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P3 (optional): Every input that reaches the asset URL uses the id
Suggested change
|
||||||||||||||||||
| { url: '/api/view?filename=scene.exr', expected: undefined }, | ||||||||||||||||||
| { url: '/api/view?filename=scene.png&preview_id=p1', expected: undefined }, | ||||||||||||||||||
| { url: undefined, expected: undefined } | ||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P3 (optional): The
Suggested change
|
||||||||||||||||||
| ])('maps $url to $expected', ({ url, expected }) => { | ||||||||||||||||||
| expect(getHdrPreviewUrl(url)).toBe(expected) | ||||||||||||||||||
| }) | ||||||||||||||||||
| }) | ||||||||||||||||||
|
|
||||||||||||||||||
| describe('toFullResolutionUrl', () => { | ||||||||||||||||||
| it('strips the preview parameter', () => { | ||||||||||||||||||
| expect( | ||||||||||||||||||
|
|
||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,3 +1,5 @@ | ||||||||||||||||||||||||||||
| import { api } from '@/scripts/api' | ||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2 (optional): Import for the delegation in
Suggested change
|
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| const HDR_EXTENSIONS = ['.exr', '.hdr'] as const | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| export function isHdrImageFilename(filename: string | undefined): boolean { | ||||||||||||||||||||||||||||
|
|
@@ -25,6 +27,18 @@ export function isHdrImageUrl(url: string | undefined): boolean { | |||||||||||||||||||||||||||
| return isHdrImageFilename(getImageFilenameFromUrl(url)) | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| export function getHdrPreviewUrl(url: string | undefined): string | undefined { | ||||||||||||||||||||||||||||
| const previewId = | ||||||||||||||||||||||||||||
| url && | ||||||||||||||||||||||||||||
| isHdrImageUrl(url) && | ||||||||||||||||||||||||||||
| new URL(url, window.location.origin).searchParams.get('preview_id') | ||||||||||||||||||||||||||||
| return previewId ? hdrPreviewAssetUrl(previewId) : undefined | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
AustinMroz marked this conversation as resolved.
Resolved
Comment on lines
+30
to
+36
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2 (optional):
Suggested change
|
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| export function hdrPreviewAssetUrl(previewId: string): string { | ||||||||||||||||||||||||||||
| return api.apiURL(`/assets/${previewId}/content?disposition=inline`) | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
Comment on lines
+37
to
+40
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2 (optional): Unused after the delegation on lines 30-36.
Suggested change
|
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| export function toFullResolutionUrl(url: string): string { | ||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||
| const parsed = new URL(url, window.location.origin) | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,43 @@ | ||||||||||||
| import { describe, expect, it } from 'vitest' | ||||||||||||
|
|
||||||||||||
| import type { AugmentedResultItem } from '@/utils/resultItem' | ||||||||||||
| import { resultItemPreviewUrl } from '@/utils/resultItemUrl' | ||||||||||||
|
|
||||||||||||
| function resultItem( | ||||||||||||
| overrides: Partial<AugmentedResultItem> | ||||||||||||
| ): AugmentedResultItem { | ||||||||||||
| return { | ||||||||||||
| filename: 'out.png', | ||||||||||||
| subfolder: '', | ||||||||||||
| type: 'output', | ||||||||||||
| nodeId: '3', | ||||||||||||
| mediaType: 'images', | ||||||||||||
| ...overrides | ||||||||||||
| } | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| describe('resultItemPreviewUrl', () => { | ||||||||||||
| it.for([ | ||||||||||||
| { | ||||||||||||
| filename: 'render.exr', | ||||||||||||
| preview_id: 'p1', | ||||||||||||
| pathname: '/api/assets/p1/content' | ||||||||||||
| }, | ||||||||||||
| { | ||||||||||||
| filename: 'render.HDR', | ||||||||||||
| preview_id: 'p1', | ||||||||||||
| pathname: '/api/assets/p1/content' | ||||||||||||
| }, | ||||||||||||
|
Comment on lines
+26
to
+30
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P3 (optional):
Suggested change
|
||||||||||||
| { filename: 'render.exr', preview_id: undefined, pathname: '/api/view' }, | ||||||||||||
| { filename: 'render.png', preview_id: 'p1', pathname: '/api/view' } | ||||||||||||
| ])( | ||||||||||||
| 'resolves $filename with preview_id $preview_id to $pathname', | ||||||||||||
| ({ filename, preview_id, pathname }) => { | ||||||||||||
| const url = new URL( | ||||||||||||
| resultItemPreviewUrl(resultItem({ filename, preview_id })), | ||||||||||||
| window.location.origin | ||||||||||||
| ) | ||||||||||||
| expect(url.pathname).toBe(pathname) | ||||||||||||
| } | ||||||||||||
| ) | ||||||||||||
| }) | ||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P3 (optional):
failedImageUrllatches the first URL that fails and never retries it. A transient error, or a preview that isn't readable yet right after a job completes, leaves the row on the fallback icon until the URL changes or the row remounts. The video branch handles the same case withuseRetryableMediaSrc(line 213), andMediaImageTop.vueusesuseImageQuiet, so this component now has two failure models for one prop. Passing images throughuseRetryableMediaSrc(() => previewUrl)as well would leave one. Prose because whether image previews should retry is your call.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not terribly concerned given that the fallback image icon is rather graceful already and this is a preview in one of the many view areas.
Will plan to remove this section entirely when there's not risk of fallback to unsupported endpoints on the backend.