Compare commits

...

3 Commits

Author SHA1 Message Date
Austin
6e4b8619fc Fix test 2026-05-18 20:27:40 -07:00
Austin
38248a6040 Add test 2026-05-18 19:55:39 -07:00
Austin
8e67b83fa8 Fix restoring values to dynamic combos 2026-05-18 19:55:38 -07:00
2 changed files with 48 additions and 1 deletions

View File

@@ -52,4 +52,42 @@ test.describe('Vue Widget Reactivity', { tag: '@vue-nodes' }, () => {
})
await expect(loadCheckpointNode).toHaveCount(3)
})
test('Can load dynamic combos', async ({ comfyPage }) => {
await comfyPage.settings.setSetting(
'Comfy.NodeSearchBoxImpl',
'v1 (legacy)'
)
await comfyPage.menu.topbar.newWorkflowButton.click()
await comfyPage.nextFrame()
await test.step('Add node with dynamic combo', async () => {
await comfyPage.page.mouse.dblclick(500, 500, { delay: 5 })
await comfyPage.searchBox.fillAndSelectFirstNode('Resize Image/Mask')
await expect(comfyPage.searchBox.input).toBeHidden()
})
const widget = comfyPage.vueNodes.getWidgetByName(
'Resize Image/Mask',
'resize_type'
)
await test.step('Update value of the dynamic combo widget', async () => {
await widget.click()
await comfyPage.page.getByRole('searchbox').fill('scale width')
await comfyPage.page.keyboard.press('ArrowDown')
await comfyPage.page.keyboard.press('Enter')
await expect(widget.locator('input')).toBeHidden()
await expect(widget).toHaveText('scale width')
})
await test.step('Swap to a different workflow and back', async () => {
await comfyPage.menu.topbar.getTab(0).click()
await expect(widget).toBeHidden()
await comfyPage.menu.topbar.getTab(1).click()
await expect(widget).toBeVisible()
})
await expect(widget, 'Widget has restored value').toHaveText('scale width')
})
})

View File

@@ -11,6 +11,7 @@ import type { LGraphNode } from '@/lib/litegraph/src/LGraphNode'
import { LiteGraph } from '@/lib/litegraph/src/litegraph'
import type { LLink } from '@/lib/litegraph/src/LLink'
import { commonType } from '@/lib/litegraph/src/utils/type'
import { resolveNodeRootGraphId } from '@/lib/litegraph/src/utils/widget'
import { transformInputSpecV1ToV2 } from '@/schemas/nodeDef/migration'
import type { ComboInputSpec, InputSpec } from '@/schemas/nodeDefSchema'
import type { InputSpec as InputSpecV2 } from '@/schemas/nodeDef/nodeDefSchemaV2'
@@ -22,6 +23,7 @@ import {
import { useLitegraphService } from '@/services/litegraphService'
import { app } from '@/scripts/app'
import type { ComfyApp } from '@/scripts/app'
import { useWidgetValueStore } from '@/stores/widgetValueStore'
const INLINE_INPUTS = false
@@ -185,11 +187,18 @@ function dynamicComboWidget(
//A little hacky, but onConfigure won't work.
//It fires too late and is overly disruptive
let widgetValue = widget.value
const graphId = resolveNodeRootGraphId(node)
const getState = () =>
graphId
? useWidgetValueStore().getWidget(graphId, node.id, widget.name)
: undefined
Object.defineProperty(widget, 'value', {
get() {
return widgetValue
return getState()?.value ?? widgetValue
},
set(value) {
const state = getState()
if (state) state.value = value
widgetValue = value
updateWidgets(value)
}