Repository navigation
fix: open EXR/HDR outputs in the HDR viewer and type untyped HDR drops #20839
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
Changes from all commits
bca0b1b
cdc9b53
d543672
d8414b0
fe89e8b
2e55427
c82b9d3
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 |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| import { expect } from '@playwright/test' | ||
| import type { Locator, Page } from '@playwright/test' | ||
|
|
||
| import { BaseDialog } from '@e2e/fixtures/components/BaseDialog' | ||
|
|
||
| export class HdrViewerDialog extends BaseDialog { | ||
| readonly resolution: Locator | ||
| readonly loadError: Locator | ||
|
|
||
| constructor(page: Page, filename: string) { | ||
| super(page, page.getByRole('dialog').filter({ hasText: filename })) | ||
| this.resolution = this.root.getByText('Resolution', { exact: true }) | ||
| this.loadError = this.root.getByRole('alert') | ||
| } | ||
|
|
||
| async expectDecoded() { | ||
| await expect(this.resolution).toBeVisible() | ||
| await expect(this.loadError).toBeHidden() | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| import { expect, mergeTests } from '@playwright/test' | ||
|
|
||
| import { comfyPageFixture } from '@e2e/fixtures/ComfyPage' | ||
| import { | ||
| createRouteMockJob, | ||
| jobsRouteFixture, | ||
| routeMockJobTimestamp | ||
| } from '@e2e/fixtures/jobsRouteFixture' | ||
| import { HdrViewerDialog } from '@e2e/fixtures/components/HdrViewerDialog' | ||
| import { mockViewFiles } from '@e2e/fixtures/utils/viewFileMocks' | ||
|
|
||
| const hdrJob = createRouteMockJob({ | ||
| id: 'hdr-job', | ||
| create_time: routeMockJobTimestamp - 1_000, | ||
| execution_start_time: routeMockJobTimestamp - 1_000, | ||
| execution_end_time: routeMockJobTimestamp, | ||
| preview_output: { | ||
| filename: 'sky.exr', | ||
| subfolder: 'renders', | ||
| type: 'output', | ||
| nodeId: '1', | ||
| mediaType: 'images' | ||
| } | ||
| }) | ||
|
|
||
| const test = mergeTests(comfyPageFixture, jobsRouteFixture).extend<{ | ||
| mockHdrJob: void | ||
| }>({ | ||
| mockHdrJob: [ | ||
| async ({ jobsRoutes, page }, use) => { | ||
| await jobsRoutes.mockJobsScenario({ history: [hdrJob], queue: [] }) | ||
| await jobsRoutes.mockJobsHistory([hdrJob]) | ||
| await mockViewFiles(page, { | ||
| 'sky.exr': { | ||
| path: 'browser_tests/assets/test_upload_image.exr', | ||
| contentType: 'image/x-exr' | ||
| } | ||
| }) | ||
| await page.route('**/api/view**', async (route) => { | ||
|
Comment on lines
+33
to
+39
Collaborator
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. The doubled route mock is real ugly. I'd rather you extend the existing 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. Will do in the follow-up: |
||
| const url = new URL(route.request().url()) | ||
| const wrongLocation = | ||
| url.searchParams.get('filename') === 'sky.exr' && | ||
| (url.searchParams.get('type') !== 'output' || | ||
| url.searchParams.get('subfolder') !== 'renders') | ||
| await (wrongLocation | ||
| ? route.fulfill({ status: 404 }) | ||
| : route.fallback()) | ||
| }) | ||
| await use() | ||
| }, | ||
| { auto: true } | ||
| ] | ||
| }) | ||
|
|
||
| test.describe('HDR outputs open in the HDR viewer', { tag: '@ui' }, () => { | ||
| test.describe('from job history', () => { | ||
| test.use({ initialSettings: { 'Comfy.Queue.QPOV2': true } }) | ||
|
|
||
| test('opens the job output instead of the image lightbox', async ({ | ||
| comfyPage | ||
| }) => { | ||
| await comfyPage.menu.jobHistoryTab.open() | ||
| await comfyPage.queuePanel.jobRow('hdr-job').dblclick() | ||
| await new HdrViewerDialog(comfyPage.page, 'sky.exr').expectDecoded() | ||
| await expect(comfyPage.page.getByRole('dialog')).toHaveCount(1) | ||
| }) | ||
| }) | ||
|
|
||
| test.describe('from the assets sidebar', () => { | ||
| test('opens a generated HDR card on double click', async ({ | ||
| comfyPage | ||
| }) => { | ||
| const tab = comfyPage.menu.assetsTab | ||
| await tab.open() | ||
| await tab.getAssetCardByName('sky').dblclick() | ||
| await new HdrViewerDialog(comfyPage.page, 'sky.exr').expectDecoded() | ||
| }) | ||
| }) | ||
| }) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ import { createI18n } from 'vue-i18n' | |
|
|
||
| import { useMediaAssetActions } from '@/platform/assets/composables/useMediaAssetActions' | ||
| import { resolveOutputAssetItems } from '@/platform/assets/utils/outputAssetUtil' | ||
| import { openHdrViewer } from '@/services/hdrViewerService' | ||
| import { useAssetsStore } from '@/stores/assetsStore' | ||
|
|
||
| import AssetsSidebarTab from './AssetsSidebarTab.vue' | ||
|
|
@@ -82,6 +83,8 @@ vi.mock(import('@/platform/assets/composables/useMediaAssetActions')) | |
|
|
||
| vi.mock(import('@/platform/assets/utils/outputAssetUtil')) | ||
|
|
||
| vi.mock(import('@/services/hdrViewerService')) | ||
|
|
||
| const i18n = createI18n({ | ||
| legacy: false, | ||
| locale: 'en', | ||
|
|
@@ -197,6 +200,33 @@ it('shows the sidebar close button when mounted as a sidebar tab', () => { | |
| }) | ||
|
|
||
| describe('AssetsSidebarTab context menu', () => { | ||
| it('inspects an HDR output in the HDR viewer', async () => { | ||
| useAssetsStore().outputAssets.items = [ | ||
| { | ||
| ...folderAsset, | ||
| name: 'sky.exr', | ||
| loader_path: 'renders/sky.exr', | ||
| preview_url: '/api/assets/sky-preview/content' | ||
| } | ||
| ] | ||
| renderTab() | ||
|
|
||
| await fireEvent.contextMenu( | ||
| screen.getByRole('button', { name: 'Enter output folder' }) | ||
| ) | ||
| await userEvent.click( | ||
| await screen.findByRole('menuitem', { | ||
| name: 'mediaAsset.actions.inspect' | ||
| }) | ||
| ) | ||
|
|
||
| expect(openHdrViewer).toHaveBeenCalledWith( | ||
| expect.stringMatching( | ||
| /\/view\?filename=sky\.exr&type=output&subfolder=renders$/ | ||
| ) | ||
|
Comment on lines
+224
to
+226
Collaborator
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. This becomes a change detector against the planned migration to 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. Noted; it moves with the by-id content migration. |
||
| ) | ||
| }) | ||
|
|
||
| it('inserts a loadable image as a node', async () => { | ||
| const asset = { ...folderAsset, name: 'image.png' } | ||
| useAssetsStore().outputAssets.items = [asset] | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -210,18 +210,21 @@ import type { AssetItem } from '@/platform/assets/schemas/assetSchema' | |
| import { getAssetDisplayName } from '@/platform/assets/utils/assetMetadataUtils' | ||
| import { | ||
| getAssetFileUrl, | ||
| getAssetSubfolder | ||
| getAssetSubfolder, | ||
| getAssetViewUrl | ||
| } from '@/platform/assets/utils/assetUrlUtil' | ||
| import { resolveOutputAssetItems } from '@/platform/assets/utils/outputAssetUtil' | ||
| import { isCloud } from '@/platform/distribution/types' | ||
| import { supportsWorkflowMetadata } from '@/platform/workflow/utils/workflowExtractionUtil' | ||
| import { openHdrViewer } from '@/services/hdrViewerService' | ||
| import { useAssetsStore } from '@/stores/assetsStore' | ||
| import { useDialogStore } from '@/stores/dialogStore' | ||
| import { | ||
| formatDuration, | ||
| getMediaTypeFromFilename, | ||
| isPreviewableMediaType | ||
| } from '@/utils/formatUtil' | ||
| import { isHdrImageFilename } from '@/utils/hdrFormatUtil' | ||
| import { detectNodeTypeFromFilename } from '@/utils/loaderNodeUtil' | ||
| import type { AugmentedResultItem } from '@/utils/resultItem' | ||
|
|
||
|
|
@@ -543,7 +546,9 @@ function handleAssetContextMenu(event: MouseEvent, asset: AssetItem) { | |
| { | ||
| label: t('mediaAsset.actions.inspect'), | ||
| icon: 'icon-[lucide--zoom-in]', | ||
| visible: isPreviewableMediaType(getMediaTypeFromFilename(asset.name)), | ||
| visible: | ||
| isPreviewableMediaType(getMediaTypeFromFilename(asset.name)) || | ||
| isHdrImageFilename(asset.name), | ||
|
DrJKL marked this conversation as resolved.
Resolved
Comment on lines
+549
to
+551
Collaborator
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'd rather we make From my personal inspection, this seems like it would be fairly involved and would be better handled as an isolated folllowup PR (which would not need backport) 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. Agreed, as a separate follow-up PR (no backport). |
||
| command: () => handleZoomClick(asset) | ||
| }, | ||
| { | ||
|
|
@@ -618,6 +623,11 @@ const handleBulkExportWorkflow = async (assets: AssetItem[]) => { | |
| } | ||
|
|
||
| const handleZoomClick = (asset: AssetItem) => { | ||
| if (isHdrImageFilename(asset.name)) { | ||
| openHdrViewer(getAssetViewUrl(asset)) | ||
| return | ||
| } | ||
|
|
||
| const mediaType = getMediaTypeFromFilename(asset.name) | ||
| if (!isPreviewableMediaType(mediaType)) { | ||
| return | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ import { partition } from 'es-toolkit' | |
| import type { LGraphNode } from '@/lib/litegraph/src/litegraph' | ||
| import { parseAssetInfo } from '@/platform/assets/schemas/mediaAssetSchema' | ||
| import type { ResultItem } from '@/platform/remote/comfyui/execution/types' | ||
| import { withHdrImageType } from '@/utils/eventUtils' | ||
|
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. The fact that this needs to get wired through a general utility is a pretty big smell. 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. Noted for the follow-up. |
||
|
|
||
| type DragHandler = (e: DragEvent) => boolean | ||
| type DropHandler<T> = (files: File[]) => Promise<T[]> | ||
|
|
@@ -51,7 +52,7 @@ export const useNodeDragAndDrop = <T>( | |
| const { dataTransfer } = e | ||
| if (!dataTransfer) return false | ||
|
|
||
| const droppedFiles = Array.from(dataTransfer.files) | ||
| const droppedFiles = Array.from(dataTransfer.files, withHdrImageType) | ||
|
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 question: OS drops get retyped here and in 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. Tracked with the fetched-drop follow-up: this PR covers OS drops. Paste and the file input reach the same
Collaborator
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. Don't name this specific to 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. Will rename to a generic |
||
| const [files, rejectedFiles] = partition(droppedFiles, fileFilter) | ||
| const rejectedFilesClaimed = handleRejectedFiles(rejectedFiles) | ||
| if (files.length) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,10 @@ | ||
| import { describe, expect, it, vi } from 'vitest' | ||
|
|
||
| vi.mock(import('@/platform/assets/composables/media/assetMappers')) | ||
| vi.mock(import('@/services/hdrViewerService')) | ||
|
|
||
| import { useResultGallery } from '@/composables/queue/useResultGallery' | ||
| import { openHdrViewer } from '@/services/hdrViewerService' | ||
| import type { JobListItem as JobListViewItem } from '@/composables/queue/useJobList' | ||
| import type { JobListItem } from '@/platform/remote/comfyui/jobs/jobTypes' | ||
| import { TaskItemImpl } from '@/stores/queueStore' | ||
|
|
@@ -160,4 +162,77 @@ describe('useResultGallery', () => { | |
| expect(galleryItems.value).toEqual(fullOutputs) | ||
| expect(galleryActiveIndex.value).toBe(0) | ||
| }) | ||
|
|
||
| it('opens the HDR viewer for a job whose cover is HDR, even with image outputs', async () => { | ||
| const image = createResultItem('image.png') | ||
| const exr = { | ||
| ...createResultItem('/api/view?filename=out.exr'), | ||
| filename: 'out.exr' | ||
| } | ||
| const task = createTask(exr, [image, exr]) | ||
|
|
||
| const { galleryItems, galleryActiveIndex, onViewItem } = useResultGallery( | ||
| () => [task] | ||
| ) | ||
|
|
||
| await onViewItem(createJobViewItem('job-mixed', task)) | ||
|
|
||
| expect(openHdrViewer).toHaveBeenCalledWith('/api/view?filename=out.exr') | ||
| expect(galleryItems.value).toEqual([]) | ||
| expect(galleryActiveIndex.value).toBe(-1) | ||
| }) | ||
|
|
||
| it('opens a job with an image cover in the gallery without its HDR outputs', async () => { | ||
| const image = createResultItem('image.png') | ||
| const exr = { | ||
| ...createResultItem('/api/view?filename=out.exr'), | ||
| filename: 'out.exr' | ||
| } | ||
| const task = createTask(image, [exr, image]) | ||
|
|
||
| const { galleryItems, galleryActiveIndex, onViewItem } = useResultGallery( | ||
| () => [task] | ||
| ) | ||
|
|
||
| await onViewItem(createJobViewItem('job-mixed', task)) | ||
|
|
||
| expect(galleryItems.value).toEqual([image]) | ||
| expect(galleryActiveIndex.value).toBe(0) | ||
| expect(openHdrViewer).not.toHaveBeenCalled() | ||
| }) | ||
|
|
||
| it.for(['resolves', 'rejects'])( | ||
| 'does not open a slower gallery request that %s over a later HDR selection', | ||
| async (outcome) => { | ||
| const image = createResultItem('image.png') | ||
| const exr = { | ||
| ...createResultItem('/api/view?filename=out.exr'), | ||
| filename: 'out.exr' | ||
| } | ||
| const imageJob = createMockJob('slow-image-job', 2) | ||
| const imageTask = new TaskItemImpl(imageJob, {}, [image]) | ||
| let settle!: () => void | ||
| imageTask.loadFullOutputs = () => | ||
| new Promise((resolve, reject) => { | ||
| settle = () => | ||
| outcome === 'resolves' | ||
| ? resolve(new TaskItemImpl(imageJob, {}, [image, image])) | ||
| : reject(new Error('load failed')) | ||
| }) | ||
| const hdrTask = createTask(exr) | ||
|
|
||
| const { galleryItems, galleryActiveIndex, onViewItem } = useResultGallery( | ||
| () => [imageTask, hdrTask] | ||
| ) | ||
|
|
||
| const imageView = onViewItem(createJobViewItem('job-image', imageTask)) | ||
| await onViewItem(createJobViewItem('job-hdr', hdrTask)) | ||
| settle() | ||
| await imageView | ||
|
|
||
| expect(openHdrViewer).toHaveBeenCalledOnce() | ||
| expect(galleryItems.value).toEqual([]) | ||
| expect(galleryActiveIndex.value).toBe(-1) | ||
| } | ||
| ) | ||
|
Comment on lines
+204
to
+237
Collaborator
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. This test is particularly excessive. It does not guard against an observed regression and the behavior it guards against is a minor (if that) QoL change. 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. Agreed; I'll trim this test in the follow-up. |
||
| }) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,10 @@ | ||
| import { ref, shallowRef } from 'vue' | ||
|
|
||
| import type { JobListItem } from '@/composables/queue/useJobList' | ||
| import { openHdrViewer } from '@/services/hdrViewerService' | ||
| import { findActiveIndex, getOutputsForTask } from '@/services/jobOutputCache' | ||
| import type { TaskItemImpl } from '@/stores/queueStore' | ||
| import { isHdrImageFilename } from '@/utils/hdrFormatUtil' | ||
| import type { AugmentedResultItem } from '@/utils/resultItem' | ||
| import { resultItemUrl } from '@/utils/resultItemUrl' | ||
|
|
||
|
|
@@ -13,7 +15,7 @@ | |
| const galleryActiveIndex = ref(-1) | ||
| const galleryItems = shallowRef<AugmentedResultItem[]>([]) | ||
|
|
||
| async function onViewItem(item: JobListItem) { | ||
|
Check warning on line 18 in src/composables/queue/useResultGallery.ts
|
||
| const tasks = getFilteredTasks() | ||
| if (!tasks.length) return | ||
|
|
||
|
|
@@ -25,15 +27,20 @@ | |
| // Request was superseded by a newer one | ||
| if (targetOutputs === null && targetTask) return | ||
|
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. 🟢 Low — The stale-request guard only fires when Raised by 2 of 6 reviewers (claude-opus-5-5-xhigh adversarial, gpt-5.6-sol-xhigh adversarial). 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. Rejected for this PR: the fallback on a failed full-outputs load is in |
||
|
|
||
| // Use target's outputs if available, otherwise fall back to all previews | ||
| const items = targetOutputs?.length | ||
| ? targetOutputs | ||
| : tasks.map((t) => t.previewOutput).filter((o) => !!o) | ||
|
|
||
| const previewOutput = targetTask?.previewOutput | ||
| if (previewOutput && isHdrImageFilename(previewOutput.filename)) { | ||
|
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 question: when the cover is HDR, this returns before the gallery is built, whatever else the job produced. The cover is the last previewable output ( 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. Intended: a job whose cover output is HDR opens that file in the HDR viewer. The gallery can't show HDR, and the cover is the output the job row represents. The Known limitations now say that the job's other outputs aren't reachable from the queue in that case. |
||
| openHdrViewer(resultItemUrl(previewOutput)) | ||
|
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. 🟢 Low — The HDR early return opens the HDR viewer but leaves Raised by 3 of 6 reviewers (kimi-k3-high adversarial, gpt-5.6-sol-xhigh edge-case, kimi-k3-high edge-case). 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. Rejected: the lightbox is only visible while |
||
| return | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
| } | ||
|
|
||
| const items = ( | ||
| targetOutputs?.length | ||
| ? targetOutputs | ||
| : tasks.map((t) => t.previewOutput).filter((o) => !!o) | ||
| ).filter((o) => !isHdrImageFilename(o.filename)) | ||
| if (!items.length) return | ||
|
|
||
| galleryItems.value = items | ||
| const previewOutput = item.taskRef?.previewOutput | ||
| galleryActiveIndex.value = findActiveIndex( | ||
| items, | ||
| previewOutput ? resultItemUrl(previewOutput) : undefined | ||
|
|
||
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:
jobHistory.spec.ts:93-99still opens this same tab through its ownopenJobHistorySidebar, using the raw toolbar click. That leaves two ways to open Job History, six call sites on the old one, and the selector recipe in two places. Moving that spec tocomfyPage.menu.jobHistoryTab.open()and keeping itsawait expect(jobHistorySidebar(comfyPage)).toBeVisible()line, sinceSidebarTab.open()doesn't wait for the panel, leaves one path. Prose because the change is in another file.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.
Deferred to the follow-up:
jobHistory.spec.tsswitches to the getter there; that change is ready.