-
Notifications
You must be signed in to change notification settings - Fork 670
fix(subgraph): avoid positional bypass links #15526
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ import { toNodeId } from '@/types/nodeId' | |
|
|
||
| import { | ||
| createNestedSubgraphs, | ||
| createTestRootGraph, | ||
| createTestSubgraph, | ||
| createTestSubgraphNode, | ||
| resetSubgraphFixtureState | ||
|
|
@@ -361,6 +362,55 @@ describe('Bypass node output resolution', () => { | |
| expect(resolved).toBeDefined() | ||
| expect(resolved?.node).toBe(upstreamDto) | ||
| }) | ||
|
|
||
| it('should not pair an unrelated subgraph input with a bypassed output', () => { | ||
| const rootGraph = createTestRootGraph() | ||
| const subgraph = createTestSubgraph({ | ||
| rootGraph, | ||
| inputs: [{ name: 'input', type: 'IMAGE' }], | ||
| outputs: [{ name: 'output', type: 'IMAGE' }] | ||
| }) | ||
| const subgraphNode = createTestSubgraphNode(subgraph, { | ||
| id: 1, | ||
| parentGraph: rootGraph | ||
| }) | ||
| rootGraph.add(subgraphNode) | ||
|
|
||
| const unrelatedNode = new LGraphNode('Unrelated interior node') | ||
| unrelatedNode.addOutput('source', 'IMAGE') | ||
| subgraph.add(unrelatedNode) | ||
|
|
||
| const upstreamNode = new LGraphNode('Upstream') | ||
| upstreamNode.addOutput('image', 'IMAGE') | ||
| rootGraph.add(upstreamNode) | ||
| upstreamNode.connect(0, subgraphNode, 0) | ||
|
|
||
| const nodesByExecutionId = new Map() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
file='src/lib/litegraph/src/subgraph/ExecutableNodeDTO.test.ts'
# Inspect the existing DTO imports and the untyped registry declaration.
rg -n -C 3 "ExecutableNodeDTO|ExecutionId|ExecutableLGraphNode|new Map\\(\\)" "$file"Repository: Comfy-Org/ComfyUI_frontend Length of output: 12681 🏁 Script executed: #!/bin/bash
set -euo pipefail
file='src/lib/litegraph/src/subgraph/ExecutableNodeDTO.test.ts'
rg -n -C 8 "^(import|export)|class ExecutableNodeDTO|constructor\\(|nodesByExecutionId|ExecutableLGraphNode|ExecutionId" "$file" | sed -n '1,240p'
printf '\n--- relevant source declarations ---\n'
rg -n -C 8 "class ExecutableNodeDTO|type ExecutionId|interface ExecutableLGraphNode|ExecutableLGraphNode|Map<.*Executable" src/lib/litegraphRepository: Comfy-Org/ComfyUI_frontend Length of output: 16165 🏁 Script executed: #!/bin/bash
set -euo pipefail
# Check the repository's TypeScript version and compiler settings without executing project code.
rg -n -C 3 '"typescript"|"noImplicitAny"|"strict"' package.json tsconfig*.json pnpm-lock.yaml 2>/dev/null | sed -n '1,220p'Repository: Comfy-Org/ComfyUI_frontend Length of output: 847 🏁 Script executed: #!/bin/bash
set -euo pipefail
if ! command -v tsc >/dev/null 2>&1; then
echo 'tsc: unavailable'
exit 0
fi
tsc --version
probe="$(mktemp --suffix=.ts)"
trap 'rm -f "$probe"' EXIT
cat >"$probe" <<'TS'
const untyped = new Map()
untyped.set('id', 1)
const typed: Map<string, number> = new Map()
TS
echo '--- strict compiler result for standalone new Map() ---'
tsc --strict --noEmit --skipLibCheck --lib es2015 "$probe"
TSRepository: Comfy-Org/ComfyUI_frontend Length of output: 376 🏁 Script executed: #!/bin/bash
set -euo pipefail
probe="$(mktemp --suffix=.ts)"
trap 'rm -f "$probe"' EXIT
cat >"$probe" <<'TS'
const untyped = new Map()
untyped.set('id', 1)
const typed: Map<string, number> = new Map()
TS
tsc --ignoreConfig --strict --noEmit --skipLibCheck --lib es2015 "$probe"Repository: Comfy-Org/ComfyUI_frontend Length of output: 164 🏁 Script executed: #!/bin/bash
set -euo pipefail
probe="$(mktemp --suffix=.ts)"
out="$(mktemp -d)"
trap 'rm -f "$probe"; rm -rf "$out"' EXIT
cat >"$probe" <<'TS'
const untyped = new Map()
export { untyped }
TS
tsc --ignoreConfig --strict --declaration --emitDeclarationOnly --skipLibCheck --lib es2015 --outDir "$out" "$probe"
cat "$out/$(basename "$probe" .ts).d.ts"Repository: Comfy-Org/ComfyUI_frontend Length of output: 222 Type the DTO registry map. Declare 🤖 Prompt for AI AgentsSources: Coding guidelines, Path instructions |
||
| const upstreamDto = new ExecutableNodeDTO( | ||
| upstreamNode, | ||
| [], | ||
| nodesByExecutionId, | ||
| undefined | ||
| ) | ||
| const subgraphDto = new ExecutableNodeDTO( | ||
| subgraphNode, | ||
| [], | ||
| nodesByExecutionId, | ||
| undefined | ||
| ) | ||
| nodesByExecutionId.set(upstreamDto.id, upstreamDto) | ||
| nodesByExecutionId.set(subgraphDto.id, subgraphDto) | ||
|
|
||
| subgraphNode.mode = LGraphEventMode.BYPASS | ||
| const warningSpy = vi.spyOn(console, 'warn').mockImplementation(() => {}) | ||
| try { | ||
| const resolved = subgraphDto.resolveOutput(0, 'IMAGE', new Set()) | ||
|
|
||
| expect(resolved).toBeUndefined() | ||
| } finally { | ||
| warningSpy.mockRestore() | ||
| } | ||
| }) | ||
| }) | ||
|
|
||
| describe('ALWAYS mode node output resolution', () => { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Connect the unrelated node to the subgraph output.
unrelatedNodeis not wired tosubgraph.outputNode.resolveSubgraphOutputLink(0)therefore fails because the output is disconnected. The test does not verify rejection of an output that is produced by an unrelated interior node.Connect output slot
0to the subgraph output input before callingresolveOutput. The warning spy becomes unnecessary after this connection.Proposed fix
unrelatedNode.addOutput('source', 'IMAGE') subgraph.add(unrelatedNode) + unrelatedNode.connect(0, subgraph.outputNode, 0) @@ - const warningSpy = vi.spyOn(console, 'warn').mockImplementation(() => {}) - try { - const resolved = subgraphDto.resolveOutput(0, 'IMAGE', new Set()) - - expect(resolved).toBeUndefined() - } finally { - warningSpy.mockRestore() - } + const resolved = subgraphDto.resolveOutput(0, 'IMAGE', new Set()) + + expect(resolved).toBeUndefined()As per path instructions, the test must “directly verify graph wiring behavior, especially that only a directly connected corresponding subgraph input can provide a bypass.”
📝 Committable suggestion
🤖 Prompt for AI Agents
Source: Path instructions