Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
c87ef56
perf: show downscaled previews for large images in Vue nodes
DrJKL Nov 11, 2026
6d78e97
fix: settle image previews when downscaling cannot finish
DrJKL Nov 11, 2026
4520016
test: keep the grid node count private to its fixture
DrJKL Nov 11, 2026
5a810e8
test: move image preview pan and zoom sweeps into the grid fixture
DrJKL Nov 11, 2026
d82fe46
test: register grid upload cleanup before uploading
DrJKL Nov 11, 2026
5f37295
test: assert mask layers load the original file; move benchmark field…
DrJKL Nov 11, 2026
520f05a
fix: keep animations, live previews and Vue copy at full fidelity
DrJKL Nov 12, 2026
3419ff7
test: wait for the downscale worker reply in the preview scope test
DrJKL Nov 12, 2026
aa3f57b
fix: detect animated images from their bytes and toast Vue copy failures
DrJKL Nov 12, 2026
0067cd5
fix: keep AVIF sequences animated and return decode failures as values
DrJKL Nov 12, 2026
47b2a42
fix: make image preview ownership and worker processing safe
DrJKL Nov 12, 2026
cf9e825
refactor: reuse image preview and benchmark helpers
DrJKL Nov 12, 2026
90126f2
fix: encode benchmark PNGs with node:zlib so e2e tooling resolves the…
DrJKL Nov 12, 2026
1eee698
refactor: scope image preview workers and localize fixtures
DrJKL Nov 12, 2026
0102b77
fix: keep preview display type private
DrJKL Nov 12, 2026
815f38d
feat: preload neighboring batch images on zoomed-in nodes and in the …
DrJKL Nov 12, 2026
7a2e87f
refactor: carry structured preview metadata through Vue nodes
DrJKL Nov 12, 2026
67f43bb
fix: keep widget-specific images out of generic previews
DrJKL Nov 12, 2026
cea2518
fix: preserve preview media types and fallback behavior
DrJKL Nov 12, 2026
9336f60
fix: preserve explicit media URLs without separate previews
DrJKL Nov 12, 2026
bac2c2f
Merge main into drjkl/structured-preview-metadata
DrJKL Nov 12, 2026
80c2e76
fix: exclude non-video outputs from node video previews
DrJKL Nov 12, 2026
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
146 changes: 79 additions & 67 deletions src/composables/node/usePromotedPreviews.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,24 @@ function addInteriorNode(
return node
}

function seedOutputs(subgraphId: string, nodeIds: Array<number | string>) {
function seedOutputs(
subgraphId: string,
nodeIds: Array<number | string>,
filename = 'output.png'
) {
const store = useNodeOutputStore()
for (const nodeId of nodeIds) {
const locatorId = createNodeLocatorId(subgraphId, toNodeId(nodeId))
store.nodeOutputs[locatorId] = {
images: [{ filename: 'output.png' }]
images: [{ filename }]
}
}
}

function outputItems(...filenames: string[]) {
return filenames.map((filename) => expect.objectContaining({ filename }))
}

function seedPreviewImages(
subgraphId: string,
entries: Array<{ nodeId: number | string; urls: string[] }>
Expand Down Expand Up @@ -77,21 +85,16 @@ function exposePreview(
interface ArrangeOptions {
id?: number
previewMediaType?: 'image' | 'video' | 'audio' | 'model'
urls?: string[]
filename?: string
}

function arrangePromotedPreview(options: ArrangeOptions = {}) {
const {
id = 10,
previewMediaType,
urls = ['/view?filename=output.png']
} = options
const { id = 10, previewMediaType, filename = 'output.png' } = options
const setup = createSetup()
addInteriorNode(setup, { id, previewMediaType })
exposePreview(setup, String(id))
seedOutputs(setup.subgraph.id, [id])
vi.mocked(useNodeOutputStore().getNodeImageUrls).mockReturnValue(urls)
return { setup, urls }
seedOutputs(setup.subgraph.id, [id], filename)
return { setup, items: outputItems(filename) }
}

describe(usePromotedPreviews, () => {
Expand Down Expand Up @@ -127,7 +130,7 @@ describe(usePromotedPreviews, () => {
})

it('returns image preview for promoted $$ widget with outputs', () => {
const { setup, urls } = arrangePromotedPreview({
const { setup, items } = arrangePromotedPreview({
previewMediaType: 'image'
})

Expand All @@ -137,62 +140,71 @@ describe(usePromotedPreviews, () => {
sourceNodeId: '10',
sourceWidgetName: CANVAS_IMAGE_PREVIEW_WIDGET,
type: 'image',
urls
items
}
])
})

it('returns video type when interior node has video previewMediaType', () => {
const { setup } = arrangePromotedPreview({
previewMediaType: 'video',
filename: 'output.webm'
})

const { promotedPreviews } = usePromotedPreviews(() => setup.subgraphNode)
expect(promotedPreviews.value[0].type).toBe('video')
})

it.for([
['video', '/view?filename=output.webm'],
['audio', '/view?filename=output.mp3']
] as const)(
'returns %s type when interior node has %s previewMediaType',
([mediaType, url]) => {
const { setup } = arrangePromotedPreview({
previewMediaType: mediaType,
urls: [url]
})
{ bucket: 'video', filename: 'output.webm', expected: 'video' },
{ bucket: 'audio', filename: 'output.flac', expected: 'audio' }
])(
'infers promoted $expected output without a node media hint',
({ bucket, filename, expected }) => {
const setup = createSetup()
addInteriorNode(setup)
exposePreview(setup, '10')
useNodeOutputStore().nodeOutputs[
createNodeLocatorId(setup.subgraph.id, toNodeId(10))
] = {
[bucket]: [{ filename }]
}

const { promotedPreviews } = usePromotedPreviews(() => setup.subgraphNode)
expect(promotedPreviews.value[0].type).toBe(mediaType)

expect(promotedPreviews.value).toEqual([
expect.objectContaining({
type: expected,
items: outputItems(filename)
})
])
}
)

it('defaults preview type to image when previewMediaType is unset', () => {
const { setup, urls } = arrangePromotedPreview()
const { setup, items } = arrangePromotedPreview()

const { promotedPreviews } = usePromotedPreviews(() => setup.subgraphNode)
expect(promotedPreviews.value).toEqual([
expect.objectContaining({ type: 'image', urls })
expect.objectContaining({ type: 'image', items })
])
})

it('returns separate entries for multiple promoted $$ widgets', () => {
const setup = createSetup()
const node10 = addInteriorNode(setup, {
id: 10,
previewMediaType: 'image'
})
const node20 = addInteriorNode(setup, {
id: 20,
previewMediaType: 'image'
})
addInteriorNode(setup, { id: 10, previewMediaType: 'image' })
addInteriorNode(setup, { id: 20, previewMediaType: 'image' })
exposePreview(setup, '10')
exposePreview(setup, '20')

seedOutputs(setup.subgraph.id, [10, 20])
vi.mocked(useNodeOutputStore().getNodeImageUrls).mockImplementation(
(node: LGraphNode) => {
if (node === node10) return ['/view?a=1']
if (node === node20) return ['/view?b=2']
return undefined
}
)
seedOutputs(setup.subgraph.id, [10], 'a.png')
seedOutputs(setup.subgraph.id, [20], 'b.png')

const { promotedPreviews } = usePromotedPreviews(() => setup.subgraphNode)
expect(promotedPreviews.value).toHaveLength(2)
expect(promotedPreviews.value[0].urls).toEqual(['/view?a=1'])
expect(promotedPreviews.value[1].urls).toEqual(['/view?b=2'])
expect(promotedPreviews.value).toEqual([
expect.objectContaining({ items: outputItems('a.png') }),
expect.objectContaining({ items: outputItems('b.png') })
])
})

it('returns preview when only nodePreviewImages exist (e.g. GLSL live preview)', () => {
Expand All @@ -204,19 +216,31 @@ describe(usePromotedPreviews, () => {
seedPreviewImages(setup.subgraph.id, [
{ nodeId: toNodeId(10), urls: [blobUrl] }
])
vi.mocked(useNodeOutputStore().getNodeImageUrls).mockReturnValue([blobUrl])

const { promotedPreviews } = usePromotedPreviews(() => setup.subgraphNode)
expect(promotedPreviews.value).toEqual([
{
sourceNodeId: '10',
sourceWidgetName: CANVAS_IMAGE_PREVIEW_WIDGET,
type: 'image',
urls: [blobUrl]
type: 'preview',
url: blobUrl
}
])
})

it('prefers the live preview over saved outputs of the same node', () => {
const { setup } = arrangePromotedPreview({ previewMediaType: 'image' })
const blobUrl = 'blob:http://localhost/live'
seedPreviewImages(setup.subgraph.id, [
{ nodeId: toNodeId(10), urls: ['blob:http://localhost/stale', blobUrl] }
])

const { promotedPreviews } = usePromotedPreviews(() => setup.subgraphNode)
expect(promotedPreviews.value).toEqual([
expect.objectContaining({ type: 'preview', url: blobUrl })
])
})

it('recomputes when preview images are populated after first evaluation', () => {
const setup = createSetup()
addInteriorNode(setup, { id: 10, previewMediaType: 'image' })
Expand All @@ -229,14 +253,13 @@ describe(usePromotedPreviews, () => {
seedPreviewImages(setup.subgraph.id, [
{ nodeId: toNodeId(10), urls: [blobUrl] }
])
vi.mocked(useNodeOutputStore().getNodeImageUrls).mockReturnValue([blobUrl])

expect(promotedPreviews.value).toEqual([
{
sourceNodeId: '10',
sourceWidgetName: CANVAS_IMAGE_PREVIEW_WIDGET,
type: 'image',
urls: [blobUrl]
type: 'preview',
url: blobUrl
}
])
})
Expand Down Expand Up @@ -286,11 +309,7 @@ describe(usePromotedPreviews, () => {
sourcePreviewName: CANVAS_IMAGE_PREVIEW_WIDGET
})

const mockUrls = ['/view?filename=leaf.png']
seedOutputs(innerSetup.subgraph.id, [leafNode.id])
vi.mocked(useNodeOutputStore().getNodeImageUrls).mockImplementation(
(node: LGraphNode) => (node === leafNode ? mockUrls : [])
)
seedOutputs(innerSetup.subgraph.id, [leafNode.id], 'leaf.png')

const { promotedPreviews } = usePromotedPreviews(
() => outerSetup.subgraphNode
Expand All @@ -300,7 +319,7 @@ describe(usePromotedPreviews, () => {
sourceNodeId: '10',
sourceWidgetName: CANVAS_IMAGE_PREVIEW_WIDGET,
type: 'image',
urls: mockUrls
items: outputItems('leaf.png')
}
])
})
Expand Down Expand Up @@ -347,21 +366,14 @@ describe(usePromotedPreviews, () => {
return undefined
}
)
vi.mocked(outputStore.getNodeImageUrlsByExecutionId).mockImplementation(
(executionId) => {
if (executionId === firstLeafExecutionId) return ['blob:first']
if (executionId === secondLeafExecutionId) return ['blob:second']
return undefined
}
)

expect(usePromotedPreviews(() => firstHost).promotedPreviews.value).toEqual(
[
{
sourceNodeId: '10',
sourceWidgetName: CANVAS_IMAGE_PREVIEW_WIDGET,
type: 'image',
urls: ['blob:first']
type: 'preview',
url: 'blob:first'
}
]
)
Expand All @@ -371,8 +383,8 @@ describe(usePromotedPreviews, () => {
{
sourceNodeId: '10',
sourceWidgetName: CANVAS_IMAGE_PREVIEW_WIDGET,
type: 'image',
urls: ['blob:second']
type: 'preview',
url: 'blob:second'
}
])
})
Expand Down
Loading
Loading