Skip to content

Commit

Permalink
Revert "Restrict applyToGraph to PrimitiveNode" (#2677)
Browse files Browse the repository at this point in the history
  • Loading branch information
huchenlei authored Feb 22, 2025
1 parent d7c9a43 commit f43eac7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/nodes/PrimitiveNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ export function isValidCombo(combo: string[], obj: unknown) {
return true
}

export function isPrimitiveNode(node: LGraphNode): node is PrimitiveNode {
function isPrimitiveNode(node: LGraphNode): node is PrimitiveNode {
return node.type === 'PrimitiveNode'
}

Expand Down
1 change: 1 addition & 0 deletions src/types/litegraph-augmentation.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ declare module '@comfyorg/litegraph' {
convertToNodes?(): LGraphNode[]
recreate?(): Promise<LGraphNode>
refreshComboInNode?(defs: Record<string, ComfyNodeDef>)
applyToGraph?(extraLinks?: LLink[]): void
updateLink?(link: LLink): LLink | null
onExecutionStart?(): unknown
/**
Expand Down
8 changes: 5 additions & 3 deletions src/utils/executionUtil.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { LGraph } from '@comfyorg/litegraph'
import { LGraphEventMode } from '@comfyorg/litegraph'

import { isPrimitiveNode } from '@/nodes/PrimitiveNode'
import type { ComfyApiWorkflow, ComfyWorkflowJSON } from '@/types/comfyWorkflow'

/**
Expand All @@ -20,8 +19,11 @@ export const graphToPrompt = async (
? outerNode.getInnerNodes()
: [outerNode]
for (const node of innerNodes) {
if (isPrimitiveNode(node)) {
node.applyToGraph()
if (node.isVirtualNode) {
// Don't serialize frontend only nodes but let them make changes
if (node.applyToGraph) {
node.applyToGraph()
}
}
}
}
Expand Down

0 comments on commit f43eac7

Please sign in to comment.