Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions browser_tests/fixtures/ComfyPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ class ComfyPropertiesPanel {

class ComfyMenu {
private _appsTab: SidebarTab | null = null
private _jobHistoryTab: SidebarTab | null = null
private _assetsTab: AssetsSidebarTab | null = null
private _modelLibraryTab: ModelLibrarySidebarTab | null = null
private _nodeLibraryTab: NodeLibrarySidebarTab | null = null
Expand Down Expand Up @@ -142,6 +143,11 @@ class ComfyMenu {
return this._appsTab
}

get jobHistoryTab() {
this._jobHistoryTab ??= new SidebarTab(this.page, 'job-history')
return this._jobHistoryTab
}
Comment on lines +146 to +149

Copy link
Copy Markdown
Contributor

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-99 still opens this same tab through its own openJobHistorySidebar, 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 to comfyPage.menu.jobHistoryTab.open() and keeping its await expect(jobHistorySidebar(comfyPage)).toBeVisible() line, since SidebarTab.open() doesn't wait for the panel, leaves one path. Prose because the change is in another file.

Copy link
Copy Markdown

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.ts switches to the getter there; that change is ready.


get assetsTab() {
this._assetsTab ??= new AssetsSidebarTab(this.page)
return this._assetsTab
Expand Down
20 changes: 20 additions & 0 deletions browser_tests/fixtures/components/HdrViewerDialog.ts
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()
}
}
79 changes: 79 additions & 0 deletions browser_tests/tests/sidebar/hdrOutputViewer.spec.ts
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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The 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 mockViewFiles to enforce type/subfolder when they are provided.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do in the follow-up: mockViewFiles enforcing type/subfolder is ready.

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()
})
})
})
30 changes: 30 additions & 0 deletions src/components/sidebar/tabs/AssetsSidebarTab.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This becomes a change detector against the planned migration to assets/<id>/content, but I'll allow it.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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]
Expand Down
14 changes: 12 additions & 2 deletions src/components/sidebar/tabs/AssetsSidebarTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -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),
Comment thread
DrJKL marked this conversation as resolved.
Resolved
Comment on lines +549 to +551

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather we make .exr/.hdr a previewableMediaType.

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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, as a separate follow-up PR (no backport).

command: () => handleZoomClick(asset)
},
{
Expand Down Expand Up @@ -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
Expand Down
22 changes: 22 additions & 0 deletions src/composables/node/useNodeDragAndDrop.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,28 @@ describe('useNodeDragAndDrop', () => {
expect(onDrop).toHaveBeenCalledWith([keep])
})

it('onDragDrop passes an untyped HDR file to an image filter as an image', async () => {
const onDrop = vi.fn().mockResolvedValue([])
const node = createNode()

useNodeDragAndDrop(node, {
onDrop,
fileFilter: (file) => file.type.startsWith('image/')
})

const result = await node.onDragDrop?.(
createDragEvent({
files: [createFile('sky.exr', '')],
items: [{ kind: 'file' }]
})
)

expect(result).toBe(true)
expect(onDrop).toHaveBeenCalledWith([
expect.objectContaining({ name: 'sky.exr', type: 'image/x-exr' })
])
})

it('onDragDrop returns false for invalid drops', async () => {
const onDrop = vi.fn().mockResolvedValue([])
const node = createNode()
Expand Down
3 changes: 2 additions & 1 deletion src/composables/node/useNodeDragAndDrop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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[]>
Expand Down Expand Up @@ -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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3 question: OS drops get retyped here and in extractFilesFromDragEvent. The same untyped .exr pasted onto a LoadImage node (useNodePaste.ts:24), picked through the node's file input (useNodeFileInput.ts:30-31), or pasted on the canvas (usePaste.ts:36) still has type === ''. useNodeImageUpload.ts:146-166 feeds the same hasImageType filter to all three, so dropping the file onto the node uploads it while pasting the same file is rejected. Retyping once where those paths meet (for example an extension fallback in hasImageType) would cover them all. The description scopes this to drops, so this is your call. Prose because it spans files.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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 hasImageType filter and would be handled there in one place.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't name this specific to hdr. It's o to have a generic function that extends missing drag/drop data, but we want to avoid the number of hdr specific exceptions

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will rename to a generic withInferredFileType in the follow-up.

const [files, rejectedFiles] = partition(droppedFiles, fileFilter)
const rejectedFilesClaimed = handleRejectedFiles(rejectedFiles)
if (files.length) {
Expand Down
75 changes: 75 additions & 0 deletions src/composables/queue/useResultGallery.test.ts
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'
Expand Down Expand Up @@ -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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The 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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed; I'll trim this test in the follow-up.

})
19 changes: 13 additions & 6 deletions src/composables/queue/useResultGallery.ts
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'

Expand All @@ -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

View workflow job for this annotation

GitHub Actions / fallow / fallow

High CRAP score (moderate)

Function 'onViewItem' has a CRAP score of 43.1 (threshold: 30). • Severity: moderate • Cyclomatic: 12 • Cognitive: 9 • CRAP: 43.1 (threshold: 30) • Lines: 31 CRAP combines complexity with coverage: high CRAP means changes here carry high risk. Consider adding tests, simplifying the function, or both.
const tasks = getFilteredTasks()
if (!tasks.length) return

Expand All @@ -25,15 +27,20 @@
// Request was superseded by a newer one
if (targetOutputs === null && targetTask) return

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Low — The stale-request guard only fires when getOutputsForTask returns null. Its failure branch returns the task's preview outputs without checking the latest request id. So if a slow full-outputs load for an image job fails after the user has opened an HDR job, the old call fills galleryItems and opens the lightbox over the HDR viewer. The new race test only covers the success path; add a rejection case and re-check request identity after the await.

Raised by 2 of 6 reviewers (claude-opus-5-5-xhigh adversarial, gpt-5.6-sol-xhigh adversarial).

Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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 getOutputsForTask (jobOutputCache.ts), which this PR doesn't change. The same race exists between two image jobs on main. Fixing it means changing the cache's contract for every caller.


// 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)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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 (queueStore.ts:83-90), so a job that saves a PNG and then an EXR opens only the EXR, and its PNG is unreachable from View or double-click. The test "opens the HDR viewer for a job whose cover is HDR, even with image outputs" pins that. Is that the intended behavior, or should a job with non-HDR outputs still open the gallery on those? Either way, the first Known limitations bullet only mentions jobs with several HDR outputs, so it understates this. Something like: "A job whose cover output is HDR opens only that file in the HDR viewer; its other outputs aren't reachable from the queue." This needs your product call, so it's prose.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Low — The HDR early return opens the HDR viewer but leaves galleryItems and galleryActiveIndex as they were. If a gallery from an earlier job is still populated or active, the two viewers are no longer mutually exclusive and the lightbox can stay mounted behind the HDR dialog with the previous job's images. Reset both refs before calling openHdrViewer.

Raised by 3 of 6 reviewers (kimi-k3-high adversarial, gpt-5.6-sol-xhigh edge-case, kimi-k3-high edge-case).

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rejected: the lightbox is only visible while galleryActiveIndex isn't -1, and it sets it back to -1 on close. It's an aria-modal overlay, so a job can't be selected while it's open, and an HDR selection always starts with it closed. The leftover items are never displayed.

return
Comment thread
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
Expand Down
Loading
Loading