Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
ComfyUI
Commits
6453dc1c
Commit
6453dc1c
authored
Dec 16, 2023
by
pythongosssss
Browse files
Fix name counter preventing more than 3 of the same node
Fix linked widget offset when populating values
parent
e45d920a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
4 deletions
+37
-4
tests-ui/tests/groupNode.test.js
tests-ui/tests/groupNode.test.js
+32
-0
web/extensions/core/groupNode.js
web/extensions/core/groupNode.js
+5
-4
No files found.
tests-ui/tests/groupNode.test.js
View file @
6453dc1c
...
@@ -970,4 +970,36 @@ describe("group node", () => {
...
@@ -970,4 +970,36 @@ describe("group node", () => {
});
});
});
});
});
});
test
(
"
converted inputs with linked widgets map values correctly on creation
"
,
async
()
=>
{
const
{
ez
,
graph
,
app
}
=
await
start
();
const
k1
=
ez
.
KSampler
();
const
k2
=
ez
.
KSampler
();
k1
.
widgets
.
seed
.
convertToInput
();
k2
.
widgets
.
seed
.
convertToInput
();
const
rr
=
ez
.
Reroute
();
rr
.
outputs
[
0
].
connectTo
(
k1
.
inputs
.
seed
);
rr
.
outputs
[
0
].
connectTo
(
k2
.
inputs
.
seed
);
const
group
=
await
convertToGroup
(
app
,
graph
,
"
test
"
,
[
k1
,
k2
,
rr
]);
expect
(
group
.
widgets
.
steps
.
value
).
toBe
(
20
);
expect
(
group
.
widgets
.
cfg
.
value
).
toBe
(
8
);
expect
(
group
.
widgets
.
scheduler
.
value
).
toBe
(
"
normal
"
);
expect
(
group
.
widgets
[
"
KSampler steps
"
].
value
).
toBe
(
20
);
expect
(
group
.
widgets
[
"
KSampler cfg
"
].
value
).
toBe
(
8
);
expect
(
group
.
widgets
[
"
KSampler scheduler
"
].
value
).
toBe
(
"
normal
"
);
});
test
(
"
allow multiple of the same node type to be added
"
,
async
()
=>
{
const
{
ez
,
graph
,
app
}
=
await
start
();
const
nodes
=
[...
Array
(
10
)].
map
(()
=>
ez
.
ImageScaleBy
());
const
group
=
await
convertToGroup
(
app
,
graph
,
"
test
"
,
nodes
);
expect
(
group
.
inputs
.
length
).
toBe
(
10
);
expect
(
group
.
outputs
.
length
).
toBe
(
10
);
expect
(
group
.
widgets
.
length
).
toBe
(
20
);
expect
(
group
.
widgets
.
map
((
w
)
=>
w
.
widget
.
name
)).
toStrictEqual
(
[...
Array
(
10
)]
.
map
((
_
,
i
)
=>
`
${
i
>
0
?
"
ImageScaleBy
"
:
""
}${
i
>
1
?
i
+
"
"
:
""
}
`
)
.
flatMap
((
p
)
=>
[
`
${
p
}
upscale_method`
,
`
${
p
}
scale_by`
])
);
});
});
});
web/extensions/core/groupNode.js
View file @
6453dc1c
...
@@ -331,16 +331,17 @@ export class GroupNodeConfig {
...
@@ -331,16 +331,17 @@ export class GroupNodeConfig {
getInputConfig
(
node
,
inputName
,
seenInputs
,
config
,
extra
)
{
getInputConfig
(
node
,
inputName
,
seenInputs
,
config
,
extra
)
{
let
name
=
node
.
inputs
?.
find
((
inp
)
=>
inp
.
name
===
inputName
)?.
label
??
inputName
;
let
name
=
node
.
inputs
?.
find
((
inp
)
=>
inp
.
name
===
inputName
)?.
label
??
inputName
;
let
key
=
name
;
let
prefix
=
""
;
let
prefix
=
""
;
// Special handling for primitive to include the title if it is set rather than just "value"
// Special handling for primitive to include the title if it is set rather than just "value"
if
((
node
.
type
===
"
PrimitiveNode
"
&&
node
.
title
)
||
name
in
seenInputs
)
{
if
((
node
.
type
===
"
PrimitiveNode
"
&&
node
.
title
)
||
name
in
seenInputs
)
{
prefix
=
`
${
node
.
title
??
node
.
type
}
`;
prefix
=
`
${
node
.
title
??
node
.
type
}
`;
name = `
$
{
prefix
}
$
{
inputName
}
`;
key =
name = `
$
{
prefix
}
$
{
inputName
}
`;
if (name in seenInputs) {
if (name in seenInputs) {
name = `
$
{
prefix
}
$
{
seenInputs
[
name
]}
$
{
inputName
}
`;
name = `
$
{
prefix
}
$
{
seenInputs
[
name
]}
$
{
inputName
}
`;
}
}
}
}
seenInputs[
name
] = (seenInputs[
name
] ?? 1) + 1;
seenInputs[
key
] = (seenInputs[
key
] ?? 1) + 1;
if (inputName === "seed" || inputName === "noise_seed") {
if (inputName === "seed" || inputName === "noise_seed") {
if (!extra) extra = {};
if (!extra) extra = {};
...
@@ -1010,10 +1011,10 @@ export class GroupNodeHandler {
...
@@ -1010,10 +1011,10 @@ export class GroupNodeHandler {
const
newName
=
map
[
oldName
];
const
newName
=
map
[
oldName
];
const
widgetIndex
=
this
.
node
.
widgets
.
findIndex
((
w
)
=>
w
.
name
===
newName
);
const
widgetIndex
=
this
.
node
.
widgets
.
findIndex
((
w
)
=>
w
.
name
===
newName
);
const
mainWidget
=
this
.
node
.
widgets
[
widgetIndex
];
const
mainWidget
=
this
.
node
.
widgets
[
widgetIndex
];
if
(
this
.
populatePrimitive
(
node
,
nodeId
,
oldName
,
i
,
linkedShift
))
{
if
(
this
.
populatePrimitive
(
node
,
nodeId
,
oldName
,
i
,
linkedShift
)
||
widgetIndex
===
-
1
)
{
// Find the inner widget and shift by the number of linked widgets as they will have been removed too
// Find the inner widget and shift by the number of linked widgets as they will have been removed too
const
innerWidget
=
this
.
innerNodes
[
nodeId
].
widgets
?.
find
((
w
)
=>
w
.
name
===
oldName
);
const
innerWidget
=
this
.
innerNodes
[
nodeId
].
widgets
?.
find
((
w
)
=>
w
.
name
===
oldName
);
linkedShift
+=
innerWidget
.
linkedWidgets
?.
length
??
0
;
linkedShift
+=
innerWidget
?
.
linkedWidgets
?.
length
??
0
;
}
}
if
(
widgetIndex
===
-
1
)
{
if
(
widgetIndex
===
-
1
)
{
continue
;
continue
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment