Compare commits

..

13 Commits

Author SHA1 Message Date
Christian Byrne
a38bc25f45 Merge branch 'main' into glary/resize-corner-e2e-tests 2026-05-13 13:15:33 -07:00
Connor Byrne
109fa9249f test(fixture): expose poll{Left,Top,Right,Bottom}Edge and poll{Width,Height}
Move the bounding-box edge accessors from local helpers in resize.spec
into the fixture so resize tests can read 'expect.poll(node.pollWidth)'
instead of repeating the inline 'async () => (await node.boundingBox()).X'
shape. The opposite-edge anchoring test now references node-bound poll
helpers directly and the per-test edge-of factories disappear from the
spec.

Addresses review feedback:
https://github.com/Comfy-Org/ComfyUI_frontend/pull/11408#discussion_r3107737141
2026-05-04 13:35:47 -07:00
bymyself
a29c36f3ec test(fixture): extract expectAnchoredAt for drift assertions
Wraps the polled bounding-box x/y assertions that drift tests duplicate
on each axis. Drift test now reads as 'select, anchor, resize, anchor'
instead of repeated polling boilerplate.

Addresses review feedback:
https://github.com/Comfy-Org/ComfyUI_frontend/pull/11408#discussion_r3184280358
2026-05-04 13:32:13 -07:00
bymyself
80735dac10 test: drive drift test through fixture's resizeFromCorner
Replaces the bespoke select-then-mouse-drag plumbing with the existing
fixture helpers (setupResizableNode + resizeFromCorner). Drops the
hand-computed corner offset and the raw page.mouse sequence so the
drift test follows the same shape as the parameterized cases.

Addresses review feedback:
https://github.com/Comfy-Org/ComfyUI_frontend/pull/11408#discussion_r3184276374
2026-05-04 13:31:21 -07:00
bymyself
3682ae2ac0 test(fixture): add selectAndGetBox helper to VueNodeFixture
Encapsulates the click-header-then-grab-bounding-box pattern that
geometry-sensitive tests need. Removes the inline header click and
bounding-box null check from setupResizableNode.

Addresses review feedback:
https://github.com/Comfy-Org/ComfyUI_frontend/pull/11408#discussion_r3184278489
2026-05-04 13:31:00 -07:00
bymyself
213bf7b4cb test: include SE in parameterized corner resize sweeps
Drop the SE filter and its 'Exercise every non-SE corner' explanation;
SE belongs in the same parameterized loops as the other three corners.

Addresses review feedback:
https://github.com/Comfy-Org/ComfyUI_frontend/pull/11408#discussion_r3184283386
2026-05-04 13:30:27 -07:00
jaeone94
d03013372d Merge branch 'main' into glary/resize-corner-e2e-tests 2026-05-02 15:51:08 +09:00
jaeone94
2fceb9b68a Merge branch 'main' into glary/resize-corner-e2e-tests 2026-04-29 22:21:50 +09:00
jaeone94
7c88b22ad3 test: address resize review feedback
- Replace English aria-label lookup with a data-corner attribute on the
  handle div; drop RESIZE_HANDLE_ARIA_LABELS_EN and its main.json
  import so resizeHandleConfig stays locale-independent
- Tighten NE clamp test: poll actual clamped height, then drive a second
  overdrag and assert height stays at the same lower bound (idempotent
  clamp). Rename test to match what it verifies; rename the inner box
  to expandedBox to avoid shadowing the setup fixture's box
- Restore Comfy.Minimap.Visible in afterEach so the override does not
  leak into other specs sharing the user-data-dir
- Normalize canvas state with canvasOps.resetView() in beforeEach so
  anchor assertions stay subpixel-stable regardless of prior pan/zoom
- Guard setupResizableNode with toHaveCount(1) so the helper fails
  loudly if the default workflow ever gains a duplicate title
- Add handle.hover() before the drag mouse sequence; Playwright's
  actionability checks now verify the handle is hit-testable
- Extract edge-coordinate pollers (leftEdgeOf / rightEdgeOf /
  topEdgeOf / bottomEdgeOf) to replace nested ternaries inside
  expect.poll callbacks
- Tag the suite with @canvas @node per the Playwright guidance
- Reword the parameterization comment to stop leaking the production
  switch statement as test rationale
- Drop the aria-label mirror test; add a completeness test that asserts
  RESIZE_HANDLES defines exactly one entry per CompassCorners
- JSDoc on hasWestEdge/hasNorthEdge and the fixture's resize helpers
2026-04-21 21:08:40 +09:00
jaeone94
f5a1c724e6 refactor: share resize corner helpers across production and E2E
- Expose hasWestEdge, hasNorthEdge, and RESIZE_HANDLE_ARIA_LABELS_EN
  from resizeHandleConfig so useNodeResize and the VueNodeFixture
  consume a single source per corner; resolve English labels from
  main.json instead of hardcoding a duplicate map in tests
- Replace activeCorner.includes('W'|'N') substring checks in
  useNodeResize with the new helpers
- Drop nextFrame from resizeFromCorner; call sites rely on expect.poll
- Disable Comfy.Minimap.Visible in the resize spec's beforeEach so the
  minimap overlay does not hijack handle pointer events mid-drag and
  trigger forwardPanEvent on the LGraphCanvas
- Target KSampler (center-positioned with open canvas around it) for
  corner-resize cases; pre-expand via SE before NE clamp so there is
  room to shrink below minContentHeight
- Replace the redundant runtime corner-existence guard with the
  exhaustive CompassCorners union; extract setupResizableNode to drop
  repeated header-click + boundingBox scaffolding
- Unit tests cover the new helpers and verify aria-label resolution
  stays in sync with the handles' i18nKey values
2026-04-21 20:40:59 +09:00
Glary-Bot
c77bccefea test: add nextFrame after resize, tighten min-size assertions
- resizeFromCorner() now waits one frame after mouse up for layout
  settlement, preventing intermittent failures
- SW width clamp asserts >= MIN_NODE_WIDTH instead of > 0
- NE height clamp asserts < original height (actual shrinkage)
2026-04-19 08:15:54 +00:00
Glary-Bot
77c69cf931 test: add upfront guard against silent corner removal
Fail loudly if RESIZE_HANDLES drops a corner, preventing the
parameterized tests from silently losing coverage.
2026-04-19 08:06:00 +00:00
Glary-Bot
c84fa6ac39 test: add E2E coverage for NE, SW, NW corner node resizing
Adds parameterized Playwright tests covering all non-SE resize
corners, derived from the production RESIZE_HANDLES config.

- Add resizeFromCorner() and getResizeHandle() to VueNodeFixture
  using locator-based aria-label handle discovery
- Corner resize direction tests (NE, SW, NW)
- Opposite edge anchoring tests
- Minimum size enforcement tests (SW width clamp, NE height clamp)
2026-04-19 08:00:04 +00:00
70 changed files with 418 additions and 2066 deletions

View File

@@ -1,45 +0,0 @@
{
"last_node_id": 1,
"last_link_id": 0,
"nodes": [
{
"id": 1,
"type": "LoadImage",
"pos": [50, 120],
"size": [400, 200],
"flags": {},
"order": 0,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"links": null
},
{
"name": "MASK",
"type": "MASK",
"links": null
}
],
"properties": {
"Node name for S&R": "LoadImage"
},
"widgets_values": [
"147257c95a3e957e0deee73a077cfec89da2d906dd086ca70a2b0c897a9591d6e.png[output]",
"image"
]
}
],
"links": [],
"groups": [],
"config": {},
"extra": {
"ds": {
"offset": [0, 0],
"scale": 1
}
},
"version": 0.4
}

View File

@@ -1,84 +0,0 @@
{
"last_node_id": 3,
"last_link_id": 0,
"nodes": [
{
"id": 1,
"type": "LoadImage",
"pos": [50, 120],
"size": [400, 200],
"flags": {},
"order": 0,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"links": null
},
{
"name": "MASK",
"type": "MASK",
"links": null
}
],
"properties": {
"Node name for S&R": "LoadImage"
},
"widgets_values": ["ComfyUI_00001_.png [output]", "image"]
},
{
"id": 2,
"type": "LoadVideo",
"pos": [430, 120],
"size": [400, 200],
"flags": {},
"order": 1,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "VIDEO",
"type": "VIDEO",
"links": null
}
],
"properties": {
"Node name for S&R": "LoadVideo"
},
"widgets_values": ["clip.mp4 [output]", "image"]
},
{
"id": 3,
"type": "LoadAudio",
"pos": [810, 120],
"size": [400, 200],
"flags": {},
"order": 2,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "AUDIO",
"type": "AUDIO",
"links": null
}
],
"properties": {
"Node name for S&R": "LoadAudio"
},
"widgets_values": ["sound.wav [output]", null, ""]
}
],
"links": [],
"groups": [],
"config": {},
"extra": {
"ds": {
"offset": [0, 0],
"scale": 1
}
},
"version": 0.4
}

Binary file not shown.

View File

@@ -1,90 +0,0 @@
{
"id": "06e5b524-5a40-40b9-b561-199dfab18cf0",
"revision": 0,
"last_node_id": 12,
"last_link_id": 10,
"nodes": [
{
"id": 10,
"type": "KSampler",
"pos": [230, 110],
"size": [270, 317.5666809082031],
"flags": {},
"order": 1,
"mode": 0,
"inputs": [
{
"name": "model",
"type": "MODEL",
"link": null
},
{
"name": "positive",
"type": "CONDITIONING",
"link": null
},
{
"name": "negative",
"type": "CONDITIONING",
"link": null
},
{
"name": "latent_image",
"type": "LATENT",
"link": null
},
{
"name": "denoise",
"type": "FLOAT",
"widget": {
"name": "denoise"
},
"link": 10
}
],
"outputs": [
{
"name": "LATENT",
"type": "LATENT",
"links": null
}
],
"properties": {
"Node name for S&R": "KSampler"
},
"widgets_values": [0, "randomize", 20, 8, "euler", "simple", 1]
},
{
"id": 11,
"type": "PrimitiveFloat",
"pos": [-80.55032348632812, 375.2260443115233],
"size": [270, 80.23332977294922],
"flags": {},
"order": 0,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "FLOAT",
"type": "FLOAT",
"links": [10]
}
],
"properties": {
"Node name for S&R": "PrimitiveFloat"
},
"widgets_values": [0]
}
],
"links": [[10, 11, 0, 10, 4, "FLOAT"]],
"groups": [],
"config": {},
"extra": {
"ds": {
"scale": 0.8264462809917354,
"offset": [1335.8909766107738, 692.7345403667316]
},
"frontendVersion": "1.45.4"
},
"version": 0.4
}

View File

@@ -246,18 +246,4 @@ export class VueNodeHelpers {
position: { x: box.width / 2, y: box.height * 0.75 }
})
}
async isSlotConnected(slot: Locator) {
const key = await slot.getByTestId('slot-dot').getAttribute('data-slot-key')
if (!key) return false
return await this.page.evaluate((key) => {
const [nodeId, type, slotId] = key.split('-')
const node = app?.canvas?.graph?.getNodeById(nodeId)
if (!node) return false
return type === 'in'
? node.inputs[Number(slotId)]?.link !== null
: !!node.outputs[Number(slotId)].links?.length
}, key)
}
}

View File

@@ -6,16 +6,12 @@ export class ContextMenu {
public readonly litegraphMenu: Locator
public readonly litegraphContextMenu: Locator
public readonly menuItems: Locator
protected readonly anyMenu: Locator
constructor(public readonly page: Page) {
this.primeVueMenu = page.locator('.p-contextmenu, .p-menu')
this.litegraphMenu = page.locator('.litemenu')
this.litegraphContextMenu = page.locator('.litecontextmenu')
this.menuItems = page.locator('.p-menuitem, .litemenu-entry')
this.anyMenu = this.primeVueMenu
.or(this.litegraphMenu)
.or(this.litegraphContextMenu)
}
async clickMenuItem(name: string): Promise<void> {
@@ -40,7 +36,16 @@ export class ContextMenu {
}
async isVisible(): Promise<boolean> {
return await this.anyMenu.isVisible()
const primeVueVisible = await this.primeVueMenu
.isVisible()
.catch(() => false)
const litegraphVisible = await this.litegraphMenu
.isVisible()
.catch(() => false)
const litegraphContextVisible = await this.litegraphContextMenu
.isVisible()
.catch(() => false)
return primeVueVisible || litegraphVisible || litegraphContextVisible
}
async assertHasItems(items: string[]): Promise<void> {
@@ -53,7 +58,7 @@ export class ContextMenu {
async openFor(locator: Locator): Promise<this> {
await locator.click({ button: 'right' })
await expect(this.anyMenu).toBeVisible()
await expect.poll(() => this.isVisible()).toBe(true)
return this
}

View File

@@ -95,7 +95,6 @@ export class NodeLibrarySidebarTabV2 extends SidebarTab {
public readonly allTab: Locator
public readonly blueprintsTab: Locator
public readonly sortButton: Locator
public readonly nodePreview: Locator
constructor(public override readonly page: Page) {
super(page, 'node-library')
@@ -104,7 +103,6 @@ export class NodeLibrarySidebarTabV2 extends SidebarTab {
this.allTab = this.getTab('All')
this.blueprintsTab = this.getTab('Blueprints')
this.sortButton = this.sidebarContent.getByRole('button', { name: 'Sort' })
this.nodePreview = page.getByTestId(TestIds.sidebar.nodePreviewCard)
}
getTab(name: string) {

View File

@@ -1,81 +0,0 @@
import type { Locator } from '@playwright/test'
import { comfyExpect as expect } from '@e2e/fixtures/ComfyPage'
import type { ComfyPage } from '@e2e/fixtures/ComfyPage'
import { TestIds } from '@e2e/fixtures/selectors'
import { dragByIndex } from '@e2e/fixtures/utils/dragAndDrop'
import { VueNodeFixture } from '@e2e/fixtures/utils/vueNodeFixtures'
export class SubgraphEditor {
public readonly root: Locator
public readonly promotionItems: Locator
constructor(protected readonly comfyPage: ComfyPage) {
this.root = this.comfyPage.menu.propertiesPanel.root
this.promotionItems = this.root.getByTestId(
TestIds.subgraphEditor.widgetItem
)
}
async open(subgraphNode: Locator) {
await new VueNodeFixture(subgraphNode).select()
const menu = await this.comfyPage.contextMenu.openFor(subgraphNode)
await menu.clickMenuItemExact('Edit Subgraph Widgets')
await expect(this.root, 'Open Properties Panel').toBeVisible()
}
resolveItem(options: {
nodeName?: string
nodeId?: string
widgetName: string
}): Locator {
const nodeItems =
options.nodeId !== undefined
? this.comfyPage.page.locator(`[data-nodeid="${options.nodeId}"]`)
: options.nodeName !== undefined
? this.promotionItems.filter({
has: this.comfyPage.page
.getByTestId(TestIds.subgraphEditor.nodeName)
.filter({ hasText: options.nodeName })
})
: this.promotionItems
return nodeItems.filter({
has: this.comfyPage.page
.getByTestId(TestIds.subgraphEditor.widgetLabel)
.filter({ hasText: options.widgetName })
})
}
getToggleButton(item: Locator) {
return item.getByTestId(TestIds.subgraphEditor.widgetToggle)
}
async togglePromotionOnItem(item: Locator, toState?: boolean) {
const toggleIcon = item.getByTestId(TestIds.subgraphEditor.iconEye)
if (toState !== undefined) {
const expectedIcon = `icon-[lucide--eye${toState ? '-off' : ''}]`
await expect(toggleIcon).toContainClass(expectedIcon)
}
await toggleIcon.click()
}
async togglePromotion(
subgraphNode: Locator,
options: {
nodeName?: string
nodeId?: string
widgetName: string
toState?: boolean
}
) {
await this.open(subgraphNode)
const item = this.resolveItem(options)
await this.togglePromotionOnItem(item, options.toState)
}
async dragItem(fromIndex: number, toIndex: number) {
await dragByIndex(this.promotionItems, fromIndex, toIndex)
await this.comfyPage.nextFrame()
}
}

View File

@@ -2,7 +2,34 @@ import type { Locator, Page } from '@playwright/test'
import type { ComfyPage } from '@e2e/fixtures/ComfyPage'
import { TestIds } from '@e2e/fixtures/selectors'
import { dragByIndex } from '@e2e/fixtures/utils/dragAndDrop'
/**
* Drag an element from one index to another within a list of locators.
* Uses mousedown/mousemove/mouseup to trigger the DraggableList library.
*
* DraggableList toggles position when the dragged item's center crosses
* past an idle item's center. To reliably land at the target position,
* we overshoot slightly past the target's far edge.
*/
async function dragByIndex(items: Locator, fromIndex: number, toIndex: number) {
const fromBox = await items.nth(fromIndex).boundingBox()
const toBox = await items.nth(toIndex).boundingBox()
if (!fromBox || !toBox) throw new Error('Item not visible for drag')
const draggingDown = toIndex > fromIndex
const targetY = draggingDown
? toBox.y + toBox.height * 0.9
: toBox.y + toBox.height * 0.1
const page = items.page()
await page.mouse.move(
fromBox.x + fromBox.width / 2,
fromBox.y + fromBox.height / 2
)
await page.mouse.down()
await page.mouse.move(toBox.x + toBox.width / 2, targetY, { steps: 10 })
await page.mouse.up()
}
export class BuilderSelectHelper {
/** All IoItem locators in the current step sidebar. */

View File

@@ -9,17 +9,12 @@ import type { ComfyWorkflow } from '@/platform/workflow/management/stores/comfyW
import type { ComfyWorkflowJSON } from '@/platform/workflow/validation/schemas/workflowSchema'
import type { ComfyPage } from '@e2e/fixtures/ComfyPage'
import { SubgraphEditor } from '@e2e/fixtures/components/SubgraphEditor'
import { TestIds } from '@e2e/fixtures/selectors'
import type { NodeReference } from '@e2e/fixtures/utils/litegraphUtils'
import { SubgraphSlotReference } from '@e2e/fixtures/utils/litegraphUtils'
export class SubgraphHelper {
public readonly editor: SubgraphEditor
constructor(private readonly comfyPage: ComfyPage) {
this.editor = new SubgraphEditor(comfyPage)
}
constructor(private readonly comfyPage: ComfyPage) {}
private get page(): Page {
return this.comfyPage.page
@@ -332,23 +327,6 @@ export class SubgraphHelper {
await this.comfyPage.nextFrame()
}
async promoteWidget(nodeLocator: Locator, widgetName: string): Promise<void> {
const widget = nodeLocator.getByLabel(widgetName, { exact: true })
await this.comfyPage.contextMenu
.openFor(widget)
.then((m) => m.clickMenuItemExact(`Promote Widget: ${widgetName}`))
}
async unpromoteWidget(
nodeLocator: Locator,
widgetName: string
): Promise<void> {
const widget = nodeLocator.getByLabel(widgetName, { exact: true })
await this.comfyPage.contextMenu
.openFor(widget)
.then((m) => m.clickMenuItemExact(`Un-Promote Widget: ${widgetName}`))
}
async isInSubgraph(): Promise<boolean> {
return this.page.evaluate(() => {
const graph = window.app!.canvas.graph

View File

@@ -8,7 +8,6 @@ export const TestIds = {
toolbar: 'side-toolbar',
nodeLibrary: 'node-library-tree',
nodeLibrarySearch: 'node-library-search',
nodePreviewCard: 'node-preview-card',
workflows: 'workflows-sidebar',
modeToggle: 'mode-toggle'
},
@@ -104,16 +103,14 @@ export const TestIds = {
errorsTab: 'panel-tab-errors'
},
subgraphEditor: {
hiddenSection: 'subgraph-editor-hidden-section',
iconEye: 'icon-eye',
iconLink: 'icon-link',
nodeName: 'subgraph-widget-node-name',
shownSection: 'subgraph-editor-shown-section',
toggle: 'subgraph-editor-toggle',
widgetActionsMenuButton: 'widget-actions-menu-button',
widgetItem: 'subgraph-widget-item',
shownSection: 'subgraph-editor-shown-section',
hiddenSection: 'subgraph-editor-hidden-section',
widgetToggle: 'subgraph-widget-toggle',
widgetLabel: 'subgraph-widget-label',
widgetToggle: 'subgraph-widget-toggle'
iconLink: 'icon-link',
iconEye: 'icon-eye',
widgetActionsMenuButton: 'widget-actions-menu-button'
},
node: {
titleInput: 'node-title-input',

View File

@@ -1,33 +0,0 @@
import type { Locator } from '@playwright/test'
/**
* Drag an element from one index to another within a list of locators.
* Uses mousedown/mousemove/mouseup to trigger the DraggableList library.
*
* DraggableList toggles position when the dragged item's center crosses
* past an idle item's center. To reliably land at the target position,
* we overshoot slightly past the target's far edge.
*/
export async function dragByIndex(
items: Locator,
fromIndex: number,
toIndex: number
) {
const fromBox = await items.nth(fromIndex).boundingBox()
const toBox = await items.nth(toIndex).boundingBox()
if (!fromBox || !toBox) throw new Error('Item not visible for drag')
const draggingDown = toIndex > fromIndex
const targetY = draggingDown
? toBox.y + toBox.height * 0.9
: toBox.y + toBox.height * 0.1
const page = items.page()
await page.mouse.move(
fromBox.x + fromBox.width / 2,
fromBox.y + fromBox.height / 2
)
await page.mouse.down()
await page.mouse.move(toBox.x + toBox.width / 2, targetY, { steps: 10 })
await page.mouse.up()
}

View File

@@ -1,8 +1,16 @@
import { expect } from '@playwright/test'
import type { Locator } from '@playwright/test'
import type { CompassCorners } from '@/lib/litegraph/src/interfaces'
import { TitleEditor } from '@e2e/fixtures/components/TitleEditor'
import { TestIds } from '@e2e/fixtures/selectors'
interface BoxOrigin {
readonly x: number
readonly y: number
}
/** DOM-centric helper for a single Vue-rendered node on the canvas. */
export class VueNodeFixture {
public readonly header: Locator
@@ -15,7 +23,6 @@ export class VueNodeFixture {
public readonly root: Locator
public readonly widgets: Locator
public readonly imagePreview: Locator
public readonly content: Locator
constructor(private readonly locator: Locator) {
this.header = locator.locator('[data-testid^="node-header-"]')
@@ -28,7 +35,6 @@ export class VueNodeFixture {
this.root = locator
this.widgets = this.locator.locator('.lg-node-widget')
this.imagePreview = locator.locator('.image-preview')
this.content = locator.locator('.lg-node-content')
}
async getTitle(): Promise<string> {
@@ -41,10 +47,6 @@ export class VueNodeFixture {
await this.titleEditor.setTitle(value)
}
async select() {
await this.header.click()
}
async toggleCollapse(): Promise<void> {
await this.collapseButton.click()
}
@@ -67,14 +69,99 @@ export class VueNodeFixture {
return this.locator.boundingBox()
}
getSlot(nameOrLocator: string | Locator) {
const slotLocators = this.root
.getByTestId('node-widget')
.or(this.root.locator('.lg-slot'))
const filteredLocator =
typeof nameOrLocator === 'string'
? slotLocators.filter({ hasText: nameOrLocator })
: slotLocators.filter({ has: nameOrLocator })
return filteredLocator.getByTestId('slot-dot').locator('..')
/**
* Click the node header to select it, then return its bounding box.
* Throws if the node is not laid out (no bounding box) — resize and other
* geometry-sensitive tests cannot proceed without coordinates.
*/
async selectAndGetBox(): Promise<{
x: number
y: number
width: number
height: number
}> {
await this.header.click()
const box = await this.boundingBox()
if (!box) {
throw new Error('Node bounding box not found after select')
}
return box
}
/**
* Assert this node's top-left origin stays within `precision` decimal
* places of `expected`. Wraps the polled bounding-box pattern that drift
* tests repeat for both axes.
*/
async expectAnchoredAt(
expected: BoxOrigin,
{ precision = 1 }: { precision?: number } = {}
): Promise<void> {
await expect.poll(this.pollLeftEdge).toBeCloseTo(expected.x, precision)
await expect.poll(this.pollTopEdge).toBeCloseTo(expected.y, precision)
}
/** Poll the node's left/x edge for use with `expect.poll`. */
pollLeftEdge = async (): Promise<number | null> =>
(await this.boundingBox())?.x ?? null
/** Poll the node's top/y edge for use with `expect.poll`. */
pollTopEdge = async (): Promise<number | null> =>
(await this.boundingBox())?.y ?? null
/** Poll the node's right edge (x + width) for use with `expect.poll`. */
pollRightEdge = async (): Promise<number | null> => {
const b = await this.boundingBox()
return b ? b.x + b.width : null
}
/** Poll the node's bottom edge (y + height) for use with `expect.poll`. */
pollBottomEdge = async (): Promise<number | null> => {
const b = await this.boundingBox()
return b ? b.y + b.height : null
}
/** Poll the node's width for use with `expect.poll`. */
pollWidth = async (): Promise<number | null> =>
(await this.boundingBox())?.width ?? null
/** Poll the node's height for use with `expect.poll`. */
pollHeight = async (): Promise<number | null> =>
(await this.boundingBox())?.height ?? null
/** Locator for the resize handle at the given corner, scoped to this node. */
getResizeHandle(corner: CompassCorners): Locator {
return this.root.locator(`[data-corner="${corner}"]`)
}
/**
* Drag the resize handle at `corner` by (deltaX, deltaY) viewport pixels.
* Uses `hover()` to land the pointer on the handle with Playwright's
* actionability checks before starting the mouse sequence, which protects
* against occluding overlays and subpixel hit-test misses.
*/
async resizeFromCorner(
corner: CompassCorners,
deltaX: number,
deltaY: number
): Promise<void> {
const handle = this.getResizeHandle(corner)
await handle.hover()
const box = await handle.boundingBox()
if (!box) {
throw new Error(
`Resize handle for corner "${corner}" has no bounding box`
)
}
const page = this.locator.page()
const startX = box.x + box.width / 2
const startY = box.y + box.height / 2
await page.mouse.move(startX, startY)
await page.mouse.down()
await page.mouse.move(startX + deltaX, startY + deltaY, {
steps: 5
})
await page.mouse.up()
}
}

View File

@@ -25,21 +25,6 @@ const FIXTURES: readonly MetadataFixture[] = [
{ fileName: 'with_metadata.webm', parser: 'ebml (webm)' }
] as const
// NaN-variant fixtures embed only an API-format prompt containing bare
// `NaN`/`Infinity` tokens (Python's `json.dumps` default). The loader must
// tolerate Python generated JSON for these to import successfully.
const NAN_FIXTURES: readonly MetadataFixture[] = [
{ fileName: 'with_nan_metadata.json', parser: 'json' },
{ fileName: 'with_nan_metadata.png', parser: 'png' },
{ fileName: 'with_nan_metadata.avif', parser: 'avif' },
{ fileName: 'with_nan_metadata.webp', parser: 'webp' },
{ fileName: 'with_nan_metadata.flac', parser: 'flac' },
{ fileName: 'with_nan_metadata.mp3', parser: 'mp3' },
{ fileName: 'with_nan_metadata.opus', parser: 'ogg' },
{ fileName: 'with_nan_metadata.mp4', parser: 'isobmff' },
{ fileName: 'with_nan_metadata.webm', parser: 'ebml (webm)' }
] as const
test.describe(
'Metadata drop-to-load workflow import',
{ tag: ['@workflow'] },
@@ -73,42 +58,5 @@ test.describe(
})
})
}
for (const { fileName, parser } of NAN_FIXTURES) {
test(`loads Python JSON prompt with NaN/Infinity from ${fileName} (${parser})`, async ({
comfyPage
}) => {
await test.step(`drop ${fileName} on canvas`, async () => {
await comfyPage.dragDrop.dragAndDropFilePath(
metadataFixturePath(fileName)
)
})
await test.step('graph contains only the embedded KSampler', async () => {
await expect
.poll(() => comfyPage.nodeOps.getGraphNodesCount())
.toBe(1)
const ksamplers =
await comfyPage.nodeOps.getNodeRefsByType('KSampler')
expect(
ksamplers,
'exactly one KSampler should have been loaded from the NaN-laden prompt'
).toHaveLength(1)
})
await test.step('NaN-coerced widget values are 0', async () => {
const [ksampler] =
await comfyPage.nodeOps.getNodeRefsByType('KSampler')
for (const widgetName of ['cfg', 'denoise']) {
const widget = await ksampler.getWidgetByName(widgetName)
expect(
await widget.getValue(),
`${widgetName} should be 0 after NaN coercion to null`
).toBe(0)
}
})
})
}
}
)

View File

@@ -1,357 +0,0 @@
import { expect, mergeTests } from '@playwright/test'
import type { Page, Route } from '@playwright/test'
import type { Asset, ListAssetsResponse } from '@comfyorg/ingest-types'
import {
assetRequestIncludesTag,
createCloudAssetsFixture
} from '@e2e/fixtures/assetApiFixture'
import { comfyPageFixture } from '@e2e/fixtures/ComfyPage'
import type { ComfyPage } from '@e2e/fixtures/ComfyPage'
import { jobsApiMockFixture } from '@e2e/fixtures/jobsApiMockFixture'
import { TestIds } from '@e2e/fixtures/selectors'
import {
createMockJob,
createMockJobRecords
} from '@e2e/fixtures/utils/jobFixtures'
import { PropertiesPanelHelper } from '@e2e/tests/propertiesPanel/PropertiesPanelHelper'
const ossTest = mergeTests(comfyPageFixture, jobsApiMockFixture)
const outputHash =
'147257c95a3e957e0deee73a077cfec89da2d906dd086ca70a2b0c897a9591d6e.png'
const plainVideoFileName = 'plain_video.mp4'
const graphDropPosition = { x: 500, y: 300 }
const missingMediaUploadObservationMs = 1_000
const missingMediaUploadPollMs = 100
const cloudOutputAsset: Asset = {
id: 'test-output-hash-001',
name: 'ComfyUI_00001_.png',
asset_hash: outputHash,
size: 4_194_304,
mime_type: 'image/png',
tags: ['output'],
created_at: '2026-05-01T00:00:00Z',
updated_at: '2026-05-01T00:00:00Z',
last_access_time: '2026-05-01T00:00:00Z'
}
const cloudUploadedVideoAsset: Asset = {
id: 'test-uploaded-video-001',
name: plainVideoFileName,
asset_hash: plainVideoFileName,
size: 1_024,
mime_type: 'video/mp4',
tags: ['input'],
created_at: '2026-05-01T00:00:00Z',
updated_at: '2026-05-01T00:00:00Z',
last_access_time: '2026-05-01T00:00:00Z'
}
// The Cloud test app starts with a default LoadImage node. Keep that baseline
// input resolvable so this spec only observes the media it creates.
const cloudDefaultGraphInputAsset: Asset = {
id: 'test-default-input-001',
name: '00000000000000000000000Aexample.png',
asset_hash: '00000000000000000000000Aexample.png',
size: 1_024,
mime_type: 'image/png',
tags: ['input'],
created_at: '2026-05-01T00:00:00Z',
updated_at: '2026-05-01T00:00:00Z',
last_access_time: '2026-05-01T00:00:00Z'
}
interface CloudUploadAssetState {
isUploadedAssetAvailable: boolean
}
const cloudOutputTest = createCloudAssetsFixture([cloudOutputAsset])
const cloudUploadAssetStateByPage = new WeakMap<Page, CloudUploadAssetState>()
const cloudUploadRaceTest = comfyPageFixture.extend<{
markUploadedCloudAssetAvailable: () => void
}>({
page: async ({ page }, use) => {
const state: CloudUploadAssetState = {
isUploadedAssetAvailable: false
}
cloudUploadAssetStateByPage.set(page, state)
const assetsRouteHandler = async (route: Route) => {
const allAssets = [
cloudDefaultGraphInputAsset,
...(state.isUploadedAssetAvailable ? [cloudUploadedVideoAsset] : [])
]
const includeTags =
new URL(route.request().url()).searchParams
.get('include_tags')
?.split(',')
.filter(Boolean) ?? []
const assets = includeTags.length
? allAssets.filter((asset) =>
asset.tags?.some((tag) => includeTags.includes(tag))
)
: allAssets
const response: ListAssetsResponse = {
assets,
total: assets.length,
has_more: false
}
await route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify(response)
})
}
await page.route(/\/api\/assets(?:\?.*)?$/, assetsRouteHandler)
await use(page)
await page.unroute(/\/api\/assets(?:\?.*)?$/, assetsRouteHandler)
cloudUploadAssetStateByPage.delete(page)
},
markUploadedCloudAssetAvailable: async ({ page }, use) => {
await use(() => {
const state = cloudUploadAssetStateByPage.get(page)
if (state) state.isUploadedAssetAvailable = true
})
}
})
async function enableErrorsTab(comfyPage: ComfyPage) {
await comfyPage.settings.setSetting(
'Comfy.RightSidePanel.ShowErrorsTab',
true
)
}
function getErrorOverlay(comfyPage: ComfyPage) {
return comfyPage.page.getByTestId(TestIds.dialogs.errorOverlay)
}
async function expectNoErrorsTab(comfyPage: ComfyPage) {
await expect(getErrorOverlay(comfyPage)).toBeHidden()
const panel = new PropertiesPanelHelper(comfyPage.page)
await panel.open(comfyPage.actionbar.propertiesButton)
await expect(
panel.root.getByTestId(TestIds.propertiesPanel.errorsTab)
).toBeHidden()
}
async function delayNextUpload(comfyPage: ComfyPage) {
let releaseUpload!: () => void
let resolveUploadStarted!: () => void
const uploadStarted = new Promise<void>((resolve) => {
resolveUploadStarted = resolve
})
const release = new Promise<void>((resolve) => {
releaseUpload = resolve
})
const uploadRouteHandler = async (route: Route) => {
resolveUploadStarted()
await release
await route.continue()
}
await comfyPage.page.route('**/upload/image', uploadRouteHandler)
return {
waitForUploadStarted: () => uploadStarted,
finishUpload: async () => {
const uploadResponse = comfyPage.page.waitForResponse(
(response) =>
response.url().includes('/upload/image') && response.status() === 200,
{ timeout: 10_000 }
)
releaseUpload()
try {
await uploadResponse
} finally {
await comfyPage.page.unroute('**/upload/image', uploadRouteHandler)
}
}
}
}
async function expectLoadVideoUploading(comfyPage: ComfyPage) {
await expect
.poll(
() =>
comfyPage.page.evaluate(() =>
window.app!.graph.nodes.some(
(node) => node.type === 'LoadVideo' && node.isUploading
)
),
{ timeout: 5_000 }
)
.toBe(true)
}
async function expectNoMissingMediaDuringUpload(comfyPage: ComfyPage) {
await comfyPage.nextFrame()
await comfyPage.nextFrame()
let sawErrorOverlay = false
const startedAt = Date.now()
await expect
.poll(
async () => {
sawErrorOverlay =
sawErrorOverlay || (await getErrorOverlay(comfyPage).isVisible())
return (
!sawErrorOverlay &&
Date.now() - startedAt >= missingMediaUploadObservationMs
)
},
{
timeout: missingMediaUploadObservationMs + missingMediaUploadPollMs * 5,
intervals: [missingMediaUploadPollMs]
}
)
.toBe(true)
}
function outputHistoryJobs() {
return createMockJobRecords([
createMockJob({
id: 'history-output-image',
preview_output: {
filename: 'ComfyUI_00001_.png',
subfolder: '',
type: 'output',
nodeId: '1',
mediaType: 'images'
}
}),
createMockJob({
id: 'history-output-video',
preview_output: {
filename: 'clip.mp4',
subfolder: '',
type: 'output',
nodeId: '2',
mediaType: 'video'
}
}),
createMockJob({
id: 'history-output-audio',
preview_output: {
filename: 'sound.wav',
subfolder: '',
type: 'output',
nodeId: '3',
mediaType: 'audio'
}
})
])
}
ossTest.describe(
'Errors tab - OSS missing media runtime sources',
{ tag: '@ui' },
() => {
ossTest.beforeEach(async ({ comfyPage }) => {
await enableErrorsTab(comfyPage)
})
ossTest(
'resolves annotated output media from job history',
async ({ comfyPage, jobsApi }) => {
await jobsApi.mockJobs(outputHistoryJobs())
await comfyPage.workflow.loadWorkflow(
'missing/missing_media_output_annotations'
)
await expectNoErrorsTab(comfyPage)
}
)
ossTest(
'does not surface missing media while dropped video upload is in progress',
async ({ comfyFiles, comfyPage }) => {
await comfyPage.nodeOps.clearGraph()
const delayedUpload = await delayNextUpload(comfyPage)
await comfyPage.dragDrop.dragAndDropFile(plainVideoFileName, {
dropPosition: graphDropPosition
})
await delayedUpload.waitForUploadStarted()
comfyFiles.deleteAfterTest({
filename: plainVideoFileName,
type: 'input'
})
await expectLoadVideoUploading(comfyPage)
await expectNoMissingMediaDuringUpload(comfyPage)
await delayedUpload.finishUpload()
await expect(getErrorOverlay(comfyPage)).toBeHidden()
}
)
}
)
cloudOutputTest.describe(
'Errors tab - Cloud missing media runtime sources',
{ tag: '@cloud' },
() => {
cloudOutputTest.beforeEach(async ({ comfyPage }) => {
await enableErrorsTab(comfyPage)
})
cloudOutputTest(
'resolves compact annotated output media from output assets',
async ({ cloudAssetRequests, comfyPage }) => {
await comfyPage.workflow.loadWorkflow(
'missing/missing_media_cloud_output_annotation'
)
await expect
.poll(() =>
cloudAssetRequests.some((url) =>
assetRequestIncludesTag(url, 'output')
)
)
.toBe(true)
await expectNoErrorsTab(comfyPage)
}
)
}
)
cloudUploadRaceTest.describe(
'Errors tab - Cloud missing media upload race',
{ tag: '@cloud' },
() => {
cloudUploadRaceTest.beforeEach(async ({ comfyPage }) => {
await enableErrorsTab(comfyPage)
})
cloudUploadRaceTest(
'does not surface missing media while dropped video upload is in progress',
async ({ comfyFiles, comfyPage, markUploadedCloudAssetAvailable }) => {
await comfyPage.nodeOps.clearGraph()
const delayedUpload = await delayNextUpload(comfyPage)
await comfyPage.dragDrop.dragAndDropFile(plainVideoFileName, {
dropPosition: graphDropPosition
})
await delayedUpload.waitForUploadStarted()
comfyFiles.deleteAfterTest({
filename: plainVideoFileName,
type: 'input'
})
await expectLoadVideoUploading(comfyPage)
await expectNoMissingMediaDuringUpload(comfyPage)
markUploadedCloudAssetAvailable()
await delayedUpload.finishUpload()
await expect(getErrorOverlay(comfyPage)).toBeHidden()
}
)
}
)

View File

@@ -120,13 +120,4 @@ test.describe('Node library sidebar V2', () => {
await expect(options.first()).toBeVisible()
await expect.poll(() => options.count()).toBeGreaterThanOrEqual(2)
})
test('Blueprint previews include description', async ({ comfyPage }) => {
const tab = comfyPage.menu.nodeLibraryTabV2
await tab.blueprintsTab.click()
await tab.getNode('test blueprint').hover()
await expect(tab.nodePreview, 'Preview displays on hover').toBeVisible()
await expect(tab.nodePreview).toContainText('Inverts the image')
})
})

View File

@@ -607,218 +607,3 @@ test.describe(
)
}
)
test('Promote/Demote by Context Menu @vue-nodes', async ({ comfyPage }) => {
await comfyPage.workflow.loadWorkflow('subgraphs/basic-subgraph')
const ksampler = comfyPage.vueNodes.getNodeLocator('1')
const steps = comfyPage.vueNodes.getWidgetByName('New Subgraph', 'steps')
const subgraphNode = comfyPage.vueNodes.getNodeLocator('2')
await test.step('Promote widget', async () => {
await comfyPage.vueNodes.enterSubgraph('2')
await comfyPage.subgraph.promoteWidget(ksampler, 'steps')
await comfyPage.subgraph.exitViaBreadcrumb()
await expect(steps).toBeVisible()
})
await test.step('Un-promote widget', async () => {
await comfyPage.vueNodes.enterSubgraph('2')
await comfyPage.subgraph.unpromoteWidget(ksampler, 'steps')
await comfyPage.subgraph.exitViaBreadcrumb()
await expect(subgraphNode).toBeVisible()
await expect(steps).toBeHidden()
})
})
test('Properties panel operations @vue-nodes', async ({ comfyPage }) => {
await comfyPage.workflow.loadWorkflow('subgraphs/basic-subgraph')
const { editor } = comfyPage.subgraph
const subgraphNode = comfyPage.vueNodes.getNodeLocator('2')
const steps = comfyPage.vueNodes.getWidgetByName('New Subgraph', 'steps')
const cfg = comfyPage.vueNodes.getWidgetByName('New Subgraph', 'cfg')
await editor.togglePromotion(subgraphNode, {
nodeName: 'KSampler',
widgetName: 'steps',
toState: true
})
await expect(steps, 'Promote widget').toBeVisible()
await editor.togglePromotion(subgraphNode, {
nodeName: 'KSampler',
widgetName: 'cfg',
toState: true
})
await expect(cfg, 'Promote widget').toBeVisible()
await test.step('widgets display in order promoted', async () => {
await expect(editor.promotionItems.first()).toContainText('steps')
await expect(subgraphNode.locator('.lg-node-widget').first()).toHaveText(
'steps'
)
})
await test.step('Reorder widgets', async () => {
await editor.dragItem(0, 1)
await expect(editor.promotionItems.first()).toContainText('cfg')
await expect(subgraphNode.locator('.lg-node-widget').first()).toHaveText(
'cfg'
)
})
await editor.togglePromotion(subgraphNode, {
nodeName: 'KSampler',
widgetName: 'steps',
toState: false
})
await expect(steps, 'Un-promote widget').toBeHidden()
})
test('Can intermix linked and proxy @vue-nodes', async ({ comfyPage }) => {
await comfyPage.workflow.loadWorkflow('subgraphs/basic-subgraph')
const { editor } = comfyPage.subgraph
const subgraphNode = comfyPage.vueNodes.getNodeLocator('2')
await test.step('Enter subgraph and link widget to input', async () => {
await comfyPage.vueNodes.enterSubgraph('2')
const ksampler = await comfyPage.vueNodes.getFixtureByTitle('KSampler')
await comfyPage.subgraph.promoteWidget(ksampler.root, 'cfg')
const fromSlot = ksampler.getSlot('steps')
const toPos = await comfyPage.subgraph.getInputSlot().getOpenSlotPosition()
await fromSlot.dragTo(comfyPage.canvas, { targetPosition: toPos })
const isConnected = () => comfyPage.vueNodes.isSlotConnected(fromSlot)
await expect.poll(isConnected).toBe(true)
await comfyPage.subgraph.exitViaBreadcrumb()
})
await expect(
subgraphNode.locator('.lg-node-widget').first(),
'linked widgets are first by default'
).toHaveText('steps')
await editor.open(subgraphNode)
await editor.dragItem(0, 1)
await expect(
editor.promotionItems.first(),
'Swap widget order'
).toContainText('cfg')
// FIXME: solve actual bug and remove the not
await expect(
subgraphNode.locator('.lg-node-widget').first(),
'Linked widget is first on node'
).not.toHaveText('cfg')
})
test('Link already promoted widget @vue-nodes', async ({ comfyPage }) => {
await comfyPage.workflow.loadWorkflow('subgraphs/basic-subgraph')
const { editor } = comfyPage.subgraph
const subgraphNode = comfyPage.vueNodes.getNodeLocator('2')
const steps = comfyPage.vueNodes.getWidgetByName('New Subgraph', 'steps')
await editor.togglePromotion(subgraphNode, {
nodeName: 'KSampler',
widgetName: 'steps',
toState: true
})
await expect(steps, 'Promote widget').toBeVisible()
await test.step('Enter subgraph and link widget to input', async () => {
await comfyPage.vueNodes.enterSubgraph('2')
const ksampler = await comfyPage.vueNodes.getFixtureByTitle('KSampler')
const fromSlot = ksampler.getSlot('steps')
const toPos = await comfyPage.subgraph.getInputSlot().getOpenSlotPosition()
await fromSlot.dragTo(comfyPage.canvas, { targetPosition: toPos })
const isConnected = () => comfyPage.vueNodes.isSlotConnected(fromSlot)
await expect.poll(isConnected).toBe(true)
await comfyPage.subgraph.exitViaBreadcrumb()
})
await expect(steps).toHaveCount(1)
})
test('Can promote multiple previews @vue-nodes', async ({ comfyPage }) => {
await comfyPage.settings.setSetting('Comfy.NodeSearchBoxImpl', 'v1 (legacy)')
await comfyPage.menu.topbar.newWorkflowButton.click()
await comfyPage.nextFrame()
await test.step('Add and rename a Load Image node', async () => {
await comfyPage.page.mouse.dblclick(300, 300, { delay: 5 })
await comfyPage.searchBox.fillAndSelectFirstNode('Load Image')
const loadImage = await comfyPage.vueNodes.getFixtureByTitle('Load Image')
await loadImage.setTitle('Character Reference')
})
await test.step('Add a second Load Image node', async () => {
await comfyPage.page.mouse.dblclick(600, 300, { delay: 5 })
await comfyPage.searchBox.fillAndSelectFirstNode('Load Image')
})
await test.step('Convert both nodes to subgraph', async () => {
await comfyPage.canvas.focus()
await comfyPage.page.keyboard.press('Control+a')
await comfyPage.contextMenu
.openFor(comfyPage.vueNodes.getNodeLocator('1'))
.then((m) => m.clickMenuItemExact('Convert to Subgraph'))
})
const { editor } = comfyPage.subgraph
const subgraph = await comfyPage.vueNodes.getFixtureByTitle('New Subgraph')
await test.step('Promote both image previews', async () => {
await editor.togglePromotion(subgraph.root, {
nodeId: '1',
widgetName: '$$canvas-image-preview',
toState: true
})
await expect(subgraph.content).toHaveCount(1)
await editor.togglePromotion(subgraph.root, {
nodeId: '2',
widgetName: '$$canvas-image-preview',
toState: true
})
await expect(subgraph.content).toHaveCount(2)
})
// FUTURE: Add test for re-ordering previews?
await test.step('Demote image', async () => {
await editor.togglePromotion(subgraph.root, {
nodeId: '1',
widgetName: '$$canvas-image-preview',
toState: false
})
await expect(subgraph.content).toHaveCount(1)
})
})
test('Linked widgets can not be demoted @vue-nodes', async ({ comfyPage }) => {
await comfyPage.workflow.loadWorkflow('subgraphs/basic-subgraph')
const { editor } = comfyPage.subgraph
const subgraphNode = comfyPage.vueNodes.getNodeLocator('2')
await test.step('Enter subgraph and link widget to input', async () => {
await comfyPage.vueNodes.enterSubgraph('2')
const ksampler = await comfyPage.vueNodes.getFixtureByTitle('KSampler')
const fromSlot = ksampler.getSlot('steps')
const toPos = await comfyPage.subgraph.getInputSlot().getOpenSlotPosition()
await fromSlot.dragTo(comfyPage.canvas, { targetPosition: toPos })
const isConnected = () => comfyPage.vueNodes.isSlotConnected(fromSlot)
await expect.poll(isConnected).toBe(true)
await comfyPage.subgraph.exitViaBreadcrumb()
})
await editor.open(subgraphNode)
const stepsItem = await editor.resolveItem({ widgetName: 'steps' })
await expect(editor.getToggleButton(stepsItem)).toBeDisabled()
})

View File

@@ -1133,108 +1133,3 @@ test.describe(
})
}
)
test.describe('Vue Node Widget Link Position', { tag: '@vue-nodes' }, () => {
test('should keep widget-input link aligned after persisted-workflow reload', async ({
comfyPage
}) => {
test.setTimeout(30000)
await comfyPage.workflow.loadWorkflow(
'vueNodes/ksampler-denoise-widget-link'
)
await comfyPage.vueNodes.waitForNodes(2)
await comfyPage.workflow.waitForDraftPersisted()
await comfyPage.workflow.reloadAndWaitForApp()
await comfyPage.vueNodes.waitForNodes(2)
const ksampler = await comfyPage.page.evaluate(() => {
const node = window.app!.graph.nodes.find((n) => n.type === 'KSampler')
if (!node) return null
const findIndex = (name: string) =>
node.inputs.findIndex(
(input) => input.name === name || input.widget?.name === name
)
return {
id: node.id,
denoiseIndex: findIndex('denoise'),
schedulerIndex: findIndex('scheduler')
}
})
if (!ksampler) {
throw new Error('KSampler should be present in fixture')
}
expect(
ksampler.denoiseIndex,
'denoise input slot not found'
).toBeGreaterThanOrEqual(0)
expect(
ksampler.schedulerIndex,
'scheduler input slot not found'
).toBeGreaterThanOrEqual(0)
const denoiseSlot = slotLocator(
comfyPage.page,
ksampler.id,
ksampler.denoiseIndex,
true
)
const schedulerSlot = slotLocator(
comfyPage.page,
ksampler.id,
ksampler.schedulerIndex,
true
)
await expectVisibleAll(denoiseSlot, schedulerSlot)
await expect
.poll(() =>
getInputLinkDetails(comfyPage.page, ksampler.id, ksampler.denoiseIndex)
)
.toMatchObject({
targetId: ksampler.id,
targetSlot: ksampler.denoiseIndex
})
// If the regression returns, getInputPos stays stale relative to the
// grown slot DOM and the endpoint drifts toward scheduler. Re-read
// positions each retry so layout settle doesn't cause flakes.
await expect(async () => {
const linkEnd = await comfyPage.page.evaluate(
([nodeId, targetSlotIndex]) => {
const node = window.app!.graph.getNodeById(nodeId)
if (!node) return null
const slotPos = node.getInputPos(targetSlotIndex)
const [cx, cy] = window.app!.canvas.ds.convertOffsetToCanvas([
slotPos[0],
slotPos[1]
])
const rect = window.app!.canvas.canvas.getBoundingClientRect()
return { x: cx + rect.left, y: cy + rect.top }
},
[ksampler.id, ksampler.denoiseIndex] as const
)
expect(linkEnd, 'link endpoint should resolve').not.toBeNull()
const denoiseCenter = await getCenter(denoiseSlot)
const schedulerCenter = await getCenter(schedulerSlot)
const distToDenoise = Math.hypot(
linkEnd!.x - denoiseCenter.x,
linkEnd!.y - denoiseCenter.y
)
const rowGap = Math.hypot(
denoiseCenter.x - schedulerCenter.x,
denoiseCenter.y - schedulerCenter.y
)
// Bound at rowGap / 4 - half the inter-slot midpoint, so any drift
// toward scheduler fails well before reaching it.
expect(
distToDenoise,
`Link endpoint (${linkEnd!.x.toFixed(1)}, ${linkEnd!.y.toFixed(1)}) is ` +
`${distToDenoise.toFixed(1)}px from denoise — should be within ` +
`${(rowGap / 4).toFixed(1)}px (quarter of inter-slot gap ${rowGap.toFixed(1)}px)`
).toBeLessThan(rowGap / 4)
}).toPass({ timeout: 5000 })
})
})

View File

@@ -1,56 +1,165 @@
import type { ComfyPage } from '@e2e/fixtures/ComfyPage'
import {
comfyExpect as expect,
comfyPageFixture as test
} from '@e2e/fixtures/ComfyPage'
import { MIN_NODE_WIDTH } from '@/renderer/core/layout/transform/graphRenderTransform'
import {
RESIZE_HANDLES,
hasNorthEdge,
hasWestEdge
} from '@/renderer/extensions/vueNodes/interactions/resize/resizeHandleConfig'
test.describe('Vue Node Resizing', { tag: '@vue-nodes' }, () => {
test('should resize node without position drift after selecting', async ({
comfyPage
}) => {
// Get a Vue node fixture
const node = await comfyPage.vueNodes.getFixtureByTitle('Load Checkpoint')
const initialBox = await node.boundingBox()
if (!initialBox) throw new Error('Node bounding box not found')
async function setupResizableNode(comfyPage: ComfyPage, title: string) {
await expect(comfyPage.vueNodes.getNodeByTitle(title)).toHaveCount(1)
const node = await comfyPage.vueNodes.getFixtureByTitle(title)
const box = await node.selectAndGetBox()
return { node, box }
}
// Select the node first (this was causing the bug)
await node.header.click()
test.describe(
'Vue Node Resizing',
{ tag: ['@vue-nodes', '@canvas', '@node'] },
() => {
let originalMinimapVisible: boolean | undefined
// Get position after selection
const selectedBox = await node.boundingBox()
if (!selectedBox)
throw new Error('Node bounding box not found after select')
// Minimap overlays the canvas and intercepts pointer events that land in
// its hit area during resize drags, so disable it for this suite. Capture
// and restore the prior value to avoid leaking the override to other specs
// that run on the same user-data-dir.
test.beforeEach(async ({ comfyPage }) => {
originalMinimapVisible = await comfyPage.settings.getSetting<boolean>(
'Comfy.Minimap.Visible'
)
await comfyPage.settings.setSetting('Comfy.Minimap.Visible', false)
await comfyPage.canvasOps.resetView()
})
// Verify position unchanged after selection
await expect
.poll(async () => (await node.boundingBox())?.x)
.toBeCloseTo(initialBox.x, 1)
await expect
.poll(async () => (await node.boundingBox())?.y)
.toBeCloseTo(initialBox.y, 1)
test.afterEach(async ({ comfyPage }) => {
if (originalMinimapVisible !== undefined) {
await comfyPage.settings.setSetting(
'Comfy.Minimap.Visible',
originalMinimapVisible
)
}
})
// Now resize from bottom-right corner
const resizeStartX = selectedBox.x + selectedBox.width - 5
const resizeStartY = selectedBox.y + selectedBox.height - 5
test('should resize node without position drift after selecting', async ({
comfyPage
}) => {
const { node, box: initialBox } = await setupResizableNode(
comfyPage,
'Load Checkpoint'
)
await comfyPage.page.mouse.move(resizeStartX, resizeStartY)
await comfyPage.page.mouse.down()
await comfyPage.page.mouse.move(resizeStartX + 50, resizeStartY + 30)
await comfyPage.page.mouse.up()
await node.expectAnchoredAt(initialBox)
// Position should NOT have changed (the bug was position drift)
await expect
.poll(async () => (await node.boundingBox())?.x)
.toBeCloseTo(initialBox.x, 1)
await expect
.poll(async () => (await node.boundingBox())?.y)
.toBeCloseTo(initialBox.y, 1)
await node.resizeFromCorner('SE', 50, 30)
// Size should have increased
await expect
.poll(async () => (await node.boundingBox())?.width)
.toBeGreaterThan(initialBox.width)
await expect
.poll(async () => (await node.boundingBox())?.height)
.toBeGreaterThan(initialBox.height)
})
})
await node.expectAnchoredAt(initialBox)
await expect.poll(node.pollWidth).toBeGreaterThan(initialBox.width)
await expect.poll(node.pollHeight).toBeGreaterThan(initialBox.height)
})
const cornerCases = RESIZE_HANDLES.map((h) => ({
corner: h.corner,
dragX: hasWestEdge(h.corner) ? -50 : 50,
dragY: hasNorthEdge(h.corner) ? -40 : 40
}))
test.describe('corner resize directions', () => {
cornerCases.forEach(({ corner, dragX, dragY }) => {
test(`${corner}: size increases and correct edges shift`, async ({
comfyPage
}) => {
const { node, box } = await setupResizableNode(comfyPage, 'KSampler')
await node.resizeFromCorner(corner, dragX, dragY)
await expect.poll(node.pollWidth).toBeGreaterThan(box.width)
await expect.poll(node.pollHeight).toBeGreaterThan(box.height)
if (hasWestEdge(corner)) {
await expect.poll(node.pollLeftEdge).toBeLessThan(box.x)
} else {
await expect.poll(node.pollLeftEdge).toBeCloseTo(box.x, 0)
}
if (hasNorthEdge(corner)) {
await expect.poll(node.pollTopEdge).toBeLessThan(box.y)
} else {
await expect.poll(node.pollTopEdge).toBeCloseTo(box.y, 0)
}
})
})
})
test.describe('opposite edge anchoring', () => {
cornerCases.forEach(({ corner, dragX, dragY }) => {
test(`${corner} resize keeps opposite corner fixed`, async ({
comfyPage
}) => {
const { node, box } = await setupResizableNode(comfyPage, 'KSampler')
const pollAnchorX = hasWestEdge(corner)
? node.pollRightEdge
: node.pollLeftEdge
const pollAnchorY = hasNorthEdge(corner)
? node.pollBottomEdge
: node.pollTopEdge
const anchorX = hasWestEdge(corner) ? box.x + box.width : box.x
const anchorY = hasNorthEdge(corner) ? box.y + box.height : box.y
await node.resizeFromCorner(corner, dragX, dragY)
await expect.poll(pollAnchorX).toBeCloseTo(anchorX, 0)
await expect.poll(pollAnchorY).toBeCloseTo(anchorY, 0)
})
})
})
test.describe('minimum size enforcement', () => {
test('SW resize clamps width, keeping right edge fixed', async ({
comfyPage
}) => {
const { node, box } = await setupResizableNode(comfyPage, 'KSampler')
const rightEdge = box.x + box.width
await node.resizeFromCorner('SW', box.width + 100, 0)
await expect.poll(node.pollRightEdge).toBeCloseTo(rightEdge, 0)
await expect.poll(node.pollWidth).toBeGreaterThanOrEqual(MIN_NODE_WIDTH)
})
test('NE resize clamps height at its lower bound', async ({
comfyPage
}) => {
const { node } = await setupResizableNode(comfyPage, 'KSampler')
// Default nodes render at content-minimum height; grow from SE so NE
// has room to shrink back down to the clamp.
await node.resizeFromCorner('SE', 0, 200)
const expandedBox = await node.boundingBox()
if (!expandedBox)
throw new Error('Node bounding box not found after SE grow')
const bottomEdge = expandedBox.y + expandedBox.height
// Overdrag once to hit the clamp, then again to prove further dragging
// does not shrink past the minimum (idempotent clamp).
await node.resizeFromCorner('NE', 0, expandedBox.height + 100)
const clampedHeight = (await node.boundingBox())?.height
if (clampedHeight === undefined)
throw new Error('Node bounding box not found after NE clamp')
expect(clampedHeight).toBeLessThan(expandedBox.height)
await node.resizeFromCorner('NE', 0, 200)
await expect.poll(node.pollHeight).toBeCloseTo(clampedHeight, 0)
await expect.poll(node.pollBottomEdge).toBeCloseTo(bottomEdge, 0)
})
})
}
)

View File

@@ -36,19 +36,8 @@ WORKFLOW = {
}
PROMPT = {'1': {'class_type': 'KSampler', 'inputs': {}}}
# API-format prompt with bare NaN/Infinity tokens (as Python's json.dumps emits
# by default). The NaN variant fixtures omit the workflow field so the loader
# must route through prompt-parsing, which trips JSON.parse on bare NaN.
PROMPT_NAN = {
'1': {
'class_type': 'KSampler',
'inputs': {'cfg': float('nan'), 'denoise': float('inf')},
}
}
WORKFLOW_JSON = json.dumps(WORKFLOW, separators=(',', ':'))
PROMPT_JSON = json.dumps(PROMPT, separators=(',', ':'))
PROMPT_NAN_JSON = json.dumps(PROMPT_NAN, separators=(',', ':'))
def out(name: str) -> str:
@@ -64,21 +53,15 @@ def make_1x1_image() -> Image.Image:
return Image.new('RGB', (1, 1), (255, 0, 0))
def build_exif_bytes(
workflow_str: str | None = WORKFLOW_JSON,
prompt_str: str | None = PROMPT_JSON,
) -> bytes:
def build_exif_bytes() -> bytes:
"""Build EXIF bytes matching the backend's tag assignments.
Backend: 0x010F (Make) = "workflow:<json>", 0x0110 (Model) = "prompt:<json>"
Pass ``None`` to omit a tag.
"""
img = make_1x1_image()
exif = img.getexif()
if workflow_str is not None:
exif[0x010F] = f'workflow:{workflow_str}'
if prompt_str is not None:
exif[0x0110] = f'prompt:{prompt_str}'
exif[0x010F] = f'workflow:{WORKFLOW_JSON}'
exif[0x0110] = f'prompt:{PROMPT_JSON}'
return exif.tobytes()
@@ -110,9 +93,6 @@ def generate_av_fixture(
codec: str,
rate: int = 44100,
options: dict | None = None,
*,
prompt_json: str | None = PROMPT_JSON,
workflow_json: str | None = WORKFLOW_JSON,
):
"""Generate an audio fixture via PyAV container.metadata[], matching the backend."""
path = out(name)
@@ -120,10 +100,8 @@ def generate_av_fixture(
stream = container.add_stream(codec, rate=rate)
stream.layout = 'mono'
if prompt_json is not None:
container.metadata['prompt'] = prompt_json
if workflow_json is not None:
container.metadata['workflow'] = workflow_json
container.metadata['prompt'] = PROMPT_JSON
container.metadata['workflow'] = WORKFLOW_JSON
sample_fmt = stream.codec_context.codec.audio_formats[0].name
samples = stream.codec_context.frame_size or 1024
@@ -197,63 +175,6 @@ def generate_webm():
generate_av_fixture('with_metadata.webm', 'webm', 'libvorbis')
def generate_nan_variants():
"""Per-format fixtures carrying ONLY a NaN/Infinity-laden API prompt.
These force the loader through the prompt-parsing path, where Python's
bare NaN/Infinity tokens trip JSON.parse.
"""
img = make_1x1_image()
info = PngInfo()
info.add_text('prompt', PROMPT_NAN_JSON)
img.save(out('with_nan_metadata.png'), 'PNG', pnginfo=info)
report('with_nan_metadata.png')
exif_nan = build_exif_bytes(workflow_str=None, prompt_str=PROMPT_NAN_JSON)
img = make_1x1_image()
img.save(out('with_nan_metadata.webp'), 'WEBP', exif=exif_nan)
report('with_nan_metadata.webp')
img = make_1x1_image()
img.save(out('with_nan_metadata.avif'), 'AVIF', exif=exif_nan)
report('with_nan_metadata.avif')
generate_av_fixture(
'with_nan_metadata.flac', 'flac', 'flac',
prompt_json=PROMPT_NAN_JSON, workflow_json=None,
)
generate_av_fixture(
'with_nan_metadata.opus', 'opus', 'libopus', rate=48000,
prompt_json=PROMPT_NAN_JSON, workflow_json=None,
)
generate_av_fixture(
'with_nan_metadata.mp3', 'mp3', 'libmp3lame',
prompt_json=PROMPT_NAN_JSON, workflow_json=None,
)
generate_av_fixture(
'with_nan_metadata.webm', 'webm', 'libvorbis',
prompt_json=PROMPT_NAN_JSON, workflow_json=None,
)
path = out('with_nan_metadata.mp4')
subprocess.run([
'ffmpeg', '-y', '-loglevel', 'error',
'-f', 'lavfi', '-i', 'anullsrc=r=44100:cl=mono',
'-t', '0.01', '-c:a', 'aac', '-b:a', '32k',
'-movflags', 'use_metadata_tags',
'-metadata', f'prompt={PROMPT_NAN_JSON}',
path,
], check=True)
report('with_nan_metadata.mp4')
# Direct JSON file containing API-format prompt with bare NaN/Infinity.
json_path = out('with_nan_metadata.json')
with open(json_path, 'w', encoding='utf-8') as f:
f.write(PROMPT_NAN_JSON)
report('with_nan_metadata.json')
if __name__ == '__main__':
print('Generating fixtures...')
generate_png()
@@ -264,5 +185,4 @@ if __name__ == '__main__':
generate_mp3()
generate_mp4()
generate_webm()
generate_nan_variants()
print('Done.')

View File

@@ -141,21 +141,6 @@ describe('PointerZone', () => {
y: 45
})
})
it('should preventDefault on wheel to block browser zoom on ctrl+wheel', () => {
renderZone()
const zone = getZone()
const event = new WheelEvent('wheel', {
bubbles: true,
cancelable: true,
deltaY: -1,
ctrlKey: true
})
zone.dispatchEvent(event)
expect(event.defaultPrevented).toBe(true)
})
})
describe('isPanning watcher', () => {

View File

@@ -11,7 +11,7 @@
@touchstart="handleTouchStart"
@touchmove="handleTouchMove"
@touchend="handleTouchEnd"
@wheel.prevent="handleWheel"
@wheel="handleWheel"
@contextmenu.prevent
/>
</template>

View File

@@ -2,7 +2,6 @@
<div
class="flex flex-col overflow-hidden rounded-lg border border-border-default bg-base-background"
:style="{ width: `${BASE_WIDTH_PX * (scaleFactor / BASE_SCALE)}px` }"
data-testid="node-preview-card"
>
<div ref="previewContainerRef" class="overflow-hidden p-3">
<div

View File

@@ -263,7 +263,6 @@ onMounted(() => {
<SubgraphNodeWidget
v-for="[node, widget] in filteredActive"
:key="toKey([node, widget])"
:data-nodeid="node.id"
:class="cn(!searchQuery && dragClass, 'bg-comfy-menu-bg')"
:node-title="node.title"
:widget-name="widget.label || widget.name"
@@ -296,7 +295,6 @@ onMounted(() => {
<SubgraphNodeWidget
v-for="[node, widget] in filteredCandidates"
:key="toKey([node, widget])"
:data-nodeid="node.id"
class="bg-comfy-menu-bg"
:node-title="node.title"
:widget-name="widget.name"

View File

@@ -41,13 +41,9 @@ const icon = computed(() =>
className
)
"
data-testid="subgraph-widget-item"
>
<div class="pointer-events-none flex-1">
<div
class="line-clamp-1 text-xs text-text-secondary"
data-testid="subgraph-widget-node-name"
>
<div class="line-clamp-1 text-xs text-text-secondary">
{{ nodeTitle }}
</div>
<div class="line-clamp-1 text-sm/8" data-testid="subgraph-widget-label">

View File

@@ -1837,7 +1837,6 @@ export class LGraphCanvas implements CustomEventDispatcher<LGraphCanvasEventMap>
// this.offset = [0,0];
this.dragging_rectangle = null
for (const item of this.selectedItems.keys()) item.selected = undefined
this.selected_nodes = {}
this.selected_group = null
this.selectedItems.clear()

View File

@@ -1380,6 +1380,9 @@ export class LGraphNode
changeMode(modeTo: number): boolean {
switch (modeTo) {
case LGraphEventMode.ON_EVENT:
break
case LGraphEventMode.ON_TRIGGER:
this.addOnTriggerInput()
this.addOnExecutedOutput()
@@ -1396,8 +1399,7 @@ export class LGraphNode
break
default:
// Numeric default-accept: any caller-supplied numeric mode (including
// the deprecated slot 1 / ON_EVENT) falls through and is assigned.
return false
break
}
this.mode = modeTo

View File

@@ -122,9 +122,7 @@ export class LiteGraphGlobal {
/** use with node_box_coloured_by_mode */
NODE_MODES_COLORS = ['#666', '#422', '#333', '#224', '#626']
ALWAYS = LGraphEventMode.ALWAYS
// ON_EVENT is registered as a deprecation getter in the constructor — see
// Object.defineProperty call below. The numeric slot (1) is preserved for
// v2 ABI; the symbol will be removed in release N+1.
ON_EVENT = LGraphEventMode.ON_EVENT
NEVER = LGraphEventMode.NEVER
ON_TRIGGER = LGraphEventMode.ON_TRIGGER
@@ -374,15 +372,6 @@ export class LiteGraphGlobal {
constructor() {
Object.defineProperty(this, 'Classes', { writable: false })
Object.defineProperty(this, 'ON_EVENT', {
get() {
console.warn(
'LiteGraph.ON_EVENT is deprecated; numeric slot 1 is preserved for v2 ABI but the symbol will be removed in release N+1. ON_EVENT is a no-op mode — use NEVER to mute a node.'
)
return 1
},
configurable: true
})
}
Classes = {

View File

@@ -82,9 +82,7 @@ export enum TitleMode {
export enum LGraphEventMode {
ALWAYS = 0,
/** @deprecated No-op mode. Numeric slot 1 is preserved for v2 ABI; the
* symbol will be removed in release N+1. Use NEVER to mute a node. */
_UNUSED_1 = 1,
ON_EVENT = 1,
NEVER = 2,
ON_TRIGGER = 3,
BYPASS = 4

View File

@@ -9,7 +9,6 @@ import { getOutputAssetMetadata } from '@/platform/assets/schemas/assetMetadataS
import { getAssetUrl } from '@/platform/assets/utils/assetUrlUtil'
import { getWorkflowDataFromFile } from '@/scripts/metadata/parser'
import { getJobWorkflow } from '@/services/jobOutputCache'
import { parseJsonWithNonFinite } from '@/utils/jsonUtil'
/**
* Extract workflow from AssetItem using jobs API
@@ -52,11 +51,11 @@ export async function extractWorkflowFromAsset(asset: AssetItem): Promise<{
// Handle both string and object workflow data
const workflow =
typeof workflowData.workflow === 'string'
? parseJsonWithNonFinite<ComfyWorkflowJSON>(workflowData.workflow)
: (workflowData.workflow as ComfyWorkflowJSON)
? JSON.parse(workflowData.workflow)
: workflowData.workflow
return {
workflow,
workflow: workflow as ComfyWorkflowJSON,
filename: baseFilename
}
}

View File

@@ -216,6 +216,7 @@
v-for="handle in RESIZE_HANDLES"
:key="handle.corner"
role="button"
:data-corner="handle.corner"
:aria-label="t(handle.i18nKey)"
:class="
cn(

View File

@@ -90,7 +90,6 @@ import { useCanvasInteractions } from '@/renderer/core/canvas/useCanvasInteracti
import AppInput from '@/renderer/extensions/linearMode/AppInput.vue'
import { useNodeZIndex } from '@/renderer/extensions/vueNodes/composables/useNodeZIndex'
import { useProcessedWidgets } from '@/renderer/extensions/vueNodes/composables/useProcessedWidgets'
import { useVueElementTracking } from '@/renderer/extensions/vueNodes/composables/useVueNodeResizeTracking'
import { cn } from '@comfyorg/tailwind-utils'
import InputSlot from './InputSlot.vue'
@@ -135,9 +134,4 @@ const {
processedWidgets,
showAdvanced
} = useProcessedWidgets(() => nodeData)
// Tracks widget-row growth that the node-level RO can't see
if (nodeData?.id != null) {
useVueElementTracking(String(nodeData.id), 'widgets-grid')
}
</script>

View File

@@ -29,10 +29,7 @@ const raf = createRafBatch(() => {
flushScheduledSlotLayoutSync()
})
export function scheduleSlotLayoutSync(nodeId: string) {
// Drop signals for unregistered nodes (e.g. preview nodes with synthetic
// ids from LGraphNodePreview) - they'd otherwise pump setDirty per RAF.
if (!useNodeSlotRegistryStore().getNode(nodeId)) return
function scheduleSlotLayoutSync(nodeId: string) {
pendingNodes.add(nodeId)
raf.schedule()
}

View File

@@ -43,8 +43,7 @@ const testState = vi.hoisted(() => ({
nodeLayouts: new Map<NodeId, NodeLayout>(),
batchUpdateNodeBounds: vi.fn(),
setSource: vi.fn(),
syncNodeSlotLayoutsFromDOM: vi.fn(),
scheduleSlotLayoutSync: vi.fn()
syncNodeSlotLayoutsFromDOM: vi.fn()
}))
vi.mock('@vueuse/core', () => ({
@@ -74,7 +73,6 @@ vi.mock('@/renderer/core/layout/store/layoutStore', () => ({
}))
vi.mock('./useSlotElementTracking', () => ({
scheduleSlotLayoutSync: testState.scheduleSlotLayoutSync,
syncNodeSlotLayoutsFromDOM: testState.syncNodeSlotLayoutsFromDOM
}))
@@ -161,7 +159,6 @@ describe('useVueNodeResizeTracking', () => {
testState.batchUpdateNodeBounds.mockReset()
testState.setSource.mockReset()
testState.syncNodeSlotLayoutsFromDOM.mockReset()
testState.scheduleSlotLayoutSync.mockReset()
resizeObserverState.observe.mockReset()
resizeObserverState.unobserve.mockReset()
resizeObserverState.disconnect.mockReset()
@@ -320,25 +317,4 @@ describe('useVueNodeResizeTracking', () => {
expect(testState.setSource).toHaveBeenCalledWith(LayoutSource.DOM)
expect(testState.batchUpdateNodeBounds).toHaveBeenCalled()
})
it('widgets-grid resize schedules a slot resync without writing node bounds', () => {
const parentNodeId: NodeId = 'parent-node'
const element = document.createElement('div')
element.dataset.widgetsGridNodeId = parentNodeId
const boxSizes = [{ inlineSize: 200, blockSize: 80 }]
const entry = {
target: element,
borderBoxSize: boxSizes,
contentBoxSize: boxSizes,
devicePixelContentBoxSize: boxSizes,
contentRect: new DOMRect(0, 0, 200, 80)
} satisfies ResizeEntryLike
resizeObserverState.callback?.([entry], createObserverMock())
expect(testState.scheduleSlotLayoutSync).toHaveBeenCalledWith(parentNodeId)
expect(testState.batchUpdateNodeBounds).not.toHaveBeenCalled()
expect(testState.setSource).not.toHaveBeenCalled()
expect(testState.syncNodeSlotLayoutsFromDOM).not.toHaveBeenCalled()
})
})

View File

@@ -24,10 +24,7 @@ import {
} from '@/renderer/core/layout/utils/geometry'
import { removeNodeTitleHeight } from '@/renderer/core/layout/utils/nodeSizeUtil'
import {
scheduleSlotLayoutSync,
syncNodeSlotLayoutsFromDOM
} from './useSlotElementTracking'
import { syncNodeSlotLayoutsFromDOM } from './useSlotElementTracking'
/**
* Generic update item for element bounds tracking
@@ -50,14 +47,14 @@ interface CachedNodeMeasurement {
interface ElementTrackingConfig {
/** Data attribute name (e.g., 'nodeId') */
dataAttribute: string
/** Handler for processing bounds updates. Omit for signal-only entries. */
updateHandler?: (updates: ElementBoundsUpdate[]) => void
/** Handler for processing bounds updates */
updateHandler: (updates: ElementBoundsUpdate[]) => void
}
/**
* Registry of tracking configurations by element type
*/
const trackingConfigs = new Map<string, ElementTrackingConfig>([
const trackingConfigs: Map<string, ElementTrackingConfig> = new Map([
[
'node',
{
@@ -70,10 +67,7 @@ const trackingConfigs = new Map<string, ElementTrackingConfig>([
layoutStore.batchUpdateNodeBounds(nodeUpdates)
}
}
],
// Signal-only: outer node stays at its persisted min-h floor during
// widget hydration, so the inner grid's RO is the only slot-drift signal.
['widgets-grid', { dataAttribute: 'widgetsGridNodeId' }]
]
])
// Elements whose ResizeObserver fired while the tab was hidden
@@ -127,14 +121,6 @@ const resizeObserver = new ResizeObserver((entries) => {
if (!(entry.target instanceof HTMLElement)) continue
const element = entry.target
// Signal-only widgets-grid resize - route the parent node through the
// slot-layout pipeline and skip bounds processing entirely.
const widgetsGridParentNodeId = element.dataset.widgetsGridNodeId
if (widgetsGridParentNodeId) {
scheduleSlotLayoutSync(widgetsGridParentNodeId as NodeId)
continue
}
// Find which type this element belongs to
let elementType: string | undefined
let elementId: string | undefined
@@ -252,7 +238,7 @@ const resizeObserver = new ResizeObserver((entries) => {
// Flush per-type
for (const [type, updates] of updatesByType) {
const config = trackingConfigs.get(type)
if (config?.updateHandler && updates.length) config.updateHandler(updates)
if (config && updates.length) config.updateHandler(updates)
}
}

View File

@@ -0,0 +1,36 @@
import { describe, expect, it } from 'vitest'
import type { CompassCorners } from '@/lib/litegraph/src/interfaces'
import { RESIZE_HANDLES, hasNorthEdge, hasWestEdge } from './resizeHandleConfig'
describe('hasWestEdge', () => {
it.each<[CompassCorners, boolean]>([
['NW', true],
['SW', true],
['NE', false],
['SE', false]
])('corner %s -> %s', (corner, expected) => {
expect(hasWestEdge(corner)).toBe(expected)
})
})
describe('hasNorthEdge', () => {
it.each<[CompassCorners, boolean]>([
['NW', true],
['NE', true],
['SW', false],
['SE', false]
])('corner %s -> %s', (corner, expected) => {
expect(hasNorthEdge(corner)).toBe(expected)
})
})
describe('RESIZE_HANDLES', () => {
it('defines exactly one entry per CompassCorners member', () => {
const expected = new Set<CompassCorners>(['NE', 'NW', 'SE', 'SW'])
const actual = new Set(RESIZE_HANDLES.map((handle) => handle.corner))
expect(actual).toEqual(expected)
expect(RESIZE_HANDLES).toHaveLength(expected.size)
})
})

View File

@@ -43,3 +43,11 @@ export const RESIZE_HANDLES: ResizeHandle[] = [
svgTransform: 'scale(-1, -1)'
}
] as const
/** True for corners on the left edge of a node (SW, NW) — these move the x-origin when dragged. */
export const hasWestEdge = (corner: CompassCorners): boolean =>
corner === 'SW' || corner === 'NW'
/** True for corners on the top edge of a node (NE, NW) — these move the y-origin when dragged. */
export const hasNorthEdge = (corner: CompassCorners): boolean =>
corner === 'NE' || corner === 'NW'

View File

@@ -8,6 +8,10 @@ import { MIN_NODE_WIDTH } from '@/renderer/core/layout/transform/graphRenderTran
import { useNodeSnap } from '@/renderer/extensions/vueNodes/composables/useNodeSnap'
import { useShiftKeySync } from '@/renderer/extensions/vueNodes/composables/useShiftKeySync'
import { useTransformState } from '@/renderer/core/layout/transform/useTransformState'
import {
hasNorthEdge,
hasWestEdge
} from '@/renderer/extensions/vueNodes/interactions/resize/resizeHandleConfig'
export interface ResizeCallbackPayload {
size: Size
@@ -135,20 +139,23 @@ export function useNodeResize(
break
}
const isWestCorner = hasWestEdge(activeCorner)
const isNorthCorner = hasNorthEdge(activeCorner)
// Apply snap-to-grid
if (shouldSnap(moveEvent)) {
// Snap position first for N/W corners, then compensate size
if (activeCorner.includes('N') || activeCorner.includes('W')) {
if (isNorthCorner || isWestCorner) {
const originalX = newX
const originalY = newY
const snapped = applySnapToPosition({ x: newX, y: newY })
newX = snapped.x
newY = snapped.y
if (activeCorner.includes('N')) {
if (isNorthCorner) {
newHeight += originalY - newY
}
if (activeCorner.includes('W')) {
if (isWestCorner) {
newWidth += originalX - newX
}
}
@@ -166,7 +173,7 @@ export function useNodeResize(
parseFloat(nodeElement.style.getPropertyValue('min-width') || '0') ||
MIN_NODE_WIDTH
if (newWidth < minWidth) {
if (activeCorner.includes('W')) {
if (isWestCorner) {
newX =
resizeStartPosition.value.x + resizeStartSize.value.width - minWidth
}
@@ -179,7 +186,7 @@ export function useNodeResize(
// a responsive breakpoint.
const minContentHeight = measureMinContentHeight(newWidth)
if (newHeight < minContentHeight) {
if (activeCorner.includes('N')) {
if (isNorthCorner) {
newY =
resizeStartPosition.value.y +
resizeStartSize.value.height -

View File

@@ -84,7 +84,6 @@ import type { ComfyExtension, MissingNodeType } from '@/types/comfy'
import type { ExtensionManager } from '@/types/extensionTypes'
import type { NodeExecutionId } from '@/types/nodeIdentification'
import { graphToPrompt } from '@/utils/executionUtil'
import { parseJsonWithNonFinite } from '@/utils/jsonUtil'
import { getCnrIdFromProperties } from '@/platform/nodeReplacement/cnrIdUtil'
import { rescanAndSurfaceMissingNodes } from '@/platform/nodeReplacement/missingNodeScan'
import {
@@ -1092,7 +1091,7 @@ export class ComfyApp {
}
// Check for old clipboard format
const data = parseJsonWithNonFinite<{ reroutes?: unknown }>(template.data)
const data = JSON.parse(template.data)
if (!data.reroutes) {
deserialiseAndCreate(template.data, app.canvas)
} else {
@@ -1803,9 +1802,7 @@ export class ComfyApp {
let workflowObj: ComfyWorkflowJSON | undefined = undefined
try {
workflowObj =
typeof workflow === 'string'
? parseJsonWithNonFinite<ComfyWorkflowJSON>(workflow)
: (workflow as ComfyWorkflowJSON)
typeof workflow === 'string' ? JSON.parse(workflow) : workflow
// Only load workflow if parsing succeeded AND validation passed
if (
@@ -1834,9 +1831,7 @@ export class ComfyApp {
if (prompt) {
try {
const promptObj =
typeof prompt === 'string'
? parseJsonWithNonFinite<ComfyApiWorkflow>(prompt)
: prompt
typeof prompt === 'string' ? JSON.parse(prompt) : prompt
if (this.isApiJson(promptObj)) {
this.loadApiJson(promptObj, fileName)
return

View File

@@ -8,12 +8,6 @@ export const EXPECTED_PROMPT = {
'1': { class_type: 'KSampler', inputs: {} }
}
// API prompt as parsed from the `with_nan_metadata.*` fixtures, after the
// loader coerces bare NaN/Infinity tokens to null.
export const EXPECTED_PROMPT_NAN_COERCED = {
'1': { class_type: 'KSampler', inputs: { cfg: null, denoise: null } }
}
type ReadMethod = 'readAsText' | 'readAsArrayBuffer'
export function mockFileReaderError(method: ReadMethod): void {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 486 B

View File

@@ -1 +0,0 @@
{"1":{"class_type":"KSampler","inputs":{"cfg":NaN,"denoise":Infinity}}}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 159 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 200 B

View File

@@ -4,7 +4,6 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import {
EXPECTED_PROMPT,
EXPECTED_PROMPT_NAN_COERCED,
EXPECTED_WORKFLOW,
mockFileReaderAbort,
mockFileReaderError
@@ -12,10 +11,6 @@ import {
import { getFromAvifFile } from './avif'
const fixturePath = path.resolve(__dirname, '__fixtures__/with_metadata.avif')
const nanFixturePath = path.resolve(
__dirname,
'__fixtures__/with_nan_metadata.avif'
)
afterEach(() => vi.restoreAllMocks())
@@ -30,16 +25,6 @@ describe('AVIF metadata', () => {
expect(JSON.parse(result.prompt)).toEqual(EXPECTED_PROMPT)
})
it('parses Python generated prompt with bare NaN/Infinity tokens', async () => {
const bytes = fs.readFileSync(nanFixturePath)
const file = new File([bytes], 'nan.avif', { type: 'image/avif' })
const result = await getFromAvifFile(file)
expect(result.workflow).toBeUndefined()
expect(JSON.parse(result.prompt)).toEqual(EXPECTED_PROMPT_NAN_COERCED)
})
it('returns empty for non-AVIF data', async () => {
vi.spyOn(console, 'error').mockImplementation(() => {})
const file = new File([new Uint8Array(16)], 'fake.avif')

View File

@@ -1,7 +1,3 @@
import type {
ComfyApiWorkflow,
ComfyWorkflowJSON
} from '@/platform/workflow/validation/schemas/workflowSchema'
import {
type AvifIinfBox,
type AvifIlocBox,
@@ -10,7 +6,6 @@ import {
ComfyMetadataTags,
type IsobmffBoxContentRange
} from '@/types/metadataTypes'
import { parseJsonWithNonFinite } from '@/utils/jsonUtil'
const readNullTerminatedString = (
dataView: DataView,
@@ -286,10 +281,7 @@ function parseAvifMetadata(buffer: ArrayBuffer): ComfyMetadata {
if (typeof value === 'string') {
if (key === 'usercomment') {
try {
const metadataJson = parseJsonWithNonFinite<{
prompt?: ComfyApiWorkflow
workflow?: ComfyWorkflowJSON
}>(value)
const metadataJson = JSON.parse(value)
if (metadataJson.prompt) {
metadata[ComfyMetadataTags.PROMPT] = metadataJson.prompt
}
@@ -309,9 +301,7 @@ function parseAvifMetadata(buffer: ArrayBuffer): ComfyMetadata {
ComfyMetadataTags.WORKFLOW.toLowerCase()
) {
try {
const jsonValue = parseJsonWithNonFinite<
ComfyApiWorkflow | ComfyWorkflowJSON
>(metadataValue)
const jsonValue = JSON.parse(metadataValue)
metadata[metadataKey.toLowerCase() as keyof ComfyMetadata] =
jsonValue
} catch (e) {

View File

@@ -4,7 +4,6 @@ import { afterEach, describe, expect, it, vi } from 'vitest'
import {
EXPECTED_PROMPT,
EXPECTED_PROMPT_NAN_COERCED,
EXPECTED_WORKFLOW,
mockFileReaderAbort,
mockFileReaderError
@@ -12,10 +11,6 @@ import {
import { getFromWebmFile } from './ebml'
const fixturePath = path.resolve(__dirname, '__fixtures__/with_metadata.webm')
const nanFixturePath = path.resolve(
__dirname,
'__fixtures__/with_nan_metadata.webm'
)
describe('WebM/EBML metadata', () => {
it('extracts workflow and prompt from EBML SimpleTag elements', async () => {
@@ -28,16 +23,6 @@ describe('WebM/EBML metadata', () => {
expect(result.prompt).toEqual(EXPECTED_PROMPT)
})
it('parses Python generated prompt with bare NaN/Infinity tokens', async () => {
const bytes = fs.readFileSync(nanFixturePath)
const file = new File([bytes], 'nan.webm', { type: 'video/webm' })
const result = await getFromWebmFile(file)
expect(result.workflow).toBeUndefined()
expect(result.prompt).toEqual(EXPECTED_PROMPT_NAN_COERCED)
})
it('returns empty for non-WebM data', async () => {
const file = new File([new Uint8Array(16)], 'fake.webm')

View File

@@ -10,7 +10,6 @@ import {
type TextRange,
type VInt
} from '@/types/metadataTypes'
import { parseJsonWithNonFinite } from '@/utils/jsonUtil'
const WEBM_SIGNATURE = [0x1a, 0x45, 0xdf, 0xa3]
const MAX_READ_BYTES = 2 * 1024 * 1024
@@ -246,9 +245,7 @@ const parseJsonText = (
if (jsonEndPos === null) return null
try {
return parseJsonWithNonFinite<ComfyWorkflowJSON | ComfyApiWorkflow>(
jsonText.substring(0, jsonEndPos)
)
return JSON.parse(jsonText.substring(0, jsonEndPos))
} catch {
return null
}

View File

@@ -3,7 +3,6 @@ import { afterEach, describe, expect, it, vi } from 'vitest'
import { ASCII, GltfSizeBytes } from '@/types/metadataTypes'
import {
EXPECTED_PROMPT_NAN_COERCED,
mockFileReaderAbort,
mockFileReaderError
} from './__fixtures__/helpers'
@@ -16,6 +15,12 @@ describe('GLTF binary metadata parser', () => {
return { header, headerView }
}
const jsonToBinary = (json: object) => {
const jsonString = JSON.stringify(json)
const jsonData = new TextEncoder().encode(jsonString)
return jsonData
}
const createJSONChunk = (jsonData: ArrayBuffer) => {
const chunkHeader = new ArrayBuffer(GltfSizeBytes.CHUNK_HEADER)
const chunkView = new DataView(chunkHeader)
@@ -46,14 +51,7 @@ describe('GLTF binary metadata parser', () => {
}
function createMockGltfFile(jsonContent: object): File {
return createMockGltfFileFromText(JSON.stringify(jsonContent))
}
// Builds a GLB whose JSON chunk is the literal text passed in - used to
// embed Python generated bare NaN/Infinity tokens that JSON.stringify
// would otherwise coerce to null.
function createMockGltfFileFromText(jsonText: string): File {
const jsonData = new TextEncoder().encode(jsonText)
const jsonData = jsonToBinary(jsonContent)
const { header, headerView } = createGLTFFileStructure()
setHeaders(headerView, jsonData.buffer)
@@ -161,18 +159,6 @@ describe('GLTF binary metadata parser', () => {
expect(workflow.nodes[0].type).toBe('StringifiedNode')
})
it('parses Python generated prompt with bare NaN/Infinity tokens', async () => {
const pythonJsonText =
'{"asset":{"version":"2.0","extras":{"prompt":' +
'{"1":{"class_type":"KSampler","inputs":{"cfg":NaN,"denoise":Infinity}}}' +
'}}}'
const mockFile = createMockGltfFileFromText(pythonJsonText)
const metadata = await getGltfBinaryMetadata(mockFile)
expect(metadata.prompt).toEqual(EXPECTED_PROMPT_NAN_COERCED)
})
it('should handle invalid GLTF binary files gracefully', async () => {
const invalidEmptyFile = new File([], 'invalid.glb')
const metadata = await getGltfBinaryMetadata(invalidEmptyFile)

View File

@@ -11,7 +11,6 @@ import {
type GltfJsonData,
GltfSizeBytes
} from '@/types/metadataTypes'
import { parseJsonWithNonFinite } from '@/utils/jsonUtil'
const MAX_READ_BYTES = 1 << 20
@@ -82,17 +81,19 @@ const extractJsonChunkData = (buffer: ArrayBuffer): Uint8Array | null => {
return new Uint8Array(buffer, chunkLocation.start, chunkLocation.length)
}
const parseJson = <T = unknown>(text: string): T | null => {
const parseJson = (text: string): ReturnType<typeof JSON.parse> | null => {
try {
return parseJsonWithNonFinite<T>(text)
return JSON.parse(text)
} catch {
return null
}
}
const parseJsonBytes = <T = unknown>(bytes: Uint8Array): T | null => {
const parseJsonBytes = (
bytes: Uint8Array
): ReturnType<typeof JSON.parse> | null => {
const jsonString = byteArrayToString(bytes)
return parseJson<T>(jsonString)
return parseJson(jsonString)
}
const parseMetadataValue = (
@@ -101,7 +102,10 @@ const parseMetadataValue = (
if (typeof value !== 'string')
return value as ComfyWorkflowJSON | ComfyApiWorkflow
return parseJson<ComfyWorkflowJSON | ComfyApiWorkflow>(value) ?? undefined
const parsed = parseJson(value)
if (!parsed) return undefined
return parsed as ComfyWorkflowJSON | ComfyApiWorkflow
}
const extractComfyMetadata = (jsonData: GltfJsonData): ComfyMetadata => {
@@ -132,7 +136,7 @@ const processGltfFileBuffer = (buffer: ArrayBuffer): ComfyMetadata => {
const jsonChunk = extractJsonChunkData(buffer)
if (!jsonChunk) return {}
const parsedJson = parseJsonBytes<GltfJsonData>(jsonChunk)
const parsedJson = parseJsonBytes(jsonChunk)
if (!parsedJson) return {}
return extractComfyMetadata(parsedJson)

View File

@@ -4,7 +4,6 @@ import { afterEach, describe, expect, it, vi } from 'vitest'
import {
EXPECTED_PROMPT,
EXPECTED_PROMPT_NAN_COERCED,
EXPECTED_WORKFLOW,
mockFileReaderAbort,
mockFileReaderError
@@ -12,10 +11,6 @@ import {
import { getFromIsobmffFile } from './isobmff'
const fixturePath = path.resolve(__dirname, '__fixtures__/with_metadata.mp4')
const nanFixturePath = path.resolve(
__dirname,
'__fixtures__/with_nan_metadata.mp4'
)
describe('ISOBMFF (MP4) metadata', () => {
it('extracts workflow and prompt from QuickTime keys/ilst boxes', async () => {
@@ -28,16 +23,6 @@ describe('ISOBMFF (MP4) metadata', () => {
expect(result.prompt).toEqual(EXPECTED_PROMPT)
})
it('parses Python generated prompt with bare NaN/Infinity tokens', async () => {
const bytes = fs.readFileSync(nanFixturePath)
const file = new File([bytes], 'nan.mp4', { type: 'video/mp4' })
const result = await getFromIsobmffFile(file)
expect(result.workflow).toBeUndefined()
expect(result.prompt).toEqual(EXPECTED_PROMPT_NAN_COERCED)
})
it('returns empty for non-ISOBMFF data', async () => {
const file = new File([new Uint8Array(16)], 'fake.mp4', {
type: 'video/mp4'

View File

@@ -8,7 +8,6 @@ import {
ComfyMetadataTags,
type IsobmffBoxContentRange
} from '@/types/metadataTypes'
import { parseJsonWithNonFinite } from '@/utils/jsonUtil'
// Set max read high, as atoms are stored near end of file
// while search is made to be efficient.
@@ -86,9 +85,7 @@ const extractJson = (
try {
const jsonText = new TextDecoder().decode(data.slice(jsonStart, end))
return parseJsonWithNonFinite<ComfyWorkflowJSON | ComfyApiWorkflow>(
jsonText
)
return JSON.parse(jsonText)
} catch {
return null
}

View File

@@ -1,20 +1,12 @@
import fs from 'fs'
import path from 'path'
import { afterEach, describe, expect, it, vi } from 'vitest'
import {
EXPECTED_PROMPT_NAN_COERCED,
mockFileReaderAbort,
mockFileReaderError,
mockFileReaderResult
} from './__fixtures__/helpers'
import { getDataFromJSON } from './json'
const nanFixturePath = path.resolve(
__dirname,
'__fixtures__/with_nan_metadata.json'
)
function jsonFile(content: object): File {
return new File([JSON.stringify(content)], 'test.json', {
type: 'application/json'
@@ -49,15 +41,6 @@ describe('getDataFromJSON', () => {
expect(result).toEqual({ templates })
})
it('parses Python generated API prompt with bare NaN/Infinity tokens', async () => {
const bytes = fs.readFileSync(nanFixturePath, 'utf-8')
const file = new File([bytes], 'nan.json', { type: 'application/json' })
const result = await getDataFromJSON(file)
expect(result).toEqual({ prompt: EXPECTED_PROMPT_NAN_COERCED })
})
it('returns undefined for non-JSON content', async () => {
const file = new File(['not valid json'], 'bad.json', {
type: 'application/json'

View File

@@ -1,7 +1,5 @@
import { isObject } from 'es-toolkit/compat'
import { parseJsonWithNonFinite } from '@/utils/jsonUtil'
export function getDataFromJSON(
file: File
): Promise<Record<string, object> | undefined> {
@@ -13,11 +11,9 @@ export function getDataFromJSON(
resolve(undefined)
return
}
const jsonContent = parseJsonWithNonFinite<Record<string, unknown>>(
reader.result
)
const jsonContent = JSON.parse(reader.result)
if (jsonContent?.templates) {
resolve({ templates: jsonContent.templates as object })
resolve({ templates: jsonContent.templates })
return
}
if (isApiJson(jsonContent)) {

View File

@@ -4,7 +4,6 @@ import { afterEach, describe, expect, it, vi } from 'vitest'
import {
EXPECTED_PROMPT,
EXPECTED_PROMPT_NAN_COERCED,
EXPECTED_WORKFLOW,
mockFileReaderAbort,
mockFileReaderError
@@ -12,10 +11,6 @@ import {
import { getMp3Metadata } from './mp3'
const fixturePath = path.resolve(__dirname, '__fixtures__/with_metadata.mp3')
const nanFixturePath = path.resolve(
__dirname,
'__fixtures__/with_nan_metadata.mp3'
)
afterEach(() => vi.restoreAllMocks())
@@ -68,16 +63,6 @@ describe('MP3 metadata', () => {
expect(errorSpy).not.toHaveBeenCalled()
})
it('parses Python generated prompt with bare NaN/Infinity tokens', async () => {
const bytes = fs.readFileSync(nanFixturePath)
const file = new File([bytes], 'nan.mp3', { type: 'audio/mpeg' })
const result = await getMp3Metadata(file)
expect(result.workflow).toBeUndefined()
expect(result.prompt).toEqual(EXPECTED_PROMPT_NAN_COERCED)
})
it('extracts metadata that spans the 4096-byte page boundary', async () => {
vi.spyOn(console, 'error').mockImplementation(() => {})
const metadata =
@@ -99,31 +84,6 @@ describe('MP3 metadata', () => {
expect(result.prompt).toEqual(EXPECTED_PROMPT)
})
it('logs and skips when embedded JSON is malformed', async () => {
const errorSpy = vi.spyOn(console, 'error').mockImplementation(() => {})
const metadata = `prompt\0{not json}\0workflow\0{also bad}\0`
const buf = new Uint8Array(64 + metadata.length)
buf[0] = 0xff
buf[1] = 0xfb
for (let i = 0; i < metadata.length; i++) {
buf[16 + i] = metadata.charCodeAt(i)
}
const file = new File([buf], 'malformed.mp3', { type: 'audio/mpeg' })
const result = await getMp3Metadata(file)
expect(result.prompt).toBeUndefined()
expect(result.workflow).toBeUndefined()
expect(errorSpy).toHaveBeenCalledWith(
'Failed to parse MP3 prompt metadata',
expect.any(SyntaxError)
)
expect(errorSpy).toHaveBeenCalledWith(
'Failed to parse MP3 workflow metadata',
expect.any(SyntaxError)
)
})
describe('FileReader failure modes', () => {
const file = new File([new Uint8Array(16)], 'test.mp3')

View File

@@ -1,9 +1,3 @@
import type {
ComfyApiWorkflow,
ComfyWorkflowJSON
} from '@/platform/workflow/validation/schemas/workflowSchema'
import { parseJsonWithNonFinite } from '@/utils/jsonUtil'
export async function getMp3Metadata(file: File) {
const reader = new FileReader()
const read_process = new Promise<ArrayBuffer | null>((r) => {
@@ -33,23 +27,10 @@ export async function getMp3Metadata(file: File) {
header += page
if (page.match('\u00ff\u00fb')) break
}
let workflow: ComfyWorkflowJSON | undefined
let prompt: ComfyApiWorkflow | undefined
let workflow, prompt
let prompt_s = header.match(/prompt\u0000(\{.*?\})\u0000/s)?.[1]
if (prompt_s) {
try {
prompt = parseJsonWithNonFinite<ComfyApiWorkflow>(prompt_s)
} catch (e) {
console.error('Failed to parse MP3 prompt metadata', e)
}
}
if (prompt_s) prompt = JSON.parse(prompt_s)
let workflow_s = header.match(/workflow\u0000(\{.*?\})\u0000/s)?.[1]
if (workflow_s) {
try {
workflow = parseJsonWithNonFinite<ComfyWorkflowJSON>(workflow_s)
} catch (e) {
console.error('Failed to parse MP3 workflow metadata', e)
}
}
if (workflow_s) workflow = JSON.parse(workflow_s)
return { prompt, workflow }
}

View File

@@ -4,7 +4,6 @@ import { afterEach, describe, expect, it, vi } from 'vitest'
import {
EXPECTED_PROMPT,
EXPECTED_PROMPT_NAN_COERCED,
EXPECTED_WORKFLOW,
mockFileReaderAbort,
mockFileReaderError
@@ -12,10 +11,6 @@ import {
import { getOggMetadata } from './ogg'
const fixturePath = path.resolve(__dirname, '__fixtures__/with_metadata.opus')
const nanFixturePath = path.resolve(
__dirname,
'__fixtures__/with_nan_metadata.opus'
)
afterEach(() => vi.restoreAllMocks())
@@ -30,16 +25,6 @@ describe('OGG/Opus metadata', () => {
expect(result.prompt).toEqual(EXPECTED_PROMPT)
})
it('parses Python generated prompt with bare NaN/Infinity tokens', async () => {
const bytes = fs.readFileSync(nanFixturePath)
const file = new File([bytes], 'nan.opus', { type: 'audio/ogg' })
const result = await getOggMetadata(file)
expect(result.workflow).toBeUndefined()
expect(result.prompt).toEqual(EXPECTED_PROMPT_NAN_COERCED)
})
it('returns undefined fields for non-OGG data', async () => {
vi.spyOn(console, 'error').mockImplementation(() => {})
const file = new File([new Uint8Array(16)], 'fake.ogg', {
@@ -67,32 +52,6 @@ describe('OGG/Opus metadata', () => {
expect(result.prompt).toBeUndefined()
})
it('logs and skips when embedded JSON is malformed', async () => {
const errorSpy = vi.spyOn(console, 'error').mockImplementation(() => {})
const metadata = `prompt={not json}\0workflow={also bad}\0`
const oggs = new TextEncoder().encode('OggS\0')
const buf = new Uint8Array(128)
buf.set(oggs, 0)
for (let i = 0; i < metadata.length; i++) {
buf[16 + i] = metadata.charCodeAt(i)
}
buf.set(oggs, 16 + metadata.length + 8)
const file = new File([buf], 'malformed.opus', { type: 'audio/ogg' })
const result = await getOggMetadata(file)
expect(result.prompt).toBeUndefined()
expect(result.workflow).toBeUndefined()
expect(errorSpy).toHaveBeenCalledWith(
'Failed to parse Ogg prompt metadata',
expect.any(SyntaxError)
)
expect(errorSpy).toHaveBeenCalledWith(
'Failed to parse Ogg workflow metadata',
expect.any(SyntaxError)
)
})
describe('FileReader failure modes', () => {
const file = new File([new Uint8Array(16)], 'test.ogg')

View File

@@ -1,9 +1,3 @@
import type {
ComfyApiWorkflow,
ComfyWorkflowJSON
} from '@/platform/workflow/validation/schemas/workflowSchema'
import { parseJsonWithNonFinite } from '@/utils/jsonUtil'
export async function getOggMetadata(file: File) {
const reader = new FileReader()
const read_process = new Promise<ArrayBuffer | null>((r) => {
@@ -30,27 +24,14 @@ export async function getOggMetadata(file: File) {
header += page
if (oggs > 1) break
}
let workflow: ComfyWorkflowJSON | undefined
let prompt: ComfyApiWorkflow | undefined
let workflow, prompt
let prompt_s = header
.match(/prompt=(\{.*?(\}.*?\u0000))/s)?.[1]
?.match(/\{.*\}/)?.[0]
if (prompt_s) {
try {
prompt = parseJsonWithNonFinite<ComfyApiWorkflow>(prompt_s)
} catch (e) {
console.error('Failed to parse Ogg prompt metadata', e)
}
}
if (prompt_s) prompt = JSON.parse(prompt_s)
let workflow_s = header
.match(/workflow=(\{.*?(\}.*?\u0000))/s)?.[1]
?.match(/\{.*\}/)?.[0]
if (workflow_s) {
try {
workflow = parseJsonWithNonFinite<ComfyWorkflowJSON>(workflow_s)
} catch (e) {
console.error('Failed to parse Ogg workflow metadata', e)
}
}
if (workflow_s) workflow = JSON.parse(workflow_s)
return { prompt, workflow }
}

View File

@@ -39,18 +39,4 @@ describe('getSvgMetadata', () => {
expect(result).toEqual({})
})
it('coerces bare NaN/Infinity tokens to null (Python json.dumps output)', async () => {
const svg = `<svg xmlns="http://www.w3.org/2000/svg">
<metadata><![CDATA[{"prompt": {"1": {"class_type": "KSampler", "inputs": {"cfg": NaN, "denoise": Infinity}}}}]]></metadata>
</svg>`
const result = await getSvgMetadata(svgFile(svg))
expect(result).toEqual({
prompt: {
'1': { class_type: 'KSampler', inputs: { cfg: null, denoise: null } }
}
})
})
})

View File

@@ -1,5 +1,4 @@
import { type ComfyMetadata } from '@/types/metadataTypes'
import { parseJsonWithNonFinite } from '@/utils/jsonUtil'
export async function getSvgMetadata(file: File): Promise<ComfyMetadata> {
const text = await file.text()
@@ -8,7 +7,7 @@ export async function getSvgMetadata(file: File): Promise<ComfyMetadata> {
if (metadataMatch && metadataMatch[1]) {
try {
return parseJsonWithNonFinite<ComfyMetadata>(metadataMatch[1].trim())
return JSON.parse(metadataMatch[1].trim())
} catch (error) {
console.error('Error parsing SVG metadata:', error)
return {}

View File

@@ -289,9 +289,7 @@ export const useSubgraphStore = defineStore('subgraph', () => {
)
const workflowExtra = workflow.initialState.extra
const description =
workflowExtra?.BlueprintDescription ??
workflow.initialState?.definitions?.subgraphs[0].description ??
'User generated subgraph blueprint'
workflowExtra?.BlueprintDescription ?? 'User generated subgraph blueprint'
const search_aliases = workflowExtra?.BlueprintSearchAliases
const subgraphDefCategory =
workflow.initialState.definitions?.subgraphs?.[0]?.category

View File

@@ -1,242 +0,0 @@
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { parseJsonWithNonFinite } from '@/utils/jsonUtil'
beforeEach(() => {
vi.spyOn(console, 'warn').mockImplementation(() => {})
})
afterEach(() => {
vi.restoreAllMocks()
})
describe('parseJsonWithNonFinite', () => {
it('parses standard JSON unchanged', () => {
expect(
parseJsonWithNonFinite(
'{"x": 1, "y": "hello", "z": [1, 2, null, true, false]}'
)
).toEqual({ x: 1, y: 'hello', z: [1, 2, null, true, false] })
})
it('handles compact Python separators with no spaces', () => {
expect(parseJsonWithNonFinite('{"a":NaN,"b":Infinity}')).toEqual({
a: null,
b: null
})
})
it('coerces NaN as the last value before object close', () => {
expect(parseJsonWithNonFinite('{"a":1,"b":NaN}')).toEqual({
a: 1,
b: null
})
})
it('handles multi-line pretty-printed Python output', () => {
expect(
parseJsonWithNonFinite('{\n "x": NaN,\n "y": Infinity\n}')
).toEqual({
x: null,
y: null
})
})
it('coerces NaN deeply nested across object and array levels', () => {
expect(
parseJsonWithNonFinite(
'{"a": {"b": {"c": [1, {"d": [NaN, [Infinity, {"e": -Infinity}]]}]}}}'
)
).toEqual({
a: { b: { c: [1, { d: [null, [null, { e: null }]] }] } }
})
})
it.for([
['NaN', null],
['Infinity', null],
['-Infinity', null],
['null', null],
['true', true],
['false', false],
['{}', {}],
['[]', []]
] as const)('parses bare top-level value: %s', ([input, expected]) => {
expect(parseJsonWithNonFinite(input)).toEqual(expected)
})
it.for([
['[NaN]', [null]],
['[Infinity]', [null]],
['[-Infinity]', [null]]
] as const)(
'coerces token at right-boundary of array: %s',
([input, expected]) => {
expect(parseJsonWithNonFinite(input)).toEqual(expected)
}
)
it.for([
['tab', '{"x":\tNaN}'],
['newline', '{"x":\nNaN}'],
['carriage return', '{"x":\rNaN}'],
['runs of spaces', '{"x": NaN}']
])('treats %s as a delimiter', ([, input]) => {
expect(parseJsonWithNonFinite(input)).toEqual({ x: null })
})
it('preserves NaN appearing inside string values', () => {
expect(parseJsonWithNonFinite('{"desc": "value is NaN here"}')).toEqual({
desc: 'value is NaN here'
})
})
it('preserves Infinity appearing inside string values', () => {
expect(parseJsonWithNonFinite('{"x": "to Infinity and beyond"}')).toEqual({
x: 'to Infinity and beyond'
})
})
it('preserves NaN appearing as a string key', () => {
expect(parseJsonWithNonFinite('{"NaN": 1, "Infinity": 2}')).toEqual({
NaN: 1,
Infinity: 2
})
})
it('preserves token-like substrings inside strings with escaped quotes', () => {
expect(
parseJsonWithNonFinite('{"x": "say \\"NaN\\" loud", "y": NaN}')
).toEqual({
x: 'say "NaN" loud',
y: null
})
})
it('handles escaped backslash immediately before a closing quote', () => {
expect(parseJsonWithNonFinite('{"x": "a\\\\", "y": NaN}')).toEqual({
x: 'a\\',
y: null
})
})
it('preserves token-like text after escape sequences inside strings', () => {
expect(
parseJsonWithNonFinite('{"x": "a\\nNaN", "y": "\\u0022Infinity\\u0022"}')
).toEqual({ x: 'a\nNaN', y: '"Infinity"' })
})
it('throws SyntaxError on otherwise-invalid JSON', () => {
expect(() => parseJsonWithNonFinite('{not json}')).toThrow(SyntaxError)
})
it.for([
['NaN with trailing digits', '{"x": NaN123}'],
['Infinity with trailing letter', '{"x": Infinityy}'],
['-Infinity with trailing digit', '{"x": -Infinity0}'],
['adjacent NaNs', '{"x": NaNNaN}'],
['-Infinity with trailing letter', '{"x": -Infinityy}']
])('throws on partial token match: %s', ([, input]) => {
expect(() => parseJsonWithNonFinite(input)).toThrow(SyntaxError)
})
it.for([
['after digit', '{"x": 1-Infinity}'],
['after decimal float', '{"x": 1.5-Infinity}']
])(
'throws when -Infinity is not delimiter-bounded on the left: %s',
([, input]) => {
expect(() => parseJsonWithNonFinite(input)).toThrow(SyntaxError)
}
)
it('throws on unterminated string ending in a lone backslash', () => {
expect(() => parseJsonWithNonFinite('{"x": "abc\\')).toThrow(SyntaxError)
})
it('throws on unsupported +Infinity prefix', () => {
expect(() => parseJsonWithNonFinite('{"x": +Infinity}')).toThrow(
SyntaxError
)
})
it('does not treat non-ASCII letters as a token boundary (throws)', () => {
expect(() => parseJsonWithNonFinite('{"x": éNaN}')).toThrow(SyntaxError)
})
it.for([
['top-level JSON string of NaN', '"NaN"', 'NaN'],
['token alone as string value', '{"x": "NaN"}', { x: 'NaN' }],
[
'-Infinity alone as string value',
'{"x": "-Infinity"}',
{ x: '-Infinity' }
],
[
'multiple tokens in one string',
'{"x": "NaN Infinity -Infinity"}',
{ x: 'NaN Infinity -Infinity' }
],
[
'token as prefix of identifier in string',
'{"s": "NaNny"}',
{ s: 'NaNny' }
],
[
'hyphen-bracketed Infinity in string',
'{"s": "pre-Infinity-post"}',
{ s: 'pre-Infinity-post' }
]
] as const)(
'preserves token text inside string contexts: %s',
([, input, expected]) => {
expect(parseJsonWithNonFinite(input)).toEqual(expected)
}
)
it('preserves numeric exponents (does not match Infinity prefix)', () => {
expect(parseJsonWithNonFinite('[1e10, -1.5e-3]')).toEqual([1e10, -1.5e-3])
})
it.for([
['token embedded in identifier', '{"x": fooNaNbar}'],
['Infinity followed by decimal point', '{"x": Infinity.123}'],
['trailing garbage after valid JSON', '{"a": 1} extra'],
['bare unknown identifier', '{"a": Foo}']
])('throws on invalid JSON: %s', ([, input]) => {
expect(() => parseJsonWithNonFinite(input)).toThrow(SyntaxError)
})
it('handles 10k-element array of mixed tokens without backtracking', () => {
const items = Array.from({ length: 10000 }, (_, i) =>
i % 3 === 0 ? 'NaN' : i % 3 === 1 ? 'Infinity' : '-Infinity'
).join(',')
const result = parseJsonWithNonFinite<null[]>(`[${items}]`)
expect(result).toHaveLength(10000)
expect(result[0]).toBeNull()
expect(result[9999]).toBeNull()
})
describe('fallback warning', () => {
it('does not warn when strict parse succeeds', () => {
parseJsonWithNonFinite('{"a": 1}')
expect(console.warn).not.toHaveBeenCalled()
})
it('warns once per call regardless of how many tokens are replaced', () => {
parseJsonWithNonFinite('{"a": NaN, "b": Infinity, "c": [-Infinity, NaN]}')
expect(console.warn).toHaveBeenCalledTimes(1)
})
it('warns again on a separate call', () => {
parseJsonWithNonFinite('{"a": NaN}')
parseJsonWithNonFinite('{"b": Infinity}')
expect(console.warn).toHaveBeenCalledTimes(2)
})
it('does not warn when the relaxed parse itself throws on input with no tokens', () => {
expect(() => parseJsonWithNonFinite('{not json}')).toThrow(SyntaxError)
expect(console.warn).not.toHaveBeenCalled()
})
})
})

View File

@@ -1,37 +0,0 @@
/**
* Parse JSON that may contain bare `NaN`/`Infinity`/`-Infinity` tokens
* (which Python's `json.dumps` emits) by replacing them with `null` on
* fallback. Coercion is lossy; a one-time warning is logged when it fires.
*/
export function parseJsonWithNonFinite<T = unknown>(text: string): T {
try {
return JSON.parse(text) as T
} catch {
return JSON.parse(replaceNonFiniteTokens(text)) as T
}
}
// Match a JSON string OR a non-finite token outside string.
// - `"(?:\\.|[^"\\])*"` a quoted string - matched first so anything that
// looks like a token inside a string is skipped
// - `(?<![\w.-])` skip non bare tokens (e.g. 1NaN)
// - `(-?Infinity|NaN)` capture the non-finite token
// - `(?![\w.])` skip non bare suffix tokens (e.g. NaN1)
const NON_FINITE_TOKEN =
/"(?:\\.|[^"\\])*"|(?<![\w.-])(-?Infinity|NaN)(?![\w.])/g
function replaceNonFiniteTokens(text: string): string {
let hasWarned = false
return text.replace(NON_FINITE_TOKEN, (match, token) => {
if (token) {
if (!hasWarned) {
console.warn(
'JSON contained non-finite numeric tokens (NaN/Infinity); they were replaced with null.'
)
hasWarned = true
}
return 'null'
}
return match
})
}

View File

@@ -1,7 +1,6 @@
import { createTestingPinia } from '@pinia/testing'
import ProgressSpinner from 'primevue/progressspinner'
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { ref } from 'vue'
import { render, screen } from '@testing-library/vue'
@@ -57,8 +56,7 @@ vi.mock('@vueuse/core', () => ({
createSharedComposable: vi.fn((fn) => {
let cached: ReturnType<typeof fn>
return (...args: Parameters<typeof fn>) => (cached ??= fn(...args))
}),
useDocumentVisibility: vi.fn(() => ref<'visible' | 'hidden'>('visible'))
})
}))
vi.mock('@/config', () => ({

View File

@@ -1,133 +0,0 @@
{
"revision": 0,
"last_node_id": 2,
"last_link_id": 0,
"nodes": [
{
"id": 2,
"type": "d0056772-3aca-4bc2-9971-8781df454c2b",
"pos": [470.93671874999995, 461],
"size": [225, 100],
"flags": {},
"order": 0,
"mode": 0,
"inputs": [
{
"name": "image",
"type": "IMAGE",
"link": null
}
],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"links": null
}
],
"properties": {
"proxyWidgets": []
},
"widgets_values": [],
"title": "test blueprint"
}
],
"links": [],
"version": 0.4,
"definitions": {
"subgraphs": [
{
"id": "d0056772-3aca-4bc2-9971-8781df454c2b",
"version": 1,
"state": {
"lastGroupId": 0,
"lastNodeId": 2,
"lastLinkId": 2,
"lastRerouteId": 0
},
"revision": 0,
"config": {},
"name": "test blueprint",
"inputNode": {
"id": -10,
"bounding": [240.43671874999995, 435, 128, 68]
},
"outputNode": {
"id": -20,
"bounding": [713.43671875, 435, 128, 68]
},
"inputs": [
{
"id": "d291ee9e-b1a6-4a9b-8163-ae7980ad312d",
"name": "image",
"type": "IMAGE",
"linkIds": [1],
"pos": [344.43671874999995, 459]
}
],
"outputs": [
{
"id": "4836730c-14a8-487d-9009-594b7e745076",
"name": "IMAGE",
"type": "IMAGE",
"linkIds": [2],
"pos": [737.43671875, 459]
}
],
"widgets": [],
"nodes": [
{
"id": 1,
"type": "ImageInvert",
"pos": [428.43671874999995, 438],
"size": [225, 72],
"flags": {},
"order": 0,
"mode": 0,
"inputs": [
{
"localized_name": "image",
"name": "image",
"type": "IMAGE",
"link": 1
}
],
"outputs": [
{
"localized_name": "IMAGE",
"name": "IMAGE",
"type": "IMAGE",
"links": [2]
}
],
"properties": {
"Node name for S&R": "ImageInvert"
}
}
],
"groups": [],
"links": [
{
"id": 1,
"origin_id": -10,
"origin_slot": 0,
"target_id": 1,
"target_slot": 0,
"type": "IMAGE"
},
{
"id": 2,
"origin_id": 1,
"origin_slot": 0,
"target_id": -20,
"target_slot": 0,
"type": "IMAGE"
}
],
"extra": {},
"description": "Inverts the image"
}
]
},
"extra": {}
}