Compare commits

..

1 Commits

Author SHA1 Message Date
CodeRabbit Fixer
461bea6d99 fix: refactor: create rename-aware detach/attach helper in workflowStore to avoid duplicate mutation paths (#9407)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 15:34:12 +01:00
2 changed files with 8 additions and 68 deletions

View File

@@ -113,62 +113,4 @@ describe('DomWidget disabled style', () => {
expect(root.style.pointerEvents).toBe('none')
expect(root.style.opacity).toBe('0.5')
})
it('uses enabled style when promoted override widget is not computedDisabled', async () => {
const widgetState = createWidgetState(false)
const wrapper = mount(DomWidget, {
props: {
widgetState
}
})
widgetState.zIndex = 3
await wrapper.vm.$nextTick()
const root = wrapper.get('.dom-widget').element as HTMLElement
expect(root.style.pointerEvents).toBe('auto')
expect(root.style.opacity).toBe('1')
})
it('falls back to widget.computedDisabled when no position override exists', async () => {
const domWidgetStore = useDomWidgetStore()
const node = createMockLGraphNode({
id: 3,
constructor: {
nodeData: {}
}
})
const widget = {
id: 'dom-widget-no-override',
name: 'test_widget',
type: 'custom',
value: '',
options: {},
node,
computedDisabled: true
} as unknown as BaseDOMWidget<object | string>
domWidgetStore.registerWidget(widget)
const state = domWidgetStore.widgetStates.get(widget.id)
if (!state) throw new Error('Expected registered DomWidgetState')
state.zIndex = 2
state.size = [100, 40]
const widgetState = reactive(state)
const wrapper = mount(DomWidget, {
props: {
widgetState
}
})
widgetState.zIndex = 3
await wrapper.vm.$nextTick()
const root = wrapper.get('.dom-widget').element as HTMLElement
expect(root.style.pointerEvents).toBe('none')
expect(root.style.opacity).toBe('0.5')
})
})

View File

@@ -103,14 +103,16 @@ export const useWorkflowStore = defineStore('workflow', () => {
/**
* Detach the workflow from the store. lightweight helper function.
* @param workflow The workflow to detach.
* @param oldPath Optional previous path to detach from (used during rename when workflow.path has already changed).
* @returns The index of the workflow in the openWorkflowPaths array, or -1 if the workflow was not open.
*/
const detachWorkflow = (workflow: ComfyWorkflow) => {
delete workflowLookup.value[workflow.path]
const index = openWorkflowPaths.value.indexOf(workflow.path)
const detachWorkflow = (workflow: ComfyWorkflow, oldPath?: string) => {
const path = oldPath ?? workflow.path
delete workflowLookup.value[path]
const index = openWorkflowPaths.value.indexOf(path)
if (index !== -1) {
openWorkflowPaths.value = openWorkflowPaths.value.filter(
(path) => path !== workflow.path
(p) => p !== path
)
}
return index
@@ -501,12 +503,8 @@ export const useWorkflowStore = defineStore('workflow', () => {
// Synchronously swap old path for new path in lookup and open paths
// to avoid a tab flicker caused by an async gap between detach/attach.
delete workflowLookup.value[oldPath]
workflowLookup.value[workflow.path] = workflow
const openIndex = openWorkflowPaths.value.indexOf(oldPath)
if (openIndex !== -1) {
openWorkflowPaths.value.splice(openIndex, 1, workflow.path)
}
const openIndex = detachWorkflow(workflow, oldPath)
attachWorkflow(workflow, openIndex)
draftStore.moveDraft(oldPath, newPath, workflow.key)