Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/platform/nodeReplacement/missingNodesErrorStore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,20 @@ describe('missingNodesErrorStore', () => {
expect(store.missingNodesError?.nodeTypes[0]).toBe('StringNode')
})

it('matches numeric node IDs against string execution IDs', () => {
const store = useMissingNodesErrorStore()
store.setMissingNodeTypes([
{ type: 'NodeA', nodeId: 1, isReplaceable: false },
{ type: 'NodeB', nodeId: 2, isReplaceable: false }
])

store.removeMissingNodesByNodeId('1')

expect(store.missingNodesError?.nodeTypes).toStrictEqual([
{ type: 'NodeB', nodeId: 2, isReplaceable: false }
])
})

it('keeps entries with different nodeIds', () => {
const store = useMissingNodesErrorStore()
store.setMissingNodeTypes([
Expand Down
51 changes: 19 additions & 32 deletions src/platform/nodeReplacement/missingNodesErrorStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ import { st } from '@/i18n'
import type { LGraphNode } from '@/lib/litegraph/src/litegraph'
import { isCloud } from '@/platform/distribution/types'
import { useSettingStore } from '@/platform/settings/settingStore'
import {
dedupeMissingNodeTypes,
removePendingMissingNodeTypesByExecutionIdPrefix,
removePendingMissingNodeTypesByNodeId,
removePendingMissingNodeTypesByType
} from '@/platform/workflow/core/utils/pendingWarnings'
import { app } from '@/scripts/app'
import type { MissingNodeType } from '@/types/comfy'
import { getAncestorExecutionIds } from '@/types/nodeIdentification'
Expand All @@ -26,24 +32,7 @@ export const useMissingNodesErrorStore = defineStore(
missingNodesError.value = null
return
}
const seen = new Set<string>()
const uniqueTypes = types.filter((node) => {
// For string entries (group nodes), deduplicate by the string itself.
// For object entries, prefer nodeId so multiple instances of the same
// type are kept as separate rows; fall back to type if nodeId is absent.
const isString = typeof node === 'string'
let key: string
if (isString) {
key = node
} else if (node.nodeId != null) {
key = String(node.nodeId)
} else {
key = node.type
}
if (seen.has(key)) return false
seen.add(key)
return true
})
const uniqueTypes = dedupeMissingNodeTypes(types)
missingNodesError.value = {
message: isCloud
? st(
Expand All @@ -66,10 +55,10 @@ export const useMissingNodesErrorStore = defineStore(

function removeMissingNodesByNodeId(nodeId: string) {
if (!missingNodesError.value) return
const remaining = missingNodesError.value.nodeTypes.filter((node) => {
if (typeof node === 'string') return true
return node.nodeId !== nodeId
})
const remaining = removePendingMissingNodeTypesByNodeId(
missingNodesError.value.nodeTypes,
nodeId
)
setMissingNodeTypes(remaining)
}

Expand All @@ -83,22 +72,20 @@ export const useMissingNodesErrorStore = defineStore(
*/
function removeMissingNodesByPrefix(prefix: string) {
if (!missingNodesError.value) return
const remaining = missingNodesError.value.nodeTypes.filter((node) => {
if (typeof node === 'string') return true
if (node.nodeId == null) return true
return !String(node.nodeId).startsWith(prefix)
})
const remaining = removePendingMissingNodeTypesByExecutionIdPrefix(
missingNodesError.value.nodeTypes,
prefix
)
setMissingNodeTypes(remaining)
}

/** Remove specific node types from the missing nodes list (e.g. after replacement). */
function removeMissingNodesByType(typesToRemove: string[]) {
if (!missingNodesError.value) return
const removeSet = new Set(typesToRemove)
const remaining = missingNodesError.value.nodeTypes.filter((node) => {
const nodeType = typeof node === 'string' ? node : node.type
return !removeSet.has(nodeType)
})
const remaining = removePendingMissingNodeTypesByType(
missingNodesError.value.nodeTypes,
typesToRemove
)
setMissingNodeTypes(remaining)
}

Expand Down
Loading
Loading